function localWxCheck(){
	var zipValue = new String("" + trim(document.forms[0].zipcode.value));
    zipValue = zipValue.toLowerCase();
	if((zipValue.toLowerCase() == "zipcode or city,state")||(zipValue == "")){
	    var locationCookie = getCookie('locz');
	    if(locationCookie != ""){
	        var checkCookiePieces = locationCookie.split('|');
	        var checkCookieZip = checkCookiePieces[1];  //grab zipcode out of split cookie (second item in array)
	        if(checkCookieZip != ""){document.forms[0].zipcode.value = checkCookieZip;}
	    }
	}
	return true;
}
function canadaWxCheck(){
	var postValue = new String("" + trim(document.forms[0].postalcode.value));
    postValue = postValue.toLowerCase();
	if((postValue == "postalcode or city,province")||(postValue == "")){
	    var locationCookie = getCookie('canada');
	    if(locationCookie != ""){
	        var checkCookiePieces = locationCookie.split('|');
	        var checkCookieZip = checkCookiePieces[1];  //grab zipcode out of split cookie (second item in array)
	        if(checkCookieZip != ""){document.forms[0].postalcode.value = checkCookieZip;}
	    }
	}
	return true;
}
function worldWxCheck(){
	var zipValue = new String("" + trim(document.forms[0].zipcode.value));
	zipValue = zipValue.toLowerCase();
	if((zipValue == "city,country")||(zipValue == "city, country")||(zipValue == "")){
	    var locationCookie = getCookie('world');
	    if(locationCookie != ""){
	        var checkCookiePieces = locationCookie.split('|');
	        var checkCookieZip = checkCookiePieces[3] + ';' + checkCookiePieces[4] + ';' + checkCookiePieces[5] + ';' + checkCookiePieces[6] + ';'; //grab zipcode out of split cookie (second item in array)
	        if(checkCookieZip != ""){document.forms[0].zipcode.value = checkCookieZip;}
	    }
    	return true; 			
	}
}

//Jump menu function written by Macromedia
//Used in the selectbox on forecast-detail.asp to toggle between foreacst days
function MM_jumpMenu(targ,selObj,restore)
{ //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}
//attached to table cells and alike for navigation
function getUrl(thelink)
{
	location.href = thelink
}
function trim(fieldValue) {
	var tempValue = fieldValue;
	var RGXobj = /^(\s*)([\W\w]*)(\b\s*$)/;
	if (RGXobj.test(tempValue)) { tempValue = tempValue.replace(RGXobj, '$2'); }
	return tempValue;
}
function getCookie(theCkeName)
{
    var CookieString = document.cookie;
    var CookieSet = CookieString.split (';');
    var SetSize = CookieSet.length;
    var CookiePieces = new Array();
    var ReturnValue = "";
    for (x = 0; ((x < SetSize) && (ReturnValue == "")); x++)
    {
        CookiePieces = CookieSet[x].split ('=');
        if (CookiePieces[0].substring (0,1) == ' '){CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length);}
        if (CookiePieces[0] == theCkeName) {ReturnValue = unescape(CookiePieces[1]);}
    }
    return ReturnValue;
}

function getTrackingCookie(theCkeName)
{
    var CookieString = document.cookie;
    var CookieSet = CookieString.split (';');
    var SetSize = CookieSet.length;
    var CookiePieces = new Array();
    var ReturnValue = "";
    for (x = 0; ((x < SetSize) && (ReturnValue == "")); x++)
    {
        CookiePieces = CookieSet[x].split ('=');
        if (CookiePieces[0].substring (0,1) == ' '){CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length);}
        if (CookiePieces[0] == theCkeName) {ReturnValue = unescape(CookiePieces[1]);}
    }
    return ReturnValue;
}



function setCookie(ckeValue,ckeName)
{
    ckeValue = ckeValue + "::::" + ckeName;
    var today = new Date();
    var expireDate = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000); // plus 365 days in milliseconds
    document.cookie=ckeName+"="+escape(ckeValue)+"; expires=" + expireDate.toGMTString() + "; domain=.accuweather.com; path=/";
}
function setTrackingCookie(ckeValue,ckeName)
{
    var today = new Date();
    var expireDate = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000); // plus 365 days in milliseconds
    document.cookie=ckeName+"="+escape(ckeValue)+"; expires=" + expireDate.toGMTString() + "; domain=.accuweather.com; path=/";
}
function getTheID(theLayerID)
{	
	if(document.getElementById){				
		return document.getElementById(theLayerID); //DOM; IE5, NS6, Mozilla, Opera
	}else if(document.all){
		return document.all[theLayerID]; //Proprietary DOM; IE4
	}else if(document[theLayerID]){
		return document[theLayerID]; //Netscape alternative
	}
	//Netscape layers - not currently supporting
	//if( document.layers ){//return document.layers[theLayerID];//}
	return false;
}

function placeToolBox(theBox)
{
	var promoBarHeight = 40;

	var toolBoxObj = getTheID(theBox);
	if(!toolBoxObj){return;}
	var pageHeaderObj = getTheID("adcpage_header");
	if(!pageHeaderObj){return;}
	
	var pageHeaderHeight = pageHeaderObj.offsetHeight;
	var popupLookupBoxYpos = pageHeaderHeight - promoBarHeight;
	
	if(toolBoxObj.style )
	{
		toolBoxObj.style.top = popupLookupBoxYpos + "px";	
	}
	else
	{
		toolBoxObj.top = popupLookupBoxYpos + "px";
	}
}

function showHideToolbox(activeBox)
{
	var activeToolBoxRef = getTheID(activeBox);
	if(!activeToolBoxRef){return;}
	if(activeToolBoxRef.style)
	{
		if(activeToolBoxRef.style.visibility == "visible"){activeToolBoxRef.style.visibility = "hidden";}
		else{activeToolBoxRef.style.visibility = "visible";}
	}
	else
	{
		if(toolBoxRef.visibility == "visible"){activeToolBoxRef.visibility = "hidden";}
		else{activeToolBoxRef.visibility = "visible";}
	}
}
/*
function getUserPreferences()
{  
    var optionsCookie = getCookie("adc0");
    if(optionsCookie != ""){userSettings = optionsCookie.split("|");}
    else{userSettings = new Array('0','1110');} //default settings: myADC,roads-cities-markers-compass   values: 1=on,0=off
}
*/
// set global scoped vars
var userSettings;
var optionsCookie = getCookie("adc0");
if(optionsCookie != ""){userSettings = optionsCookie.split("|");}
else{userSettings = new Array('0','1-1-1-1','0');} //default settings: myADC,roads-cities-markers-compass   values: 1=on,0=off
var radarLayerPrefs;
if (userSettings.length < 2) {
   radarLayerPrefs = '1-1-1-1';
}
else
{ 
   radarLayerPrefs = userSettings[1];
}
if((radarLayerPrefs=="") || (radarLayerPrefs == undefined)){radarLayersPrefs="1-1-1-1";}    //default settings if none cookied
radarLayers = radarLayerPrefs.split("-");
