/*	SONY | SONY STYLE.COM - [MODAL OF FUNCTIONALITY NAME]
 *	Author(s): 	Branden Thompson	| Front End Architect , Branden.Thompson at am dot sony dot com
 *				Jonathan Cheung 	| Sr. Flash Developer , Jonathan.Cheung at am dot sony dot com
 *  Modified By:  Nathan Fineberg, Front End Web Developer - Nathan.Fineberg at am dot sony dot com
 *	Date:		November 10, 2009
 *
 *	JS FILE PRE-CONDITIONS:
 *	-------------------------------------------------------------------------------------------------
 *
 *		- Prototype must be included before this .js (or included functions) is referenced.
 *
 *
 *
 *	FUNCTIONALITY THAT THIS JS WILL PROVIDE
 *	-------------------------------------------------------------------------------------------------
 *
 *	This file will allow us to strip the DOM level2 events that are used ON ALL FILES ON SONY STYLE
 *	Examples would include: AjaxInit()
*/

Event.observe(window, 'load', function(){
	// All existing HTML's will need the ss_accordion.js added



	// RICO AJAX CALLS WILL NEED TO GO HERE:

	// We need to set our default image
	// First thing we're always going to do is set our default product detail tab:

	// First need to check for a tabname in the url parameters ('tab')
	var paramTabName = getURLParameter('tab');
	var isContentUniverseTab = false;
	if(paramTabName){
		// Remove trailing anchor links appended to URL Param
		if(paramTabName.indexOf('#') > 0){
			paramTabName = paramTabName.substring(0, paramTabName.indexOf('#'));
		}

		// first, let's turn all our Nav Tab elements back to off:
		$$('a.readerCategoryTabNavLink').invoke('removeClassName', 'activeTab');
		$$('.readerCategoryTab').invoke('removeClassName', 'defaultTab');

		$$('.readerCategoryTab').invoke('hide');

		switch(paramTabName){
			case 'contentUniverseTab':
				$('tabNavContentUniverse').addClassName('activeTab');
				isContentUniverseTab = true;
				break;
			case 'technologyTab':
				$('tabNavTechnology').addClassName('activeTab');
				break;
			case 'accessoriesTab':
				$('tabNavAccessories').addClassName('activeTab');
				break;
			case 'compatibilityTab':
				$('tabNavCompatibility').addClassName('activeTab');
				break;
			default:
				$('tabNavContentUniverse').addClassName('activeTab');
				isContentUniverseTab = true;
				break;
		}

		// ... and finally, let's turn on the layer that we want to show, while turning off all the
		// others with the class "readerCategoryTab":
		toggleLayer(paramTabName, 'readerCategoryTab');

	}
	else{
		if($$('.readerCategoryTab')[0])
		{
			$$('.readerCategoryTab')[0].addClassName('defaultTab');
			toggleDefaultElement('defaultTab', 'readerCategoryTab');
			isContentUniverseTab = true;
		}
	}

	if(isContentUniverseTab){
		$$('a.readerCategoryTabNavLink')[0].addClassName('activeTab');
	}

	$$('a').invoke('observe', 'mouseover', function(evt){

	});// end  MouseOut Event Listener

	/*	PRODUCT DETAIL TAB EVENT LISTENERS:
	 *	--------------------------------------------------------------------------------------------------
	*/
	$$('a.readerCategoryTabNavLink').invoke('observe', 'mouseover', function(evt){

		//ourSiblings = $(this).siblings();
		//ourSiblings[0].addClassName('activeTab');

	});


	$$('a.readerCategoryTabNavLink').invoke('observe', 'mouseout', function(evt){

		//ourSiblings = $(this).siblings();
		//ourSiblings[0].removeClassName('activeTab');

	});


	$$('a.readerCategoryTabNavLink').invoke('observe','click', function(evt){

		// first, let's turn all our Nav Tab elements back to off:
		$$('a.readerCategoryTabNavLink').invoke('removeClassName', 'activeTab');

		// next, let's turn the tab we clicked on to have an "active" state showing the tab highlighted:
		$(this).addClassName('activeTab');

		// ... and finally, let's turn on the layer that we want to show, while turning off all the
		// others with the class "readerCategoryTab":
		toggleLayer(($(this).readAttribute('rel')), 'readerCategoryTab');


	});//end ProductDetail Active Tab Event Listener


});//end Window Load Event Observer.

