 function showloader(div)
 {
 
    var cookie = getCookie('loader');
    
    if(cookie != '2')
    {
        setCookie('loader',1,3);
    }
    
    var browser=navigator.appName;
    
    //cant show in firefox!  back button bug.
    if (browser != "Netscape")
    {
        var loader;
        //alert(div)
        loader = document.getElementById(div);
        loader.style.visibility = "hidden";
        loader.style.display = "none";
}
    
}

function hideme(div)
{
    var loader;
    loader = document.getElementById(div);
    loader.style.visibility = "hidden";
    loader.style.display = "none";
}

     function setCookie(c_name,value,expiredays)
	 {
		 var exdate=new Date();
		 exdate.setDate(exdate.getDate()+expiredays);
		 document.cookie=c_name+ "=" +escape(value)+
		 ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
	 }

	 function getCookie(c_name)
	 {
		 if (document.cookie.length>0)
		   {
		   c_start=document.cookie.indexOf(c_name + "=");
		   if (c_start!=-1)
		     {
		     c_start=c_start + c_name.length+1;
		     c_end=document.cookie.indexOf(";",c_start);
		     if (c_end==-1) c_end=document.cookie.length;
		     return unescape(document.cookie.substring(c_start,c_end));
		     }
		   }
		 return "";
	 }
	 
	 function checkCookie()
	 {
	     var cookie = getCookie('loader');
	     //alert(cookie);
	     var loader;
	     loader = document.getElementById('TopBar1_search_loader');
    	 
	     if(cookie == '1')
	       {
	        alert("test1 " + cookie);
	        return;
	       }
	     else
	       {
	        loader.style.display = 'none';
	        alert("test2 " + cookie);
	        return;
	       }
	 }      


function openWindow(url)
{
	popupWin = window.open(url,'win','scrollbars,resizable,menubar,width=550,height=450')
} 

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 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_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

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];}
}

var ie = (navigator.appName.indexOf('Microsoft') != -1) ? true : false;
var ns = (navigator.appName.indexOf('Netscape') != -1) ? true : false;
var jamoke = 600;

var submitted = false;

function submitCheck(){

	if (submitted) {
	alert("Your payment is being processed. Please wait....");
	return false;
		}
		else {
		submitted = true;
		return true;
		}
	}


function printpage() {
window.print();  
}

function openWindow(url) {
          popupWin = window.open(url,'win','scrollbars,resizable,menubar,width=550,height=450')
        }

function pop(url) {
 	sealWin = window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=1,width=700,height=450');
self.name = "mainWin"; 
}

function popSize(url, mwidth, mheight) {
	var rndNum = Math.floor(Math.random()*23);
        popup = window.open(url,'win'+rndNum,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=' + mwidth + ',height=' + mheight);
}

function openPyramatShipQuoteBox(theform) {
	var w = window.open('about:blank', "shipQuote",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=300,height=200');
        theform.target = "shipQuote";
	return true;
}

function popSizeScroll(url, mwidth, mheight) {
        popup = window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=' + mwidth + ',height=' + mheight);
}

function popSize(url, mwidth, mheight) {
	var rndNum = Math.floor(Math.random()*23);
        popup = window.open(url,'win'+rndNum,'left=' + ((screen.width-mwidth)/2) + ',top=' + ((screen.height-mheight)/2) + ',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=' + mwidth + ',height=' + mheight);
}

function init(){
         //       define('address_type_name','string','Shipping Location',2,36);
                define('first_name','string','First Name',2,36);
                define('last_name','string','Last Name',2,36);
                define('address_1','string','Address',6,32);
                define('city','string','City',3,36);
                define('state','string','State',2,2);
                define('zip','num','Zip Code',5,10);
                define('phone_1','string','Phone Number',10,20);
                define('user_email','email','Email');

        }


function scream()
{
        alert(document.forms[1].order_payment_number.value);
}

function getDocHeight() {
  if (ie) return (document.body.scrollHeight > document.body.clientHeight) ? document.body.scrollHeight : document.body.clientHeight;
else if (ns) return (document.height > window.innerHeight) ? document.height : window.innerHeight;
   }


var menublock=new Array()
setgs = "Verdana;2;FFFF99;1;Verdana;1;FFFFFF;1;"
menublock[0]= setgs +
			 "Brands|#|;"+
                         "AT&T|/?page=shop/browse&category_id=46dfb535af92d12dc99529c40bb5e3ab|;"+
                         "Brother|test.html|;"+
                         "Engenius|/?page=shop/browse&category_id=fc0e040427b5a2d124b13c554ccff536|;"+
                         "Nortel|/?page=shop/browse&category_id=4371db2713400dd8d0aad2fb74f040c6|;"+
                      "On-Hold Plus|/?page=shop/browse&category_id=426ba283f752e38ca6df91dc84777c11|;"+
			 "Panasonic|/?page=shop/browse&category_id=6e4295be69c8420810f72d019890fd54|;"+
                         "Plantronics|/?page=shop/browse&category_id=15b24e7273b2889edb06c4ee1671890a|;"+
                         "Polycom|/?page=shop/browse&category_id=8b4439ca83d10ed01ce10d3aa281d303|;"+
                         "Siemens|/?page=shop/browse&category_id=4b07e6e635732d45680c62b99f0f57c9|;"+
                         "Sony|/?page=shop/browse&category_id=3e74ef2e5927dcf8f498cef158f58175|;"+
                         "Uniden|/?page=shop/browse&category_id=99664282173d37e8fbbfa937588b74b7|;"+
                         "V-Tech|/?page=shop/browse&category_id=7dbf09607b0176bc686958f506649336|;"



			 "Brands|#|;"+
			 "AT&T|test.html|;"+
			 "Brother|test.html|;"+
			 "Engenius|test.html|;"+
			 "Nortel|test.html|;"+
			 "On-Hold Plus|test.html|;"+
			 "Panasonic|test.html|;"+
			 "Plantronics|test.html|;"+
			 "Polycom|test.html|;"+
			 "Siemens|test.html|;"+
			 "Sony|test.html|;"+
			 "Uniden|test.html|;"+
			 "V-Tech|test.html|;"	 
		 
menublock[1]= setgs +
			 "Phones|#|;"+
			 "Cordless|test.html|;"+
			 "Corded|test.html|;"+
			 "Conference|test.html|;"+
			 "Video Conference|test.html|;"+
			 "Fax Machines|test.html|;"+
			 "Novelty Phones|test.html|;"+
			 "Special Needs|test.html|;"+
			 "Phones with Rebate|test.html|;"+
			 "Refurbished Phones|test.html|;"

menublock[2]= setgs +
			 "Accessories|#|;"+
			 "Headsets|test.html|;"+
			 "Batteries|test.html|;"+
			 "On-Hold Plus|test.html|;"+
			 "Palm-Link 2-Ways|test.html|;"+
			 "Antennas|test.html|;"+
			 "Answering Machines|test.html|;"+
			 "Caller ID|test.html|;"+
			 "Amplifiers|test.html|;"+
			 "Runt & 24V Scooters|test.html|;"	
			 
	 
var menusplit
var urlsplit
var font_weight_main
var font_weight_sub
			 
var showsubmenus=new Array()
for (i=0;i<=menublock.length-1;i++) {
	showsubmenus[i]=-1
}

function openandclose(visi) {
	//alert(visi)
	for (i=0;i<=menublock.length-1;i++) {
		if (i != visi) showsubmenus[i]=-1
	}
	showsubmenus[visi]=(-1)*showsubmenus[visi]

	var menucontent=""

	for (i=0;i<=menublock.length-1;i++) {
		menusplit=menublock[i].split(";")
		urlsplit=menusplit[8].split("|")
		if (menusplit[3]==1) {font_weight_main="<b>"}
		if (menusplit[3]==0) {font_weight_main=""}
		if (menusplit[7]==1) {font_weight_sub="&nbsp;"}
		if (menusplit[7]==0) {font_weight_sub=""}

menucontent+=font_weight_main+"<a href='javascript:openandclose("+i+")'><font style='font-size:13px' face="+menusplit[0]+" color="+menusplit[2]+" size="+menusplit[1]+">"+urlsplit[0]+"</font></a></b><br>"
		if (showsubmenus[i]==1) {
			for (ii=9;ii<=menusplit.length-1;ii++) {
				urlsplit=menusplit[ii].split("|")
    			menucontent+=font_weight_sub+"<a href="+urlsplit[1]+" target="+urlsplit[2]+"><font style='font-size:12px' face="+menusplit[4]+" color="+menusplit[6]+" size="+menusplit[5]+">"+urlsplit[0]+"</font></a><br>"
			}
		}
	}
	if (document.all) {
		menu.innerHTML=menucontent
	}
	if (document.layers) {
		document.menu.document.write(menucontent)
		document.menu.document.close()
	}
}

function assign() 

{

var ccard = window.document.checkout.order_payment_number.value;
window.document.checkout.x_Card_Num.value = ccard;
var cyear = window.document.checkout.order_payment_expire_year.options[window.document.checkout.order_payment_expire_year.selectedIndex].value;
var cmonth = window.document.checkout.order_payment_expire_month.options[window.document.checkout.order_payment_expire_month.selectedIndex].value;
window.document.checkout.x_Exp_Date.value = cmonth + "/" + cyear;

}

/**
 * Author: Lawrence So
 * Date: 8/25/2005
 * Used for "Finder Box". Dropdown menu in HTML must use 
 * "finderDropdown1" or "finderDropdown2" as <select> name.
 */
function finderGo(findBy)
{
	var selectedIndex;
	var newUrl;
	var redirect = false;
    
	if (findBy == "finderDropdown1")
	{
	    var dropdown = document.getElementById("finderDropdown1")
		selectedIndex = dropdown.selectedIndex;
		//selectedIndex = document.finder.finderDropdown1.selectedIndex;

		if (selectedIndex != 0)
		{
			newUrl = dropdown.options[selectedIndex].value;
			//newUrl = document.finder.finderDropdown1.options[selectedIndex].value;
			redirect = true;
		}
	}
	else if (findBy == "finderDropdown2")
	{
		var dropdown = document.getElementById("finderDropdown2")
		selectedIndex = dropdown.selectedIndex;
		//selectedIndex = document.finder.finderDropdown2.selectedIndex;

		if (selectedIndex != 0)
		{
			newUrl = dropdown.options[selectedIndex].value;
			//newUrl = document.finder.finderDropdown2.options[selectedIndex].value;
			redirect = true;
		}
	}

	if (redirect)
	{
		window.location.href = newUrl;
	}
}




// SOURCE: http://www.nsftools.com/misc/SearchAndHighlight.htm

/*
 * This is the function that actually highlights a text string by
 * adding HTML tags before and after all occurrences of the search
 * term. You can pass your own tags if you'd like, or if the
 * highlightStartTag or highlightEndTag parameters are omitted or
 * are empty strings then the default <font> tags will be used.
 */
function doHighlight(bodyText, searchTerm, highlightStartTag, highlightEndTag)
{
	// the highlightStartTag and highlightEndTag parameters are optional
	if ((!highlightStartTag) || (!highlightEndTag)) {
		highlightStartTag = '<font class="finder_highlight">';
		highlightEndTag = '</font>';
	}

	// find all occurrences of the search term in the given text,
	// and add some "highlight" tags to them (we're not using a
	// regular expression search, because we want to filter out
	// matches that occur within HTML tags and script blocks, so
	// we have to do a little extra validation)
	var newText = "";
	var i = -1;
	var lcSearchTerm = searchTerm.toLowerCase();
	var lcBodyText = bodyText.toLowerCase();

	while (bodyText.length > 0) {
		i = lcBodyText.indexOf(lcSearchTerm, i+1);

		// if bodyText does not contain search term
		if (i < 0) {
			newText += bodyText;
			bodyText = "";
		} else { // if bodyText does contain search term
			numOccurrences++;
			
			// skip anything inside an HTML tag
			if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
				// skip anything inside a <script> block
					if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i)) {
						newText += bodyText.substring(0, i) + highlightStartTag + bodyText.substr(i, searchTerm.length) + highlightEndTag;
						bodyText = bodyText.substr(i + searchTerm.length); // increments
						lcBodyText = bodyText.toLowerCase(); // controls highlighting??
						i = -1;
					}
			}
		}
	}

	return newText;
}

var originalText = "";
var numOccurrences = 0;

/*
 * This is sort of a wrapper function to the doHighlight function.
 * It takes the searchText that you pass, optionally splits it into
 * separate words, and transforms the text on the current web page.
 * Only the "searchText" parameter is required; all other parameters
 * are optional and can be omitted.
 */
function highlightSearchTerms(searchText, treatAsPhrase, warnOnFailure, highlightStartTag, highlightEndTag)
{
	// if the treatAsPhrase parameter is true, then we should search for
	// the entire phrase that was entered; otherwise, we will split the
	// search string so that each word is searched for and highlighted
	// individually

	if (treatAsPhrase) {
		searchArray = [searchText];
	} else {
		searchArray = searchText.split(" ");
	}

	if (!document.body || typeof(document.body.innerHTML) == "undefined") {
		if (warnOnFailure) {
			alert("Sorry, for some reason the text of this page is unavailable. Searching will not work.");
		}

		return false;
	}

	var bodyText = document.body.innerHTML;

	// Save original text for resetting later (Law 8/31/2005)
	if (originalText == "") {
		originalText = bodyText;
	}

	// Reset highlighting (Law 8/31/2005)
	if (originalText != "") {
		bodyText = originalText;
	}
	
	numOccurrences = 0;

	for (var i = 0; i < searchArray.length; i++) {
		bodyText = doHighlight(bodyText, searchArray[i], highlightStartTag, highlightEndTag);
	}
	
	if (numOccurrences == 0) {
		alert('Sorry, no results found for \"' + searchText + '\".');
	}

	document.body.innerHTML = bodyText;
	return true;
}

function searchPrompt2(searchText, treatAsPhrase, textColor, bgColor)
{
	document.getElementById("t1").value = "";
	
	// This function prompts the user for any words that should
	// be highlighted on this web page

	// we can optionally use our own highlight tag values
	if ((!textColor) || (!bgColor)) {
		highlightStartTag = "";
		highlightEndTag = "";
	} else {
		highlightStartTag = '<font class="finder_highlight">';
		highlightEndTag = '</font>';
	}

	if (!searchText)  {
		alert("No search terms were entered.");
		return false;
	}


	/** Start Page Jump Code **/
	// SOURCE: http://www.javascripter.net/faq/searchin.htm
	var str = searchText;
	var TRange=null

	if (parseInt(navigator.appVersion) < 4) return;
	
	var strFound;
	
	if (navigator.appName == "Netscape") {
		// NAVIGATOR-SPECIFIC CODE

		strFound=self.find(str);

		if (!strFound) {
			strFound=self.find(str,0,1)
			while (self.find(str,0,1)) continue
		}
	}
	
	if (navigator.appName.indexOf("Microsoft")!=-1) {
		// EXPLORER-SPECIFIC CODE

		if (TRange!=null) {
			TRange.collapse(false)
			strFound=TRange.findText(str)
			if (strFound) TRange.select()
		}
		
		if (TRange==null || strFound==0) {
			TRange=self.document.body.createTextRange()
			strFound=TRange.findText(str)
		
			if (strFound) TRange.select()
		}
	}
	window.scrollBy(0,200);
	//if (!strFound) alert ("String '"+str+"' not found!")
	
	/** End Page Jump Code **/




	return highlightSearchTerms(searchText, treatAsPhrase, true, highlightStartTag, highlightEndTag);
}




/** Script from HTMLHelpCentral.com - visit for tutorials, scripts, helpful forums and more! **/
function winBRopen(theURL, Name, popW, popH, scroll) {
	var winleft = (screen.width - popW) / 2;
	var winUp = (screen.height - popH) / 2;
	
	winProp = 'width='+popW+',height='+popH+',left='+winleft+',top='+winUp+',scrollbars='+scroll+',resizable'
	
	Win = window.open(theURL, Name, winProp)
	
	if (parseInt(navigator.appVersion) >= 4) {
		Win.window.focus();
	}
}