
var isNav4, isIE4, isNav6 = false;
var range = "";
var styleObj = "";

if (navigator.appVersion.charAt(0) >= 4) {
	if (navigator.appName == "Netscape") {
		if (navigator.appVersion.charAt(0) >= 5) {
			isNav6 = true;
		}
		else {
			isNav4 = true;
		}
	}
	else {
		isIE4 = true;
		range = "all.";
		styleObj = ".style";
	}
}

function getObject(obj) {
	var theObj;
	if (typeof obj == "string") {
		if (isNav6) {
			theObj = document.getElementById(obj);
			if (theObj != null) theObj = theObj.style;
		}
		else {
			theObj = eval("document." + range + obj);
			if (theObj != null) theObj = eval("theObj" + styleObj);
		}
	}
	else {
		theObj = obj;
	}
	return theObj;
}

function show () {
	var theObj;
	for (var i = 0; i < show.arguments.length; i++) {
		theObj = getObject(show.arguments[i]);
		if (theObj != null) {
			theObj.display = "block";
			theObj.visibility = "visible";
		}
	}
}

function hide () {
	var theObj;
	for (var i = 0; i < hide.arguments.length; i++) {
		theObj = getObject(hide.arguments[i]);
		if (theObj != null) {
			theObj.display = "none";
			theObj.visibility = "hidden";
		}
	}
}

function ValidateZip(value)
{
	var re = /^\d{5}$/;
	return re.test(value);
}

function offerBoxActivate(offerBox, offerCount) 
{
	for (var i = 1; i <= offerCount; i++)
	{
		var boxID = "" + i;
		var boxName = "offerBox" + boxID;
		if (offerBox == boxID)
		{
			show(boxName);
		}
		else
		{
			hide(boxName);
		}
	}
}

function changeBtn(offerBtn, offerBtnCount, baseSkinPath) {
	for (var i = 1; i <= offerBtnCount; i++)
	{
		var btnID = "" + i;
		var btnName = "offerBtn" + btnID;
		if (offerBtn == btnID)
		{
			newImage = "url(" + baseSkinPath + "/images/offer_nav_on.gif)";
			document.getElementById(btnName).style.backgroundImage = newImage;
			document.getElementById(btnName).style.color = '#000000';
		}
		else
		{
			newImage = "url(" + baseSkinPath + "/images/offer_nav_off.gif)";
			document.getElementById(btnName).style.backgroundImage = newImage;
			document.getElementById(btnName).style.color = '#FFFFFF';
		}
	}
}

function launchWindow(strURL, strName, intWidth, intHeight, strProperties) 
{
	createWindow(strURL, strName, intWidth, intHeight, strProperties);
}

function createWindow(strURL, strName, intWidth, intHeight, strProperties)
{
	var mywin;
	var intVersion;
	var dummyDate = new Date(); 
/*
	if (strURL != "") 
	{
		if (strURL.indexOf("?") != -1) { 
			strURL = strURL + "&rnd="
		} else {
			strURL = strURL + "?rnd="
		}
			
		strURL = strURL + dummyDate.getTime();
	}
*/	
	if (strProperties == "") {
		strProperties = "scrollbars=yes,resizable=yes,menubar=no,location=no,directories=no,toolbar=no";
	}
	
	strProperties = "status=yes,height=" + intHeight + ",width=" + intWidth + "," + strProperties;
	
	strName = strName.toLowerCase();
	
	mywin = window.open(strURL, strName, strProperties);

	return mywin;
}

function setStyleByName(n, p, v)
{
	var elements = document.getElementsByName(n);
	for(var i = 0; i < elements.length; i++)
	{
		elements.item(i).style.backgroundColor = v;
	}
}

var cclass = "odd";
function setBgColor(box, oddColor, evenColor)
{
	var color;
	if (cclass == "odd")
	{
		if (oddColor == null)
		{
			oddColor = "#EDEEEF";
		}
		
		cclass = "even";
		setStyleByName(box, "backgroundColor", oddColor);
	}
	else
	{
		if (evenColor == null)
		{
			evenColor = "#F8F8F9";
		}

		cclass = "odd";
		setStyleByName(box, "backgroundColor", evenColor);
	}
}

function ReplaceTokenInText( emailObject, emailText, tokenText, token )
{
	var s = document.forms['Form1'].elements[emailText].value;
	var s2 = s.replace( token, tokenText );
	document.forms['Form1'].elements[emailObject].value = s2;
}

var redirectUrl = "";
var tFunc = "";
function RedirectOnTimeout(timeout)
{
	tFunc = setTimeout("PageRedirect()", timeout);
} 

function PageRedirect()
{
	document.location = redirectUrl;
}

function trackSpotlight(src, type, cat) {
	var click1 = new Image();
	var axel = Math.random() + "";
	var ord = axel * 1000000000000000000;
	//click1.src = 'http://ad.doubleclick.net/activity;src=123456;type=test123;cat=test456;ord=' + ord + '?';
	click1.src = 'http://ad.doubleclick.net/activity;src=' + src + ';type=' + type + ';cat=' + cat + ';ord=' + ord + '?';
}
