var qty
			function idisplay(ids,fcolor,ccolor){
				if (ids!='')
					document.getElementById(ids).style.visibility ='visible';

				if (ccolor=='')
					fcolor.style.color='#900000';
				else
					fcolor.style.color=ccolor;
			}

			function dontdisplay(ids,fcolor,ccolor){
				if (ids!='')
					document.getElementById(ids).style.visibility ='hidden';

				if (ccolor=='')
					fcolor.style.color='';
				else
					fcolor.style.color=ccolor;
			}

			function history_check(){
				var the_url = document.referrer;

				var lead_slashes = the_url.indexOf("//");

				var domain_start = lead_slashes + 2;

				var without_resource = the_url.substring(domain_start, the_url.length);

				var next_slash = without_resource.indexOf("/");

				var domain = without_resource.substring(0, next_slash);					

				if (domain =='www.mendax.com') 
					history.back(-1);
				else
					document.location.href="/default.aspx";												
			}

// this function will open a new window
			function displayWindow(url,w,h){
				var win = null;
				LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
				TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
				settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+' ,resizable, scrollbars'
				win = window.open(url,'',settings)
				win.focus()
			}
			
			function displayWindowResisable(url, width, height) {
			
				var Win = window.open(url,'','width=' + width + ',height=' + height + ',resizable=1,scrollbars=1,menubar=1,status=0' );
				Win.focus()
			}
			function displayWindowAllOptions(url, width, height) {
			
				var Win = window.open(url,'');
				Win.focus()
			} 
// this function gets and ID, search for it in the document and returns  the object
			function getObj(id){
				var i;
				for (i =1 ; i <= document.forms[0].elements.length-1; i++)
				{
					if (document.forms[0].elements[i].id.indexOf(id)>=0)
						return document.forms[0].elements[i];
				}
			}
			 

	function ResizeObj(obj,width,height){
		// arrange the with(max: 80px) by keeping the proportionality
		
			if (obj.width>width){
			var oldWidth=obj.width;
			obj.width=width;
			//obj.height=(obj.width * obj.height/oldWidth);
		}
		// arrange the height of the image,	 can not be more than 108px
		if (obj.height>height){
			var oldHeight= obj.height;
			obj.height=height;
			//obj.width=(obj.height * obj.width/oldHeight);
		}
	}

// this function will execute the click of a button when ENTER is pressed
// it will reconize the button by the id parameter
	function enterKey(id,dummy){
			if(typeof(dummy)!="undefined"){
			if (event.keyCode == 13)
			{
				event.cancelBubble = true;
				event.returnValue = false;
				document.getElementById(id).click();
			}
			}
		}	
		
		
/* to display the waiting div for the search use control*/	
function showWaitLayerHeader()
{
divWait.style.visibility = 'visible';
}	

		
function showWaitLayer2()
{
	divWait2.style.visibility = 'visible';
}	


/*		LOGIN PAGE */
function openWindow(url,w,h){
		window.open(url,"", 'menubar=no,personalbar=no,statusbar=no,toolbar=no,resizable=yes,scrollbars=auto,top=' + (screen.height - h)/2 + ', left=' + (screen.width - w)/2 + ',width=' + w + ',height=' + h + "'");
	}
	
	function reminder(){ 
		openWindow('forgotPass.aspx',400,200);
	}
	
function searchEngine()
{
	if(document.getElementById("ddlShippRefSource").value=="Other (Specify below)"){
		document.getElementById("txtSpecify").style.visibility="visible"
		document.getElementById("lblSpecify").style.visibility="visible"
	}
	else{
		document.getElementById("txtSpecify").style.visibility="hidden"
		document.getElementById("lblSpecify").style.visibility="hidden"
	}
}
function changeShippingDiv(){
	//alert(obj.checked)
	if (! document.getElementById("checkShip").checked){
		divShipping.style.visibility='visible'
		document.getElementById("checkShip").checked=false
	}
	else{
		divShipping.style.visibility='hidden'
		document.getElementById("checkShip").checked=true
	}
	return true
}

function checkBobShip(){
	if (!typeof(isChecked)=="undefined"){
		if(isChecked==1)
			document.getElementById("checkShip").checked=true;
		else
			document.getElementById("checkShip").checked=false;
	}
	changeShippingDiv(document.getElementById("checkShip"))
}

/************************************************/		
/* for product info page*/
/************************************************/
// this function get the all request parameters of the product
function getRequestParameters(){
	var loc = window.location.href;
	var params = loc.split("?");
	
	return params[1];
}

// this function get the productID of the product
function getProdID(){
	var loc = window.location.href;
	var productID = loc.split("productID=")[1];
	return productID
}
/** BBB online */
function Rcertify() 
{
	popupWin = window.open('http://www.bbbonline.org/cks.asp?id=1040105772733362', 'Participant','location=yes,scrollbars=yes,width=450,height=300'); 
	window.name = 'opener';
} 	
var color
/*this function receives and object, it will make it flash depending on the speed sent and colors*/
function flashobject(obj,speed,color1,color2){
	obj.style.color=color1
	if (color==color1)
		color=color2
	else
		color=color1
	t=setTimeout('quick()', speed)
}

/*
This function used in the category page to redirect to the same page with params
*/	
function redirectCategory(txtsearch,ddlgrp)
{
	var loc
	var str
	var pos
	str=location.href
	pos=str.indexOf("&s=")
	loc =location.href
	if (pos>0)
		loc =location.href.substr(0,pos)
	pos=str.indexOf("&pn=")
	if (pos>0)
		loc =location.href.substr(0,pos)
	location.href=loc + '&pn=1&dis=1&s=' + txtsearch+ '&ddl=' + ddlgrp

}		
		

/*
	this funciton is used in the mainleft.ascx page
*/		
function changeLeftMenu(type,nocookie)
{
	
	if (type=='Telephony')
		location.href='telephony.aspx';
	else
		if (type=='newProducts')
			location.href='product_new.aspx';
			else
				if (type=='Specials')
					location.href='Specials.aspx';
			else			
				if(nocookie=='onlyLeftMenu')
				{
					divMendaxOnly.style.display="none";
					divParts.style.display="block";
				}
				else
				{
					if(type=='empty')
					{
					
						var cookie = document.cookie;
						
						var index = cookie.indexOf ("leftMenu");
						if (index == -1)
							{
								document.cookie = "leftMenu=" + 'mendax';
							}
							type=GetCookie('leftMenu')
					}
					else
					{
						document.cookie = "leftMenu=" + type;
					}
					
					if(type=='mendax')
						{
							divParts.style.display="none";
							divMendaxOnly.style.display="block";
							//selectLeftMenu
						}
					else
						{
							divMendaxOnly.style.display="none";
							divParts.style.display="block";
						}
				}
}

/*This function is used by the user control unitDdl.ascx to */
function changeUnitDdl(obj){
	if (obj.options[obj.selectedIndex].value!='')
		location.href=obj.options[obj.selectedIndex].value
}
// This function loop throught the all the cookies in the web site
// return the leftMenu cookie value
/*****************************************/
function GetCookie (name)  // here "name" is cookie name
{  
	var arg = name + "=";  
	var alen = arg.length;  //desired cookie length
	var clen = document.cookie.length;  // all the cookies in the web site
	var i = 0;  
	while (i < clen) // if the whole cookie length less than 0 then return null
	{    
		var j = i + alen; 
		if (document.cookie.substring(i, j) == arg)   
		return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return null;
}



//returning the value of the desired cookie
function getCookieVal (offset) 
{  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)    
	endstr = document.cookie.length;  
	return unescape(document.cookie.substring(offset, endstr));
}
// using in the shoppingcart.aspx . 
//if the cookie(productAdded")exist  then pop up the proposal window
//and delete the cookie

function proposalProducts()
	{

		var cookval=GetCookie('productAdded')
			
		if(cookval!=null)
		{
			var exp = new Date();
			exp.setTime(exp.getTime() - 1);
			document.cookie= 'productAdded=' + escape(location.pathname) + escape(location.search) + '; path=/; expires=' + exp.toGMTString();
			window.open('productProposals.aspx?productID=' + cookval,'','width=600,height=500');
		}
	
	}

// if the value entered in the qty text box is not  a integer then alert the message
function onlyNumeric(id)
{
	if (isNaN(document.getElementById(id).value) || document.getElementById(id).value < 1)
	{
		alert('Please enter a valid quantity')
		document.getElementById(id).focus();
		document.getElementById(id).value=qty
	}
			
}
	
//storing the qty before changing the value in the text box
function onfocusing(id)
{
	qty=document.getElementById(id).value
}
// calling from the newLeftMenu user control
function mainLeftClicked(item)
	{
		var i
		
		document.getElementById('close'+item).style.display="none"
		document.getElementById('open'+item).style.display="none"
			
		if(document.getElementById(item).style.display=='inline')
		{
			
			document.getElementById('open'+item).style.display="inline"
			document.getElementById(item).style.display="none"
		}
		else
		{	
			document.getElementById('close'+item).style.display="inline"
			document.getElementById(item).style.display="inline"
		}
		
		for (i = 1; i <= document.Form1.totalCat.value; i++)
		{
			if(i!=item)
			{
				if(eval(document.getElementById('open'+i))!=null)
				{
					document.getElementById('open'+i).style.display="inline"
					document.getElementById('close'+i).style.display="none"
					document.getElementById(i).style.display="none"
				}
			}
		}
		/********************************
		DO NOT REMOVE THIS CODE 
		WE WILL USE IT WHEN WE GENERATE THE MENDAX PRODUCTS DYNAMICALLY
		/*
		var close
		var open
		var product
		var count
		
		if(item.indexOf('mendax')>=0)
		{
			var num
			item=item.replace('mendax', '');
			close='mendaxClose'
			open='mendaxOpen'
			product='mendax'
			count=document.Form1.mendaxTotalCat.value
		}
		else
		{
			close='close'
			open='open'
			product=''
			count=document.Form1.totalCat.value
		}
			
			
			document.getElementById(close+item).style.display="none"
			document.getElementById(open+item).style.display="none"
				
			if(document.getElementById(product+item).style.display=='inline')
			{
				document.getElementById(open+item).style.display="inline"
				document.getElementById(product+item).style.display="none"
			}
			else
			{	
				document.getElementById(close+item).style.display="inline"
				document.getElementById(product+item).style.display="inline"
			}
			
			for (i = 1; i <= count; i++)
			{
				if(i!=item)
				{
					
					if(eval(document.getElementById(open+i))!=null)
					{
						document.getElementById(open+i).style.display="inline"
						document.getElementById(close+i).style.display="none"
						document.getElementById(product+i).style.display="none"
					}
				}
			}
			*/
	}
	function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}



function thirdClicked(itemThree)
{

 var item
 var cat
 var subCat
 item=trim(itemThree.substring(0,itemThree.indexOf(' ')))
 cat=trim(itemThree.substring(itemThree.indexOf(' '),itemThree.lastIndexOf(' ')))
 subCat=trim(itemThree.substring(itemThree.lastIndexOf(' ')))

  openClose=document.getElementById(item+'Div '+cat +' '+subCat).style.display
 closeAllItems(item,cat,subCat)
 	
 document.getElementById(item+'div').style.display='inline'	
 document.getElementById(item +'Close').style.display="inline"
 document.getElementById(item +'Open').style.display='none'
 document.getElementById(item+'div '+cat).style.display='inline'	
 document.getElementById(item +'Close '+cat).style.display="inline"
 document.getElementById(item +'Open '+cat).style.display="none"
 
 document.getElementById(item +'Open '+cat +' '+subCat).style.display="none"
 document.getElementById(item+'div '+cat +' '+ subCat).style.display='none'
 if(openClose=='inline')
		{
			document.getElementById(item +'Open '+cat +' ' +subCat).style.display="inline"
		}
		else 
		{	
			document.getElementById(item+'div '+cat+' ' +subCat).style.display="inline"
			document.getElementById(item+ 'Close '+cat+' ' +subCat).style.display="inline"
		}
}

function secondClicked(itemTwo)
{
 
 var cat
 var item


 item=trim(itemTwo.substring(0,itemTwo.indexOf(' ')))
 cat=trim(itemTwo.substring(itemTwo.lastIndexOf(' ')))
 
  var openClose
openClose=document.getElementById(item+'Div '+cat).style.display
 closeAllItems(item,cat,'0')
 	
 document.getElementById(item+'div').style.display='inline'	
 document.getElementById(item +'Close').style.display="inline"
 document.getElementById(item +'Open').style.display="none"
 
 document.getElementById(item +'Open '+cat).style.display="none"
 document.getElementById(item+'div '+cat).style.display='none'
 if(openClose=='inline')
		{
			document.getElementById(item +'Open '+cat).style.display="inline"
		}
		else 
		{	
			document.getElementById(item+'div '+cat).style.display="inline"
			document.getElementById(item+ 'Close '+cat).style.display="inline"
		}

}
function firstClicked(itemOne)
	{
		var item
		item=itemOne
		var openClose
		openClose=document.getElementById(item+'div').style.display
		
		
		closeAllItems(item,'0','0')
		document.getElementById(item +'Open').style.display='none'
		document.getElementById(item+'div').style.display='none'
		if(openClose=='inline')
		{
			document.getElementById(item +'Open').style.display="inline"
		}
		else 
		{	
			document.getElementById(item+'div').style.display="inline"
			document.getElementById(item+ 'Close').style.display="inline"
		}
	}
	function closeAllItems(item,cat,subCat)
	{
		var i
		var id 
		for(i=0;i<document.Form1.elements.length;i++)
			{
				if(document.Form1.elements[i].id!='')
				{
					if(document.Form1.elements[i].id.indexOf('H')==0)
					{
						id=document.Form1.elements[i].id.replace('H','')
						if(id.indexOf('Open')>0)
							document.getElementById(id).style.display='inline'
						else
							document.getElementById(id).style.display="none"
					}
				}
			}
	}
		
		
function mc(maincat)
{
	location.href='rackmount-server.aspx?maincat='+ maincat
}
function cg(cat)
{
	location.href='rackmount-server.aspx?cat='+ cat
}
function sc(cat,sub)
{
	location.href='rackmount-server.aspx?cat='+ cat + '&sub='+ sub
}

function openMendaxMenu(maincat,cat,sub)
{
	var i
	if(maincat!="")
	{
		firstClicked('top' + maincat)
	}
	else
	{
		for(i=0;i<document.Form1.elements.length;i++)
			{
				if(document.Form1.elements[i].id!='')
				{
					if (sub!='')
					{
						if(document.Form1.elements[i].id.indexOf(sub)>0)
							thirdClicked(document.Form1.elements[i].id.replace(' '+ sub,''))
					}

					else if(cat!='')
					{
						if(document.Form1.elements[i].id.indexOf(cat)>0)
							secondClicked(document.Form1.elements[i].id.replace(' '+ cat,''))
					}
				}
			}
	}
}
function clickButton(e, buttonid){ 
      var bt = document.getElementById(buttonid); 
      if (typeof bt == 'object'){ 
            if(navigator.appName.indexOf("Netscape")>(-1)){ 
                  if (e.keyCode == 13){ 
                        bt.click(); 
                        return false; 
                  } 
            } 
            if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){ 
                  if (event.keyCode == 13){ 
                        bt.click(); 
                        return false; 
                  } 
            } 
      } 
} 

function clickrect(ids,active)
{
	if (active==0)
		document.getElementById(ids).style.display='none';
	else
		document.getElementById(ids).style.display='block';
}

function mOvr(src,alink){
	src.style.cursor = 'hand';
	document.getElementById(alink).style.color='#900000';
}
function mOut(src,alink){
	src.style.cursor = 'default';
	document.getElementById(alink).style.color='#000000';
}