/*

File: VmlSwf.js
Author: Ed Haack (ehaack@vml.com)
Date: May 3, 2006

Usage Examples:
	Content SWF:
		var vmlSwf = new VmlSwf();
		vmlSwf.SetProperty("swfFilename", 			"content.swf");
		vmlSwf.SetProperty("swfVersion", 			"7");
		vmlSwf.SetProperty("swfWidth", 				"550");
		vmlSwf.SetProperty("swfHeight", 			"400");	
		vmlSwf.SetProperty("swfBackgroundColor", 	"#F5ECCF");	
		vmlSwf.SetProperty("swfConnectionId", 		"<%=LCID%>");
		vmlSwf.SetProperty("pageTitle", 			"<%=PageTitle%>"); 
		vmlSwf.WriteContentSwf();
	
	History SWF:
		var vmlSwf = new VmlSwf();
		vmlSwf.SetProperty("swfConnectionId", 	"<%=LCID%>");
		vmlSwf.SetProperty("pageTitle", 		"<%=PageTitle%>");
		vmlSwf.SetProperty("page", 				"<%=Page%>");
		vmlSwf.WriteHistorySwf();
*/
//Custom Settings for this site

//Properties (with default values, if possible.
var swfFilename; 		//Required for Content swf
var swfVersion			= '8';
var swfWidth;			//Required for Content swf
var swfHeight;			//Required for Content swf
var swfBackgroundColor	= '#FFFFFF';
var swfHistoryPage; 	//Required for Content swf
var swfConnectionId; 	//Required for Content swf & History swf
var pageTitle; 			//Required for Content swf & History swf
var page;      			//Required for History swf
var isDebugMode;		//Allowing for SOS Trace statements & point to dev for data
var siteName;			//The name of the site - Used for No JS and No Flash messages.
var siteHostName;
var requiresWebTrends;
var swfAlign;           //Alignment on the page: LEFT|CENTER|RIGHT;
		
var _hashName 				= '#page=';
var _hashDefaultValue 		= '0';
var historyPage;            //Required for History swf - indicates which history page to use.
var _detectionRedirectUrl   = window.location.href;

//VmlSwf Constructor
function VmlSwf()
{
	//Methods
	this.WriteContentSwf	= WriteContentSwf;
	this.WriteHistorySwf	= WriteHistorySwf;
	this.SetProperty		= SetProperty;
}

//Methods
function SetProperty(name, value)
{
	this[name] = value;
}

function WriteContentSwf()
{
	//If the user links directly to a page, set the page here.
	with(this)
	{
		var pageNameValue = '&Page=';
		var pageHash = top.location.hash;
		var pageValue;
		if(pageHash.indexOf(_hashName) > -1)
		{
			pageValue = pageHash.substring(pageHash.indexOf(_hashName) + _hashName.length, pageHash.length);
			pageNameValue += pageValue;
		}
		else
		{
			pageNameValue += _hashDefaultValue;
		}
	
		//Write the History Hidden IFrame
		var hiddenStyle = "";
		if(navigator.appName.indexOf("Microsoft") == -1)
		{
			hiddenStyle = 'STYLE="visibility:hidden;"';
		}
		
		//History IFrame
		//This is the source page for the history frame
		var historyPageUrl = historyPage + '?PageTitle='+ unescape(pageTitle) +'&lcid='+ swfConnectionId + pageNameValue;
		var historyFrameName = 'historyFrame';
		var historyIFrame = '<IFRAME NAME="'+ historyFrameName +'" SRC="'+ historyPageUrl +'" TITLE="'+ pageTitle +'" WIDTH="0" HEIGHT="0" '+ hiddenStyle +'>Please upgrade your browser</IFRAME>';
		document.write(historyIFrame);
		
		//Write the div tag for swf placement on the page.
		var flashContentDivId = 'flashContent';
		var imgTag = "";
		var _alternateContent = '<div id=\"noscript\"><BR><BR><BR>'+ imgTag +'<BR><BR><B>Macromedia Flash Player Required.</B><BR><BR>The \''+ siteName +'\' requires the use of the Macromedia Flash Player.<BR>Please click here to <a href=http://www.adobe.com/go/getflash/>Get Flash</a><BR><BR><BR><BR><BR></div>';
		var divStyle = 'text-align:'+ swfAlign +';';
		document.write('<div id="'+ flashContentDivId +'" STYLE="'+ divStyle +'">'+ _alternateContent +'</div>');
		
		//Write the swf object
		var swfObject = new SWFObject(swfFilename, "base", swfWidth, swfHeight, swfVersion, swfBackgroundColor, true);
		swfObject.addParam("quality", "auto");
		swfObject.addParam("wmode", "transparent");
		swfObject.addParam("menu", "false");
		swfObject.addParam("swLiveConnect", "true");
		swfObject.addParam("allowScriptAccess", "sameDomain");
		//swfObject.addVariable("page", pageValue);
		//swfObject.addVariable("pageTitle", pageTitle);
		swfObject.addVariable("swfURL", swfURL);
		swfObject.addVariable("videoURL", videoURL);
		swfObject.addVariable("soundURL", soundURL);
		swfObject.addVariable("sendToAFriendURL", sendToAFriendURL);
		swfObject.addVariable("shenanigansURL", shenanigansURL);
		swfObject.addVariable("productPageURL", productPageURL);
		swfObject.addVariable("pod1URL", pod1URL);
        swfObject.addVariable("pod2URL", pod2URL);
        swfObject.addVariable("pod3URL", pod3URL);
		swfObject.addVariable("lcid", swfConnectionId);
		swfObject.addVariable("isDebugMode", isDebugMode);
		swfObject.addVariable("historyPage", historyPage);
		swfObject.addVariable("historyFrame", historyFrameName);
		swfObject.setAttribute("xiRedirectUrl", _detectionRedirectUrl);
		// Left Navigation 
		swfObject.addVariable("homeURL", homeURL);
		swfObject.addVariable("oddcastURL", oddcastURL);
		swfObject.addVariable("sweepsstakesURL", sweepsstakesURL);
		swfObject.addVariable("irishwaysURL", irishwaysURL);
		swfObject.addVariable("leprechaunURL", leprechaunURL);
		swfObject.addVariable("shenanigansURL", shenanigansURL);
		swfObject.addVariable("irishspringURL", irishspringURL);
		// End Left Navigation 
		// Bottom pods homepage
		swfObject.addVariable("podsweepsURL", podsweepsURL);
		swfObject.addVariable("pododdcastURL", pododdcastURL);
		swfObject.addVariable("podmaximURL", podmaximURL);
		swfObject.write(flashContentDivId);
	}
}

function WriteHistorySwf()
{
	with(this)
	{
		//Fail-Safe Function - If the Connection could not be made,
		// check to see if the hash is set, if so, go to that page,
		// otherwise, go to the default page (in this example: 0)
		var pageHash = top.location.hash;
		pageHash = pageHash.substring(pageHash.indexOf(_hashName) + _hashName.length, pageHash.length);
		if(page == 'undefined' && pageHash != '') 
		{
			page = pageHash;	
		}
		else if(page == 'undefined')
		{
			page = _hashDefaultValue;
		}
		
		//Update the Page Title
		var documentTitle = siteTitle + ' - ' + pageTitle;
		top.document.title = documentTitle;
		document.title = documentTitle;

		//Detect for IE Browser - Upage Hash value for bookmarking...
		//As of: May 1, 2006:
		//NOTE: Although other browers can update the hash in this manner,
		//      it will hinder the functionality 
		//      of the "Back" and "Next" Buttons in the Mozilla browser.
		if(navigator.appName.indexOf("Microsoft") != -1)
		{
			top.location.hash = _hashName.substring(1, _hashName.length) + page;
		}

		//Write the div tag for swf placement on the page.
		var flashHistoryDivId = "flashHistory";
		document.write('<div id="'+ flashHistoryDivId +'"></div>');
		
		//Write the swf object
		var swfObject = new SWFObject("/IrishSpring/US/EN/Bodywash/GetIrishNow/Microsite/swf/history.swf", "history", "0", "0", "7", "#F5ECCF");
		swfObject.addParam("quality", "auto");
		swfObject.addParam("menu", "false");
		swfObject.addParam("swLiveConnect", "true");
		swfObject.addParam("allowScriptAccess", "sameDomain");
		swfObject.addVariable("page", page);
		swfObject.addVariable("pageTitle", pageTitle);
		swfObject.addVariable("lcid", swfConnectionId);
		swfObject.write(flashHistoryDivId);
	}
}


function getLocale()
{
    //Note: This is included for instances when passing the user's locale is required.
	var locale;
	if (typeof(navigator.language) != "undefined")
	{
	  	locale = navigator.language;
	}
	else if (typeof(navigator.browserLanguage) != "undefined")
	{
	  	locale = navigator.browserLanguage;
	}
	else
	{
		locale = "Unknown";
	}
	return locale;
}



