// Wait function jquery Start
var xmlhttp;
var xmlhttp1;
var xmlHttp;
function GetXmlHttpObject()
{
	if (window.XMLHttpRequest)
	{
		return new XMLHttpRequest();
	}
	if (window.ActiveXObject)
	{
	  // code for IE6, IE5
	  return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}
$.fn.wait = function(time, type) {
	time = time || 100;
	type = type || "fx";
	return this.queue(type, function() {
		var self = this;
		setTimeout(function() {
			$(self).dequeue();
		}, time);
	});
};
// Wait function jquery End

function snapshopclose(poss)
{
	$("#snapshopDIV").fadeOut("slow");
	document.getElementById("quickview"+poss).src = 'images/quick_view.gif';
}

function snapshop(pos, url, catid)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}

	url = scriptpath + "snapshop.php?pid=" + pos+"&url="+url+"&catid="+catid;
	xmlhttp.onreadystatechange=StateChangeSnap;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	
	document.getElementById("quickview"+pos).src = 'images/quick_view_hover.jpg';
	
	$("#snapshopDIV").wait();	
		// snapshop height width (here I adjust width if it's for last product Please see live pinacola site if you have query)
	var swidth = 280;
	
	// Snapshop Height
	var sheigh = 230;
	var wpos = 0;
	var hpos = 0;
	var counter = 0;
	
		function showit()
		{
			if(counter == 0)
			{
			/*	LeftPos = (event.clientX + document.documentElement.scrollLeft) - (swidth / 2);
				if(LeftPos > 900)
					LeftPos = 500;*/
				LeftPos = "500";
				document.getElementById("snapshopDIV").style.left =  LeftPos + "px";
				var HeightCalcBot = document.documentElement.clientHeight - event.clientY;
				if(event.clientY < (sheigh / 2))
				{
					document.getElementById("snapshopDIV").style.top = document.documentElement.scrollTop +"px";
				}
				else if(HeightCalcBot < (sheigh / 2))
				{
					document.getElementById("snapshopDIV").style.top = (event.clientY + document.documentElement.scrollTop + HeightCalcBot) - (sheigh + 20) +"px";
				}
				else
				{
					document.getElementById("snapshopDIV").style.top = (event.clientY + document.documentElement.scrollTop) - (sheigh / 2) +"px";
				}
				//document.getElementById("snapshopDIV").innerHTML = ihtml;
				/*document.getElementById("snapshop").style.display = "";*/
				$("#snapshopDIV").fadeIn("slow");
				//display product details
				//document.getElementById("prodetails").innerHTML = dummy[pos].productdetails;
				counter++;
			}
		}
		function showitMOZ(e)
		{
			if(counter == 0)
			{
/*				LeftPos = e.pageX - (swidth / 2);
				if(LeftPos > 900)
					LeftPos = 730;*/
				LeftPos = "500";
				document.getElementById("snapshopDIV").style.left = LeftPos + "px";
				//alert(document.getElementById("snapshopDIV").style.left);
				if(document.getElementById("snapshopDIV").style.left);				
				var HeightCalcTop = e.pageY - window.pageYOffset;
				var HeightCalcBot = (window.pageYOffset + window.innerHeight) - e.pageY;
				if(HeightCalcTop < (sheigh / 2))
				{
					document.getElementById("snapshopDIV").style.top = (e.pageY - HeightCalcTop) + 5 +"px";
				}
				else if(HeightCalcBot < (sheigh / 2))
				{
					document.getElementById("snapshopDIV").style.top = (e.pageY - sheigh - 20) + (HeightCalcBot) +"px";
				}
				else
				{
					document.getElementById("snapshopDIV").style.top = e.pageY - (sheigh / 2) +"px";
				}
				//document.getElementById("snapshopDIV").innerHTML = ihtml;
				/*document.getElementById("snapshop").style.display = "";*/
				$("#snapshopDIV").fadeIn("slow");
				//display product details
				//document.getElementById("prodetails").innerHTML = dummy[pos].productdetails;
				counter++;
			}
		}
		if (!document.all){
			window.captureEvents(Event.CLICK);
			window.onclick=showitMOZ;
		}
		else
		{		
			document.onclick=showit;
		}
		// end mouse pos
		
		// Start Dragging Coading
		$('#snapshopDIV').draggable({ handle: 'abbr' });
		var handle = $('#snapshopDIV').draggable('option', 'handle');
		$('#snapshopDIV').draggable('option', 'handle', 'abbr');
		
		$('#snapshopDIV').draggable({ opacity: 0.35 });
		var opacity = $('#snapshopDIV').draggable('option', 'opacity');
		$('#snapshopDIV').draggable('option', 'opacity', 0.35);
		// End Dragging Coading
		// Wait before load snapshop
//		pos = Number(Response);

}

function StateChangeSnap()
{		
	if (xmlhttp.readyState==4)
	{		
		str = xmlhttp.responseText;
		Response = str.split("CUTHERE");

		document.getElementById("snapshopDIV").innerHTML=Response[1];
		
		ihtml = Response[1];
		pos = Number(Response[0]);			
	}
}

function chekqty_minicart()
{
	loadingScreen();

	var dml=document.forms["checkoutfrm"];

	var len = document.checkoutfrm.elements.length;
    for( i=0 ; i<len ; i++)
	{
		//check the textbox with the elements name
		if (dml.elements[i].name=='qty[]')
        {
			  // if exists do the validation and set the focus to the textbox
              if (dml.elements[i].value>=0)
			  {		
			  		var rel = /^[0-9]*$/;
					if(!dml.elements[i].value.match(rel))
					{
						alert("Please enter valid digit only!");
						dml.elements[i].value=1;
						dml.elements[i].focus();
						return false;
					}
				}
			  else
			  {
				alert("Please enter valid digit only!");
				dml.elements[i].value=1;
				dml.elements[i].focus();
				return false;                       
			  }
		}
    }
	addToCart_test(999, ajaxpath + 'manage.php?p=shopping_cart_minicart&a=update');

}

function loadingScreen()
{
	document.getElementById("mcart").style.display = "none";	
	document.getElementById("staticval").value = 1;
	document.getElementById("loadscreen").style.display = "";

}

function clearfloatcart()
{
	document.getElementById('floating-cart').innerHTML = '';
}

function showCart()
{
	window.onresize = myResize;
	function myResize() {
	  if (document.all)
	    {
			curscrwidth = document.body.clientWidth;
			if(curscrwidth > layoutwidth)
			{
				left = (curscrwidth - layoutwidth) / 2;
				document.getElementById("floating-cart").style.left = (left + ((layoutwidth - minicartwidth) - 6)) + "px";
			}
			else
			{
				document.getElementById("floating-cart").style.left = ((layoutwidth - minicartwidth) - 6) + "px";
			}
		}
	  else
	    {
			curscrwidth = window.innerWidth;
			if(curscrwidth > layoutwidth)
			{
				left = (curscrwidth - layoutwidth) / 2;
				document.getElementById("floating-cart").style.left = (left + ((layoutwidth - minicartwidth) - 15)) + "px";
			}
			else
			{
				document.getElementById("floating-cart").style.left = ((layoutwidth - minicartwidth) - 9) + "px";
			}
		}
	}
	
	myResize();
	document.getElementById('floating-cart').style.top = topspacing +"px";
	$("#floating-cart").fadeIn("slow");
	$("#floating-cart").slideDown();
}


//call this fun on event
function callphppage(requestURL)
{ 
	if (requestURL.length > 0)
	{ 
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request");
			return;
		}
		var url = ajaxpath + 'script/'+ requestURL; //alert(url);		
		xmlHttp.onreadystatechange=stateChangeHandler;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);	
	} 
	else 
	{ 
		alert('Please enter proper URL.');
	}	
} 

//stateChangeHandler will fire when the state has changed, i.e. data is received back 
// This is non-blocking (asynchronous) 
function stateChangeHandler() 
{ 
	//readyState of 4 or 'complete' represents that data has been returned 
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
	{ 
		//Gather the results from the callback 
		var str = xmlHttp.responseText; 
		str = str.split("::");

		switch(str[0])
		{
			case "Inventory":
					if(str[1] != "OK")
					{
						alert(str[1]);
						document.getElementById("qty").focus();
						return false;
					}
					else
					{
						qty = document.getElementById("qty").value;
						pid = document.getElementById('PID904').value;
						formobj = document.forms["orderform"];
						var url = "";
						var price=0;
						for(i=0; i < formobj.elements.length; i++)
						{
							if(formobj.elements[i].type == "select-one")
							{
								if((formobj.elements[i].name).toUpperCase()=='SIZE')
								{
								//	alert(formobj.elements[i].value);
									if(formobj.elements[i].value.length>3)
									{
									var str=formobj.elements[i].value.split("(+");
										if(str[1].length>1)
										{
												var pr=str[1].split(")");
												price=pr[0];
										}
										else
										price=0;
									}
								}
								else
								price=0;
								url += "&" + formobj.elements[i].name + "=" + formobj.elements[i].value+ "&Variant_Management=Y&addprice="+price;
							}
						}
//						alert(url);
					//	alert(ajaxpath + 'manage.php?p=shopping_cart_minicart&a=add&qty='+qty+'&ProductID='+pid+url);
						addToCart_test(904, ajaxpath + 'manage.php?p=shopping_cart_minicart&a=add&qty='+qty+'&ProductID='+pid+url);
						//document.orderform.submit();
					}
					break;
					
			case "GiftCard":
					if(IsNumeric(str[1]) == false)
					{						
						alert(str[1]);
						document.getElementById("GiftDiscount").innerHTML = 0;							
						document.getElementById("order_gift_discount").value = "";																						
						document.getElementById("order_gift_card").value = "";
						return false;
					}
					else
					{
						giftDiscount = Number(str[1]);								
						document.getElementById("GiftDiscountRow").style.display = '';
						document.getElementById("GiftDiscount").innerHTML = giftDiscount.toFixed(2);			
						document.getElementById("order_gift_discount").value = giftDiscount.toFixed(2);										
						document.getElementById("order_gift_card").value = document.getElementById("gift_card").value;		
						setTimeout(updateNetAmount,100);
					}													
					break;

			case "CouponCode":
					if(IsNumeric(str[1]) == false)
					{	
						alert(str[1]);
						document.getElementById("CouponDiscount").innerHTML = 0;							
						document.getElementById("order_coupon_discount").value = "";			
						document.getElementById("order_coupon_code").value = "";
						return false;
					}
					else
					{
						couponDiscount = Number(str[1]);
						document.getElementById("CouponDiscountRow").style.display = '';
						document.getElementById("CouponDiscount").innerHTML = couponDiscount.toFixed(2);
						document.getElementById("order_coupon_discount").value = couponDiscount.toFixed(2);																
						document.getElementById("order_coupon_code").value = document.getElementById("coupon_code").value;							
						updateNetAmount();
					}								
					break;
					
			case "Shipping":		
					if(IsNumeric(str[1]) == false)
					{
						alert(str[1]);
						document.getElementById("ShippingCharge").innerHTML = "0";			
						document.getElementById("ShippingCharge1").innerHTML = "0";			
						return false;
					}
					else
					{
						Shipping = Number(str[1]);			
						document.getElementById("ShippingCharge").innerHTML = Shipping.toFixed(2);			
						document.getElementById("ShippingCharge1").innerHTML = Shipping.toFixed(2);			
						document.getElementById("order_shipping").innerHTML = Shipping.toFixed(2);									
					}
					
					updateNetAmount();					
					break;

			default: 	
					//updateNetAmount();	
					showresult(str[0]);
					break;			
		}
	} 
} 


// XMLHttp send GET request 
function xmlHttp_Get(xmlhttp, url) 
{ 
	xmlhttp.open('GET', url, true); 
	xmlhttp.send(null); 
} 
// XMLHttp send GET request 
function xmlHttp_Get1(xmlhttp1, url) 
{ 
	xmlhttp1.open('GET', url, true); 
	xmlhttp1.send(null); 
} 

/* FUNCTION : checkQty(), Developer : Vikas Patel, Date : 15/09/2009 */
function checkQty(product_id, store_id, formobj)
{ 	
	if(isNaN(document.getElementById("qty").value))
	{
		alert('Please enter valid digit only!');
		document.getElementById('qty').value=1;
		document.getElementById('qty').focus();
		document.getElementById('qty').select();
		return false;
	}
	else if(!IsNumericinteger(document.getElementById("qty").value))
	{
		alert('Please enter valid digit only!');
		document.getElementById('qty').value=1;
		document.getElementById('qty').focus();
		document.getElementById('qty').select();
		return false;
	}
	
	else if(document.getElementById("qty").value==0)
	{
		alert("Please enter valid digit only!");
		document.getElementById('qty').value=1;
		document.getElementById('qty').focus();
		document.getElementById('qty').select();
		return false;
	}
	else
	{
		if(document.getElementById("qty").value.length == 0)
		{
			alert("Please Enter Qty");
			return false;
		}
		form = document.forms["orderform"];
		var url = "";
		for(i=0; i < form.elements.length; i++)
		{
			if(form.elements[i].type == "select-one")
			{
				url += "&" + form.elements[i].name + "=" + form.elements[i].value;
			}
		}
		url += "&qty=" + document.getElementById("qty").value;
		var final_url = 'checkqty.php?id='+ product_id + "&store_id=" + store_id + url + "&type=Inventory"; 
		callphppage(final_url);
		return false;
	}
	
	
	/*else
	{
		document.getElementById('qtyp').style.display='';
		return false;
	}*/
} 

function IsNumericinteger(sText)
{
	var ValidChars = "0123456789";
	var IsNumber=true;
	var Char; 
	for (i = 0; i < sText.length && IsNumber == true; i++) 
	{ 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
		{
			IsNumber = false;
		}
	}
	return IsNumber;   
}
function checkQtygift(product_id, store_id, formobj)
{       
	//alert(document.getElementById("qty").value);
	//alert(document.getElementById("qty").value);
	//return false;
	
	if(isNaN(document.getElementById("qty").value))
	{
		alert('Please enter valid digit only!');
		document.getElementById('qty').value=1;
		document.getElementById('qty').focus();
		document.getElementById('qty').select();
		return false;
	}
	else if(!IsNumericinteger(document.getElementById("qty").value))
	{
		alert('This is not a valid Quantity!');
		document.getElementById('qty').value=1;
		document.getElementById('qty').focus();
		document.getElementById('qty').select();
		return false;
	}
	
	else if(document.getElementById("qty").value==0)
	{
		alert("Quantity should be greater than 0");
		document.getElementById('qty').value=1;
		document.getElementById('qty').focus();
		document.getElementById('qty').select();
		return false;
	}
	
	
	if(document.getElementById("qty").value.length == 0)
	{
		alert("Please Enter Qty");
		document.getElementById('qty').value=1;
		document.getElementById('qty').focus();
		return false;
	}
	form = document.forms["orderform"];
	var url = "";
	for(i=0; i < form.elements.length; i++)
	{
		if(form.elements[i].type == "select-one")
		{
			url += "&" + form.elements[i].name + "=" + form.elements[i].value;
		}
	}
	url += "&qty=" + document.getElementById("qty").value;
	var final_url = 'checkqty.php?id='+ product_id + "&store_id=" + store_id + "&" + url + "&type=Inventory"; 
	callphppage(final_url);
	return false;
	
} 
function statusQty()
{
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
	{ 
		//Gather the results from the callback 		
		var res=xmlHttp.responseText;
		//alert(res);
		switch(res)
		{
			case "Insufficient": 
								alert("Insufficient Qty");
								break;
			case "Inventory Not Set": 
								alert("Inventory Not Set");
								break;
			case "OK": 
								document.orderform.submit();
								break;								
		}
	}
}

function IsNumeric(sText)
{
	var ValidChars = "0123456789.";
   	var IsNumber = true;
   	var Char;
 
	for (i = 0; i < sText.length && IsNumber == true; i++) 
	{ 
		Char = sText.charAt(i); 
		if(ValidChars.indexOf(Char) == -1) 
		{
			IsNumber = false;
		}
	}
	return IsNumber;   
}

function updateNetAmount()
{	
	/*alert(document.getElementById("SubTotal"));
alert(Number(document.getElementById("SubTotal").innerHTML));
	alert(Number(document.getElementById("TaxTotal").innerHTML));
	alert(Number(document.getElementById("CouponDiscount").innerHTML));
	alert(Number(document.getElementById("ShippingCharge").innerHTML));
	alert(Number(document.getElementById("GiftDiscount").innerHTML));
	alert(document.getElementById("CustomerDiscount").innerHTML);*/
	
	NetTotal = Number(document.getElementById("SubTotal").innerHTML) + Number(document.getElementById("TaxTotal").innerHTML) - Number(document.getElementById("CouponDiscount").innerHTML) + Number(document.getElementById("ShippingCharge").innerHTML) - Number(document.getElementById("GiftDiscount").innerHTML)-Number(document.getElementById("QuantityDiscount").innerHTML);

	if(document.getElementById("CustomerDiscount"))
		NetTotal = NetTotal - Number(document.getElementById("CustomerDiscount").innerHTML);
		
	document.getElementById("NetAmount").innerHTML = NetTotal.toFixed(2);
	document.getElementById("order_netamt").value = NetTotal.toFixed(2);							
	document.getElementById("ship_netamt").value = NetTotal.toFixed(2);									

	NetTotal = Number(document.getElementById("SubTotal").innerHTML) - Number(document.getElementById("CouponDiscount").innerHTML) - Number(document.getElementById("GiftDiscount").innerHTML)-Number(document.getElementById("QuantityDiscount").innerHTML);
	if(document.getElementById("CustomerDiscount"))
		NetTotal = NetTotal - Number(document.getElementById("CustomerDiscount").innerHTML);
	
	//document.getElementById("ship_subtotal").innerHTML = NetTotal;
}


function getRates(val, weight)
{
	xmlhttp1=GetXmlHttpObject();
	if (xmlhttp1==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}

	if(val == 1 || val == 2)
		zipcode = document.getElementById("zipcode").value;
	else
		zipcode = document.getElementById("staticzipcode").value;
		
	if(val == 2)
		parameters = "zipcode=" + zipcode+"&country="+ document.getElementById("country").value+"&weight="+weight+"&type=2";
	else
		parameters = "zipcode=" + zipcode+"&type=1&weight="+weight;


	url = "script/getUPSRates.php?" + parameters;

	//alert(url);
	if(val == 2)
		xmlhttp1.onreadystatechange=StateChangeCart;		
	else
		xmlhttp1.onreadystatechange=StateChange;		

	xmlhttp1.open("GET",url,true);
	xmlhttp1.send(null);
//	xmlHttp_Get1(xmlHttp1, url); 

}

function StateChange()
{
	if (xmlhttp1.readyState==4)
	{
		result = xmlhttp1.responseText;
		result = result.split("CUTHERE");
		document.getElementById("shippingloader").style.display = "none";
		document.getElementById("estimShipping").style.display = "";
		document.getElementById("estshipheader").innerHTML="Estimated Shipping : ";
		document.getElementById("estshipvalue").innerHTML = result[0];
		document.getElementById("otherService").innerHTML=result[1];		
		//document.getElementById("otherService").style.display = '';
		document.getElementById("otherServicesLinkText").innerHTML = "Other Services";
	}
}

function StateChangeCart()
{
	if (xmlhttp1.readyState==4)
	{
		result = xmlhttp1.responseText;
		result = result.split("CUTHERE");
		document.getElementById("rateDiv").innerHTML = result[1];
	}
}

function qtyCheck(val)
{
	if(document.getElementById("qty"+val).value.length == 0)
	{
		alert("Please enter valid Quantity.");
		return false;
	}
	if(document.getElementById("qty"+val).value == 0)
	{
		alert("Please enter valid digit only !");
		return false;
	}
	pid = document.getElementById("PID"+val).value;
	qty = document.getElementById("qty"+val).value;
//	alert(ajaxpath + 'manage.php?p=shopping_cart_minicart&a=add&type=single&qty='+qty+"&ProductID="+pid);
	addToCart_test(val, ajaxpath + 'manage.php?p=shopping_cart_minicart&a=add&type=single&qty='+qty+"&ProductID="+pid);
//	document.snaporderform.onsubmit = addToCart(0);
}
function qtyCheck1(val,ProductID)
{
	
	if(document.getElementById("qty"+val).value.length == 0)
	{
		alert("Please enter valid Quantity.");
		return false;
	}
	if(document.getElementById("qty"+val).value == 0)
	{
		alert("Please enter valid digit only !");
		return false;
	}
	pid = document.getElementById("PID"+val).value;
	qty = document.getElementById("qty"+val).value;
	formobj = document.forms["snaporderform"];
	var price;
//	alert(formobj.elements.length);
						var url = "";
						for(i=0; i < formobj.elements.length; i++)
						{
							if(formobj.elements[i].type == "select-one")
							{
								if((formobj.elements[i].name).toUpperCase()=='SIZE')
								{
								//	alert(formobj.elements[i].value);
									if(formobj.elements[i].value.length>3)
									{
									var str=formobj.elements[i].value.split("(+");
										if(str[1].length>1)
										{
												var pr=str[1].split(")");
												price=pr[0];
												formobj.Price.value=price;
										}
										else
										price=0;
									}
								}
								else
								price=0;
							//	alert(formobj.elements[i].value);
								url += "&" + formobj.elements[i].name + "=" + formobj.elements[i].value+ "&addprice="+price;
								//url += "&" + formobj.elements[i].name + "=" + formobj.elements[i].value;
							}
						}
					
				//alert(ajaxpath + 'manage.php?p=shopping_cart_minicart&a=add&type=single&qty='+qty+"&ProductID="+pid+url+ "&Variant_Management=Y");
	//				return false;
//	alert(ajaxpath + 'manage.php?p=shopping_cart_minicart&a=add&type=single&qty='+qty+"&ProductID="+pid);
snapshopclose(ProductID);
	addToCart_test(val, ajaxpath + 'manage.php?p=shopping_cart_minicart&a=add&type=single&qty='+qty+"&ProductID="+pid+url+ "&Variant_Management=Y");
//	document.snaporderform.onsubmit = addToCart(0);
}

function pricecal(size,CurrencySymbol,orginalrpriceval,originalsaleprice)
{
	//alert(CurrencySymbol);
	var price=document.getElementById('tempSPrice').value;
	var RetailPrice=document.getElementById('tempRPrice').value;
	//var sp=RetailPriceid.split(CurrencySymbol);
	//RetailPrice=sp[1];
//		alert(CurrencySymbol);
	if(size.length>3)
	{
		var str=size.split("(+");
		if(str[1].length>1)
		{
				var pr=str[1].split(")");
				addprice=pr[0];
				totprize=Number(price)+Number(addprice);
				totsRetailPrice=Number(RetailPrice)+Number(addprice);
				document.getElementById('Price').value=Number(originalsaleprice)+Number(addprice);
				document.getElementById('RetailPriceid').innerHTML=CurrencySymbol+totsRetailPrice.toFixed(2);
				document.getElementById('SalePriceid').innerHTML=CurrencySymbol+totprize.toFixed(2);		
				var save_price = totsRetailPrice- totprize ; 
				var save_price_per = (save_price * 100)/totsRetailPrice;	//alert(save_price);
				document.getElementById("save_price_perc").innerHTML = save_price_per.toFixed(2) +"% ("+save_price.toFixed(2)+")"; //$CurrencySymbol;
		}
		
	}
	else
	{
			document.getElementById('Price').value=originalsaleprice;
			var rsale=Number(RetailPrice).toFixed(2);
			document.getElementById('RetailPriceid').innerHTML=CurrencySymbol+Number(RetailPrice).toFixed(2);
			document.getElementById('SalePriceid').innerHTML=CurrencySymbol+Number(price).toFixed(2);	
			var save_price = RetailPrice- price ; 
			var save_price_per = (save_price * 100)/RetailPrice;	//alert(save_price);
			document.getElementById("save_price_perc").innerHTML = save_price_per.toFixed(2) +"% ("+CurrencySymbol+save_price.toFixed(2)+")"; //$CurrencySymbol;
	}
	
}

function showresult(security_key_img)
{   
	document.getElementById('SecurityKey').value = security_key_img;
	document.getElementById("security_img").src = "/shopprom/security_images/"+security_key_img+".jpg";
	//document.getElementById("security_img").value=security_key_img;
}

function removeItem(i)
{
	loadingScreen();
	xmlhttp1=GetXmlHttpObject();
	if (xmlhttp1==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}

	url = ajaxpath + "manage.php?p=shopping_cart_minicart&a=delete&sess_id=" + document.getElementById('sess_id'+i).value;
	xmlhttp1.onreadystatechange=StateChangeBuyNow;		
	xmlhttp1.open("GET",url,true);
	xmlhttp1.send(null);	
}

function saveShipCode(ShipCode)
{
	xmlhttp1=GetXmlHttpObject();
	url = "script/saveShipmethod.php?ShipCode=" + ShipCode;
	xmlhttp1.onreadystatechange=ShippingChange;		
	xmlhttp1.open("GET",url,true);
	xmlhttp1.send(null);

}
function ShippingChange()
{
	if (xmlhttp1.readyState==4)
	{
	}
}
