/*=======Ver: 7.0.60906========*/
 document.write("<script type='text/javascript' src='/include/enlarge.js'></"+"script>");
	function Diagram(itemnumber)
		{
			window.open("/Showdiagram/Diagram.aspx?item_number="+itemnumber,'_blank','status=yes,scrollbars=yes,resizable=1,width=650,height=550');
		}
		
		function Diagram4Group(val)
		{
			window.open("/Showdiagram/Diagram4Group.aspx?grpCode="+val,'_blank','status=yes,scrollbars=yes,resizable=1,width=650,height=550');
		}


function priceList(itemnumber,title,price,filename)
		{
			window.open("/newproduct/Suggest_A_Price.aspx?item_number="+itemnumber+"&group_title="+escape(title)+"&item_silver="+price+"&Code_str="+filename,'','width=600,height=550')
		}


	function AddToCartProductlink(id,itemno,qty)
	{
		// alert(document.getElementById(id).value);
		qty=document.getElementById(id).value;
		var url = window.location.toString();
		//alert(url);
		var name1=qty;
		for( j=0;j<name1.length;j++)
		{
				ch = name1.charAt(j);
				if((ch>='0' && ch<='9')|| (ch==' '))
				{
				continue;
				}
				else
				{
						alert("Please Enter Valid Quantity");
						document.getElementById(id).select();
						document.getElementById(id).focus();
						return false;	
				}	
				
		}
		if(trimWhitespace(document.getElementById(id).value)=="0")
			{
			
				alert("Please Enter valid Quantity");
				document.getElementById(id).select();
				document.getElementById(id).focus();
				return false;
			}
			if(trimWhitespace(document.getElementById(id).value).length==0)
			{
				status="False"
				alert("Please Enter valid Quantity");
				document.getElementById(id).select();
				document.getElementById(id).focus();
				return false;
			}
			//alert(url);
		window.location="/CreateHtml/Addtocart.aspx?item="+ itemno +"&qty=" + qty + "&sell=''&backurl=" + url ;
	}
	function trimWhitespace(string) {
	var newString  = '';
	var substring  = '';
	beginningFound = false;
	
	// copy characters over to a new string
	// retain whitespace characters if they are between other characters
	for (var i = 0; i < string.length; i++) {
		
		// copy non-whitespace characters
		if (string.charAt(i) != ' ' && string.charCodeAt(i) != 9) {
			
			// if the temporary string contains some whitespace characters, copy them first
			if (substring != '') {
				newString += substring;
				substring = '';
			}
			newString += string.charAt(i);
			if (beginningFound == false) beginningFound = true;
		}
		
		// hold whitespace characters in a temporary string if they follow a non-whitespace character
		else if (beginningFound == true) substring += string.charAt(i);
	}
	return newString;
}
	function AddToCartGroup(totcount)
	{
		var flag="no"
		var item="";
		var qty="";
		invalid=0;
		var status="true";
		var i;
		var url = window.location.toString();
		for(i=0;i<totcount;i++)
		{
			if(trimWhitespace(document.getElementById("txtqty_" + i).value)=="0")
			{
				status="False"
				alert("Please Enter valid Quantity");
				document.getElementById("txtqty_" + i).select();
				document.getElementById("txtqty_" + i).focus();
				return false;
			}
			else if(trimWhitespace(document.getElementById("txtqty_" + i).value)!="")
			{
					flag="yes"
					item=item + document.getElementById("txtitem_" + i).value + "!";
					qty=qty + document.getElementById("txtqty_" + i).value + "!";					
			}	
			var name1=document.getElementById("txtqty_" + i).value;
			for( j=0;j<name1.length;j++)
			{
							ch = name1.charAt(j);
							if((ch>='0' && ch<='9')|| (ch==' '))
							{
							continue;
							}
							else
							{
									alert("Please Enter Valid Quantity");
									document.getElementById("txtqty_" + i).select();
									document.getElementById("txtqty_" + i).focus();
									return false;	
							}	
					
			}
			//alert("txtqty_" + i);
			//alert(document.getElementById("txtqty_" + i).value);
		}
		if(flag=="no")
		{
			alert("Please Enter The Quantity");
			//return false;
			
		}
		else 
		{
		window.location="/createhtml/addtocartgroup.aspx?item="+ item +"&qty=" + qty + "&backurl=" + url
		//window.location.href("/producthtml/addtocartgroup.aspx?item="+ "iii!" +"&qty=" + "1!")
		}
		//alert(itemno);
		//var itemno,qty;
		//for(i=0;i<totcount;i++)
		//{
			//qty=document.getElementById(txtqty_ & i)).value;
			//itemno=document.getElementById(txtitem_ & i)).value;
			//alert(document.getElementById(txtqty_ & i)).value;
			//alert(itemno);
			//alert(qty);
		//}
		//window.location="/CreateHtml/Addtocart.aspx?item="+ itemno +"&qty=" + qty + "&sell=''";
	}
	function BuyProduct(grpcode,itemno)
	{
		window.location = "/newproduct/Prod_Group.aspx?groupcode=" + grpcode + "&itemNo=" + itemno
		
	}
	
	
	
		function addtocart(Gcode,itemno,qty)
		{
			var url = window.location.toString();
			
			window.location="/createhtml/Addtocart.aspx?item="+ itemno +"&qty=1&sell=''" + "&backurl=" + url;
		}
		function getdata()
		{
			loadingusercontrol();
			//id=new String(obj.id)
		//alert(document.getElementById(id).options.length)
		//document.getElementById(id).options[document.getElementById(id).options.length]=new Option("sunny",0,false,false)
		//var item=document.getElementById(id).value
		
		//var rand_no = Math.random();
		//var requestUrl = "/CreateHTML/Viewcart4html.aspx?simply="+ rand_no;
		//var requestUrl = "http://cablesnew/CreateHTML/Viewcart4html.aspx?ff="+ rand_no;
		//var requestUrl = "http://cablesnew/CreateHTML/Viewcart4html.aspx"
		//var requestUrl = "http://www.cables4computer.com/CreateHTML/Viewcart4html.aspx" ;
			
			//CreateXmlReq();
			
			/*if(XmlReq)
			{
				
				XmlReq.onreadystatechange = HandleResponse;
				XmlReq.open("GET", requestUrl,  true);
				XmlReq.send(null);	
				
			}*/
			
		}
		
		function HandleResponse()
		{
		/*//alert(XmlReq.readyState )
			if(XmlReq.readyState == 4)
			{
			//alert(XmlReq.status)
				if(XmlReq.status == 200)
				{			
					// Before filling new contents into the DataGrid, clear the cotents by calling this function
					ClearTable();
					// Fill the cleared Datagrid with new XML Reponse
					//alert(XmlReq.responseText)
					
					FillTable(XmlReq.responseXML.documentElement);
				
					// Hides the Process Image Table after displaying the contents
					//imgtbl.style.visibility = 'hidden';
				}
				else
				{
					alert("There was a problem retrieving data from the server." );
				}
			}*/
		}
		function ClearTable()
		{
			/*document.getElementById("cartqty").innerHTML="";
			document.getElementById("cartprice").innerHTML="";*/
			
		}
		function FillTable(strXMLData)
		{
		
			
			
			

			/*for( var i = document.getElementById('lis2').options.length-1;i>=0; i-- )
			{
			
				document.getElementById('lis2').remove(i)
				
			}*/

			
		/*var str=""//<div style='border:ridge 3px; padding:7px; width:250px;'>";
			//alert(document.getElementById("cart").innerHTML);
			for(var i=0;i<strXMLData.childNodes.length;i++)
			{
				//alert(strXMLData.getElementsByTagName("news")[i].firstChild.nodeValue);
				try
				{
				
				var itemprice=strXMLData.getElementsByTagName("cartitems")[i].firstChild.nodeValue;
				var itemqty=strXMLData.getElementsByTagName("qty")[i].firstChild.nodeValue;
				
				//alert(item);
				//str+=item//strXMLData.getElementsByTagName("cartitems")[i].firstChild.nodeValue;
				//alert(str);
				//alert(itemqty);
				//alert(itemprice);
				}
				catch(ds)
				{
				}
				
				
				//document.write(document.getElementById('test').innerhtml);
			}
			//str+="</div>";
			//str="shihas"
			//document.write(str);
			//document.getElementById("cart").innerHTML=str;
			document.getElementById("cartqty").innerHTML=itemqty;
			document.getElementById("cartprice").innerHTML=itemprice;
			//document.getElementById("test").innerHTML=str;*/
				
		
			
			
		}
		/*function CreateXmlReq()
			{
				
		
		var httpRequest;
		
		//alert("shihas");
		if (window.XMLHttpRequest) { // Mozilla, Safari, ...
			try
			{
				//alert("firefox");
				XmlReq = new XMLHttpRequest();
				XmlReq.overrideMimeType('text/xml');
			}
			catch(ee)
			{
				XmlReq = new ActiveXObject("Msxml2.XMLHTTP");
											
			}
			
			
			
			
		} else if (window.ActiveXObject) { // IE
			//alert("naas");
			XmlReq = new ActiveXObject("Microsoft.XMLHTTP");
			//alert("");
		}
	
	}*/
				function CreateXmlReq()
				{
					try
					{
						//alert("ie");
						XmlReq = new ActiveXObject("Msxml2.XMLHTTP");
					}
					catch(e)
					{
						try
						{
						//alert("ie");
							XmlReq = new ActiveXObject("Microsoft.XMLHTTP");
						} 
						catch(oc)
						{
							XmlReq = null;
						}
					}
					if(!XmlReq && typeof XMLHttpRequest != "undefined") 
					{
						XmlReq = new XMLHttpRequest();
					}
					
				}
		var XmlReq,XmlReqitem;


//*************************For Item Dynamic***********************************

		function getdataitemdetail(itemno)
		{
			//id=new String(obj.id)
		//alert(document.getElementById(id).options.length)
		//document.getElementById(id).options[document.getElementById(id).options.length]=new Option("sunny",0,false,false)
		//var item=document.getElementById(id).value
		
		var rand_no = Math.random();
		var requestUrl = "/CreateHTML/xmlrequestdata.aspx?cat=indi&simply="+ rand_no + "&itemno=" + itemno;
		//var requestUrl = "http://cablesnew/CreateHTML/Viewcart4html.aspx?ff="+ rand_no;
		//var requestUrl = "http://cablesnew/CreateHTML/Viewcart4html.aspx"
		//var requestUrl = "http://www.cables4computer.com/CreateHTML/Viewcart4html.aspx" ;
			
			CreateXmlReqitem();
			
			if(XmlReqitem)
			{
				
				XmlReqitem.onreadystatechange = HandleResponseitem;
				XmlReqitem.open("GET", requestUrl,  true);
				XmlReqitem.send(null);	
				
			}
			
		}
		
		
		function CreateXmlReqitem()
		{
			try
			{
				//alert("ie");
				XmlReqitem = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e)
			{
				try
				{
				//alert("ie");
					XmlReqitem = new ActiveXObject("Microsoft.XMLHTTP");
				} 
				catch(oc)
				{
					XmlReqitem = null;
				}
			}
			if(!XmlReqitem && typeof XMLHttpRequest != "undefined") 
			{
				XmlReqitem = new XMLHttpRequest();
			}
			
		}
		
		
		function HandleResponseitem()
		{
		
			if(XmlReqitem.readyState == 4)
			{
			
				if(XmlReqitem.status == 200)
				{			
					FillTableitem(XmlReqitem.responseXML.documentElement);
				
				}
				else
				{
					alert("There was a problem retrieving data from the server." );
				}
			}
		}
		
		
		function FillTableitem(strXMLData)
		{
		
		
			
			var str=""
			for(var i=0;i<strXMLData.childNodes.length;i++)
			{
				
				try
				{
					var itemstock=strXMLData.getElementsByTagName("Item_Stock")[i].firstChild.nodeValue
					var itemprice=strXMLData.getElementsByTagName("Item_silver")[i].firstChild.nodeValue
					var itemmsrp=strXMLData.getElementsByTagName("Item_msrp")[i].firstChild.nodeValue
					var itemsave=strXMLData.getElementsByTagName("pricediff")[i].firstChild.nodeValue
					//str+=item//strXMLData.getElementsByTagName("cartitems")[i].firstChild.nodeValue;
				}
				catch(ds)
				{
				}
				
			}
			
			document.getElementById("stock").innerHTML=itemstock;
			document.getElementById("silver").innerHTML=itemprice;
			document.getElementById("msrp").innerHTML=itemmsrp;
			//document.getElementById("save").innerHTML=itemsave;
				
		}
		function onstart(itemno)
		{
			loadingusercontrol();
			//getdata();
			getdataitemdetail(itemno);
		}
		
		function getgroup(Groupcode)
		{
			//alert(Groupcode)
			window.location="/newsearch/Global_search.aspx?txtSearch=" + document.getElementById("item_0").value + "&exact=exact&ordersearch=popular"
			itemcount=document.getElementById("hidcount").value;
			loadingusercontrol();
			//getdata();
			getgroupmain(itemcount,Groupcode);
		}
		
		//***********************************
		var xmlreqgroup;
		var idcount;
		function CreateXmlReqitemgroup()
		{
			try
			{
				//alert("ie");
				xmlreqgroup = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e)
			{
				try
				{
				//alert("ie");
					xmlreqgroup = new ActiveXObject("Microsoft.XMLHTTP");
				} 
				catch(oc)
				{
					xmlreqgroup = null;
				}
			}
			if(!xmlreqgroup && typeof XMLHttpRequest != "undefined") 
			{
				xmlreqgroup = new XMLHttpRequest();
			}
			
		}
		var groupcount;
		function getgroupmain(itemcount,Groupcode)
		{
		//alert(itemcount)
			loadingusercontrol();
			groupcount=itemcount
			//alert(Groupcode)
			getgroupitemdetail(Groupcode);
				
				
		}
		
		
		function getgroupitemdetail(Groupcode)
		{
			var rand_no = Math.random();
			var requestUrl = "/CreateHTML/xmlrequestdata.aspx?cat=group&simply="+ rand_no + "&itemno=" + Groupcode //+ document.getElementById("item_" + idcount).value;
			//alert(requestUrl);
			CreateXmlReqitemgroup();
		//alert(document.getElementById("item_" + idcount).value);
		//alert(xmlreqgroup);
			if(xmlreqgroup)
			{
				
				xmlreqgroup.onreadystatechange = HandleResponsegroup;//HandleResponsegroup(idcount);
				xmlreqgroup.open("GET", requestUrl,  true);
				xmlreqgroup.send(null);	
				
			}
		}
		
		function HandleResponsegroup()
		{
		
			if(xmlreqgroup.readyState == 4)
			{
			
				if(xmlreqgroup.status == 200)
				{		
				
					FillTablegroup(xmlreqgroup.responseXML.documentElement);
				
				}
				else
				{
					alert("There was a problem retrieving data from the server." );
				}
			}
		}
		function FillTablegroup(strXMLDatagroup)
		{
					
			var str=""
			for( j=0;j<groupcount;j++)
			{
					//alert(strXMLDatagroup);
				for(var i=0;i<strXMLDatagroup.childNodes.length;i++)
				{
					
					try
					{
					
						var itemnumber=strXMLDatagroup.getElementsByTagName("Item_number")[i].firstChild.nodeValue
						//alert(itemnumber);
						if(itemnumber==document.getElementById("item_" + j).value)
						{
							var itemstock=strXMLDatagroup.getElementsByTagName("Item_Stock")[i].firstChild.nodeValue
							var itemprice=strXMLDatagroup.getElementsByTagName("Item_silver")[i].firstChild.nodeValue
							var itemmsrp=strXMLDatagroup.getElementsByTagName("Item_Msrp")[i].firstChild.nodeValue
							//str+=item//strXMLDatagroup.getElementsByTagName("cartitems")[i].firstChild.nodeValue;
							//alert(itemstock);
						}
					}
					catch(ds)
					{
					}
					
				}
				document.getElementById("stock_" + j).innerHTML=itemstock;
				document.getElementById("silver_" + j).innerHTML=itemprice;
				document.getElementById("msrp_" + j).innerHTML=itemmsrp;
			}
				
		}
		
		//**********************************************************
		var xmlreqcat;
		var cattotcount;
		function CreateXmlReqcat()
		{
			try
			{
				//alert("ie");
				xmlreqcat = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e)
			{
				try
				{
				//alert("ie");
					xmlreqcat = new ActiveXObject("Microsoft.XMLHTTP");
				} 
				catch(oc)
				{
					xmlreqcat = null;
				}
			}
			if(!xmlreqcat && typeof XMLHttpRequest != "undefined") 
			{
				xmlreqcat = new XMLHttpRequest();
			}
			
		}
		function loadingusercontrol()
		{
			getUsercontrol('includeheader','/CreateHTML/siteheader.aspx');
			getUsercontrol('includeSearch','/SiteSearch.html');
			try
			{
				getUsercontrol('includeleft','/Siteleft.html');
			}
			catch(oc)
			{
				
			}
			getUsercontrol('includefooter','/Sitefooter.html');
			
			try
			{
				getUsercontrol('includetopcat','/Sitecattop.html');
			}
			catch(oc)
			{
			
			}
			try
			{
				getUsercontrol('includebasket','/CreateHTML/getcart.aspx');
			}
			catch(oc)
			{
			
			}
			//getsearch() ;
			//getdata();
		}
		function getcat(catcount,catname,sub1,sub2)
		{
			loadingusercontrol();
			cattotcount=catcount;
			//getdata();
			getcatdetails(catname,sub1,sub2)
			try
			{
				document.getElementById("prodcat").style.display="block";
			}
			catch(ds)
					{
					}
		}
		function getcatdetails(catname,sub1,sub2)
		{
			
			var rand_no = Math.random();
			var requestUrl = "/CreateHTML/xmlrequestdata.aspx?cat=cat&simply="+ rand_no  + "&catname=" + catname + "&sub1="  + sub1 + "&sub2="  + sub2 //+ document.getElementById("item_" + idcount).value;
			CreateXmlReqcat();
		
			if(xmlreqcat)
			{
				
				xmlreqcat.onreadystatechange = HandleResponsecat;//HandleResponsegroup(idcount);
				xmlreqcat.open("GET", requestUrl,  true);
				xmlreqcat.send(null);	
				
			}
		}
		
		
		function HandleResponsecat()
		{
		
			if(xmlreqcat.readyState == 4)
			{
			
				if(xmlreqcat.status == 200)
				{		
				
					FillTablecat(xmlreqcat.responseXML.documentElement);
				
				}
				else
				{
					alert("There was a problem retrieving data from the server." );
				}
			}
		}
		function FillTablecat(strXMLData)
		{
		
		
			
			var str=""
			for( j=0;j<cattotcount;j++)
			{
				for(var i=0;i<strXMLData.childNodes.length;i++)
				{
					
					try
					{
						var itemnumber=strXMLData.getElementsByTagName("Item_Number")[i].firstChild.nodeValue
						if(itemnumber==document.getElementById("itemno_" + j).value)
						{
							//var itemstock=strXMLData.getElementsByTagName("Item_Stock")[i].firstChild.nodeValue
							var itemprice=strXMLData.getElementsByTagName("Item_Silver")[i].firstChild.nodeValue
							var itemmsrp=strXMLData.getElementsByTagName("Item_Msrp")[i].firstChild.nodeValue
							//str+=item//strXMLData.getElementsByTagName("cartitems")[i].firstChild.nodeValue;
							//alert(itemstock);
						}
					}
					catch(ds)
					{
					}
					
				}
				//document.getElementById("stock_" + j).innerHTML=itemstock;
				document.getElementById("silver_" + j).innerHTML=itemprice;
				document.getElementById("msrp_" + j).innerHTML=itemmsrp;
			}
				
		}
		function getUsercontrol(id,url) 
		{
			var req = false;
			var rand_no = Math.random();
			url= url + "?simply=" + rand_no
						
			// For Safari, Firefox, and other non-MS browsers
			if (window.XMLHttpRequest) {
				try {
				req = new XMLHttpRequest();
				} catch (e) {
				req = false;
				}
			} else if (window.ActiveXObject) {
				// For Internet Explorer on Windows
				try {
				req = new ActiveXObject("Msxml2.XMLHTTP");
				} catch (e) {
				try {
					req = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {
					req = false;
				}
				}
			}
			var element = document.getElementById(id);
			if (!element) {
			/*alert("Bad id " + id +
			"passed to clientSideInclude." +
			"You need a div or span element " +
			"with this id in your page.");*/
			return;
			}
			if (req) {
				// Synchronous request, wait till we have it all
				req.open('GET', url, false);
				req.send(null);
				element.innerHTML = req.responseText;
			} else {
				element.innerHTML =
			"Sorry, your browser does not support " +
				"XMLHTTPRequest objects. This page requires " +
				"Internet Explorer 5 or better for Windows, " +
				"or Firefox for any system, or Safari. Other " +
				"compatible browsers may also exist.";
			}
			}
			
			function Show()
			{
				document.getElementById("popcat").style.display="block";
			
			}
		function Hide()
		{
			/* hide the pop-up */
			document.getElementById("popcat").style.display="none";
			
			
		}
		function tellafriend(code_str,itemnumber,title)
		{
			window.open("/newproduct/Emailthispage.aspx?Code_str="+code_str+"&item_number="+itemnumber+"&group_title="+escape(title),'','width=600,height=525')
        }
        
        function priceList(itemnumber,title,price,filename)
		{
			window.open("/newproduct/Suggest_A_Price.aspx?item_number="+itemnumber+"&group_title="+escape(title)+"&item_silver="+price+"&Code_str="+filename,'','width=600,height=550')
		}
		
		function Diagram(itemnumber)
		{
			
			//window.location.href("/Showdiagram/Diagram.aspx?item_number="+itemnumber,'_blank','status=yes,scrollbars=yes,resizable=1,width=650,height=550');
			
			window.open("/Showdiagram/Diagram.aspx?item_number="+itemnumber,'_blank','status=yes,scrollbars=yes,resizable=1,width=650,height=550')
			//window.location.href="/Showdiagram/webform1.aspx?item_number="+itemnumber;
			
			
		}
		function getreview(itemno,groupcode)
		{
			document.location.href="/newproduct/product_review.aspx?itemno=" + itemno + "&groupcode=" + groupcode ;
		}
		function Showright()
			{
				document.getElementById("popright").style.display="block";
			
			}
		function Hideright()
		{
			/* hide the pop-up */
			document.getElementById("popright").style.display="none";
			
			
		}
		
function addtofav(linkUrl,linkTitle)
{
	var windo = navigator.appName;
	if (windo == "Netscape")
	{
		window.sidebar.addPanel(linkTitle, linkUrl,""); 
	}
	else
	{
		external.AddFavorite(linkUrl,linkTitle);
		return false;
	}
  
}

function Home()
	{
		
		nav = navigator.appName;
		if (nav=="Netscape")
		{
			alert("Browser wont support this, please do manually");
			return false;
		}
	}

function checkBrowser()
{

	nav = navigator.appName;
	if (nav == "Microsoft Internet Explorer")
	{
		document.getElementById("msDiv").style.display = "block";
	}
	else 
	{
		document.getElementById("NtmsDiv").style.display = "block";
	}
}


function Srch(Item)
{
	window.location.href = "/sortSearch/searchAlphabetically.aspx?Key=" +Item
}
function keyadd(e)
{
	if(window.event)
	{
		var unicode=e.keyCode? e.keyCode : e.charCode    //IE
	}
	else
	{
		unicode = e.which;   //firefox
	}  
	if(unicode==13)
	{
		document.getElementById("btnaddtocart").focus();
		//var objrec = document.getElementById('recalculate');
		//objrec.click();
		//document.getElementById(obj.id).focus();
		return true;
	}
	else
	{
		return false;
	}
}
function keyaddgroup(e)
{

	if(window.event)
	{
		var unicode=e.keyCode? e.keyCode : e.charCode    //IE
	}
	else
	{
		unicode = e.which;   //firefox
	}  
	if(unicode==13)
	{
		document.getElementById("add1").focus();
		//var objrec = document.getElementById('recalculate');
		//objrec.click();
		//document.getElementById(obj.id).focus();
		return true;
	}
	else
	{
		return false;
	}
}
		