// -- JavaScript Library
// -- Global Functions

function launchWindow(url, windowName, attributes)
{
	openPopUpWindow(url, windowName, attributes);
}

function openPopUpWindow(url, windowName, attributes)
{
	var myWindow = window.open(url, windowName, attributes);
}

function resizeSWF(nHeight) {
	nHeight += "px";
	document.getElementById("FlashMov").style.height = nHeight;
	document.getElementById("mainFlashMasthead").style.height = nHeight;
}



function FullbrowserSweeps() {
	if ((screen.width < 1024) || (screen.height < 768))	{
		window.open('Intersiteredirect.aspx?fromUrl=http://www.fostersbeer.com/&toUrl=http://wcserver4.net/fosters/', 'sweeps', 'left=0, top=0, scrollbars=yes, height=' + screen.availHeight + ', width=' + screen.availWidth, true);
	} else {
		window.open('Intersiteredirect.aspx?fromUrl=http://www.fostersbeer.com/&toUrl=http://wcserver4.net/fosters/', 'sweeps', 'left=0, top=0, height=' + (screen.availHeight - 30) + ', width=' + screen.availWidth, true);
	}
}

function OpenTFWin() {	
	var TeamFostersWindow = window.open('IntersiteRedirect.aspx?fromUrl=http://www.fostersbeer.com&toUrl=http://tf.fostersbeer.com/', 'TeamFosters', 'scrollbars=yes,location=yes,menubar=yes,resizable=yes,status=yes,toolbar=yes',true);
}

/*

Page dotting function to talk between Flash and JS

author: Romke de Haan

*/

function dotPage(pageName, channelName) {
    
    // Flash escapes these values before passing them for quotes and newlines
    pageName    = unescape(pageName);
    channelName = unescape(channelName);

    dotClearExtendedProperties();	
    
	//alert("dotPage name: "+pageName+"; channel: "+channelName);
	s.pageName = pageName;
	s.channel  = channelName;

	void(s.t());
}

function dotForm(pageName, channelName) 
{
    // Flash escapes these values before passing them for quotes and newlines
    pageName = unescape(pageName);
    channelName = unescape(channelName);
    
    dotClearExtendedProperties();
    
	s.eVar3    = "Foster's: Be Enormous";
	s.events   = "event2";	
	//alert("dotForm name: "+pageName+"channel: "+channelName);
	s.pageName = pageName;
	s.channel  = channelName;
	
	void(s.t());
}

function dotFormErrors(pageName, channelName, errors) 
{
    // Flash escapes these values before passing them for quotes and newlines
    pageName = unescape(pageName);
    channelName = unescape(channelName);
    
    dotClearExtendedProperties();
    
	//temp = new Array();
	//temp = errors.split(",");
	//alert("dotFormErrors name: "+pageName+" channel: "+channelName + " errors: " + errors);
	
	temp = new Array();
	temp = errors.split(",");
	
	for(var i in temp){
		s.sendFormEvent("e", pageName, channelName, temp[i]);
	}
			
/*	for(var i in errors){
		s.sendFormEvent("e", pageName, channelName, errors[i]);
	}*/
}

function dotFormSuccess(pageName, channelName) 
{
    // Flash escapes these values before passing them for quotes and newlines
    pageName = unescape(pageName);
    channelName = unescape(channelName);

    dotClearExtendedProperties();
    
	s.sendFormEvent("s", pageName, channelName);
	
	s.eVar3    = "Foster's: Be Enormous";
	s.events   = "event1,event3";	
	s.pageName = pageName;
	s.channel  = channelName;

	void(s.t());
}

function dotPremiumTipsVideo(category, title) 
{
    // Flash escapes these values before passing them for quotes and newlines
    category = unescape(category);
    title = unescape(title);

    dotClearExtendedProperties();

    // Remove any formatting
    category = category.split("\n").join(" ");
    title    = title.split("\n").joing(" ");
    
	s.pageName = "Foster's: FPA Premium Tips: " + category + ": " + title;
	s.channel  = "Foster's: FPA Premium Tips";
	s.prop3    = "FPA Premium Tips";
	s.prop4    = category;
	s.prop5 = title;

	void(s.t());
}


function dotHowToSpeakAustralianVideo(category, title) 
{
    // Flash escapes these values before passing them for quotes and newlines
    category = unescape(category);
    title = unescape(title);

    dotClearExtendedProperties();

    // Remove any formatting
    category = category.split("\n").join(" ");
    title    = title.split("\n").joing(" ");
    
	s.pageName = "Foster's: How To Speak Australian: " + category + ": " + title;
	s.channel  = "Foster's: How To Speak Australian";
	s.prop3    = "How To Speak Australian";
	s.prop4    = category;
	s.prop5 = title;

	void(s.t());
}

function dotClearExtendedProperties() 
{
    // After a call to the dotPremiumTipsVideo the s.prop variables
    // would remain populated for all later calls. This function
    // should be called before the s.t() method in all other
    // page dotting functions to clear them.
    s.events = null;
    s.eVar3  = null;
    s.prop3  = null;
    s.prop4  = null;
    s.prop5  = null;
}

// EOF
