/*	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
 *
 *	Date:		April 17, 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
	var accordion = null;

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



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

		//alert('clicked');

		if($(this).hasClassName('active') == true)
		{
			$(this).removeClassName('active');
			$(this).innerHTML ="VIEW FOOTNOTES";
			$('footNoteContent').hide();
		}
		else
		{
			$(this).addClassName('active');
			$(this).innerHTML ="HIDE FOOTNOTES";
			$('footNoteContent').show();
		}

	});


	/*
	* End tab buttons
	*
	*
	*/


	// 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 isOverviewTab = 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.vaioSeriesPageTabNavLink').invoke('removeClassName', 'activeTab');
		$$('.vaioSeriesPageTab').invoke('removeClassName', 'defaultTab');

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

		switch(paramTabName){
			case 'overviewTab':
				$('tabNavOverview').addClassName('activeTab');
				isOverviewTab = true;
				break;
			case 'featuresTab':
				$('tabNavFeatures').addClassName('activeTab');
				break;
			case 'specificationsTab':
				$('tabNavSpecifications').addClassName('activeTab');
				break;
			case 'galleryTab':
				$('tabNavGallery').addClassName('activeTab');
				break;
			case 'reviewsTab':
				$('tabNavReviews').addClassName('activeTab');
				break;
			default:
				$('tabNavOverview').addClassName('activeTab');
				isOverviewTab = true;
				break;
		}

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

	}
	else{
		if($$('.vaioSeriesPageTab')[0])
		{
			$$('.vaioSeriesPageTab')[0].addClassName('defaultTab');
			toggleDefaultElement('defaultTab', 'vaioSeriesPageTab');
			isOverviewTab = true;
		}
	}
	/*	Related Event Listeners:  Setting Default Elements for color collapse
	 *	--------------------------------------------------------------------------------
	*/

	// Let's initialize our Product Image Source and filepath:

	if(isOverviewTab){
		$$('a.vaioSeriesPageTabNavLink')[0].addClassName('activeTab');
	}

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

	});// end ColorChip MouseOut Event Listener

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

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

	});


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

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

	});


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

		// first, let's turn all our Nav Tab elements back to off:
		$$('a.vaioSeriesPageTabNavLink').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 "vaioSeriesPageTab":
		toggleLayer(($(this).readAttribute('rel')), 'vaioSeriesPageTab');


	});//end ProductDetail Active Tab Event Listener


});//end Window Load Event Observer.

function showFootnotes() {

	var anchorElement = $$('.showHideFootnotesLink')[0];
	$(anchorElement).addClassName('active');
	$(anchorElement).innerHTML ="HIDE FOOTNOTES";
	$(anchorElement).scrollTo();
	$('footNoteContent').show();
	
}


