function learnMore(productId){
	request = httpUrl+"/nm/products.do?mode=learnMore&productId="+productId
	location.href=request;
}

function nonMemberLearnMore(productId){
    request = httpUrl+"/nm/products.do?mode=learnMore&nonMember=true&productId="+productId
    location.href=request;
}

function back(url){
	location.href=httpUrl+url;
}

function addToCart(productId,maxQuantity){
       /*if(maxQuantity==undefined){
           maxQuantity=1;
       }*/ 
       post_to_url(httpUrl+"/nm/shoppingcart.do",{'productId':productId,'maxquantity':maxQuantity,'quantity':1,'&_':new Date()}); 
}

function addToCartFeature(productId){
   var productFeatureId=document.getElementById("productFeature").value;
   if(productFeatureId=="-"){
        alert(systemMessageArray['pSelectProduct']);
   }else {
        post_to_url(httpUrl+"/nm/shoppingcart.do",{'productFeatureId':productFeatureId,'productId':productId,'maxquantity':document.getElementById('maxQuantity').value,'quantity':1,'&_':new Date()});
   }
}

/*post to url*/
function post_to_url(path, params, method) {
    method = method || "post"; // Set method to post by default, if not specified.
    
    var form = document.createElement("form");
    form.setAttribute("method", method);
    form.setAttribute("action", path);

    for(var key in params) {  
        var hiddenField = document.createElement("input");
        hiddenField.setAttribute("type", "hidden");
        hiddenField.setAttribute("name", key);
        hiddenField.setAttribute("value", params[key]);
        form.appendChild(hiddenField);
    }
    document.body.appendChild(form);    
    form.submit();
}

function getStateList(){
	request = httpUrl+"/nm/shoppingcart.do?type=getStateList&countryId="+document.getElementById('countryId').value+"&_1="+Math.random();
	$.ajax({
            type:"GET", url:request,dataType:"textvalue",cache: false,success: function(response){
            $("#stateList").html(response);
			},error : function(XMLHttpRequest,textStatus,errorThrown){
                alert(systemMessageArray['cNotLoaded']);
            }
        }); 
}

function paymentSetup(val){
	if(val=='shoppingCart' && isBlank($("#promoCode").val())==true){
	window.location.href=httpsUrl+"/nm/paymentsetup.do?mode=payment";
	}else if(val=='shoppingCart' && isBlank($("#promoCode").val())==false){
	window.location.href=httpUrl+"/nm/paymentsetup.do?mode=shoppingCart&promoCode="+$("#promoCode").val();	
	}else if(val=='paymentSetup'){
	window.location.href=httpsUrl+"/nm/paymentsetup.do?mode=paymentSetup";
	}
	//post_to_url(httpsUrl+"/nm/paymentsetup.do",{'promoCode':$("#promoCode").val()}); 
}

function processOrder(){
	iFlag=1;
	/*Validation for Name on Card*/
	if ((document.getElementById('nameOnCard').value==null)||(isBlank(document.getElementById('nameOnCard').value)==true)){	
			document.getElementById("errNameOnCard").innerHTML="<span class='errorMsg'>" + systemMessageArray['cMsg'] + "</span>";
			iFlag=0;			
	}else if (isAlpha(document.getElementById('nameOnCard').value)==false){
			document.getElementById("errNameOnCard").innerHTML="<span class='errorMsg'>" + systemMessageArray['cAlphaMsg'] + "</span>";
			iFlag=0;						
	}else{
			document.getElementById("errNameOnCard").innerHTML="";			
	}
	
	/*Validation for Card Type*/
	if(document.getElementById('cardType').value=="-")	{
		document.getElementById("errCardType").innerHTML="<span class='errorMsg'>" + systemMessageArray['cMsg'] + "</span>";
		iFlag=0;			
	}else{
			document.getElementById("errCardType").innerHTML="";			
	}  
	
	/*Validation for CardNumber*/
	if ((document.getElementById('cardNumber').value==null)||(isBlank(document.getElementById('cardNumber').value)==true)){		
		document.getElementById("errCardNumber").innerHTML="<span class='errorMsg'>" + systemMessageArray['cMsg'] + "</span>";
		iFlag=0;			
	}else if(false==isBlank(document.getElementById('cardNumber').value) && document.getElementById('cardNumber').value!=null){
	    if((document.getElementById('cardNumber').value.length)!=16 && true==isInteger(document.getElementById('cardNumber').value)){
		  	document.getElementById("errCardNumber").innerHTML="<span class='errorMsg'>" + systemMessageArray['pCardNumber'] + "</span>";
			iFlag=0;			
        }
	    else if(false==isInteger(document.getElementById('cardNumber').value)){
			document.getElementById("errCardNumber").innerHTML="<span class='errorMsg'>" + systemMessageArray['pCardNumber'] + "</span>";
			iFlag=0;
	 	}else {
			document.getElementById("errCardNumber").innerHTML="";			
		}
    }else {
		document.getElementById("errCardNumber").innerHTML="";			
	}
	
	/*Validation for Expiration Date*/	
	if(document.getElementById('expirationDate').value==""){
		document.getElementById("errExpirationDate").innerHTML="<span class='errorMsg'>" + systemMessageArray['cSelectDate'] + "</span>";
		iFlag=0;
	}else if(document.getElementById('expirationDate').value!="") {
		var monthArray = new Array();
		monthArray[0]=31;
		monthArray[1]=28;
		monthArray[2]=31;
		monthArray[3]=30;
		monthArray[4]=31;
		monthArray[5]=30;
		monthArray[6]=31;
		monthArray[7]=31;
		monthArray[8]=30;
		monthArray[9]=31;
		monthArray[10]=30;
		monthArray[11]=31;
	
		var expirationDate=document.getElementById('expirationDate').value.split("-")
	
		var expire = new Date();
		var date = new Date();
	
		var month = expirationDate[0]-1;
		var year = expirationDate[1];
	
		if(month==1 && year % 4 ==0){
			monthArray[1]=29;
		}
	
	
		/*Setting our own format for expirationDate*/
	
		expire.setFullYear(year);
		expire.setMonth(month);
		expire.setDate(monthArray[month]);
		expire=Date.parse(expire);
	
		month =date.getMonth()+1;
		year = date.getFullYear();
	
		if(month==12){
			month=0;
			date.setFullYear(year+1);
		}
		
		if(month==1 && year % 4 ==0){
			monthArray[1]=29;
		}
		date.setMonth(month)
		date.setDate(monthArray[month]);
	
		date =Date.parse(date);
		if(date>expire){
			document.getElementById("errExpirationDate").innerHTML="<span class='errorMsg'>" + systemMessageArray['cExpirationDate'] + "</span>";
			iFlag=0;
		}else {
			document.getElementById("errExpirationDate").innerHTML="";
		}		
    }

	/*Validation for CvvCode*/		
	if ((document.getElementById('cvvCode').value==null)||(isBlank(document.getElementById('cvvCode').value)==true)){		
		document.getElementById("errCvvCode").innerHTML="<span class='errorMsg'>" + systemMessageArray['cMsg'] + "</span>";
		iFlag=0;			
	}else if (false==isInteger(document.getElementById('cvvCode').value)){
		document.getElementById("errCvvCode").innerHTML="<span class='errorMsg'>" + systemMessageArray['cCvvcode'] + "</span>";
		iFlag=0;			
	}else if(document.getElementById('cvvCode').value.length<=2){
		document.getElementById("errCvvCode").innerHTML="<span class='errorMsg'>" + systemMessageArray['cCvvcode'] + "</span>";
		iFlag=0;			
	}else {
		document.getElementById("errCvvCode").innerHTML="";			
	}
	
	/*Validation for Billing Address*/
	if ((document.getElementById('billingStreetAddress').value==null)||(isBlank(document.getElementById('billingStreetAddress').value)==true)){		
		document.getElementById("errBillingAddress").innerHTML="<span class='errorMsg'>" + systemMessageArray['cMsg'] + "</span>";
		iFlag=0;			
	}
	else if(false==streetCheck(document.getElementById('billingStreetAddress').value)) {
		document.getElementById("errBillingAddress").innerHTML="<span class='errorMsg'>" + systemMessageArray['pBillingAddress'] + "</span>";
		iFlag=0;			
	}else {
		document.getElementById("errBillingAddress").innerHTML="";			
	}
	
	/*Validation for City*/
	if ((document.getElementById('billingCityCode').value==null)||(isBlank(document.getElementById('billingCityCode').value)==true)){	
		document.getElementById("errCityCode").innerHTML="<span class='errorMsg'>" + systemMessageArray['cMsg'] + "</span>";
		iFlag=0;			
	}else if (isAlpha(document.getElementById('billingCityCode').value)==false){
		document.getElementById("errCityCode").innerHTML="<span class='errorMsg'>" + systemMessageArray['cAlphaMsg'] + "</span>";
		iFlag=0;						
	}else{
		document.getElementById("errCityCode").innerHTML="";			
	}
	
	/* Validation for Billing Postal Code */
	
	if ((document.getElementById('billingPostalCode').value==null)||(isBlank(document.getElementById('billingPostalCode').value)==true)){	
			document.getElementById("errPostalCode").innerHTML="<span class='errorMsg'>" + systemMessageArray['cMsg'] + "</span>";
			iFlag=0;			
		}
		var countryName=document.getElementById('billingCountryCode').options[document.getElementById('billingCountryCode').selectedIndex].text;
		if(countryName=='India' || countryName=='Singapore'){
		if ((document.getElementById('billingPostalCode').value==null)||(isBlank(document.getElementById('billingPostalCode').value)==true)){	
			document.getElementById("errPostalCode").innerHTML="<span class='errorMsg'>" + systemMessageArray['cMsg'] + "</span>";
			iFlag=0;			
		}
		else if (isInteger(document.getElementById('billingPostalCode').value)==false){
			document.getElementById("errPostalCode").innerHTML="<span class='errorMsg'>" + systemMessageArray['cNumberMsg'] + "</span>";
			iFlag=0;							
		}else if(document.getElementById('billingPostalCode').value.length!=6 ){
		document.getElementById("errPostalCode").innerHTML="<span class='errorMsg'>" + systemMessageArray['cPostalIN'] + "</span>";
		iFlag=0;							
		}else{
			document.getElementById("errPostalCode").innerHTML="";			
		}
		}
		else if(countryName=='United States'){
		if ((document.getElementById('billingPostalCode').value==null)||(isBlank(document.getElementById('billingPostalCode').value)==true)){	
			document.getElementById("errPostalCode").innerHTML="<span class='errorMsg'>" + systemMessageArray['cMsg'] + "</span>";
			iFlag=0;			
		}
		else if (isInteger(document.getElementById('billingPostalCode').value)==false){
			document.getElementById("errPostalCode").innerHTML="<span class='errorMsg'>" + systemMessageArray['cNumberMsg'] + "</span>";
			iFlag=0;							
		}else if(document.getElementById('billingPostalCode').value.length!=5){
		document.getElementById("errPostalCode").innerHTML="<span class='errorMsg'>" + systemMessageArray['cPostalUS'] + "</span>";
		iFlag=0;							
		}else{
			document.getElementById("errPostalCode").innerHTML="";			
		}
		}
		else if(countryName=='Canada'){
		if ((document.getElementById('billingPostalCode').value==null)||(isBlank(document.getElementById('billingPostalCode').value)==true)){	
			document.getElementById("errPostalCode").innerHTML="<span class='errorMsg'>" + systemMessageArray['cMsg'] + "</span>";
			iFlag=0;			
		}
		else if (isAlphaNumeric(document.getElementById('billingPostalCode').value)==false){
			document.getElementById("errPostalCode").innerHTML="<span class='errorMsg'>" + systemMessageArray['cNumberMsg'] + "</span>";
			iFlag=0;							
		}else if(document.getElementById('billingPostalCode').value.length<6 || document.getElementById('billingPostalCode').value.length>7){
		document.getElementById("errPostalCode").innerHTML="<span class='errorMsg'>" + systemMessageArray['cPostalCA'] + "</span>";
		iFlag=0;							
		}else{
			document.getElementById("errPostalCode").innerHTML="";			
		}
		}
		else if(countryName=='United Kingdom'){
		if ((document.getElementById('billingPostalCode').value==null)||(isBlank(document.getElementById('billingPostalCode').value)==true)){	
			document.getElementById("errPostalCode").innerHTML="<span class='errorMsg'>" + systemMessageArray['cMsg'] + "</span>";
			iFlag=0;			
		}
		else if (isAlphaNumeric(document.getElementById('billingPostalCode').value)==false){
			document.getElementById("errPostalCode").innerHTML="<span class='errorMsg'>" + systemMessageArray['cNumberMsg'] + "</span>";
			iFlag=0;							
		}else if(document.getElementById('billingPostalCode').value.length<5 || document.getElementById('billingPostalCode').value.length>9){
		document.getElementById("errPostalCode").innerHTML="<span class='errorMsg'>" + systemMessageArray['cPostalUK'] + "</span>";
		iFlag=0;							
		}else{
			document.getElementById("errPostalCode").innerHTML="";			
		}
		}
		else{
			if (isAlphaNumeric(document.getElementById('billingPostalCode').value)==false){
				document.getElementById("errPostalCode").innerHTML="<span class='errorMsg'>" + systemMessageArray['cNumberMsg'] + "</span>";
				iFlag=0;
			}
			else{
			document.getElementById("errPostalCode").innerHTML="";			
			}
			
		}
	
	
	/*Validation for Country Code*/
	if(document.getElementById('billingCountryCode').value=="0"){
	document.getElementById("errCountryCode").innerHTML="<span class='errorMsg'>" + systemMessageArray['cCountryMsg'] + "</span>";
	iFlag=0;			
	}else{
		document.getElementById("errCountryCode").innerHTML="";			
	}
	/*Validation for State Code*/
	if(document.getElementById('billingStateCode').value=="0")	{
	document.getElementById("errStateCode").innerHTML="<span class='errorMsg'>" + systemMessageArray['cStateMsg'] + "</span>";
	iFlag=0;			
	}else{
		document.getElementById("errStateCode").innerHTML="";			
	}  	
        if((isBlank(document.getElementById('shippingStreetAddress').value)==false)||(isBlank(document.getElementById('shippingCityCode').value)==false)||(isBlank(document.getElementById('shippingPostalCode').value)==false) || (document.getElementById('shippingStateCode').value!="0") || (document.getElementById('shippingStateCode').value!="0") ){    
	
			/*Validation for shippingAddress Address*/
			if ((document.getElementById('shippingStreetAddress').value==null)||(isBlank(document.getElementById('shippingStreetAddress').value)==true)){		
				document.getElementById("errShippingAddress").innerHTML="<span class='errorMsg'>" + systemMessageArray['cMsg'] + "</span>";
				iFlag=0;			
			}
			else if(false==streetCheck(document.getElementById('shippingStreetAddress').value)) {
				document.getElementById("errShippingAddress").innerHTML="<span class='errorMsg'>" + systemMessageArray['pShippingAddress'] + "</span>";
				iFlag=0;			
			}else {
				document.getElementById("errShippingAddress").innerHTML="";			
			}
			
			/*Validation for Shipping City*/
			if ((document.getElementById('shippingCityCode').value==null)||(isBlank(document.getElementById('shippingCityCode').value)==true)){	
				document.getElementById("errCityCode1").innerHTML="<span class='errorMsg'>" + systemMessageArray['cMsg'] + "</span>";
				iFlag=0;			
			}else if (isAlpha(document.getElementById('shippingCityCode').value)==false){
				document.getElementById("errCityCode1").innerHTML="<span class='errorMsg'>" + systemMessageArray['cAlphaMsg'] + "</span>";
				iFlag=0;						
			}else{
				document.getElementById("errCityCode1").innerHTML="";			
			}
				
			/* Validation for Shipping Postal Code */
			
			if ((document.getElementById('shippingPostalCode').value==null)||(isBlank(document.getElementById('shippingPostalCode').value)==true)){	
					document.getElementById("errPostalCode1").innerHTML="<span class='errorMsg'>" + systemMessageArray['cMsg'] + "</span>";
					iFlag=0;			
				}
				var countryName=document.getElementById('shippingCountryCode').options[document.getElementById('shippingCountryCode').selectedIndex].text;
				if(countryName=='India' || countryName=='Singapore'){
				if ((document.getElementById('shippingPostalCode').value==null)||(isBlank(document.getElementById('shippingPostalCode').value)==true)){	
					document.getElementById("errPostalCode1").innerHTML="<span class='errorMsg'>" + systemMessageArray['cMsg'] + "</span>";
					iFlag=0;			
				}
				else if (isInteger(document.getElementById('shippingPostalCode').value)==false){
					document.getElementById("errPostalCode1").innerHTML="<span class='errorMsg'>" + systemMessageArray['cNumberMsg'] + "</span>";
					iFlag=0;							
				}else if(document.getElementById('shippingPostalCode').value.length!=6 ){
				document.getElementById("errPostalCode1").innerHTML="<span class='errorMsg'>" + systemMessageArray['cPostalIN'] + "</span>";
				iFlag=0;							
				}else{
					document.getElementById("errPostalCode1").innerHTML="";			
				}
				}
				else if(countryName=='United States'){
				if ((document.getElementById('shippingPostalCode').value==null)||(isBlank(document.getElementById('shippingPostalCode').value)==true)){	
					document.getElementById("errPostalCode1").innerHTML="<span class='errorMsg'>" + systemMessageArray['cMsg'] + "</span>";
					iFlag=0;			
				}
				else if (isInteger(document.getElementById('shippingPostalCode').value)==false){
					document.getElementById("errPostalCode1").innerHTML="<span class='errorMsg'>" + systemMessageArray['cNumberMsg'] + "</span>";
					iFlag=0;							
				}else if(document.getElementById('shippingPostalCode').value.length!=5){
				document.getElementById("errPostalCode1").innerHTML="<span class='errorMsg'>" + systemMessageArray['cPostalUS'] + "</span>";
				iFlag=0;							
				}else{
					document.getElementById("errPostalCode1").innerHTML="";			
				}
				}
				else if(countryName=='Canada'){
				if ((document.getElementById('shippingPostalCode').value==null)||(isBlank(document.getElementById('shippingPostalCode').value)==true)){	
					document.getElementById("errPostalCode1").innerHTML="<span class='errorMsg'>" + systemMessageArray['cMsg'] + "</span>";
					iFlag=0;			
				}
				else if (isAlphaNumeric(document.getElementById('shippingPostalCode').value)==false){
					document.getElementById("errPostalCode1").innerHTML="<span class='errorMsg'>" + systemMessageArray['cNumberMsg'] + "</span>";
					iFlag=0;							
				}else if(document.getElementById('shippingPostalCode').value.length<6 || document.getElementById('shippingPostalCode').value.length>7){
				document.getElementById("errPostalCode1").innerHTML="<span class='errorMsg'>" + systemMessageArray['cPostalCA'] + "</span>";
				iFlag=0;							
				}else{
					document.getElementById("errPostalCode1").innerHTML="";			
				}
				}
				else if(countryName=='United Kingdom'){
				if ((document.getElementById('shippingPostalCode').value==null)||(isBlank(document.getElementById('shippingPostalCode').value)==true)){	
					document.getElementById("errPostalCode1").innerHTML="<span class='errorMsg'>" + systemMessageArray['cMsg'] + "</span>";
					iFlag=0;			
				}
				else if (isAlphaNumeric(document.getElementById('shippingPostalCode').value)==false){
					document.getElementById("errPostalCode1").innerHTML="<span class='errorMsg'>" + systemMessageArray['cNumberMsg'] + "</span>";
					iFlag=0;							
				}else if(document.getElementById('shippingPostalCode').value.length<5 || document.getElementById('shippingPostalCode').value.length>9){
				document.getElementById("errPostalCode1").innerHTML="<span class='errorMsg'>" + systemMessageArray['cPostalUK'] + "</span>";
				iFlag=0;							
				}else{
					document.getElementById("errPostalCode1").innerHTML="";			
				}
				}
				else{
					if (isAlphaNumeric(document.getElementById('shippingPostalCode').value)==false){
						document.getElementById("errPostalCode1").innerHTML="<span class='errorMsg'>" + systemMessageArray['cNumberMsg'] + "</span>";
						iFlag=0;
					}
					else{
					document.getElementById("errPostalCode1").innerHTML="";			
					}
					
				}
			
			/*Validation for Country Code*/
			if(document.getElementById('shippingCountryCode').value=="0"){
			document.getElementById("errCountryCode1").innerHTML="<span class='errorMsg'>" + systemMessageArray['cCountryMsg'] + "</span>";
			iFlag=0;			
			}else{
				document.getElementById("errCountryCode1").innerHTML="";			
			}
			/*Validation for State Code*/
			if(document.getElementById('shippingStateCode').value=="0")	{
			document.getElementById("errStateCode1").innerHTML="<span class='errorMsg'>" + systemMessageArray['cStateMsg'] + "</span>";
			iFlag=0;			
			}else{
				document.getElementById("errStateCode1").innerHTML="";			
			}  	
        }                
	if (!document.getElementById('agreeTerms').checked){	
                 $("#errAgreeTerms").html("<span class='errorMsg'>" + systemMessageArray['pAgreeTermsMsg'] + "</span>");
                 iFlag=0;                 
        } 
        if (!document.getElementById('automaticallyBeBilled').checked){	
                 $("#errAutomaticallyBeBilled").html("<span class='errorMsg'>" + systemMessageArray['pAutomaticallyBeBilledMsg'] + "</span>");
                 iFlag=0;                 
        }
        
	if(iFlag==0){			
	/*document.getElementById("reg_error_main").style.visibility = "visible";
	document.getElementById("reg_error_main").style.display = "block";
	document.getElementById("reg_error_main").innerHTML = "Please correct error fields for successful registration. Errors are mentioned below respective fields";*/
	iFlag=1;			
	}else{
	showLoadPopup('prograssBar');	
            if(user[1]!=null){		
            var parameter=createNonRegisterUser();
            $.ajax({
                            type:"POST", url:httpsUrl+"/nm/adduser.do",data:parameter,dataType:"textvalue",cache: false,success: function(response){
                                     //alert("Created User"); 
                                     TB_remove();
                                     redirect();
                            }
                    });		
            }else {
                 redirect();
            }            
	}
}

function redirect(){    
        var countryDesc=document.getElementById('billingCountryCode').options[document.getElementById('billingCountryCode').selectedIndex].text; 
        document.getElementById("billingCountryDesc").value=countryDesc;
        var stateDesc=document.getElementById('billingStateCode').options[document.getElementById('billingStateCode').selectedIndex].text; 
        document.getElementById("billingStateDesc").value=stateDesc;
        document.getElementById("billingCityDesc").value=document.getElementById('billingCityCode').value;
        document.getElementById("amount").value=document.getElementById('amount1').value;
        if(document.getElementById('shippingCountryCode').value!=0){
                var countryDesc1=document.getElementById('shippingCountryCode').options[document.getElementById('shippingCountryCode').selectedIndex].text; 
                document.getElementById("shippingCountryDesc").value=countryDesc1;
        }else{
                document.getElementById("shippingCountryDesc").value="";
        }
        if(document.getElementById('shippingStateCode').value!=0){
                var stateDesc1=document.getElementById('shippingStateCode').options[document.getElementById('shippingStateCode').selectedIndex].text; 
                document.getElementById("shippingStateDesc").value=stateDesc1;	
        }else{
                document.getElementById("shippingStateDesc").value="";		
        }
        document.getElementById("shippingCityDesc").value=document.getElementById('shippingCityCode').value;
        document.getElementById('billingStateCode').value=document.getElementById('billingStateCode').value;
        var form = document.getElementById('paymentSetUp');
        var id=document.getElementById('billingStateCode');
        var id1=document.getElementById('shippingStateCode');
        if(form.action.indexOf('?')!=-1){
                form.action=form.action+"&billingStateCode="+id.value+"&shippingStateCode="+id1.value
        }else{
                form.action=form.action+"?billingStateCode="+id.value+"&shippingStateCode="+id1.value		
        }
        form.submit();
}

function getCountries(id,innerHtmlid,replaceId){
	request = httpUrl+"/nm/paymentsetup.do?mode=getStateList&replaceId="+replaceId+"&countryCode="+document.getElementById(id).value+"&_1="+Math.random();
	$.ajax({
            type:"GET", url:request,dataType:"textvalue",cache: false,success: function(responseText){
			var response=responseText.substring(responseText.indexOf("<select "),responseText.indexOf("</select>")+9);                                 						
            $("#"+innerHtmlid).html(response);
			},error : function(XMLHttpRequest,textStatus,errorThrown){
                alert(systemMessageArray['cNotLoaded']);
            }
        }); 
}

function confirmOrder(){
	//document.forms[0].submit();
	showLoadPopup('prograssBar');	
        document.getElementById("amount").value=document.getElementById('amount1').value;
	window.location.href=httpUrl+"/nm/confirmorder.do?mode=submit";
}

function calculateTax(countryId) {
	request = httpUrl+"/nm/shoppingcart.do?type=updatetotals&countryId="+countryId+"&stateId="+document.getElementById('stateId').value+"&_1="+Math.random();
	$.ajax({
            type:"GET", url:request,dataType:"textvalue",cache: false,success: function(response){
            $("#shippingTax").html("$"+response);
			findGrantTotal();
			},error : function(XMLHttpRequest,textStatus,errorThrown){
                alert(systemMessageArray['cNotLoaded']);
            }
        }); 
}

function deleteProducts(){
	var arr=document.getElementsByName('remove');
	var str="";
	for(i=0;i<arr.length;i++){
		if(document.getElementsByName('remove')[i].checked==true){
		obj=document.getElementsByName('remove')[i].id;
		str=str+obj+",";
		}
	}
	if(str.length<2){
		alert(systemMessageArray['pDeleteSelectProducts']);
	}else {
		var deleteStatus=confirm(systemMessageArray['pDeleteProducts']);
		if(deleteStatus==true){
		str=str.substring(0,str.length-1);
		post_to_url(httpUrl+"/nm/shoppingcart.do",{'type':'removeproduct','indexPos':str}); 
		}
	}
}

function findGrantTotal() {
	var subtotal=$("#subCost").html();
	var shippingtax=$("#shippingTax").html();
	
	subtotal =subtotal.substring(1,subtotal.length);
	shippingtax =shippingtax.substring(1,shippingtax.length);
	
	var totalTax=parseFloat(subtotal)+parseFloat(shippingtax);
	totalTax=Math.round(totalTax*100)/100;
	$("#grantTotal").html("$"+totalTax);
}


function showPreviousPage(){
	var limit=parseInt(document.getElementById('cursize').value)-3;
    /*request = httpUrl+"/nm/products.do?limit="+limit
    location.href=request;*/
	post_to_url(httpUrl+"/nm/products.do",{'limit':limit}); 
}

function showNextPage(){
	var limit=parseInt(document.getElementById('cursize').value)+3;
    /*request = httpUrl+"/nm/products.do?limit="+limit
    location.href=request;*/
	post_to_url(httpUrl+"/nm/products.do",{'limit':limit}); 
}
function changeExpirationDate(){
		document.getElementById('expirationDate').value=document.getElementById('month').value+"-"+document.getElementById('year').value;
}

function moveBillingAddress(){
        if(document.getElementById('checkThis').checked){ 
            document.getElementById("shippingStreetAddress").value = document.getElementById("billingStreetAddress").value;
            document.getElementById("shippingStateCode").value = document.getElementById("billingStateCode").value;
            document.getElementById("shippingCityCode").value = document.getElementById("billingCityCode").value;
            document.getElementById("shippingPostalCode").value = document.getElementById("billingPostalCode").value;
        }else {            
            document.getElementById("shippingStreetAddress").value = "";            
            document.getElementById("shippingStateCode").selectedIndex = 0;
            document.getElementById("shippingCityCode").value = "";
            document.getElementById("shippingPostalCode").value = "";
        }
}

function getProductFeatureCost(productId){
   var productFeatureId=document.getElementById("productFeature").value;    
   if(productFeatureId=="-"){
        alert(systemMessageArray['pSelectProduct']);
   }/*else {
   $.ajax({type:"POST", url:httpUrl+"/nm/products.do",data:"mode=featureProductPrice&productId="+productId+"&productFeatureId="+productFeatureId,dataType:"textvalue",cache: false,success: function(response){
	  $("#productPrice").html("<br/>"+response);
	  },error : function(XMLHttpRequest,textStatus,errorThrown){
                alert(systemMessageArray['cNotLoaded']);
	  }
	 });     
   }*/
}