// JavaScript Document

	function getProducts(url)
	{
		if(typeof(url)=='object' || url==null)
		{ 
			url=(this.id);
		}
		if(url==null)
			return false;
		/*
		document.getElementById("chkMil").checked=true;
		document.getElementById("chkFlk").checked=true;
		document.getElementById("chkWhs").checked=true;
		*/
		//alert(url);
		window.scroll(0,0);
		var ids=url.split('_');
		if(document.getElementById('requesturi'))
		document.getElementById('requesturi').value=url;
		document.getElementById("middlecontent").innerHTML='<img id="loader" src="images/loader.gif">';
		xmlHttp=createRequestObject();
		if (xmlHttp==null)
		{
		alert ("Your browser does not support AJAX!");
		return;
		} 
		xmlHttp.onreadystatechange=productResponse;
		if(ids[ids.length-1]==39)
		{
			url="computer.php?page=comp";
		}
		else
			url="getproducts.php?"+url;
		//alert(url);
		xmlHttp.open("GET",url,true);	
		xmlHttp.send(null);
	}
	function productResponse()
	{
	
		if(xmlHttp.readyState==4)
		{
			//alert(xmlHttp.responseText);
			document.getElementById("middlecontent").innerHTML=xmlHttp.responseText;			
		}
	}
	function getProductInfo(pid,catpath)
	{
		if(document.getElementById('requesturi'))
			document.getElementById('requesturi').value='cpath=productinfo&pid='+pid+'&catpath='+catpath;
		document.getElementById("middlecontent").innerHTML='<img id="loader" src="images/loader.gif">';
		xmlHttp=createRequestObject();
		if (xmlHttp==null)
		{
		alert ("Your browser does not support AJAX!");
		return;
		} 
		url='pid='+pid+'&catpath='+catpath;
		//alert(url);
		xmlHttp.onreadystatechange=productinfoResponse;
		url="productinfo.php?"+url;
		//alert(url);
		xmlHttp.open("GET",url,true);	
		xmlHttp.send(null);
	}
	function productinfoResponse()
	{
	
		if(xmlHttp.readyState==4)
		{
			//alert(xmlHttp.responseText);
			document.getElementById("middlecontent").innerHTML=xmlHttp.responseText;
			pdesc=new animatedcollapse("pdesc", 500,false,'block',true);
			pinfo=new animatedcollapse("pinfo", 500,false,'block',true);
			pwarrenty=new animatedcollapse("pwarrenty", 500, false,'block',true);
			if(document.getElementById("psupport"))
				psupport=new animatedcollapse("psupport", 500, false,'block',true);
		}
	}
	var pwarrenty,pdesc,pinfo,psupport;
	
	function enlagreView(image)
	{
		popwindow=window.open(image,'gocomp','width=350,height=250,resizable=1');
		popwindow.focus(); return false;
	}
	function catchResponse(resp)
	{		
		if(resp>0)
			document.getElementById("divResponse").innerHTML="Question Posted Successfully !!";
		else
			document.getElementById("divResponse").innerHTML="Failed to do so !!";
	}
	function getProductReviews(pid,catpath,status,querystring)
	{
		if(document.getElementById('requesturi'))
			document.getElementById('requesturi').value='cpath=productreview&pid='+pid+'&catpath='+catpath+'&status='+status+'&querystring='+querystring;
		document.getElementById("middlecontent").innerHTML='<img id="loader" src="images/loader.gif">';
		xmlHttp=createRequestObject();
		if (xmlHttp==null)
		{
		alert ("Your browser does not support AJAX!");
		return;
		} 
		url='pid='+pid+'&catpath='+catpath+'&status='+status+'&'+querystring;
		//alert(url);
		xmlHttp.onreadystatechange=productReviewResponse;
		url="productreview.php?"+url;
		//alert(url);
		xmlHttp.open("GET",url,true);	
		xmlHttp.send(null);
	}var preview;
	function productReviewResponse()
	{
		
		if(xmlHttp.readyState==4)
		{
				document.getElementById("middlecontent").innerHTML=xmlHttp.responseText;
				if(document.getElementById("preview"))
				preview=new animatedcollapse("preview", 500,false,'block',true);
		}
	}
	function selectRating(rate)
	{
		document.getElementById("txtRate").value=rate;
		for(var i=1;i<=5;i++)
		{
			document.getElementById('r'+i).src="images/star2.gif";
			if(i<=rate)
				document.getElementById('r'+i).src="images/star2.gif";
			else
				document.getElementById('r'+i).src="images/star1.gif";
		}
		return false;
	}
	function removeRating(rate)
	{
		/*
			for(var i=1;i<=rate;i++)
			{
				document.getElementById('r'+i).src="images/star1.gif";
			}
			return false;
		*/
	}
	function setRate(rate)
	{
		document.getElementById("txtRate").value=rate;
		for(var i=1;i<=5;i++)
		{
			if(i<=rate)
				document.getElementById('r'+i).src="images/star2.gif";
			else
				document.getElementById('r'+i).src="images/star1.gif";
		}
		return false;
	}
	function sendtofriend(link)
	{
		
		var popwindow=window.open("sendtofriend.php?link="+link,'Auscomp','width=400,height=250,top=300,left=200');
		popwindow.focus(); return false;
	}
	function deleteImage(pid)
	{
		xmlHttp=createRequestObject();
		if (xmlHttp==null)
		{
		alert ("Your browser does not support AJAX!");
		return;
		} 
		xmlHttp.onreadystatechange=productImageResponse;
		url="index.php?cpath=edit_product&pid="+pid+'&mode=deleteImage';
		xmlHttp.open("GET",url,true);	
		xmlHttp.send(null);
	}
	function productImageResponse()
	{
	
		if(xmlHttp.readyState==4)
		{
			//alert(xmlHttp.responseText);
			document.getElementById('image').style.display="none";
		}
	}
	//store
	function hideProducts(chk,store)
	{
		if(chk.checked)
		{
			document.cookie=store+" =1";
			var display="";
		}
		else
		{
			document.cookie=store+" =0";
			var display="none";
		}
		if(document.getElementById("tblProducts"))
		{
			products=document.getElementById("tblProducts").getElementsByTagName("div");
			//alert(products.length);
			for(var i=0;i<products.length;i++)
			{
				element=store+'_'+i;
				if(document.getElementById(element))
				{
					
				document.getElementById(element).style.display=display;
				}
			}
		}
	}
function changeTab(obj,divid)
{
	document.getElementById("warrantydetails").style.display="none";
	document.getElementById("manufacturerurl").style.display="none";
	document.getElementById("productinfo").style.display="none";
	document.getElementById("productinfo_td").className="tab";
	document.getElementById("manufacturerurl_td").className="tab";
	document.getElementById("warrantydetails_td").className="tab";
	obj.className='selectedtab';
	document.getElementById(divid).style.display="block";
}