
if (window.serverVars == null) {
    window.serverVars = {
        applicationName: 'High Life'
    };
}

function getSect(sect){
    if(navigator.appName.indexOf("Microsoft") != -1) {
        var flash = window.FlashMov;
    }else {
        var flash = window.document.FlashMov;
    }
    flash.gotoSect(sect);
}
function getLGBGSect(sect){
    document.location.href = "/littleguysbiggame/#/" + sect;
}
function getSectAndDot(sect, page){
    dotFooterPage(page);
    getSect(sect);
}
function dotFooterPage(page){
    dotPage('HL Footer: ' + page, 'High Life Footer');
    return true;
}
function launch1secAd(){
    if(navigator.appName.indexOf("Microsoft") != -1) {
        var flash = window.FlashMov;
    }else {
        var flash = window.document.FlashMov;
    }
    flash.oneSecAdClicked();
}

function superGetSect(sect){
	if (opener && !opener.closed){ // if opener exists:
		opener.getSect(sect);
		opener.focus();
	} else { //if opener doesn't exist:
		//if the current (sitemap) window is the sitemap popup window, we want to open the site in a new window:
		if(window.name == 'popup'){
			launchWindow('Default.aspx?page=' + sect,'main','width=990,height=640,scrollbars=auto,toolbar=yes,location=yes,status=auto,menubar=yes,resizable=yes');
		} else {
			//otherwise they got to the sitemap from a search engine or other, and we don't want to open the site in a new window:
			window.location.href='Default.aspx?page=' + sect;
		}
	}
}

function superGetLGBGSect(sect){
	if (opener && !opener.closed){ // if opener exists:
		opener.getLGBGSect(sect);
		opener.focus();
	} else { //if opener doesn't exist:
		//if the current (sitemap) window is the sitemap popup window, we want to open the site in a new window:
		if(window.name == 'popup'){
			launchWindow('littleguysbiggame/#/' + sect,'main','width=990,height=640,scrollbars=auto,toolbar=yes,location=yes,status=auto,menubar=yes,resizable=yes');
		} else {
			//otherwise they got to the sitemap from a search engine or other, and we don't want to open the site in a new window:
			window.location.href='littleguysbiggame/#/' + sect;
		}
	}
}

function displayDiv(id){
    var theDiv = document.getElementById(id);
    theDiv.style.display = "block";
}
function hideDiv(id){
    var theDiv = document.getElementById(id);
    theDiv.style.display = "none";
}


String.prototype.trim = strtrim;

function strtrim()
{
	return this.replace(/^\s+/,'').replace(/\s+$/,'');
}

function SetInputFocus(fieldName)
{
	if (document.getElementById)
	{
		if (document.getElementById(fieldName) != null)
		{
			document.getElementById(fieldName).focus();
		}
		document.getElementById(fieldName).select();
	}
	else if (document.all)
	{ 
	    if (document.all[fieldName] != null)
	    {
	        document.all[fieldName].focus();
		}
		document.all[fieldName].select();
	}
	else if (document.layers)
	{
	    if (document.layers[fieldName] != null)
	    {
	        document.layers[fieldName].focus();
	    }
	    document.layers[fieldName].select();
	}
}
function ReturnControl(fieldName)
{
	if (document.getElementById)
	{
		if (document.getElementById(fieldName) != null)
		{
			return document.getElementById(fieldName);
		}
	}
	else if (document.all)
	{
		if (document.all[fieldName] != null)
		{
			return document.all[fieldName];
		}
	}
	else if (document.layers)
	{
		if (document.layers[fieldName] != null)
		{
			return document.layers[fieldName];
		}
	}
	
	return null;
}
function ChangeImage(img,src)
{
	img.src = src;
}

function RevertImage(img,src)
{
	img.src = src;
}
function launchWindow(url, windowName, attributes){
	openPopUpWindow(url, windowName, attributes);
}

function openPopUpWindow(url, windowName, attributes)
{
    // Because LGBG was authored with popup functionality built in to the swf we need to
    // hook into the function and revert it to a simple redirect for the case of returning
    // to the site itself.
    if (url == 'http://www.millerhighlife.com'
        || url == 'http://www.millerhighlife.com/'
        || url == 'http://www.millerhighlife.com/Default.aspx') 
    {
        document.location.href = '/';
        return;
    }
    windowName = windowName || 'popup';
    attributes = attributes || 'width=640,height=500,scrollbars=yes,resizable=yes';
	myWindow = window.open(url, windowName, attributes);
	myWindow.focus();
}

function Flash_Navigate(sect)
{
	if(navigator.appName.indexOf("Microsoft") != -1) {
        var flash = window.FlashMov;
    }else {
        var flash = window.document.FlashMov;
    }
    flash.gotoSect(sect);
}

function openSiteMap(url, windowName, attributes)
{
	if ((window['sitemapWindow'] == undefined) || (window['sitemapWindow'].closed))
	{
		window['sitemapWindow'] = window.open(url, windowName, attributes);

		var _parent = this;
		
		sitemapWindow.FlashNavigate = function(sect) 
		{ 
			_parent.Flash_Navigate(sect);
		}
	}

	sitemapWindow.focus();
}

function preloadImgs(imgs){
    var imgObj = new Image();
    var imgList = new Array();
    imgList = imgs.split(",");
    
    for(i=0;i<imgList.length;i++){
        imgObj.src = imgList[i];
    }
}

/*

Page dotting function to talk between Flash and JS

author: Romke de Haan

*/

//function dotPage(pageName, channelName)
//{	
//	//alert("dotPage name: "+pageName+"channel: "+channelName);
//	s.pageName = pageName;
//	s.channel = channelName;
//	void(s.t());
//}

//function dotForm(pageName, channelName)
//{
//	s.eVar3 = 'Live More Registration';
//	s.events = 'event2';	
//	//alert("dotForm name: "+pageName+"channel: "+channelName);
//	s.pageName = pageName;
//	s.channel = channelName;
//	void(s.t());
//}

//function dotFormErrors(pageName, channelName, errors)
//{
//	//temp = new Array();
//	//temp = errors.split(",");
//	//alert("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)
//{
//	s.sendFormEvent('s', pageName, channelName);
//	
//	s.eVar3 = 'Live More Registration';
//	s.events = 'event1,event3';	
//	s.pageName = pageName;
//	s.channel = channelName;
//	void(s.t());
//}