var arImages=new Array();
function PreLoad() {
	var temp = PreLoad.arguments; 
	for(x=0; x < temp.length; x++) {
		arImages[x]=new Image();
		arImages[x].src=PreLoad.arguments[x];
	}
}

function loadNavImages() {
	PreLoad(
			'/Assets/Nav/home_on.gif',
			'/Assets/Nav/so_simple_on.gif',
			'/Assets/Nav/store_finder_on.gif',
			'/Assets/Nav/celebration_on.gif',
			'/Assets/Nav/about_on.gif',
			'/Assets/Nav/store_finder_on.gif',
			'/Assets/Nav/online_store_on.gif',
			'/Assets/Nav/baby_on.gif',
			'/Assets/Nav/toddler_on.gif',
			'/Assets/Nav/kids_on.gif'
			);
}
// The Central Randomizer 1.3 (C) 1997 by Paul Houle (houle@msc.cornell.edu)
// See:  http://www.msc.cornell.edu/~houle/javascript/randomizer.html

rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd() {
        rnd.seed = (rnd.seed*9301+49297) % 233280;
        return rnd.seed/(233280.0);
};

function rand(number) {
        return Math.ceil(rnd()*number);
};

// end central randomizer. -->
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function logofied() {
	imgNum = getCookie("cartersLogo");
	if (!imgNum) {
		imgNum = rand(7);
		setCookie("cartersLogo",imgNum);
	}
	if (document.getElementById('cartersLogo')) {
		document['cartersLogo'].src = path + "Assets/CategoryHeader/logo_"+imgNum+".gif";
		document.getElementById('cartersLogo').style.visibility = "visible";
	} else {
		window.setTimeout("logofied()",2);
	}
}

function startList(elID){
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById(elID);
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}

function buildNav() {
	if (document.getElementById("subNav")) {
		startList("subNav");
		//document.getElementById("dropHeader").innerHTML = document.getElementById("drop0").innerHTML;
	}
	if (document.getElementById("subNav1") && document.getElementById("subNav2")) {
		startList("subNav1");
		startList("subNav2");
		//document.getElementById("dropHeader1").innerHTML = document.getElementById("drop0").innerHTML;
		//document.getElementById("dropHeader2").innerHTML = document.getElementById("drop20").innerHTML;	
	}
	loadNavImages();
}

function openwin(url,name,width,height)
{
	window.open(url,name,'width='+width+', height='+height+', resizable=yes, scrollbars=no, toolbar=no, location=no, directories=no, status=no, menubar=no, copyhistory=no');
}

function openwinfull(url,name,width,height)
{
	window.open(url,name,'width='+width+', height='+height+', resizable=yes, scrollbars=yes, toolbar=yes, location=yes, directories=no, status=no, menubar=no, copyhistory=no');
}

function openCatazine(theURL,winName,w,h,scrollbars) 
	{ 
	  var LeftPosition=(screen.width)?(screen.width-w)/2:100;
	  var TopPosition=(screen.height)?(screen.height-h)/2:100;
	  
	  var settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scrollbars+',location=no,directories=no,status=0,menubar=no,toolbar=no,resizable=no';
	  var URL = theURL;
	  window.open(URL,winName,settings);
}

function calculate()
{
	if (!document.fileSize)
	{
		alert('This script does not work in your browser.');
		return;
	}
	var size = (document.fileSize)*1;
	var y = document.images;
	var imglength = 0;
	for (i=0;i<y.length;i++)
	{
		imglength += (y[i].fileSize)*1;
	}
	var total = size + imglength;
	var writestring = 'File size HTML: ' + size;
	writestring += '\nFile size images: ' + imglength;
	writestring += '\nTotal file size: ' + total;
	if (total > 40000) writestring += "\nFile too large!";
	alert(writestring);
}
function fixFields(radioHolder) {
	var genderHolder = document.getElementById(radioHolder);
	if (genderHolder) {
		var genderRadioList = genderHolder.childNodes;							
		for (i = 0; i <= genderRadioList.length; i++) {
			myNode = genderRadioList[i];
			if(myNode) {
				if (myNode.nodeName.indexOf('INPUT') != -1) {
					myNode.style.width = "16px";
				}
				if (myNode.nodeName.indexOf('LABEL') != -1) {
					myNode.style.width = "auto";
				}
			} else {
				window.setTimeout("fixFields('"+radioHolder+"')",2);
			}
		}
		window.setTimeout("fixFields('"+radioHolder+"')",2);
	}
}
