/*	VAIO SPECIFIC CORE FUNCTIONS
 *	AUTHOR: Branden Thompson, Branden.Thompson@am.sony.com
 *	DATE: June 27, 2008
 *
 *	FUNCTION GUIDELINES:
 *	"If it's VAIO specific, it goes here, if not, it's a seperate file"
 *
 *	- ***DOCUMENT YOUR FUNCTIONS***
 *	- PRE-CONDITION and POST-CONDITION YOUR FUNCTIONS!
*/

/*	FUNCTION: shadowBoxInit()
 *	----------------------------------------------------------------------------
 *	PRE-CONDITIONS:		this file must be included in the calling HTML page.
 *						
 *						shadowbox.js must also be included in the calling HTML
 *						page BEFORE this file is linked.
 *
 *	POST-CONDITIONS:	defined Shadowbox options will be initialized when this
 *						function is called.
 *	----------------------------------------------------------------------------
*/

function shadowBoxInit()
{	
	// we're simply defining our customizable options in Shadowbox.
	// this is related to Shadowbox.js	
	var options = {
		loadingImage: '/wcsstore/SonyStyleStorefrontAssetStore/img/vaioimage/ajax-loading.gif',
		onClose: function(arg) {
			var overlayDiv = document.getElementById('shadowbox_overlay');
			if(overlayDiv) {
				overlayDiv.style.height = "0px";
				}
			
			
			}
	};


	// initialize the options we just defined in the Shadowbox.
	Shadowbox.init(options);		
};// end function



/*	FUNCTION: 	displayFlashHeader([string]divID, [int]width, [int]height, 
 *				[string/html]headerString, [string]alignment, [int]offsetX, 
 *				[int]offsetY, [string]objectAlign,[string]leading)
 * 	----------------------------------------------------------------------------
 *	PRE-CONDITIONS:		divID must exist and be a properly defined element 
 *						within the HTML document.
 *
 *						width, height, and headerString all MUST be defined.
 *
 *
 *	POST-CONDITIONS:	function will write the flash Object 
 *						
 *						specified and/or default variables will be passed to 
 *						the flash object so it can render headerString into a 
 *						smooth, visually appealling font.
 *	----------------------------------------------------------------------------
*/

// let's define a global variable that the function can simply re-use, rather
// than taking up more memory by using a new copy of the variable every function
// call.
var thisSWFObjectHeader;


function displayFlashHeader(divID, width, height, headerString, alignment, offsetX, offsetY, leading)
{
	// let's start our by doing some fatal-error exception alerting.
	if((!(divID)) || (!(width)) || (!(height)) ) {
		alert("FATAL ERROR - displayFlashHeader(): Required arguments are missing.  Please review the page and fix accordingly.");
		return(false);
	}	
	
	// let's perform some basic logic tests here for our non-required variables:
	
	// if alignment is not specified, default to left:
	if((!(alignment)) || (alignment == '')) {
		alignment = "lt";
	}
	
	// if offsetY is null, not-defined or blank, set to 0:
	if ((!(offsetX)) || (offsetX == '')) {
		offsetX = 0;
	}
	
	// if offsetY is null, not-defined or blank, set to 0:
	if ((!(offsetY)) || (offsetY == '')) {
		offsetY = 0;
	}	
	
	// if leading is null, not-defined or blank, set to 0:
	if ((!(leading)) || (leading == '')) {
		leading = 0;
	}	
	
	// Now that we've made sure all parameters are defined one way or another, let's define our flash Object
	
	thisSWFObjectHeader = new SWFObject("/wcsstore/SonyStyleStorefrontAssetStore/flashfiles/swfs/headerText.swf?t=" +new Date().getTime(), "hero", width, height, "8", "#FFFFFF", true);
	
	thisSWFObjectHeader.addParam("wmode", "transparent");			// this parameter makes the background of the swf object transparent
	thisSWFObjectHeader.addParam("scale", "noscale");				// do we want to have the swfObject be scalable?
	thisSWFObjectHeader.addVariable("TextHTML",headerString);		// this paramater is the text to be displayed. HTML 1.0 is supported. <font> <p> <a> <b><br>...etc. For the font face, please use 'ITC Avant Garde Std Bk' or 'ITC Avant Garde Std Md', Flash defaults to ITC Avant Garde Std Bk
	thisSWFObjectHeader.addVariable("TextAlignment", alignment);	// this paramater is the horizontal offset from the left in pixel. 	
																// If TextAlignment "right" is used. the coordinate offset will start from the right
	thisSWFObjectHeader.addVariable("OffsetX",offsetX);	
	thisSWFObjectHeader.addVariable("OffsetY",offsetY);				// this paramater is the vertical offset form the top
	thisSWFObjectHeader.addVariable("TextLeading",leading);				// this paramater is the vertical offset form the top
	thisSWFObjectHeader.addParam("salign", "lt");					// how do we want this aligned?  lt = left, rt = right.		
	thisSWFObjectHeader.write(divID); 								// write the swf file into the Div with the ID passed below:
}
// end function.






// Flash will use this function the get the pageName from the template and use that for Flash tracking
function getOmniturePageName() { if (typeof(s) == 'object') { return s.pageName; }else {return 'undefined';} };


/*
	Functions called by vaio_series_footer_popups.swf
	FooterPop Function
	Takes and ID and X Coordinate and passes 	
*/
function footerPop(ID, xcoord)
{
	//If ID is nothing, we move it out of the screen
	if (ID == "null" || ID == "undefined")	{
		ID = '';
		$('vaioFooterFlashPopups').style.left = "-2000px";
	}else{
	// If ID has anything in it, we show the movie by putting it on stage
		$('vaioFooterFlashPopups').style.left = "0px";
	}
	//Calling popup module in the flash to popup the correct Series at the given x coordinate
	thisMovie("vaioFooterFlashPopupModule").footerPopCall(ID,xcoord);
	//Calling footer with the same parameters so it knows where the other flash is at.
	thisMovie("vaioFooterFlashModule").footerPopCall(ID,xcoord);
}

/*
	Flash uses this function to locate the correct SWF movie
*/
function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName]
	}
	else {
		return document[movieName]
	}
}


 /*Function for Alternative content when Flash isn't available*/
 
 function initVaioHeroAltContent(){
	/******************************/
	//Appending Alternative content for non-flash users
	// Adding onclick event to the CTA links for Hero banners
	$$('#vaioHero a.tabs').invoke('observe','click', function(evt){
			//reads the href and  rel to pass to the function
			_cmspotObject.trackCMSOmniture($(this).href, $(this).rel);
			//Stops href from being followed
			Event.stop(evt);
	});
 }

 
 
/* function used to open and close the ESpot area for more promotions information */
function openPromotions(openVar){
/* Parameters are a boolean true or false*/
	if(openVar)
		$('vaioPromotionsFlash').style.height = '177px';
	else
		$('vaioPromotionsFlash').style.height = '40px';
}





/* 
	Flash Omniture Tracking Implementation 
	JC: 10/15/2009
*/

      function onChangeSliderCTA(params) {
			var param = params.split('/').join(':').toString();
			//Setup the Omniture code to track the thrings we need 
			if (s){
				s.linkTrackVars="prop29,hier2,eVar29";		
				s.hier2 = s.pageName+":"+param+"_CTA";
				s.prop29 = s.pageName+":"+param+"_CTA";
				s.eVar29 = s.pageName+":"+param+"_CTA";
				// Send tracking data
				s.tl(this,'o','Showcase tracking');
				// Show debug window
				if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=\"http://192.168.112.2O7.net/stats_debugger.php\"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");
				// Show data in Firebug console
				try{
					console.log ("Slider CTA "+s.pageName+":"+param+"_CTA")
				}catch(_){
				
				}
			}
      }
      function onChangeSliderImpression(params) {
      		var param = params.split('/').join(':').toString();
      		if (s){
				//Setup the Omniture code to track the thrings we need 
				s.linkTrackVars="prop29,hier2";
				s.hier2 = s.pageName+":"+param;
				s.prop29 = s.pageName+":"+param;
				// Send tracking data
				s.tl(this,'o','Slider tracking');
				// Show debug window
				if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=\"http://192.168.112.2O7.net/stats_debugger.php\"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");
				// Show data in Firebug console	
				try{
					console.log ("Slider Impression "+s.pageName+":"+param)
				}catch(_){
				
				}
			}
      }
 
	
 
      function onChangeHeaderCTA(param) {
			//Setup the Omniture code to track the thrings we need 
			s.linkTrackVars="prop29,hier2,eVar29";		
			s.hier2 = s.pageName+":"+param+"_CTA";
			s.prop29 = s.pageName+":"+param+"_CTA";
			s.eVar29 = s.pageName+":"+param+"_CTA";	
			// Send tracking data
			s.tl(this,'o','VAIO Series Header tracking');
			// Show debug window
			if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=\"http://192.168.112.2O7.net/stats_debugger.php\"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");
			// Show data in Firebug console
			try{
				console.log ("Omniture Conversion tracking: "+s.pageName+":"+param+"_CTA")
			}catch(_){
			
			}
      }
      function onChangeHeaderImpression(param) {
			//Setup the Omniture code to track the thrings we need 
			s.linkTrackVars="prop29,hier2";
			s.hier2 = s.pageName+":"+param;
			s.prop29 = s.pageName+":"+param;
			// Send tracking data
			s.tl(this,'o','VAIO Series Header tracking');
			// Show debug window
			if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=\"http://192.168.112.2O7.net/stats_debugger.php\"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");
			// Show data in Firebug console	
			try{
				console.log ("Omniture Impression tracking: "+s.pageName+":"+param)
			}catch(_){
			
			}
      }

/* 
	End Flash Omniture Tracking Implementation 
*/ 