/*	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/static_images/ajax-loading.gif'
	};

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

/*	FUNCTION: showSeriesTab([string]theContainerID, [string] theSeriesTabID, [string] theDefaultTabID)
 *	----------------------------------------------------------------------------
 *	PRE-CONDITIONS:		this file must be included in the calling HTML page.
 *
 *						theContainerID must be a valid, defined element within
 *						the calling HTML document.
 *
 *						all potential IDs that will be called by theSeriesTab
 *						must be within theContainerID, WITH THE EXCEPTIOON OF
 *						theDefaultTabID.	
 *
 *						theSeriesTabID must be valid, defined element ID witin
 *						the HTML document.
 *
 *	POST-CONDITIONS:	showSeriesTab will be displayed, while all other elements
 *						within theContainerID will be hidden.  
 *
 *						If theDefaultTabID is also specified, this element 
 *						will also be hidden unless if happens to also be the 
 *						element called by theSeriesTabID.
 *	----------------------------------------------------------------------------			
*/
function showSeriesTab(theContainerID, theSeriesTabID, theDefaultTabID)
{
	 // let's make an element for our Tab:
	var theTabWeWant = document.getElementById(theSeriesTabID);
	var ourContainer = document.getElementById(theContainerID);

	// this is our default tab... if it's specified.
	if(theDefaultTabID)
	{	
		var theDefaultTab = document.getElementById(theDefaultTabID);
		ourContainer.style.display = "block";
		theDefaultTab.style.display = "none";
	}
	
	// let's look for our div container with all the inline DIVs with tab content:
	var ourTabContainer = document.getElementById(theContainerID);
	
	// let's also create a new variable for us to parse through this stuff:
	var ourInsideElements = ourTabContainer.getElementsByTagName('div');
	
	
	// let's look for all of our nested DIVs within the container...
	for(var i = 0; i < ourInsideElements.length; i++)
	{
		
		// ...but we only want the first level of DIVS, all of which have the class "hidden":
		if(ourInsideElements[i].className == "hidden")
		{
			// alert (ourInsideElements[i].id);  //- for debugging purposes.
			
			// let's reset our displays to "off"
			ourInsideElements[i].style.display = "none";
									
		}
		
	}
	
	// now let's turn our tab "on":
	ourContainer.style.display = "block";
	theTabWeWant.style.display = "block";
}
// end function.


/*	FUNCTION: 	displayFlashHeader([string]divID, [int]width, [int]height, 
 *				[string/html]headerString, [string]alignment, [int]offsetX, 
 *				[int]offsetY, [string]objectAlign)
 * 	----------------------------------------------------------------------------
 *	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)
{
	// 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;
	}	
	
	// 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.
	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.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.

