// JavaScript Document


function UpdateProductCount(num_product){
	document.getElementById('div_totalitem').innerHTML='';
	document.getElementById('div_totalitem').innerHTML=num_product ;	
}

function showhide(id)
{
	var display=document.getElementById(id).style.display; 
	if(id=='listdiv' && display=='none'){
		document.getElementById('listimage').src='images/up.gif';	
	}else if(id=='listdiv' && display=='inline') {
		document.getElementById('listimage').src='images/down.gif';		
	}
	if(id=='catdiv' && display=='none'){
		document.getElementById('catimage').src='images/up.gif';	
	}else if(id=='catdiv' && display=='inline') {
		document.getElementById('catimage').src='images/down.gif';		
	}
	if (display=='none')
	{
		document.getElementById(id).style.display= 'inline';
	}
	else
	{
		document.getElementById(id).style.display= 'none';
	}
}

function createHttpObject(){
	if (window.XMLHttpRequest)
		req = new XMLHttpRequest();
	else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}	
	return req;
}
//To pen a popup window
function open_window(link,w,h) //opens new window
{
	var win = "width="+w+",height="+h+",menubar=no,location=no,resizable=no,scrollbars=yes,top=0,left=0";
	wishWin = window.open(link,'wishWin',win);
}

var req1=createHttpObject();

function ValidateUpdateQtyForm(){
	var reccount=document.frmCart.reccount.value;
	for(var num=0;num<reccount;num++){
		var newprice=document.getElementById("qty_"+num).value;
		if(newprice=='' || isNaN(newprice) || newprice <=0 ) {
			alert("Please enter valid quantity");
			document.getElementById("qty_"+num).focus();
			return false;
		}
	}
	document.getElementById("updatecart").value="update";
	document.frmCart.action='index.php?action=cart';
	document.frmCart.submit();
	//return true;
}
//To validate quantity of cart
function ValidateQtyForm(){
	var reccount=document.frmCart.reccount.value;
	for(var num=0;num<reccount;num++){
		var newprice=document.getElementById("qty_"+num).value;
		if(newprice=='' || isNaN(newprice)) {
			alert("Please enter valid quantity");
			document.getElementById("qty_"+num).focus();
			return false;
		}
	}
	return true;
}
