var alpha_numb = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
var alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var valid_zip = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-";
var num = "0123456789";
	function res(t,v)
	{
		var w = "";
		for (i=0; i < t.value.length; i++)
		{
			x = t.value.charAt(i);
			if (v.indexOf(x,0) != -1)
			w += x;
		}
		t.value = w;
	}
	
	
function message_paypal()
{
	var curr_factor = document.getElementById("curr_factor").value;
	var msg = "You have choosen to make payments via Paypal Payment Gateway. Since Paypal is an International Payment Gateway, hence you will be charged in USD, although your Credit Card will be billed in INR amount only.\nConversion Factor of  $1 = Rs."+curr_factor + " is used to convert your order in USD.";
	alert(msg);
	
}
function shopping_cart_check()
{
	
	var no_address_msg = "";
	var cart_amount_for_check = document.getElementById("cart_amount").value;
	var no_billing_flag = document.getElementById("no_billing").value;
	var no_shipping_flag = document.getElementById("no_shipping").value;
	//alert('cart_amount'+cart_amount_for_check);
	if(cart_amount_for_check=="")
	{
		no_address_msg = "Your Cart is Empty.";
	}
	if(no_billing_flag==1)
	{
		no_address_msg = no_address_msg + "\n";
		no_address_msg = " No Billing Address exists. Please provide your Billing Address.";
	}
	
	if(no_shipping_flag==1)
	{
		no_address_msg = no_address_msg + "\n";
		no_address_msg = no_address_msg + " No Shipping Address exists. Please provide atleast one Shipping Address.";
	}
	
	if(no_address_msg!="")
	{
	alert(no_address_msg);
	return false;
	}
	
	if(no_address_msg=="")
	{
	alert("You are being redirected to Our Payment Gateway for payments. After making the payments, do wait till you are being re-directed back to www.gurumaa.com to get your order status confirmed instantly.");
	return true;
	//return false;
	}
}


function showadd(num, shipping_len)
{
	//alert('in side showadd function'+num+',shipping_len '+shipping_len);
	
	if (num==1)
	{
		if(shipping_len==2)
		{
			document.getElementById('address1').style.display='block';	
			document.getElementById('address2').style.display='none';
			document.getElementById('updateshipping1').style.display='inline';	
			//document.getElementById('updateshipping2').style.display='none';	
		}
		
		if(shipping_len==3)
		{
			document.getElementById('address1').style.display='block';	
			document.getElementById('address2').style.display='none';
			document.getElementById('address3').style.display='none';
			document.getElementById('updateshipping1').style.display='inline';	
			document.getElementById('updateshipping2').style.display='none';	
			//document.getElementById('updateshipping3').style.display='none';
		}
		
		if(shipping_len==4)
		{
			document.getElementById('address1').style.display='block';	
			document.getElementById('address2').style.display='none';
			document.getElementById('address3').style.display='none';
			document.getElementById('address4').style.display='none';
			document.getElementById('updateshipping1').style.display='inline';	
			document.getElementById('updateshipping2').style.display='none';	
			document.getElementById('updateshipping3').style.display='none';
		}
		
		var amt_with_shipp = parseFloat(document.getElementById('cart_amount').value) + parseFloat(document.getElementById('amt_shipp1').value) ;
		document.getElementById('amt_includ_shipp').value = parseFloat(amt_with_shipp);	
		document.getElementById('shipping_cost').value = parseFloat(document.getElementById('amt_shipp1').value) ;
		
		document.getElementById('user_info_id').value =document.getElementById('user_info_id1').value ;
		document.getElementById('shipping_name').value =document.getElementById('shipping_name1').value ;
		document.getElementById('shipping_company').value =document.getElementById('company1').value ;
		document.getElementById('shipping_address1').value =document.getElementById('address_11').value ;
		document.getElementById('shipping_address2').value =document.getElementById('address_21').value ;
		document.getElementById('shipping_city').value =document.getElementById('city1').value ;
		document.getElementById('shipping_zip').value =document.getElementById('zip1').value ;
		document.getElementById('shipping_state').value =document.getElementById('state1').value ;
		document.getElementById('shipping_country').value =document.getElementById('country1').value ;
		document.getElementById('shipping_phone').value =document.getElementById('phone_11').value ;
		
					
	}
		
		
		
	if (num==2)
	{
		var cart_amount = parseFloat(document.getElementById('cart_amount').value);
		var amt_shipp = parseFloat(document.getElementById('amt_shipp2').value);
		var amt_with_shipp = cart_amount + amt_shipp ;
		
		
		document.getElementById('amt_includ_shipp').value = amt_with_shipp;	
		
		
		if(shipping_len==2)
		{
			document.getElementById('address2').style.display='block';	
			document.getElementById('address1').style.display='none';
			document.getElementById('updateshipping1').style.display='none';	
			//document.getElementById('updateshipping2').style.display='inline';
		}
		
		if(shipping_len==3)
		{
			document.getElementById('address2').style.display='block';
			document.getElementById('address1').style.display='none';
			document.getElementById('address3').style.display='none';
			document.getElementById('updateshipping1').style.display='none';	
			document.getElementById('updateshipping2').style.display='inline';	
			//document.getElementById('updateshipping3').style.display='none';
			//alert('display ok 9');
		}
		
		if(shipping_len==4)
		{
			document.getElementById('address2').style.display='block';	
			document.getElementById('address1').style.display='none';
			document.getElementById('address3').style.display='none';
			document.getElementById('address4').style.display='none';
			document.getElementById('updateshipping1').style.display='none';	
			document.getElementById('updateshipping2').style.display='inline';	
			document.getElementById('updateshipping3').style.display='none';
		}
		
		
		document.getElementById('shipping_cost').value = parseFloat(document.getElementById('amt_shipp2').value) ;
		
		document.getElementById('user_info_id').value =document.getElementById('user_info_id2').value ;
		document.getElementById('shipping_name').value =document.getElementById('shipping_name2').value ;
		document.getElementById('shipping_company').value =document.getElementById('company2').value ;
		document.getElementById('shipping_address1').value =document.getElementById('address_12').value ;
		document.getElementById('shipping_address2').value =document.getElementById('address_22').value ;
		document.getElementById('shipping_city').value =document.getElementById('city2').value ;
		document.getElementById('shipping_zip').value =document.getElementById('zip2').value ;
		document.getElementById('shipping_state').value =document.getElementById('state2').value ;
		document.getElementById('shipping_country').value =document.getElementById('country2').value ;
		document.getElementById('shipping_phone').value =document.getElementById('phone_12').value ;
		
		
	}
	
	
	
	if (num==3)
	{
		var cart_amount = parseFloat(document.getElementById('cart_amount').value);
		var amt_shipp = parseFloat(document.getElementById('amt_shipp3').value);
		var amt_with_shipp = cart_amount + amt_shipp ;
		
		document.getElementById('amt_includ_shipp').value = amt_with_shipp;	
		
		if(shipping_len==2)
		{
			document.getElementById('address3').style.display='block';	
			document.getElementById('address1').style.display='none';
			document.getElementById('address2').style.display='none';
			document.getElementById('updateshipping1').style.display='none';	
			document.getElementById('updateshipping2').style.display='inline';
		}
		
		if(shipping_len==3)
		{
			document.getElementById('address3').style.display='block';	
			document.getElementById('address1').style.display='none';
			document.getElementById('address2').style.display='none';
			document.getElementById('updateshipping1').style.display='none';	
			document.getElementById('updateshipping2').style.display='none';	
			//document.getElementById('updateshipping3').style.display='none';
		}
		
		if(shipping_len==4)
		{
			document.getElementById('address4').style.display='block';	
			document.getElementById('address1').style.display='none';
			document.getElementById('address2').style.display='none';
			document.getElementById('address3').style.display='none';
			document.getElementById('updateshipping1').style.display='none';	
			document.getElementById('updateshipping2').style.display='inline';	
			document.getElementById('updateshipping3').style.display='none';
		}
		
		
		document.getElementById('shipping_cost').value = parseFloat(document.getElementById('amt_shipp2').value) ;
		
		document.getElementById('user_info_id').value =document.getElementById('user_info_id2').value ;
		document.getElementById('shipping_name').value =document.getElementById('shipping_name2').value ;
		document.getElementById('shipping_company').value =document.getElementById('company2').value ;
		document.getElementById('shipping_address1').value =document.getElementById('address_12').value ;
		document.getElementById('shipping_address2').value =document.getElementById('address_22').value ;
		document.getElementById('shipping_city').value =document.getElementById('city2').value ;
		document.getElementById('shipping_zip').value =document.getElementById('zip2').value ;
		document.getElementById('shipping_state').value =document.getElementById('state2').value ;
		document.getElementById('shipping_country').value =document.getElementById('country2').value ;
		document.getElementById('shipping_phone').value =document.getElementById('phone_12').value ;
		
		
	}
	
	
	
	if (num==4)
	{
		document.getElementById('address4').style.display='block';	
		document.getElementById('address3').style.display='none';	
		document.getElementById('address1').style.display='none';
		document.getElementById('address2').style.display='none';
		var amt_with_shipp = parseFloat(document.getElementById('cart_amount').value) + parseFloat(document.getElementById('amt_shipp4').value) ;
		
		document.getElementById('amt_includ_shipp').value = parseFloat(amt_with_shipp);	
		document.getElementById('shipping_cost').value = parseFloat(document.getElementById('amt_shipp4').value) ;
		
		document.getElementById('user_info_id').value =document.getElementById('user_info_id4').value ;
		document.getElementById('shipping_name').value =document.getElementById('shipping_name4').value ;
		document.getElementById('shipping_company').value =document.getElementById('company4').value ;
		document.getElementById('shipping_address1').value =document.getElementById('address_14').value ;
		document.getElementById('shipping_address2').value =document.getElementById('address_24').value ;
		document.getElementById('shipping_city').value =document.getElementById('city4').value ;
		document.getElementById('shipping_zip').value =document.getElementById('zip4').value ;
		document.getElementById('shipping_state').value =document.getElementById('state4').value ;
		document.getElementById('shipping_country').value =document.getElementById('country4').value ;
		document.getElementById('shipping_phone').value =document.getElementById('phone_14').value ;
		
		document.getElementById('updateshipping1').style.display='none';	
		document.getElementById('updateshipping2').style.display='none';	
		document.getElementById('updateshipping3').style.display='none';
	}

	


}


function contribution()
{

	
	var shakti = document.getElementById("shakti_donation").value;
	var valid = true;
	if(shakti=="") document.getElementById("amt_shakti").value = 0;
	else
	{
		var len = shakti.length;		
		if (len > 10)
		{
			len = 11;
			valid = false;
		}
		else
		{
			for(var i=0 ; i<len ; i++)
			{
				var c = shakti.charAt(i);
				
					if((c <'0' || c>'9' )){valid = false;}			
			}
		}
		
		if(valid == false)
		{
			len =len -1;
			var org = shakti.slice(0,len);
			document.getElementById("shakti_donation").value = org;
		}
		
		if(valid == true)
		{
			document.getElementById("amt_shakti").value = parseFloat(shakti);
		}
	}
	
	document.getElementById("shakti").value = parseFloat(shakti);
	
}








