var transparentDiv=null , paymentValue = "" , currentPaymentOption = "divCash";
function trim(stringToTrim){
	return stringToTrim.replace(/^\s+|\s+$/g, '');
}

function PNGFIX(){
	var arVersion = navigator.appVersion.split("MSIE");
	var version = parseFloat(arVersion[1]);
	if((version >= 5.5) && (document.body.filters)){
		for(var i=0; i<document.images.length; i++){
			var img = document.images[i];
			var imgName = img.src.toUpperCase();
			if(imgName.substring(imgName.length-3, imgName.length) == "PNG"){
				var imgID = (img.id) ? "id='" + img.id + "' " : "";
				var imgClass = (img.className) ? "class='" + img.className + "' " : "";
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
				var imgStyle = "display:inline-block;" + img.style.cssText;
				if(img.align == "left") imgStyle = "float:left;" + imgStyle;
				if(img.align == "right") imgStyle = "float:right;" + imgStyle;
				if(img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
				var strNewHTML = "<span " + imgID + imgClass + imgTitle
					 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
					 + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
					 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
				img.outerHTML = strNewHTML;
				i = i-1;
			}
		}
	}
}

function isValidLetter(theValue){
	var chr;
	theValue=trim(theValue);
	for(var i=0;i<theValue.length;i++){
		chr=theValue.charAt(i)
		if( !( (chr>='A' &&  chr <= 'Z' ) || (chr>='a' &&  chr <= 'z'  ) || chr == ' ' ) ){
				return true;
		}
	}
	return false;
}

function isValidName(theValue){
	var chr;
	theValue=trim(theValue);
	for(var i=0;i<theValue.length;i++){
		chr=theValue.charAt(i)
		if( !( (chr>='A' &&  chr <= 'Z' ) || (chr>='a' &&  chr <= 'z'  ) || chr == ' ' || chr == "'" || chr == '.' ) ){
				return true;
		}
	}
	return false;
}

function isValidAlphaNumeric(theValue){
	var chr;
	theValue=trim(theValue);
	for(var i=0;i<theValue.length;i++){
		chr=theValue.charAt(i)
		if( !( (chr>='A' &&  chr <= 'Z' ) || (chr>='a' &&  chr <= 'z'  ) || (chr>='0' &&  chr <= '9') ) ){
				return true;
		}
	}
	return false;
}

function isValidPhone(theValue){
	var chr;
	theValue=trim(theValue);
	for(var i=0;i<theValue.length;i++){
		chr=theValue.charAt(i)
		if( !( chr=='-' || (chr>='0' &&  chr <= '9') ) ){
				return true;
		}
	}
	return false;
}

function isValidEmailAddress(strEmailAddress){
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(!filter.test(strEmailAddress))
		return true;
	return false;
}

function handleResults(ewin, edocel, ebody) {
	var eresult = ewin ? ewin : 0;
	if (edocel && (!eresult || (eresult > edocel)))
		eresult = edocel;
	return ebody && (!eresult || (eresult > ebody)) ? ebody : eresult;
}

function getBrowserWidth(){
	return handleResults(window.innerWidth ? window.innerWidth : 0,document.documentElement ? document.documentElement.clientWidth : 0,document.body ? document.body.clientWidth : 0);
}

function getBrowserHeight(){
	return handleResults(window.innerHeight ? window.innerHeight : 0,document.documentElement ? document.documentElement.clientHeight : 0,document.body ? document.body.clientHeight : 0);
}

function getDocWidth(){
	var D = document;
	return Math.max(Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),Math.max(D.body.clientWidth, D.documentElement.clientWidth));
}

function getDocHeight(){
	var D = document;
	return Math.max(Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),Math.max(D.body.clientHeight, D.documentElement.clientHeight));
}


function showInquiry(id, productID, popupType){
	if(typeof productID != "undefined" && popupType == "inquiry"){
		document.frmInquiry.ProductID.value = productID;
		document.getElementById("strProductTitle").innerHTML = document.getElementById("strTitle"+productID).innerHTML;
	}
	else if(typeof productID != "undefined" && popupType == "order"){
		document.frmOrder.ProductID.value = productID;
		document.getElementById("strOrderProductTitle").innerHTML = document.getElementById("strTitle"+productID).innerHTML;
		document.getElementById("strOrderProductPrice").innerHTML = document.getElementById("strPrice"+productID).innerHTML;
		document.getElementById("strOrderProductDescription").innerHTML = document.getElementById("strDescription"+productID).innerHTML;
		document.getElementById("strOrderProductImage").src = "";
		document.getElementById("strOrderProductImage").src = document.getElementById("strImage"+productID).src;
	
	}
	else if(typeof productID != "undefined" && popupType == "review"){
		reviewProductID = productID;
	}
	
	var ele = document.getElementById(id);
	divLeft = (getBrowserWidth()-parseInt(ele.style.width))/2;
	divTop = (getBrowserHeight()-parseInt(ele.style.height))/2;
	ele.style.left = divLeft+"px";
	ele.style.top = divTop+Math.max(document.documentElement.scrollTop,document.body.scrollTop)+"px";
	setTransparentDiv(id,productID,popupType);
	ele.style.zIndex = 2;
	ele.style.display = '';
}

function setTransparentDiv(id,productID,popupType){
	if(transparentDiv == null){
		transparentDiv = document.createElement('div');
		transparentDiv.style.position = 'absolute';
		transparentDiv.style.left = '0px';
		transparentDiv.style.top = '0px';
		transparentDiv.style.verticalAlign = 'middle';
		transparentDiv.style.textAlign = 'center';
		transparentDiv.style.backgroundColor = 'gray';
		transparentDiv.style.filter = 'alpha(opacity=50);';
		transparentDiv.style.opacity = .5;
		transparentDiv.style.MozOpacity = .5;
		transparentDiv.style.zIndex = 1;
		document.getElementsByTagName("body")[0].appendChild(transparentDiv);
	}
	transparentDiv.style.width = getDocWidth()+'px';
	transparentDiv.style.height = getDocHeight()+'px';
	transparentDiv.style.display = '';
	/*window.onresize = function(){
		showInquiry(id,productID,popupType);
	}
	window.onmouseup = function(){
		showInquiry(id,productID,popupType);
	}
	window.onmousemove = function(){
		showInquiry(id,productID,popupType);
	}*/
	
}

function removeTransparentDiv(id){
	window.onresize = null;
	window.onmouseup = null;
	window.onmousemove = null;
	transparentDiv.style.display = 'none';
	document.getElementById(id).style.display = 'none';
}

function submitInquiry(){
		var frm = document.frmInquiry;
		if(trim(frm.ProductID.value) == "")
			return;
		else if(trim(frm.txtName.value) == ""){
			frm.txtName.focus();
			displayAllerMessage('divAlertBox','divAlertMessage','Please enter name');
			return false;
		}
		else if(trim(frm.txtEmail.value) == ""){
			frm.txtEmail.focus();
			displayAllerMessage('divAlertBox','divAlertMessage','Please enter email');
			return false;
		}
		else if(trim(frm.txtPhone.value) == ""){
			frm.txtPhone.focus();
			displayAllerMessage('divAlertBox','divAlertMessage','Please enter phone');
			return false;
		}
		else if(trim(frm.txtMessage.value) == ""){
			frm.txtMessage.focus();
			displayAllerMessage('divAlertBox','divAlertMessage','Please enter message');
			return false;
		}
		frm.btnSendInquiry.disabled = true;
		jQuery.post(storeurl+"includes/ajax/EmailService.php",{callFunction:"sendInquiry", ProductID:trim(frm.ProductID.value), Name:trim(frm.txtName.value), Email:trim(frm.txtEmail.value), PhoneNo:trim(frm.txtPhone.value), Message:trim(frm.txtMessage.value), SubDomain:subDomain},function(response){
			frm.btnSendInquiry.disabled = false;
			if(response == "Ok"){
				frm.ProductID.value = "";
				frm.txtName.value = "";
				frm.txtEmail.value = "";
				frm.txtPhone.value = "";
				frm.txtMessage.value = "";
				removeTransparentDiv('divInquiry');
				displayAllerMessage('divAlertBox','divAlertMessage','Inquiry Sent');
			}
			else{
				displayAllerMessage('divAlertBox','divAlertMessage','An error occured while sending inquiry request,<br> please try again');
				
			}
		});
}

function submitOrder(){
		var frm = document.frmOrder;
		if(trim(productsTotal) == "0"){
			displayAllerMessage('divAlertBox','divAlertMessage','Please add product to cart');
			return false;
		}
		else if(trim(frm.txtName.value) == ""){
			frm.txtName.focus();
			displayAllerMessage('divAlertBox','divAlertMessage','Please enter name');
			return false;
		}
		else if(trim(frm.txtEmail.value) == ""){
			frm.txtEmail.focus();
			displayAllerMessage('divAlertBox','divAlertMessage','Please enter email');
			return false;
		}
		else if(isValidEmailAddress(trim(frm.txtEmail.value))){
			frm.txtEmail.focus();
			displayAllerMessage('divAlertBox','divAlertMessage','Please enter email');
			return false;
		}
		else if(trim(frm.txtPhone.value) == ""){
			frm.txtPhone.focus();
			displayAllerMessage('divAlertBox','divAlertMessage','Please enter phone');
			return false;
		}
		else if(isValidPhone(frm.txtPhone.value)){
			frm.txtPhone.focus();
			displayAllerMessage('divAlertBox','divAlertMessage','Please enter valid phone no');
			return false;
		}
		else if(trim(frm.txtAddress.value) == ""){
			frm.txtAddress.focus();
			displayAllerMessage('divAlertBox','divAlertMessage','Please enter address');
			return false;
		}
		else if(trim(frm.txtMessage.value) == ""){
			frm.txtMessage.focus();
			displayAllerMessage('divAlertBox','divAlertMessage','Please enter message');
			return false;
		}
		/*else if(trim(frm.txtQuantity.value) == ""){
			frm.txtQuantity.focus();
			alert("Please enter quantity");
			return false;
		}
		else if(isNaN(trim(frm.txtQuantity.value))){
			frm.txtQuantity.focus();
			alert("Please enter valid quantity");
			return false;
		}*/
		
		var paymentValue = frm.cmbPaymentOption.options[frm.cmbPaymentOption.selectedIndex].value;
		if(paymentValue == "BankTransfer")
			paymentValue += "|*|"+frm.cmbBanks.options[frm.cmbBanks.selectedIndex].value;
		else if(paymentValue == "CrossCheque")
			paymentValue += "|*|"+frm.cmbAccountTitle.options[frm.cmbAccountTitle.selectedIndex].value;
		
		document.getElementById("divLoading").style.display = "";
		jQuery.post(storeurl+"includes/ajax/ProductOrderService.php",{callFunction:"sendOrder", Name:trim(frm.txtName.value), Email:trim(frm.txtEmail.value), PhoneNo:trim(frm.txtPhone.value), Address:trim(frm.txtAddress.value), Message:trim(frm.txtMessage.value), SubDomain:subDomain, PaymentMethod:paymentValue},function(response){
			document.getElementById("divLoading").style.display = "none";
			if(response == "Ok"){
				/*frm.txtName.value = "";
				frm.txtEmail.value = "";
				frm.txtPhone.value = "";
				frm.txtAddress.value = "";
				frm.txtMessage.value = "";
				frm.cmbPaymentOption.selectedIndex = 0;*/
				/*document.getElementById("divCartDetail").innerHTML = "";
				document.getElementById("spanGrandTotal").innerHTML = "0";
				document.getElementById("divCartEmty").style.display = "";
				document.getElementById("divCartNotEmty").style.display = "none";
				document.getElementById("divCheckOut").innerHTML = '';
				removeTransparentDiv('divOrder');
				displayAllerMessage('divAlertBox','divAlertMessage','Order Sent successfully');*/
				frm.submit();
			}
			else{
				displayAllerMessage('divAlertBox','divAlertMessage','An error occured while sending order,<br> please try again');
				}
		});
}

/////// submitReview
function submitReview(reviewProductID)
{
	var frm = document.frmReview;
	//var recaptcha_response_field=trim(document.getElementById('recaptcha_response_field').value);
	//var recaptcha_challenge_field=trim(document.getElementById('recaptcha_challenge_field').value);
	
	//alert(recaptcha_response_field);
	//alert(recaptcha_challenge_field);
	
	if(trim(frm.txtName_review.value) == ""){
			frm.txtName_review.focus();
			displayAllerMessage('divAlertBox','divAlertMessage','Please enter name');
			return false;
		}
		else if(trim(frm.txtEmail_review.value) == ""){
			frm.txtEmail_review.focus();
			displayAllerMessage('divAlertBox','divAlertMessage','Please enter email');
			return false;
		}
		else if(isValidEmailAddress(trim(frm.txtEmail_review.value)))
		{
			frm.txtEmail_review.focus();
			displayAllerMessage('divAlertBox','divAlertMessage','Please enter valid email');
			return false;
		}
		else if(trim(frm.txtMessage_review.value) == ""){
			frm.txtMessage_review.focus();
			displayAllerMessage('divAlertBox','divAlertMessage','Please enter message');
			return false;
		}
		else if(counterRating==0)
		{
			displayAllerMessage('divAlertBox','divAlertMessage','Please mark rating for yout review.');
			return false;
		}
		/*else if(recaptcha_response_field=="")
		{
			displayAllerMessage('divAlertBox','divAlertMessage','Please enter mark recaptcha words.');
			return false;
		}*/
		
		else
		{
				
				frm.btnSendReview.disabled = true;
				document.getElementById("divLoading").style.display = "";
						jQuery.post(storeurl+"includes/ajax/ProductService.php",{FunctionType:"sendReview",/*recaptcha_response_field:recaptcha_response_field,recaptcha_challenge_field:recaptcha_challenge_field,*/ProductID:reviewProductID, Name:trim(frm.txtName_review.value), Email:trim(frm.txtEmail_review.value), Message:trim(frm.txtMessage_review.value),Rating:counterRating},function(response){
																																																																																																 					frm.btnSendReview.disabled = false;
					document.getElementById("divLoading").style.display = "none";
					//alert(response);
					if(response == "Ok")
					{
						frm.txtName_review.value = "";
						frm.txtEmail_review.value = "";
						frm.txtMessage_review.value = "";
					  counterRating=0;
						//removeTransparentDiv('divReview');
						//displayAllerMessage('divAlertBox','divAlertMessage','Review Sent');
						location.href=location.href;
					}
					else if(response="invalid code")
					{
						displayAllerMessage('divAlertBox','divAlertMessage','Please enter correct words for authentication.');
					}
					else
					{
						displayAllerMessage('divAlertBox','divAlertMessage','An error occured while sending review,<br> please try again');
						}
				});
		}
}

function addToCart(productName, productID, price, categoryName)
{
	
	var innerHTML ='';
	var strHTML ='';
	var count = 1;
	//alert(productName+'  :  '+productID+'  :  '+price+'  :  '+categoryName);
	document.getElementById("divLoading").style.display = "";
	jQuery.post(storeurl+"includes/ajax/CartService.php",{callFunction:"addToCart", ProductID:productID, ProductName:productName, CategoryName:categoryName, Price:price},								    function(response){ //alert(response);
			document.getElementById("divLoading").style.display = "none";
			var json = eval('(' +  response + ')');
			totalItems = json.TotalCount;
			json = json.Cart;
			document.getElementById("spanItemCount").innerHTML = totalItems;
			if(json.length != 0){
				for(i=0;i<json.length;i++){
					strHTML += "<div id='divProduct"+json[i].ProductID+"' ><div style='padding: 3px 0 3px 0; border-bottom: 1px solid #d4d4d4' class='blue font12'><strong>"+json[i].ProductName+"</strong><br /><span class='font11 style1' id='product"+json[i].ProductID+"'><strong>Quantity:"+json[i].PQuantity+"</strong></span><span class='font11'><br />Rs."+json[i].Price+"</span><div><img src='http://www.etailer.lahore/images/spacer.gif' alt='' width='5' height='5' /></div><span class='font11 rednew'><a href='javascrip:void(null);' onclick='removeFromCart("+json[i].ProductID+"); return false;' >Remove from Cart</a></span></div></div>";
				}
				//strHTML += document.getElementById("divCheckOut").innerHTML;
				document.getElementById("divCheckOut").innerHTML=strHTML;
				document.getElementById("divCartEmty").style.display = "none";
				document.getElementById("divCartNotEmty").style.display = "";
			}
			//continueShoping('divMessageBox','show');
		});
}
function removeFromCart(productID){
	
	jQuery.post(storeurl+"includes/ajax/CartService.php",{callFunction:"removeCart", ProductID:productID},function(response){
			if(response=='ok'){
				document.getElementById("divProduct"+productID).innerHTML='';
				var itemCount = parseInt(document.getElementById("spanItemCount").innerHTML,10);
				itemCount=itemCount-1;
				if(itemCount>0){
					document.getElementById("divCartEmty").style.display = "none";
					document.getElementById("divCartNotEmty").style.display = "";
				}
				else{
					itemCount=0;
					document.getElementById("divCartEmty").style.display = "";
					document.getElementById("divCartNotEmty").style.display = "none";
				}
				document.getElementById("spanItemCount").innerHTML=itemCount;
				}
			});
}
function checkOut(){
	
	jQuery.post(storeurl+"includes/ajax/CartService.php",{callFunction:"getProducCartList"},function(response){
			var json = eval('(' +  response + ')');
			var cart = json.Cart;
			if(cart.length == 0){
				displayAllerMessage('divAlertBox','divAlertMessage','No items added to cart');
				return;
			}
			var rootNode = cart[0];
			var grandTotal =0;
			var strHTML ='<table width="100%" border="0" cellspacing="3" cellpadding="0">';
			for(var i=0; i <cart.length; i++){
				var totalPrice = parseInt(cart[i].Price.replace(/,/gi,""),10)*parseInt(cart[i].PQuentity.replace(/,/gi,""),10);
				var unitPrice = parseInt(cart[i].Price.replace(/,/gi,""),10);
			 		grandTotal += totalPrice;
				var counter=i+1;
			 strHTML +="<tr id='tr"+cart[i].ProductID+"'><td width='6%' align='center' valign='top' class='ch_list'><b>"+counter+"</b></td><td width='63%'><b class='font12'>"+cart[i].ProductName+"</b><br /><span class='clr_blue'>Product Id: <b>"+cart[i].ProductID+"</b></span><br />Unit Price: <b>Rs."+cart[i].Price+"</b> <br />QTY:<input name='checkoutQty' id='textfield"+cart[i].ProductID+"' type='text' size='3' value='"+cart[i].PQuentity+"' maxlength='3' onchange='updateTotal("+cart[i].ProductID+","+unitPrice+");' alt='"+cart[i].ProductID+"' /> <span class='rednew'><a href='javascript:voing(null);' onclick='removeItem("+cart[i].ProductID+","+cart[i].PQuentity+"); return false;' >Remove</a></span></td><td width='31%' valign='bottom' class='ch_list_right'><b>Rs. <span id='spanSubTotal"+cart[i].ProductID+"'>"+totalPrice+"</span></b></td></tr>"
				}
		strHTML +='</table></div>';
		//alert(grandTotal);
		
		document.getElementById("spanCartCount").innerHTML="<b>Items in your Cart ("+counter+")</b>";
		document.getElementById("divCartDetail").innerHTML=strHTML;
		document.getElementById("spanGrandTotal").innerHTML=grandTotal;
		var ele = document.getElementById("divOrder");
		divLeft = (getBrowserWidth()-parseInt(ele.style.width))/2;
		divTop = (getBrowserHeight()-parseInt(ele.style.height))/2;
		ele.style.left = divLeft+"px";
		ele.style.top = divTop+Math.max(document.documentElement.scrollTop,document.body.scrollTop)+"px";
		setTransparentDiv("divOrder");
		ele.style.zIndex = 2;
		ele.style.display = '';
			});
	}
function removeItem(productID,ProductQty){
	jQuery.post(storeurl+"includes/ajax/CartService.php",{callFunction:"removeCart", ProductID:productID},function(response){
			if(response=='ok'){
				location.href=location.href;
				/*document.getElementById("divProduct"+productID).innerHTML='';
				var itemCount = parseInt(document.getElementById("spanItemCount").innerHTML,10);
				itemCount=itemCount-1;
				if(itemCount>0){
					document.getElementById("divCartEmty").style.display = "none";
					document.getElementById("divCartNotEmty").style.display = "";
				}
				else{
					itemCount=0;
					document.getElementById("divCartEmty").style.display = "";
					document.getElementById("divCartNotEmty").style.display = "none";
				}
				document.getElementById("spanItemCount").innerHTML=itemCount;*/
				}
			});
	/*var subTotal =parseInt(document.getElementById("spanSubTotal"+productID).innerHTML,10) ;
	var grandTotal =parseInt(document.getElementById("spanGrandTotal").innerHTML,10);
	grandTotal= grandTotal- subTotal;
	document.getElementById("spanGrandTotal").innerHTML=grandTotal;
	document.getElementById("tr"+productID).innerHTML='';
	var itemCount = parseInt(document.getElementById("spanItemCount").innerHTML,10);
	if(itemCount>0)
		itemCount=itemCount-1;
	document.getElementById("spanCartCount").innerHTML="<b>Items in your Cart ("+itemCount+")</b>";
	removeFromCart(productID);*/
	
	//alert(productID+'  :product to be remove:  '+ProductQty);
	}
   
function updateTotal(productID,productPrice){
	
	var QTY = document.getElementById("textfield"+productID).value;
		   if(isNaN(QTY) || QTY<1)
			{
				displayAllerMessage('divAlertBox','divAlertMessage','Product Quantity must be greater than zero.');
				document.getElementById("textfield"+productID).value=1;
			}
			
				var newQTY = parseInt(document.getElementById("textfield"+productID).value,10);
				if(newQTY>0){
					var subTotal =parseInt(document.getElementById("spanSubTotal"+productID).innerHTML,10) ;
					var grandTotal =parseInt(document.getElementById("spanGrandTotal").innerHTML,10);
					var newQTY = parseInt(document.getElementById("textfield"+productID).value,10);
					var newSubTotal =newQTY*productPrice;
					if(newSubTotal>0){
						grandTotal= grandTotal- subTotal + newSubTotal;
						document.getElementById("spanSubTotal"+productID).innerHTML=newSubTotal;
						document.getElementById("spanGrandTotal").innerHTML=grandTotal;
						}
					}
					 else{
						displayAllerMessage('divAlertBox','divAllertMessage','Product Quantity must be greater than 0');
						document.getElementById("textfield"+productID).value=1;
						}
//	alert("subTotal    : "+subTotal+"    newSubTotal  : "+newSubTotal+"   grandTotal:  "+grandTotal+"   newQTY:   "+newQTY+"   productPrice:   "+productPrice);
}
function displayAllerMessage(mainDiv, messageDiv, message){
	
	document.getElementById(mainDiv).style.display='';
	document.getElementById(messageDiv).innerHTML=message;
	//alert(mainDiv+" :  "+messageDiv+" :  "+message);
	//alert(document.getElementById(mainDiv).innerHTML);
	}
function continueShoping(divID,display){

	if(display=='hide')
	  document.getElementById(divID).style.display='none';
	 else
	 	document.getElementById(divID).style.display='';
	
}
//////////addReview
function addReview(productID)
{
	
	//alert(productID);
	/*jQuery.post("includes/ajax/CartService.php",{callFunction:"addToCart", ProductID:productID, ProductName:productName, CategoryName:categoryName, Price:price,},								function(response){
																																																		 			alert(response);
			frm.btnSendOrder.disabled = false;
			if(response == "Ok")
				alert("Order Sent");
			else
				alert("An error occured while sending order, please try again");
			});*/
}
////////////addReview
function paymentOptionChanged(obj){
	document.getElementById(currentPaymentOption).style.display = "none";
	currentPaymentOption = obj.options[obj.selectedIndex].value;
	if(document.getElementById("spn"+currentPaymentOption).innerHTML != ""){
		document.getElementById("div"+currentPaymentOption).style.display = "";
		document.getElementById("divPaymentTips").style.display = "";
	}
	else{
		document.getElementById("divPaymentTips").style.display = "none";
	}
	currentPaymentOption = "div"+currentPaymentOption;
	if(obj.options[obj.selectedIndex].value == "BankTransfer"){
		try{
			document.getElementById("trBanks").style.display = "";
			document.getElementById("trAccountTitle").style.display = "none";
		}catch(e){}
	}
	else if(obj.options[obj.selectedIndex].value == "CrossCheque"){
		try{
			document.getElementById("trAccountTitle").style.display = "";
			document.getElementById("trBanks").style.display = "none";
		}catch(e){}
	}
	else{
		try{document.getElementById("trBanks").style.display = "none";}catch(e){}
		try{document.getElementById("trAccountTitle").style.display = "none";}catch(e){}
	}
}

function updateQuantities(){
		var frm = document.frmCart , checkoutProductIDs="" , checkoutProductQty="";
		for(i=0; i<frm.elements.length; i++){
			if(frm.elements[i].name == "checkoutQty"){
				checkoutProductIDs += frm.elements[i].alt+","
				checkoutProductQty += frm.elements[i].value+","
			}
		}
		checkoutProductIDs = checkoutProductIDs.substr(0,checkoutProductIDs.length-1);
		checkoutProductQty = checkoutProductQty.substr(0,checkoutProductQty.length-1);
		
		document.getElementById("divLoading").style.display = "";
		jQuery.post(storeurl+"includes/ajax/CartService.php",{callFunction:"UpdateOrder", ProductIDs:trim(checkoutProductIDs), ProductQty:trim(checkoutProductQty)},function(response){
			document.getElementById("divLoading").style.display = "none";
			if(response == "Ok"){
				location.href = location.href;
			}
			else{
				displayAllerMessage('divAlertBox','divAlertMessage','An error occured while updating cart,<br> please try again');
				}
		});
}