﻿function FP_preloadImgs() {//v1.0
 var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
 for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
}

function FP_swapImg() {//v1.0
 var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
 n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
 elm.$src=elm.src; elm.src=args[n+1]; } }
}

function FP_getObjectByID(id,o) {//v1.0
 var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
 else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
 if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
 for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
 f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
 for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
 return null;
}

function FP_swapImgRestore() {//v1.0
 var doc=document,i; if(doc.$imgSwaps) { for(i=0;i<doc.$imgSwaps.length;i++) {
  var elm=doc.$imgSwaps[i]; if(elm) { elm.src=elm.$src; elm.$src=null; } } 
  doc.$imgSwaps=null; }
}

function CC_PreloadTabImages()
{
	// Preload the top nav tabs
	FP_preloadImgs(/*url*/'/Store/img/template/topnav/Tabs/Shopping_On.gif', /*url*/'/Store/img/template/topnav/Tabs/YourAccount_On.gif', /*url*/'/Store/img/template/topnav/Tabs/CustomerService_On.gif', /*url*/'/Store/img/template/topnav/Tabs/TechSupport_On.gif');
	// Preload the store tabs
	FP_preloadImgs(/*url*/'/Store/img/template/storetabs/Membership_On.gif', /*url*/'/Store/img/template/storetabs/Required_Products_On.gif', /*url*/'/Store/img/template/storetabs/Seminars_On.gif', /*url*/'/Store/img/template/storetabs/Shop_topic_on.gif', /*url*/'/Store/img/template/storetabs/Special_Offers_On.gif');
	
	if (typeof(getElementsByTagAndClassName) == "function")
	{
	var rounded = getElementsByTagAndClassName("div", "rounded");

	for (var i in rounded)
	{	
		var inner = DIV();
		
		var div_wrap = DIV( {"class":"rounded_A"}, DIV( {"class":"rounded_B"}, DIV( {"class":"rounded_C"}, DIV( {"class":"rounded_D"}, inner ) ) ) ); 
		
		swapDOM(rounded[i], div_wrap);
		
		swapDOM(inner, rounded[i]);
		
		/*
		var r = rounded[i];
		
		var tl = DIV( {"class":"tl"} );
		var tr = DIV( {"class":"tr"} );
		var br = DIV( {"class":"br"} );
		var bl = DIV( {"class":"bl"} );
		
		r.appendChild( tl );
		r.appendChild( tr );
		r.appendChild( br );
		r.appendChild( bl );
		*/
	}
	}
}

function fnOpenPopupScrolling(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;
	}
	
	theTop=20;
	theLeft=0;
	
	var features='height='+theHeight+',width='+theWidth+',top='+theTop+',left='+theLeft+",toolbar=0,location=0,directories=0,resizable=1,status=0,menubar=0,scrollbars=yes";
	
	theWin=window.open(url,'',features);
}

function fnPrintReceipt(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=1,scrollbars=yes";
	theWin=window.open(url,'',features);
}

function fnOpenPopup(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);
}

var phone_field_length=0;
function TabNext(obj,event,len,next_field){
try{
if(event == "down"){phone_field_length=obj.value.length;}else if(event == "up"){if(obj.value.length != phone_field_length){phone_field_length=obj.value.length;if(phone_field_length == len){next_field.focus();}}}
}
catch(ermsg){}
}

function StandingOrder(v)
{
	window.opener.document.forms[0].StandingOrderPopup.value=v;
	window.opener.document.forms[0].submit();
	window.close();
}

function BrowseTopics(BrowseID)
{
	// Attempt to grab the select box for browsing.
	
	var BrowseField = document.getElementById(BrowseID);
	
	// Check it exists and contains a value.
	
	if (BrowseField != null && BrowseField.value != "")
	{
		// Return true so that the submission will continue.
		
		return true;
	}
	else
	{		
		// Return false, so no submission will proceed.
		
		return false;
	}
}

// The CaptureKey function is used to capture an user key
// press from a user and call a specified function in response.

function CaptureKey(KeyCode, Function)
{	
	// Ensure the event object is available,
	// and that the fired key was the enter button.
	if (event && event.keyCode == KeyCode)
	{
		// Perform the specified function.
		
		Function();
		
		return false;
	}
}

function RoundedEdges()
{
	if (typeof(getElementsByTagAndClassName) == "function")
	{
		var common_mistakes = getElementsByTagAndClassName("div", "common_mistakes");

		for (var i in common_mistakes)
		{
			var inner = DIV();

			var div_wrap = DIV( {"class" : "common_mistakes_A"}, DIV( {"class" : "common_mistakes_B"}, DIV( {"class" : "common_mistakes_C"}, DIV( {"class" : "common_mistakes_D"}, inner)))); 

			swapDOM(common_mistakes[i], div_wrap);

			swapDOM(inner, common_mistakes[i]);
		}
	}
}

function Search_onKeyPress(e, SearchBox)
{
	if(e.keyCode == 13)
	{
		Search(SearchBox.value);
	
		return false;
	}
}

function Search(SearchValue)
{
    if(SearchValue == "" || SearchValue == "Search HRCalifornia")
		alert("Please enter a search value");
	else
		location.href = "/HRC/Search/Pages/default.aspx?Query=" + SearchValue;
		
	return false;
}


