//This function will fire when the page first loads...
//It preloads the top navigation images into an array
function Init() {
	imgOvers = new Array(6);
	imgOvers[0] = new Image();imgOvers[0].src = '/img/template/TabStore_On.gif';
	imgOvers[1] = new Image();imgOvers[1].src = '/img/template/TabServices_On.gif';
	imgOvers[2] = new Image();imgOvers[2].src = '/img/template/TabResources_On.gif';
	imgOvers[3] = new Image();imgOvers[3].src = '/img/template/TabMembership_On.gif';
	imgOvers[4] = new Image();imgOvers[4].src = '/img/template/TabMyMariSafe_On.gif';
	imgOvers[5] = new Image();imgOvers[5].src = '/img/template/TabNews_On.gif';
	imgOvers[6] = new Image();imgOvers[6].src = '/img/template/TabAboutUs_On.gif';
}






// -- START POPUP CHALLENGE CODE
var ThecookieName = "popChall";
var path = "/";
var expDays = 365;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));


function tfnWriteCookie(id){
	tfnSetCookie (ThecookieName,id,exp,path,null,false);
}

function tfnGetCookieVal(offset) {  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)
		endstr = document.cookie.length;  
		
	return unescape(document.cookie.substring(offset, endstr));
}

function tfnGetCookie (name) {  
	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 tfnGetCookieVal (j);    
			
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return null;
}

function tfnSetCookie (name, value,expires,path,domain,secure) {  
	document.cookie = name + "=" + escape (value) + 
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
		((path == null) ? "" : ("; path=" + path)) +  
		((domain == null) ? "" : ("; domain=" + domain)) +    
		((secure == true) ? "; secure" : "");
}

function popChallenge(){
	return;
	var popID = tfnGetCookie(ThecookieName);

	if(popID == '' || popID != 'sawit'){
		popID = "sawit";		
		tfnWriteCookie(popID);
		OpenChallenge('/Common/Promos/popChallenge.asp',399,435);
	}
	//OpenWindow('/Common/Promos/popChallenge.asp',399,432);
}

function OpenChallenge(url,theWidth,theHeight){
	var theTop
	var theLeft
	
    if (document.all)
    {
		theTop=(screen.height/2)-(theHeight/2);
		theLeft=(screen.width/2)-(theWidth/2)+175;
	}
	else
	{
		theTop=100;
		theLeft=5
		00;
	}
	
	var features='height='+theHeight+',width='+theWidth+',top='+theTop+',left='+theLeft+",toolbar=0,location=0,directories=0,resizable=1,status=0,menubar=0,scrollbars=no";theWin=window.open(url,'',features);
}
// -- END POPUP CHALLENGE CODE















//This function gets called from mouseovers on the
//top navigation tabs and will swap the images		
function SwitchImage(imgName, mode){
	document.images[imgName].src = '/img/template/' + imgName + '_' + mode + '.gif';}
	
//This function will check for a valid search box entry,
//alert the user if nothing was entered or submit the form
function SubmitSearch(){
	var fm = document.frmSearch;
	
	if (fm.Search.value == '')
		alert("Please enter a search parameter...");
	else
		fm.submit();
}

function SubmitQuickFind(){
	var fm = document.frmQuickFind;
	if (fm.ID.value == '')
		alert("Please enter an Item ID");
	else
		fm.submit();
}

//This function will pop up a window that
//will try to look up a dictionary term
function DictionaryLookup(){
	if (arguments.length>0){
		var term = arguments[0];
		var term = escape(term);
		
		url = '/Common/DictionaryLookup.asp?term=' + escape(term);
		OpenWindow(url,400,300);
	}
}

// ##############################################
// STANDARD WINDOW OPENERS
function OpenWindow(url,width,height){
	var now = new Date();
	var remote = top.window.open(url,"popup"+ now.getTime(),"width=" + width + ",height=" + height + ",toolbar=0,location=0,directories=0,resizable=1,status=0,menubar=0,scrollbars=no");
}

function OpenScrollingWindow(url,width,height){
	var now = new Date();
	var remote = top.window.open(url,"popup"+ now.getTime(),"width=" + width + ",height=" + height + ",toolbar=0,location=0,directories=0,resizable=1,status=0,menubar=0,scrollbars=yes");
}
		
