	//all_records();
	
	function all_records(CategoryID){

		SetBigBackground();		
		ProductListing(CategoryID);
		
	}

	function ProductListing(CategoryID){
	
		document.getElementById("listing_records").innerHTML="<DIV id=loadingProducts><IMG height=13 alt=loading src='images/loading.gif' width=208></DIV>";
	
		var Url = "ajax/products.php?CategoryID="+CategoryID+"&r="+Math.random();  

		httpObj.open("GET", Url, true);
		httpObj.onreadystatechange = function ProductListingRecieve(){
			if (httpObj.readyState == 4) {
				document.getElementById("listing_records").innerHTML = httpObj.responseText;
			}
		};
		httpObj.send(null);
		
	}
	

	function ProductDetail(id){
	
		document.getElementById("listing_records").innerHTML="<DIV id=loadingProducts><IMG height=13 alt=loading src='images/loading.gif' width=208></DIV>";
	
		var Url = "ajax/productDetail.php?id="+id+"&r="+Math.random();  

		httpObj.open("GET", Url, true);
		httpObj.onreadystatechange = function ProductDetailRecieve(){
			if (httpObj.readyState == 4) {
				document.getElementById("listing_records").innerHTML = httpObj.responseText;
			}
		};
		httpObj.send(null);
		
	}


	function SendPageUrl(Url){
		
		document.getElementById("listing_records").innerHTML="<DIV id=loadingProducts><IMG height=13 alt=loading src='images/loading.gif' width=208></DIV>";
		httpObj.open("GET", Url, true);
		httpObj.onreadystatechange = function ShowPages(){
			if (httpObj.readyState == 4) {
				document.getElementById("listing_records").innerHTML = httpObj.responseText;
			}
		};
		httpObj.send(null);
		
	}


	function DisplayCart(id,Price){

		var ProductSize='';
		if(document.getElementById("ProductSize") != null){
			ProductSize = document.getElementById("ProductSize").value;
		}

		SetBigBackground();		
		document.getElementById("listing_records").innerHTML="<DIV id=loadingProducts><IMG height=13 alt=loading src='images/loading.gif' width=208></DIV>";

		var Url = "ajax/cart.php?id="+id+"&Price="+Price+"&ProductSize="+ProductSize+"&r="+Math.random();  
	
		httpObj.open("GET", Url, true);
		httpObj.onreadystatechange = function CartRecieve(){
			if (httpObj.readyState == 4) {
				document.getElementById("listing_records").innerHTML = httpObj.responseText;
				//document.getElementById("cartSpan").innerHTML = document.getElementById("numCart").value; 
			}
		};
		httpObj.send(null);
		
	}


	function validateCart2(frm){
		if(frm.numCart.value > 0 ){
			var flag = true;

			for(var i=1; i<=frm.numCart.value; i++){
				if( ValidateMandQuantity(document.getElementById('Quantity'+i), "Please enter the quantiy !","Please enter valid quantity !")
				){
					if(parseInt(document.getElementById('Quantity'+i).value) > parseInt(document.getElementById('AvailableQuantity'+i).value)){
						alert("Sorry, Only "+ document.getElementById('AvailableQuantity'+i).value +" Items are available for this product !!");
						document.getElementById('Quantity'+i).select();
						flag = false;
						break;
					}else{
						flag = false;
						//alert('ok');
					}
				}else{
					flag = false;
					break;
				}
			}

			if(flag == false){
				return false;	
			}
		}
	}


	function validateCart(opt){
		var frm = document.form1;
		if(frm.numCart.value > 0 ){
			var flag = true;
			var ProductID = '';
			var Quantity = '';
			var DelCart = '';
			var UpdateUrl = '';

			for(var i=1; i<=frm.numCart.value; i++){

				ProductID = ProductID+document.getElementById('ProductID'+i).value+',';
				Quantity = Quantity+document.getElementById('Quantity'+i).value+',';
				DelCart  = DelCart+document.getElementById('DelCart'+i).checked+',';

				if( ValidateMandQuantity(document.getElementById('Quantity'+i), "Please enter the quantiy !","Please enter valid quantity !")
				){
					if(parseInt(document.getElementById('Quantity'+i).value) > parseInt(document.getElementById('AvailableQuantity'+i).value)){
						alert("Sorry, Only "+ document.getElementById('AvailableQuantity'+i).value +" Items are available for this product !!");
						document.getElementById('Quantity'+i).select();
						flag = false;
						break;
					}else{
						flag = true;

					}
				}else{
					flag = false;
					break;
				}
			}

			if(flag == false){
				return false;	
			}else{


			if(opt==1){
				UpdateUrl = 'ajax/cart.php?CartSubmit=1&numCart='+frm.numCart.value+'&ProductID='+ProductID+'&Quantity='+Quantity+'&DelCart='+DelCart+"&r="+Math.random();
			}else{
				UpdateUrl = 'ajax/checkout.php?CartSubmit=1&numCart='+frm.numCart.value+'&ProductID='+ProductID+'&Quantity='+Quantity+'&DelCart='+DelCart+"&r="+Math.random();
			}
				

				/*  Display Cart */
					
				httpObj.open("GET", UpdateUrl, true);
				httpObj.onreadystatechange = function DisplayCartRecieve(){
					if (httpObj.readyState == 4) {
						document.getElementById("listing_records").innerHTML = httpObj.responseText;
						if(opt==1){
							//document.getElementById("cartSpan").innerHTML = document.getElementById("numCart").value; 
						}else{
							//document.getElementById("MyCartDiv").style.display ='none';
						}
					}
				};
				httpObj.send(null);


				/////////////////

				return false;	

			}


		}
	}



	function CheckOut(){
	
		document.getElementById("listing_records").innerHTML="<DIV id=loadingProducts><IMG height=13 alt=loading src='images/loading.gif' width=208></DIV>";
	
		var Url = "ajax/checkout.php?r="+Math.random();  

		httpObj.open("GET", Url, true);
		httpObj.onreadystatechange = function CheckOutRecieve(){
			if (httpObj.readyState == 4) {
				document.getElementById("listing_records").innerHTML = httpObj.responseText;
			}
		};
		httpObj.send(null);
		
	}


function checkShip(){

	if(document.getElementById("SameAddress").checked==true){
		document.getElementById("shipName").value=document.getElementById("Name").value;
		document.getElementById("shipAddress").value=document.getElementById("Address").value;
		document.getElementById('shipCity').value=document.getElementById('City').value;
		document.getElementById('shipState').value=document.getElementById('State').value;
		document.getElementById("shipcountry_id").value=document.getElementById("country_id").value;
		document.getElementById("shipPostCode").value=document.getElementById("PostCode").value;
	}
	else{
		document.getElementById("shipName").value='';
		document.getElementById("shipAddress").value='';
		document.getElementById('shipCity').value='';
		document.getElementById('shipState').value='';
		document.getElementById("shipcountry_id").value='';
		document.getElementById("shipPostCode").value='';
	}

}


function validateCheckout(){
	var frm = document.form1;
	
	if( ValidateForBlank(frm.Name,"Your Name")
		&& ValidateForEmail(frm.Email)
		&& isEmail(frm.Email)
		&& ValidateOptPhoneNumber(frm.Phone)
		&& ValidateForTextareaOpt(frm.Address,"Address",10,500)
		&& ValidateForBlank(frm.State,"Billing State")
		&& ValidateForBlank(frm.City,"Billing City")
		&& isPostCode(frm.PostCode)
		&& ValidateForBlank(frm.shipName, "Shipping Name")
		&& ValidateForTextareaOpt(frm.shipAddress,"Shipping Address",10,500)
		&& ValidateForBlank(frm.shipState,"Shipping State")
		&& ValidateForBlank(frm.shipCity,"Shipping City")
		&& isPostCode(frm.shipPostCode)	
	){	

	
		var Url = "ajax/confirm.php?Name="+escape(frm.Name.value)+"&shipName="+escape(frm.shipName.value)+"&Email="+escape(frm.Email.value)+"&Address="+escape(frm.Address.value)+"&City="+escape(frm.City.value)+"&State="+escape(frm.State.value)+"&country_id="+escape(frm.country_id.value)+"&PostCode="+escape(frm.PostCode.value)+"&Phone="+escape(frm.Phone.value)+"&Address="+escape(frm.Address.value)+"&shipAddress="+escape(frm.shipAddress.value)+"&shipCity="+escape(frm.shipCity.value)+"&shipState="+escape(frm.shipState.value)+"&shipcountry_id="+escape(frm.shipcountry_id.value)+"&shipPostCode="+escape(frm.shipPostCode.value)+"&r="+Math.random();
		
		document.getElementById("listing_records").innerHTML="<DIV id=loadingProducts><IMG height=13 alt=loading src='images/loading.gif' width=208></DIV>";

		httpObj.open("GET", Url, true);
		httpObj.onreadystatechange = function ConfirmtRecieve(){
			if (httpObj.readyState == 4) {
				document.getElementById("listing_records").innerHTML = httpObj.responseText;
			}
		};
		httpObj.send(null);
		
		return false;	

	}else{
		return false;
	}	

}

function CheckoutBack(){
		var frm = document.form1;

		var Url = "ajax/checkout.php?Name="+escape(frm.Name.value)+"&shipName="+escape(frm.shipName.value)+"&Email="+escape(frm.Email.value)+"&Address="+escape(frm.Address.value)+"&City="+escape(frm.City.value)+"&State="+escape(frm.State.value)+"&country_id="+escape(frm.country_id.value)+"&PostCode="+escape(frm.PostCode.value)+"&Phone="+escape(frm.Phone.value)+"&Address="+escape(frm.Address.value)+"&shipAddress="+escape(frm.shipAddress.value)+"&shipCity="+escape(frm.shipCity.value)+"&shipState="+escape(frm.shipState.value)+"&shipcountry_id="+escape(frm.shipcountry_id.value)+"&shipPostCode="+escape(frm.shipPostCode.value)+"&r="+Math.random();

		document.getElementById("listing_records").innerHTML="<DIV id=loadingProducts><IMG height=13 alt=loading src='images/loading.gif' width=208></DIV>";

		httpObj.open("GET", Url, true);
		httpObj.onreadystatechange = function CheckRecieve(){
			if (httpObj.readyState == 4) {
				document.getElementById("listing_records").innerHTML = httpObj.responseText;
			}
		};
		httpObj.send(null);

}

function ConfirmCheckout(){
		var frm = document.form1;
		
		document.form1.submit();
		/*
		var Url = "ajax/payment.php?Name="+escape(frm.Name.value)+"&shipName="+escape(frm.shipName.value)+"&Email="+escape(frm.Email.value)+"&Address="+escape(frm.Address.value)+"&City="+escape(frm.City.value)+"&State="+escape(frm.State.value)+"&country_id="+escape(frm.country_id.value)+"&PostCode="+escape(frm.PostCode.value)+"&Phone="+escape(frm.Phone.value)+"&Address="+escape(frm.Address.value)+"&shipAddress="+escape(frm.shipAddress.value)+"&shipCity="+escape(frm.shipCity.value)+"&shipState="+escape(frm.shipState.value)+"&shipcountry_id="+escape(frm.shipcountry_id.value)+"&shipPostCode="+escape(frm.shipPostCode.value)+"&r="+Math.random();

		document.getElementById("listing_records").innerHTML="<DIV id=loadingProducts><IMG height=13 alt=loading src='images/loading.gif' width=208></DIV>";

		httpObj.open("GET", Url, true);
		httpObj.onreadystatechange = function PayRecieve(){
			if (httpObj.readyState == 4) {
				document.getElementById("listing_records").innerHTML = httpObj.responseText;
			}
		};
		httpObj.send(null);*/

}


function submitPayment()
	{
		if(document.getElementById("CheckAmount").value > 0){
			//alert('Redirecting to paypal');
		  	document.googleForm.submit();
		 }else{
		 	alert('Invalid Amount, Redirecting to home page....');
			//location.href ="index.php";
		 }
	}