var hidemenu = null;
var menuitem = null;
var currmenuitem = null;

function toggleDisplay(id)
{
	var elem=document.getElementById(id);
	if(elem.style.display=="none")
	{
		
		showElem(id);
	}
	else
	{
		hideElem(id);
	}
}
/*
function hideElem(id)
{
	if(document.getElementById(id))
	{
		var elem = document.getElementById(id);
		elem.style.display="none";
	}
}


function showElem(id)
{
	var elem = document.getElementById(id);
	elem.style.display="inline";
	
}
*/
function toggleVis(id)
{
	var elem=document.getElementById(id);
	
	if(elem.style.visibility=="hidden")
	{
		
		showVisElem(id);
	}
	else
	{
		hideVisElem(id);
	}
}
function hideMe(id)
{
	currmenuitem = id;
	menuitem	= "hideVisMenuElem('" + id + "');";
	hidemenu = setTimeout(menuitem,200);
}
function hideVisMenuElem(id)
{
	var elem 		= document.getElementById(id);
	var menuelem	= document.getElementById(id + "_pmenu");	
	if(elem != null)
	{	
		elem.style.visibility="hidden";
	}
	menuelem.style.backgroundColor = "";	
}


function showVisMenuElem(id)
{
	if (hidemenu && currmenuitem == id) 
	{
		clearTimeout(hidemenu);
		hidemenu = null;
		menuitem = null;
		currmenuitem = null;
	}
	var elem 		= document.getElementById(id);
	var menuelem	= document.getElementById(id + "_pmenu");
	var elemLeftPos = menuelem.offsetLeft; 
	var elemTopPos  = menuelem.offsetTop;         // this keyword refers to element
    var elemParent 	= menuelem.offsetParent;
    while (elemParent != null)
    {
        elemLeftPos += elemParent.offsetLeft;
		elemTopPos  += elemParent.offsetTop;
        elemParent 	=  elemParent.offsetParent;
    }
	if(elem != null)
	{	
		elem.style.left = elemLeftPos + "px";	
		elem.style.top = eval(elemTopPos+menuelem.offsetHeight) + "px";
		elem.style.visibility="visible";	
	}	
}

function addWarrantyToCart(){
	var o=document.getElementById('warrantyopt');
	var mpn=o.options[o.selectedIndex].value;
	var url='./updatecart.cfm?type=addwar&mpn='+mpn;
	self.location=url;	
}


/**********************************************************************************/
/* BEGIN REVIEW VALIDATION                                                        */ 
/* RB9742.  24 FEB 11.                                                            */
/* Added review_validation code to consolidate files                              */
/**********************************************************************************/
function ValidateReviewForm()
{
  var form_errors = "";
  var msg;
  
	if (document.getElementById('rating').value == "")
		{ 
			form_errors += 'Do not forget to rate the product.\n';
		}    
	if (document.getElementById('ownership').value == "")
		{ 
			form_errors += 'Tell us how long you have owned this product.\n'
		}    
	if (document.getElementById('understanding').value == "")
		{ 
			form_errors += 'Please tell us your technical understanding of this product.\n'
		}   
	if (document.getElementById('cons').value == "")
		{ 
			form_errors += 'Please tell us the Cons (bad things) about the product.\n'
		}   
	if (document.getElementById('pros').value == "")
		{ 
			form_errors += 'Please tell us the Pros (good things) about the product.\n';
		}  
  if (document.getElementById('agreement').checked)
    {
      document.getElementById('agreement').value = "1";
    }
  else
    {
      form_errors += 'You must read and agree to abide by the Product Review Guidelines.\n';
    }     
   if (form_errors != "")
     {
       msg  = "____________________________________________________\n\n";
       msg += "The form was not submitted because of the following error(s).\n";
       msg += "Please correct these error(s) and re-submit.\n";
       msg += "____________________________________________________\n\n";        
       msg += form_errors;
       msg += "\n";

       alert(msg);
       return false;
     }
   else
     {
       return true;
     }
}
/**********************************************************************************/
/* END REVIEW VALIDATION                                                          */   
/**********************************************************************************/


/**********************************************************************************/
/* BEGIN SUGGESTIVE_SEARCH                                                        */ 
/* RB9742.  24 FEB 11.                                                            */
/* Added suggestive_search code to consolidate files                              */
/**********************************************************************************/
  <!---AJAX LOOKUP --->
function showElem(id)
{
	document.getElementById(id).style.display='inline';
}
function hideElem(id)
{
		
		document.getElementById(id).style.display='none';
		document.getElementById(id).style.position='absolute';
		
}
var xmlHttp
function findPos(obj)
 {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
function fillForm(obj)
{
	var tForm = obj.parentNode;
	document.getElementById('submitButton').click();
	//alert(tForm.outerHTML);
}
//Function to trim the space in the left side of the string
function ltrim ( s ){
//return s.replace( /^s*/, “” );
s = s.replace(/^s*/, "");
return s;
}
//Function to trim the space in the right side of the string
function rtrim ( s ){
s = s.replace( /s*$/, "" );
return s;
}
function trim(s)
{
	return ltrim(rtrim(s));
}

function showHint(e)
{


	var str =e.value;
	var suggest;
	var e = document.getElementById("srchKey");
	//alert(e.outerHTML);
	suggest = document.getElementById("srchKeySuggest");
	

	var coord;
	coord=findPos(e);

	posx = coord[0];
	posy=coord[1];

	if(e.value=="")
	{
		document.getElementById(suggest.id).style.display='none';
	}
	else
	{
		
	}
	suggest.style.left=posx;
	suggest.style.top=posy+17;
	if (str.length==0)
  	{ 
 		 hideElem(suggest.id);
  		return;
 	 }
	 //xmlHttp=null;
	

	xmlHttp=GetXmlHttpObject();

	if(!xmlHttp && typeof XMLHttpRequest!= 'undefined'){ 
xmlHttp = new XMLHttpRequest(); 
} 


	if (xmlHttp==null)
  	{
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	var url=e.getAttribute("suggestPage");
//alert(url);
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	
	xmlHttp.onreadystatechange=function()
	{ 
		//document.getElementById(suggest.id).style.display='block';
		if ( (xmlHttp.readyState==4) )
		{ 
			var t = trim(xmlHttp.responseText.toString());
			//alert(t);
			if(t=='')
			{
				//alert('oh oh');
				document.getElementById(suggest.id).style.display='none'; 
			}
			else
			{
				//document.getElementById(suggest.id).style.display='block';
				//alert('here we are');
				document.getElementById(suggest.id).style.display="inline";
				//Effect.SlideDown(suggest.id);
				var tReg =new RegExp(str,"img");

				var newHTML = xmlHttp.responseText.replace(tReg,"" + str + "");
				newHTML = xmlHttp.responseText;
					//alert(newHTML);
				//document.getElementById(suggest.id).innerHTML=xmlHttp.responseText;
				document.getElementById(suggest.id).innerHTML=newHTML;
			}
			

			
		{	
		//document.getElementById(suggest.id).style.display='none';
		e.setAttribute("suggestID",'');
	}
}

}
//xmlHttp.onreadystatechange=function stateChanged(suggest.id);
xmlHttp.open("GET",url,true);
xmlHttp.send(null);

}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
} 

var x =null;

var selectedItem = null;
function hover(obj)
{
	obj.style.backgroundColor='#99ccff';
	obj.style.cursor='hand';
	selectItem(obj);


}
function hoverOut(obj)
{
	obj.style.backgroundColor='transparent';
	obj.style.cursor='hand';
	unSelectItem(obj);
	//showElem(obj.parentNode.id);
}

function stripHTML(oldString) {

// alert('oldString: ' + oldString + ' New String: ' + oldString.replace(/<\/?[^>]+(>|$)/g, ""));
 return oldString.replace(/<\/?[^>]+(>|$)/g, "");
  
}

function handleClick(obj,id)
{
	
	var name =  document.getElementById(id);
	var toSearch =obj.getAttribute('suggest');
	toSearch = stripHTML(toSearch);
	//alert(toSearch);
	
	name.setAttribute('value',toSearch );
	name.setAttribute('text',toSearch );
	name.setAttribute('suggestID',obj.getAttribute('suggestID'));
	hideElem(obj.id);
	handleChange(name);

}
function handleLR(obj,id)
{
	
	var name =  document.getElementById(id);
	name.setAttribute('value',obj.getAttribute('suggest'));
	name.setAttribute('text',obj.getAttribute('suggest'));
	name.setAttribute('suggestID',obj.getAttribute('suggestID'));
	hideElem(obj.id);
	//handleChange(name);

}
function handleOver(obj)
{
if (x) 
 {
  clearTimeout(x);
  x = null;
}
 
	showElem(obj.id);
}
function handleHoverOut(obj)
{
	x =  setTimeout("hideElem('" + obj.id + "');selectedItem=null;",900);	

}
function processKeyDown(k,suggestBoxID,me) {

	if (window.event) {
    	key=event.keyCode;
    } else {
    	key = k.which;
    }
	//alert(key);
	if( (key==37) || (key==39) )
	{
		var obj = document.getElementById(suggestBoxID)
		if(selectedItem!=null)
		{
			
			var toSearch =obj.getAttribute('suggest');
			toSearch = stripHTML(toSearch);
			me.value=toSearch;
	
			
			
			me.setAttribute('suggestID',obj.getAttribute('suggestID'));
			selectedItem=null;
			hideElem(suggestBoxID);
		}
		
	}
	if(key==40) 
	{
		
		var obj = document.getElementById(suggestBoxID);
		//alert(obj.outerHTML);
		if(selectedItem==null)
		{selectFirstItem(obj);}
		else{
		selectNextItem(obj);}
	}
	if(key==38)
	{
		var obj = document.getElementById(suggestBoxID);
		if(selectedItem==null)
		{selectLastItem(obj);}
		else{
		selectPrevItem(obj);}
	}
	if( (key==9) || (key==13) )
	{
		
		var obj = document.getElementById(suggestBoxID)
		if(selectedItem!=null)
		{
			
			var toSearch =obj.getAttribute('suggest');
			toSearch = stripHTML(toSearch);
			me.value=toSearch;
			me.setAttribute('suggestID',obj.getAttribute('suggestID'));
			selectedItem=null;
			hideElem(suggestBoxID);
		}
		window.event.keyCode=9;
		document.getElementById('submitButton').click();
	}
	
}
function noenter() {
  return !(window.event && window.event.keyCode == 13); }

function selectNextItem(suggestBox)
{

	var test = suggestBox.childNodes[0].firstChild.childNodes[selectedItem];
	unSelectItem(test);
	if(selectedItem==suggestBox.childNodes[0].firstChild.childNodes.length-1)
	{
		
		selectFirstItem(suggestBox);
	}
	else
	{
	selectItem(suggestBox.childNodes[0].firstChild.childNodes[selectedItem+1]);
	//selectedItem = selectedItem +1;
	}
	
}
function selectPrevItem(suggestBox)
{
	var test = suggestBox.childNodes[0].firstChild.childNodes[selectedItem-1];

	unSelectItem(test);
	if(selectedItem==1)
	{
		
		selectLastItem(suggestBox)
	}
	else
	{
	 
	
	selectItem(test);
	//selectedItem = selectedItem -1;
	}
	
}
function selectFirstItem(suggestBox)
{	
	
	var test = suggestBox.childNodes[0].firstChild.firstChild.nextSibling;
	//alert(test.outerHTML);
	selectItem(test);
	selectedItem = 1;
	
}
function selectLastItem(suggestBox)
{
	var lastItem = suggestBox.childNodes[suggestBox.childNodes.length-1].lastChild.lastChild;
	//alert(lastItem.outerHTML);
	selectItem(lastItem);
	//selectedItem = suggestBox.childNodes.length-1;
}	
function selectItem(obj)
{
	var value = obj.firstChild.firstChild.getAttribute('value');
	//var obj = obj.parentNode.parentNode;
	obj.style.backgroundColor="#ffffcc";
	//obj.style.color="white";
	
	obj.parentNode.parentNode.parentNode.setAttribute('suggest',value);
	obj.parentNode.parentNode.parentNode.setAttribute('suggestID',obj.id);
	
	selectedItemx=0;
	while(obj.parentNode.childNodes[selectedItemx]!=obj)
	{unSelectItem(obj.parentNode.childNodes[selectedItemx]);++selectedItemx;}
	selectedItem=selectedItemx;
	selectedItemx=obj.parentNode.childNodes.length-1;
	while(obj.parentNode.childNodes[selectedItemx]!=obj)
	{unSelectItem(obj.parentNode.childNodes[selectedItemx]);--selectedItemx;}
	selectedItem=selectedItemx;
	
	obj.parentNode.parentNode.parentNode.setAttribute('suggest',value);
	obj.parentNode.parentNode.parentNode.setAttribute('suggestID',obj.id);
}
function unSelectItem(obj)
{
	obj.style.backgroundColor='transparent';
}
function processKeyUp(k,suggestBoxID)
{
	
	if (window.event) {
    	key=event.keyCode;
    } else {
    	key = k.which;
    }
	
	if( (key==40) || (key==38) || (key==9))
	{
		
	}
	else
	{
		
	showHint(document.getElementById(suggestBoxID));
	}
}


function handleChange(obj)
{
	if(obj.id=='srchKey')
	{
		fillForm(obj);
	
	}
	else
	{
	var theID=(obj.getAttribute('suggestID'));
	//obj.value = obj.value + theID;
	if(theID==null)
	{
		theID='';
	}
	//document.CustomerSearch.CustNo.value = theID;
	
	if(theID!=null){
	//fillForm(theID);
	
	}
	}
	
	
}

/**********************************************************************************/
/* END SUGGESTIVE_SEARCH                                                          */   
/**********************************************************************************/


/**********************************************************************************/
/* BEGIN AC_RUNACTIVECONTENT                                                      */ 
/* RB9742.  24 FEB 11.                                                            */
/* Added AC_RunActiveContent code to consolidate files                            */
/**********************************************************************************/
 
 //v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
/**********************************************************************************/
/* END AC_RUNACTIVECONTENT                                                        */   
/**********************************************************************************/


/**********************************************************************************/
/* BEGIN filterInStock                                                            */   
/* Used on accessories/selection and search/selection                             */
/**********************************************************************************/
function filterInStock(elem)
  {    
    var newURL;
    var inStockParam;
    var currentURL = String(document.location);                             
    newURL = currentURL.replace(/&inStock=[01]/gi,'');
    var e1 = document.getElementById('inStock');
    var e2 = document.getElementById('inStock2');
    
    // Make sure both instock checkboxes (top and bottom) match
    if (elem.id == "inStock")
      {                           
        e2.checked = e1.checked;
      }
    else if (elem.id == "inStock2")
      {
        e1.checked = e2.checked;
      }
      
    if ((e1.checked == true) || (e2.checked == true))
      {
        inStockParam = '&inStock=1';
      }
    else
      {
        inStockParam = '&inStock=0';                       
      }                
 
    document.location = newURL + inStockParam;
    return false;
  } 
/**********************************************************************************/
/* END filterInStock                                                              */   
/**********************************************************************************/
function fixedForm(o)
  {		
    o.srchKey.value=o.srchKey.value.toString().replace(/\=/g,'');
    o.srchKey.value=o.srchKey.value.toString().replace(/\%/g,'');
    return true;
    //Pray.
    //thank you mr. youngman! :)
  }
function showPopUp()
  {
    var options = {
      scaleFrom:0,
      scaleTo:100,
      scaleFromCenter:true
      //scaleMode:"contents"		
    }
    
    Effect.SlideDown('divTopLeft',options);
    var theY = eval(document.body.clientHeight - 150);
  
    JSFX_FloatDiv("divTopLeft", 0,theY).floatIt();
    return false;		
  }	
  
function checkQuantityAvailable(qty_avail, minQty)
  {  
    var amountRequested;
    amountRequested = parseInt(document.forms["cartForm"].qty.value);

    if (amountRequested > qty_avail)
      {
        if (confirm("You have requested " + amountRequested + " units but only " + qty_avail + " are available.\nWould you like to continue with this product on backorder?"))
          {           
            return true;
          }
        else
          {
            // Don't add to cart unless the qty_avail is greater than the minimum order quantity
            if (qty_avail >= minQty)
              {
                document.forms["cartForm"].qty.value = qty_avail;
                return true;
              }
            else
              {
                return false;
              }
          }
      }  
  }   
  
/* From header */  
function JSFX_FloatDiv(id, sx, sy)
{
	var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
	var px = document.layers ? "" : "px";
	window[id + "_obj"] = el;
	if(d.layers)el.style=el;
	el.cx = el.sx = sx;el.cy = el.sy = sy;
	
	el.sP=function(x,y){this.style.left=x+px;this.style.top=y+px;};

	el.floatIt=function()
	{
		var pX, pY;
		pX = (this.sx >= 0) ? 0 : ns ? innerWidth : 
		document.documentElement && document.documentElement.clientWidth ? 
		document.documentElement.clientWidth : document.body.clientWidth;
		pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 
		document.documentElement.scrollTop : document.body.scrollTop;
		if(this.sy<0) 
		pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ? 
		document.documentElement.clientHeight : document.body.clientHeight;
		this.cx += (pX + this.sx - this.cx)/8;this.cy += (pY + this.sy - this.cy)/8;
		this.sP(this.cx, this.cy);
		setTimeout(this.id + "_obj.floatIt()", 40);
	}
	return el;
}  

function WSCA_Alert()
{
  alert('Warning: You are now now leaving the WSCA approved website.  Only authorized Products and Peripherals listed on the approved WSCA website are available through the WSCA Agreement.');
}

function init(customernumber){
if (customernumber == "")
   {
					$('password-clear').style.display='block';
					$('password').hide();
					$('password-clear').onfocus=function() {
					$('password-clear').hide();
					$('password').style.display='block';
					$('password').focus();
					};
					$('password').onblur=function() {
					if($('password').value == '') {
					$('password-clear').style.display='block';
					$('password').hide();
					}
					};
  }
}

function rmURLAttribute(str, atr)
  {
    var re = new RegExp(atr + "=","gi");
    if ( (typeof(str) != "string") || (str.match(re) == null) )
      {   
        return str;      
      }
    else 
      {     
        var pieces = str.split("?");
        var domain = pieces[0];
        var oldQuery = pieces[1];     
        var newQuery = "";
        var argpairs = oldQuery.split("&");
        var numArgs = argpairs.length;         
        for(var i = 0; i < numArgs; i++) 
          {
            var pos = argpairs[i].indexOf('=');
            if (pos == -1) continue;
            var argname = argpairs[i].substring(0,pos);
            var value = argpairs[i].substring(pos+1);
            if (argname != atr)
              {
                if (newQuery == "")
                  {
                    newQuery = "?"; 
                  }
                else 
                  {
                    newQuery = newQuery + "&";
                  }
                newQuery = newQuery + argname + "=" + value;
              }
          }
        return domain + newQuery;
      }
  } 

function updateURL(atr)
  {
    // Updating variables on specialProducts.cfm
    var newURL;
    var currentURL = String(document.location);
    var e = atr.value;
    newURL = rmURLAttribute(currentURL, atr.id);   
    if (e != "") 
      {
        if (newURL.match(/\?/) == null)
          {
            newURL = newURL + "?";
          }
        else  
          {
            newURL = newURL + "&";
          }
        newURL = newURL + atr.id + "=" + e;              
      }
    document.location = newURL;
  }    
  
/* Returns whether the current page is http or https */  
function getProtocol()
  {
    var currentURL = String(document.location);
    var parts = currentURL.split(":");
    var protocol;
    switch(parts[0])
      {
        case "http":
          protocol = "http";
          break;
        case "https":
          protocol = "https";
          break;
        default:
          protocol = "http";
      }
    return protocol;
  }  
