function ChangeCategory(objList) {
//			index  = index-1;
	sIndex = objList.selectedIndex;
}
function validatemodalcart(objForm,value){
	if(document.getElementById('attribute')){
		if(document.getElementById('attribute').value==""){
			alert("Please Select Color");
			document.getElementById('attribute').focus();
			return false;
		}
	}
	if(document.getElementById('attrbsiz')){
		if(document.getElementById('attribute').value==""){
			alert("Please Select Color");
			document.getElementById('attribute').focus();
			return false;
		}
		if(document.getElementById('attrbsiz').value==""){
			alert("Please Select Size");
			document.getElementById('attrbsiz').focus();
			return false;
		}
	}
	if(!IsValid(document.getElementById('quantity').value,'Quantity')){
	   document.getElementById('quantity').focus();
	   return false;
	}
	if(!IsCheck(document.getElementById('quantity').value,'Quantity')){
	   document.getElementById('quantity').focus();
	   return false;
	}
	if(document.getElementById('quantity').value==0){
	   alert("Please enter value greater than zero");
	   document.getElementById('quantity').focus();
	   return false;
	}
	document.getElementById('cdetail').value="addcart";
	document.getElementById('shzprz').value = document.getElementById('shwprz').innerHTML;
	
	//document.lForm.submit();
	var strValue='';
			for(var i =0;i<objForm.elements.length;i++){
				if(objForm.elements[i].name == "Addtocart")
				strValue += "&"+objForm.elements[i].name+"=Add to Cart";
				else
				strValue += "&"+objForm.elements[i].name+"="+objForm.elements[i].value;
			}
	ShowModalWindow('AddToCart',300,100,value,'modalwindow/modalwindow.php','',strValue)
	if(document.getElementById("Addtocart"))
		document.getElementById('Addtocart').value="Add To Cart";
	
}
function CartValidateSize(val){
	if(val!=""){
		document.getElementById('attribute').value=val;
		document.getElementById('shwsze').style.display="block";
	}else{
		document.getElementById('shwsze').style.display="none";
	}
}

//////////////////////////   AJAX SCRIPT ///////////////////////////////////

function ShowValidateSize(val,prid,methd){	
	if(methd=="cart"){
		var success = function(t){ShowValidateSizeComplete(t);}
		var failure = function(t){editFailed(t);}
		var url = "ajax/ajax_process.php"; 
		var pars = 'option=cart&attribute='+val+'&productid='+prid;
		var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
	}else if(methd=="shwprice"){
		if(document.getElementById('attribute').value==""){
			alert("Please Select Color");
			document.getElementById('attribute').focus();
			return false;
		}else{
			var success = function(t){ShowValidatePriceComplete(t);}
			var failure = function(t){editFailed(t);}
			var url = "ajax/ajax_process.php"; 
			var pars = 'option=showprice&size='+val+'&attributeid='+prid;
			var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
		}
	}
}

function ShowValidateSizeComplete(t){
	document.getElementById('shwsze').innerHTML = t.responseText;
}
function ShowValidatePriceComplete(t){
	x = t.responseText.split(",");
	document.getElementById('shwprz').innerHTML = x[0];
	document.getElementById('attsize').value = x[1];
	if(x[2]!=""){
		document.getElementById('shwsku').innerHTML = x[2];
	}
}


//////////////////////////////////////////////////////////////////////////////////////

function AddtoCart(objForm,Ident,Layer)
{ 
	Qty = 1
	if(objForm.c_quantity){
		if(objForm.c_quantity.length){
			objQty =objForm.c_quantity[Index];			
			Qty = objQty.value;
		}
		else{
			objQty =objForm.c_quantity;			
			Qty = objForm.c_quantity.value
		}
	}
	if(isNaN(Qty)){
		alert("Quantity must be numeric");
		objQty.focus();
		return false;
	}
	if(Qty<=0){
		alert("Quantity must be positive number");
		objQty.focus();
		return false;
	}
	if(!IsNumber(objForm.c_quantity.value,"Quantity")){
	objForm.c_quantity.focus();
	return false;
	}
	objForm.c_product.value = Ident;
	objForm.c_action.value  = 1;
	objForm.c_qty.value		= Qty;
	if(Layer){
	var strValue='';
			for(var i =0;i< objForm.elements.length;i++){
				if(objForm.elements[i].name == "Addtocart")
				strValue += "&"+objForm.elements[i].name+"=Add to Cart";
				else
				strValue += "&"+objForm.elements[i].name+"="+objForm.elements[i].value;
			}
		ShowModalWindow('AddToCart',500,100,Ident,'ajax/modalwindow/modalwindow.php','',strValue)
	}
	if(document.getElementById("Addtocart"))
		document.getElementById('Addtocart').value="Add To Cart";
}
