var temp1,temp2;
var jumped = false;
var w_global = null;

/* Creates a Unique number per call on one client browser.
	DOES NOT CREATE A SERVER-SCOPED UNIQUE KEY! */
function createUUID() {
	var l_dDate = new Date();
	var l_nUUID = l_dDate.getTime().toString();
	return l_nUUID;
}

/* (reloads) the current page in window (win) without the query string (adds a UUID to make browser refresh) */
function cleanReload(win) {
	var myurl = getUrl(win, 1) + "?null=" + createUUID();
	win.document.location.replace(myurl);
}
/* (reloads) the current page in window (win) with the query string (adds a UUID to make browser refresh) */
function urlReload(win) {
	var myurl = win.document.location.href;
	myurl = (myurl.indexOf("?") >= 0) ? myurl + "&" : myurl + "?";
	myurl = myurl + "null=" + createUUID();
	win.document.location.replace(myurl);
}



/* gets the document url (minus query string if (clean)) */
function getUrl(win, clean) {
  var myurl = win.document.location.href;
  if (clean) {
    var loc = myurl.indexOf("?");
    if (loc > 0) {
      myurl = myurl.substring(0,loc);
    }
  }
  return myurl;
}

/* (load new url)  */
function urlLoad(new_href) {
	var myurl = new_href;
	myurl = (myurl.indexOf("?") >= 0) ? myurl + "&" : myurl + "?";
	myurl = myurl + "null=" + createUUID();
	window.document.location.replace(myurl);
}

/* adds junk */

/* RTRIM() -removes ending spaces */
function rtrim(str) {
	if (str.length) {
		var cutLoc, i, stop;
		i = str.length;
		stop = 0;
		do {
			if (str.charAt(i-1) == " ") {
				i--;
			} else {
				stop = 1;
			}
		} while (stop == 0 && i > 0)
		if (i < (str.length)) {
			str = str.substring(0,i);
		}
	}
	return str;
}

/* LTRIM() -removes leading spaces */
function ltrim(str) {
	if (str.length) {
		var cutLoc, i, stop;
		i = 0;
		stop = 0;
		do {
			if (str.charAt(i) == " ") {
				i++;
			} else {
				stop = 1;
			}
		} while (stop == 0 && i < str.length)
		if (i > 0) {
			str = str.substring(i,str.length);
		}
	}
	return str;
}

/* TRIM() leading and ending spaces */
function trim(str) {
	if (str.length) {
		str = rtrim(str);
	}
	if (str.length) {
		str = ltrim(str);
	}
	return str;
}

/* Function to swap a font tag's font class */
function NC_swapClass(textID,myClass) {
	obj=MM_findObj(textID);
	if (obj) obj.className=myClass;
}

/* Function to find a document object */
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

/* Functions that swap layers - used only in product nav menu */
function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

/* Function that handle preload. */
function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_checkPlugin(plgIn, theURL, altURL, autoGo) { //v3.0
  var ok=false; document.MM_returnValue = false;
  with (navigator) if (appName.indexOf('Microsoft')==-1) ok=(plugins && plugins[plgIn]);
  else if (appVersion.indexOf('3.1')==-1) { //not Netscape or Win3.1
    if (plgIn.indexOf("Flash")!=-1 && window.MM_flash!=null) ok=window.MM_flash;
    else if (plgIn.indexOf("Director")!=-1 && window.MM_dir!=null) ok=window.MM_dir;
    else ok=autoGo; }
  if (!ok) theURL=altURL; if (theURL) window.location=theURL;
}

function popNew(loc,name,w,h) {
	//alert("Location: " + loc);
	pop = window.open(loc,name,"scrollbars,status,resizable,width="+w+",height="+h);
	pop.focus();
}

function popMenu(loc,name,width,height) {
	pop = window.open(loc,name,"scrollbars,menubar,status,resizable,width=" + width + ",height=" + height);
	//pop.focus();
}

function popNewResize(loc,name,width,height) {
	pop = window.open(loc,name,"scrollbars,status,resizable,width=" + width + ",height=" + height);
	pop.focus();
}

function popRestricted(loc,name,width,height) {
	pop = window.open(loc,name,"scrollbars,status,width=" + width + ",height=" + height);
	pop.focus();
}

function popNewNoChrome(loc,name,width,height) {
	pop = window.open(loc,name,"width=" + width + ",height=" + height);
	pop.focus();
}

function popReal(loc,name,width,height) {
	pop = window.open(loc,name,"scrollbars,status,toolbar,menubar,directories,location,resizable,width=" + width + ",height=" + height);
	pop.focus();
}
function openWindow (f_name, s_title, s_attrib) {
	w_global = window.open(f_name, s_title, s_attrib);
}

/* checks if text in a form field is a possible email address */
/*   x@x.xx  minimum  */
/*   usage: if (isemail('txt_username','Email not valid!')) submitForm('frm_login');  */
/* djh 2/7/01 added ',atloc' to the 4th line to fix bug with '.' before @ */
function isemail(field,message) {
	var obj=MM_findObj(field);
	var val=obj.value;
	var atloc=val.indexOf('@');
	var dotloc=val.indexOf('.',atloc);
	if ((atloc > 1) && (dotloc > atloc+1) && (val.length > dotloc+2)) {
		var bob=true;
	} else {
		alert(message);
		var bob=false;
	}
	return bob;
}

/* used to submit forms easily within divs, or from within other forms */
//v3.0
function submitForm(frm) { 
	var obj = MM_findObj(frm);
	obj.submit();
}


function submitFormCheck(form) {
	var obj = MM_findObj(form);
	var frmname = "_CF_check" + form + "(obj)";
	var success = eval(frmname);
	if (success) {
		obj.submit();
	}
	//return success;
}

/* used to ensure a combo's value is not "" */
function verifyCombo(form,cbo,message) {
	obj=MM_findObj(form);
	obj=eval('obj.'+cbo);
	var index=obj.selectedIndex;
	var val=obj.options[index].value;
	if (val == "") {
		if (message != "")
			alert(message);
		return false;
	} else {
		return true;
	}
}
/* used to jump to url specified in combo's selected VALUE */
function jumpToCombo(form,cbo,addnull) {
	if (addnull == null) addnull = 1;
	obj=MM_findObj(form);
	obj=eval('obj.'+cbo);
	var index=obj.selectedIndex;
	var val = obj.options[index].value;
	if (addnull)
		val +=  ((val.indexOf("?") >= 0) ? "&null="+createUUID() : "?null="+createUUID());
	if (val != "") {
		document.location.href=val;
	}
}

/* used to verify a user's request before connecting a link */
function verifyLink(message,myurl) {
	if (confirm(message)) {
		myurl += (myurl.indexOf('?') >= 0) ? "&null="+createUUID() : "?null="+createUUID();
		document.location.href=myurl;
	}
}

// djh 11/21/00
// This popup window will upload images to the server
// the set the parent text boxes to the correct value
//
function popUpload(p_ccaption, p_ctextname, p_noid, p_cpath) {
	popNew("uploadpop.cfm?caption=" + p_ccaption + "&textname=" + p_ctextname + "&oid=" + p_noid + "&path=" + p_cpath,"uploadwindow","270","190");
}

//  Function to open a new window and place focus there.
// If the window is already opened focus will be placed.
var newWindow
function openWebTopWindow(URL, winName, chrome) {
	if (!newWindow || newWindow.closed) {
		newWindow = window.open(URL,winName,chrome)
		if (!newWindow.opener) {
			newWindow.opener = window
		}
	} else {
		// window's already open; bring to front
		newWindow.location = URL;
		newWindow.focus();
	}
}

//populate combo from object
function populateSelectFromObject(cbo,obj,selData,defSelection) {
	// clears a select form object, and populates it using the passed data
	cbo.length = 0;
	if(defSelection && defSelection.length > 0) {
		var tmpOpt = new Option;
		tmpOpt.value = "";
		tmpOpt.text = defSelection;
		if ("" == selData) tmpOpt.selected = true;
		cbo.length++;
		cbo.options[cbo.length-1] = tmpOpt;
	}
	for (a in obj) {
		var tmpOpt = new Option;
		tmpOpt.value = a;
		tmpOpt.text = obj[a];
		if (a == selData) tmpOpt.selected = true;
		cbo.length++;
		cbo.options[cbo.length-1] = tmpOpt;
	}
}

var newWindow
function openCMAPWindow(URL, winName, chrome) {
	if (!newWindow || newWindow.closed) {
		newWindow = window.open(URL,winName,chrome)
		if (!newWindow.opener) {
			newWindow.opener = window
		}
	} else {
		// window's already open; bring to front
		newWindow.location = URL;
		newWindow.focus();
	}
}
//function used for Store Locator's dropdown navigation
function goPage(form){
	//alert(form);
	window.location.href = form;
}

// checks if a user has pressed enter then submits the form.
function checkEnter(event, myform)
{
	var frm = MM_findObj(myform);
	if(frm != null) {
		var NS4 = (document.layers) ? true : false;
		var code = 0;

		if (NS4)
			code = event.which;
		else
			code = event.keyCode;
		if (code==13) {
			//for login form on homepage//set the action.
			submitLoginS1();
		}
	}
}