	/*
		The following is not needed if the page has the externals file
	*/
	isMinNS4 = (document.layers) ? 1 : 0;
	isMinIE4 = (document.all) ? 1 : 0;
	isMinIE5 = (document.getElementById&&document.all) ? 1 : 0;
	isNS6 = (document.getElementById&&!document.all) ? 1 : 0;
	/*
		The above is not needed if the page has the externals file
	*/
	var clickme = false;
	var clickmelink = "";
	function mwo(mapUrl,mapHandle,mapParams,lid) {
		clickme = true;
		clickmelink = lid;
		setTimeout("checkClick()",1000);
		var thisGuy = window.open(mapUrl,mapHandle,mapParams);
		clickme = false;
		if (thisGuy == null) {
			clickme = true;
			return true;
		} else {
			return false;
		}
	}
	function checkClick() {
		if (clickme == true) {
			clickme = false;
			document.location = document.getElementById(clickmelink).href;
		}
	}

	function submitFormForNavButtons(formId,buttonPressed) {
		var form = document.getElementById(formId);
		if(buttonPressed == "nextStep") {
			var button1 = document.getElementById(formId + "_nextStepButtonPressed");
			button1.value = "true";
		} else {
			var button1 = document.getElementById(formId + "_previewButtonPressed");
			button1.value = "true";
		} 
}

/* code for popup windows */
var newPopwindow;
function poptastic(url)
{
    newPopwindow=window.open(url,'name','height=800,width=1024,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,status=yes'); 

    if (window.focus) {newPopwindow.focus()}
}

// **** begin stuff from ext.js on weather.com
var isLocal = (window.location.hostname.indexOf("weather.com")>=0)?1:0;

function getCookieVal (offset) {
    if (!isLocal) return false;
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1) endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
    if (!isLocal) return false;
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
    }
    return "";
}


function DeleteCookie (name,path,domain) {
    if (!isLocal) return false;
    if (GetCookie(name)) document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

// **** end stuff from ext.js on weather.com

// *** begin code from index.html on weather.com
//This was added to "touch" the UserPreferences and RMID cookies with every 
//page view so that their expiration date changes.  If the cookie exists....
	var queryString = new Object;
	function parseParameter() {
	var temp_query = new RegExp ('^[^\\?]+\\?(.*)$');
	if ( ! temp_query.test(location) ) return false;
	var array = temp_query.exec(location);
	queryString.QUERY_STRING = array[1];
	var params = queryString.QUERY_STRING.split(/&/);
	for ( var i = 0; i < params.length; i++ ) {
		var keys = params[i].split(/=/);
		queryString[ keys[0] ] = unescape(keys[1]);
		}
	}
	
function paramValue(key) {
	if ( key == null ) {
		alert("param() function has been used incorrectly.\nUSAGE: param(key)");
		return false;
	}
		return queryString[key];
}
// *** end code from index.html on weather.com

// Function to return the parameter value for the given param name
// function was found on the web somewhere
function getParameter(parameterName) {
  var paramValue= '';
  var queryString = window.top.location.search.substring(1);
  // Add "=" to the parameter name (i.e. parameterName=value)
  var parameterName = parameterName + "=";
  if ( queryString.length > 0 ) {
    // Find the beginning of the string
    begin = queryString.indexOf ( parameterName );
    // If the parameter name is not found, skip it, otherwise return the value
    if ( begin != -1 ) {
      // Add the length (integer) to the beginning
      begin += parameterName.length;
      // Multiple parameters are separated by the "&" sign
      end = queryString.indexOf ( "&" , begin );
      if ( end == -1 ) {
        end = queryString.length
      }
      // Return the string
      paramValue = unescape ( queryString.substring ( begin, end ) );
    }
  }
  if(typeof(queryString) == 'undefined') {
    return "";
  } else {
    return paramValue;
  }

}


// Functions to manage ad container DOM
function displayPageSpon() {
	var container_div = document.getElementById("side");
	var adwrap = document.getElementById("adwrap");
	var ad_div_pagespon = document.createElement("div");
	ad_div_pagespon.setAttribute("id","pagespon");
	var sscript = "<script>";
	var sscript2 = "OAS_AD('PageSpon')";
	var sscript3 = "</SCRIPT" + ">";
	ad_div_pagespon.innerHTML = sscript + sscript2 + sscript3;
	var ad_div_1 = document.getElementById("verticalAd_1");
	var ad_div_2 = document.getElementById("verticalAd_2");
	var ad_div_3 = document.getElementById("verticalAd_3");

	if ( ad_div_1.innerHTML.indexOf("empty.gif")>-1 && ad_div_2.innerHTML.indexOf("empty.gif")>-1 && ad_div_3.innerHTML.indexOf("empty.gif")>-1) {
			adwrap.appendChild(ad_div_pagespon);
			ad_div_pagespon.style.display = "block";
			ad_div_1.style.display = "none";
			ad_div_2.style.display = "none";
			ad_div_3.style.display = "none";
			container_div.style.background = "none";
			container_div.style.height = "250px";
			container_div.style.display = "block";
			container_div.style.marginTop = "-10px";
			container_div.style.padding = "0px";
			document.getElementById("official_partners").innerHTML = "";
		return null;
	}
//	else {
//		adwrap.removeChild(ad_div_pagespon);
//		return null;
//	}
}
function resizeHorizontalAdContainer() {
	var container_div = document.getElementById("adbar_full");
	var ad_div_1 = document.getElementById("horizontalAd_1");
	var ad_div_2 = document.getElementById("horizontalAd_2");
	var ad_div_3 = document.getElementById("horizontalAd_3");
	var htally = 3;
	if (ad_div_1.innerHTML.indexOf("empty.gif")>-1) {
		htally--;
	}
	if (ad_div_2.innerHTML.indexOf("empty.gif")>-1) {
		htally--;
	}
	if (ad_div_3.innerHTML.indexOf("empty.gif")>-1) {
		htally--;
	}
	switch(htally) {
		case 0:
			ad_div_1.style.display	=	"none";
			ad_div_2.style.display	=	"none";
			ad_div_3.style.display	=	"none";
			container_div.style.display = "none";
			return null;
		case 1:
			ad_div_2.style.display	=	"none";
			ad_div_3.style.display	=	"none";
			container_div.style.width = "353px";
			container_div.style.background = "url(/web/vr/gnav/featured_ad_container_1_wide.gif)";
			return null;
		case 2:
			ad_div_3.style.display	=	"none";
			container_div.style.width = "662px";
			container_div.style.background = "url(/web/vr/gnav/featured_ad_container_2_wide.gif)";
			return null;
	}
	return null;
}
function resizeVerticalAdContainer() {
	var container_div = document.getElementById("side");
	var ad_div_1 = document.getElementById("verticalAd_1");
	var ad_div_2 = document.getElementById("verticalAd_2");
	var ad_div_3 = document.getElementById("verticalAd_3");
	var vtally = 3;

	if (ad_div_1.innerHTML.indexOf("empty.gif")>-1) {
		vtally--;
	}
	if (ad_div_2.innerHTML.indexOf("empty.gif")>-1) {
		vtally--;
	}
	if (ad_div_3.innerHTML.indexOf("empty.gif")>-1) {
		vtally--;
	}
	switch(vtally) {
		case 0:
			container_div.style.display = "none";
			return null;
		case 1:
			container_div.style.height = "171px";
			container_div.style.background = "url(/web/vr/gnav/featured_ad_container_1_tall.gif)";
			return null;
		case 2:
			container_div.style.height = "272px";
			container_div.style.background = "url(/web/vr/gnav/featured_ad_container_2_tall.gif)";
			return null;
	}
	return null;
}

// Below code is used to schedule the scrolling effect on level 3 #side ad module; the animation will occur SCROLL_DELAY number of milliseconds afer the last scroll event
// I found this code at http://www.thescripts.com/forum/thread661801.html - mep
	var doAfterScroll = (function(){
		// Configure
		var SCROLL_DELAY = 250 ;
		// Do not edit the following
		var baseId = 0, scrollId = 0, currentlyScrolling = false, funcs = [] ;
		// --- Init ---
		addEvent(window,"onscroll",function(evt) {
			// update the scroll identifier
			scrollId = new Date().getTime();
			if	(!currentlyScrolling) { //Scroll has just started
				// set the info
				currentlyScrolling=true;
				// Launch the watch process
				setTimeout(
					function() {
						if(scrollId==baseId) { // Scrolling has stopped
							// set the info
							currentlyScrolling = false;
							// Execute the registered handlers
							for(var ii=funcs.length; ii--; ) {
								funcs[ii]() ;
							}
						}
						else { // Still scrolling
							// set a milestone
							baseId=scrollId ;
							// wait
							setTimeout (arguments.callee, SCROLL_DELAY);
						}
					}, SCROLL_DELAY
				);
			} 
			else {
				// a process has already been launched
				// and is waiting to be completed
				// - Do nothing
			}
		}
	);

	// --- return the registering function ---
	return function (func) { funcs.push(func); }

	// --- Helpers ---
	function addEvent(obj, evt, func){
		if(obj[evt]) {
			obj[evt]=(function(handler) {
				return function(evt){
					func.call(this, evt);
					return handler.call(this, evt);
				}
			})(obj[evt]);
		}
		else {
			obj[evt]=func;
		}
	}
	})();

