var order_number=0;
	var ran_unrounded=Math.random()*5;
	var ran_number=Math.floor(ran_unrounded);
	var ran_unrounded1=Math.random()*5;
	var ran_number1=Math.floor(ran_unrounded1);
	var ran_unrounded2=Math.random()*5;
	var ran_number2=Math.floor(ran_unrounded2);
	var ran_unrounded3=Math.random()*5;
	var ran_number3=Math.floor(ran_unrounded3);
	var order_number=ran_number.toString()+ran_number1.toString()+ran_number2.toString()+ran_number3;
	function trim(str) 
	{
        	return str.replace(/^\s+|\s+$/g,"");
	}
	function nameCheck(str)
	{
		var theRegExp = /[^a-z\s]/i; 
		var searchArray = str.match(theRegExp);
		if (searchArray == null) {
		return 1;
		} else {
		return 0;
		}
	} 
        function set()
        {
                if(document.dataform.billing_cust_notes.value == "" || trim(document.dataform.billing_cust_notes.value) =="") 
                {
                alert ("Kindly describe your requirement.");
                document.dataform.billing_cust_notes.focus();
                return false;
                }
                if (document.dataform.billing_cust_notes.value.length>4000) 
                {
                alert("Kindly describe your requirement within the limit of 4000 characters.");
                document.dataform.billing_cust_notes.focus();
                return false;
                }
                if (document.dataform.billing_cust_name.value.length == 0 || trim(document.dataform.billing_cust_name.value) =="")  
                {
                alert ("Kindly enter your name.");
                document.dataform.billing_cust_name.focus();
                return false;
                }
		if (nameCheck(document.dataform.billing_cust_name.value) ==0)  
                {
                alert ("Kindly enter only alphabets for your name.");
                document.dataform.billing_cust_name.focus();
                return false;
                }
                if (document.dataform.billing_cust_email.value.length == 0) 
                {
                        alert("Kindly enter your EmailID.");
                        document.dataform.billing_cust_email.focus();
                        return false;
                }

                if(document.dataform.billing_cust_email.value.indexOf(" ") >= 0)
                {
                        alert("Please enter your email-id without any white space character.");
                        document.dataform.billing_cust_email.focus();
                        return (false);
                }
                if ( (document.dataform.billing_cust_email.value.indexOf("@") == -1) || (document.dataform.billing_cust_email.value.indexOf(".") == -1) )
                {
                        alert("Please enter a valid email-id");
                        document.dataform.billing_cust_email.focus();
                        return (false);
                }
                
                
                BeforeAtRate = document.dataform.billing_cust_email.value.substring(0,document.dataform.billing_cust_email.value.indexOf("@"));
                AfterAtRate = document.dataform.billing_cust_email.value.substring(document.dataform.billing_cust_email.value.indexOf("@")+1,document.dataform.billing_cust_email.value.length);
                
                if (AfterAtRate.indexOf(".") == -1)
                {
                        alert("Please enter a valid email-id");
                        document.dataform.billing_cust_email.focus();
                        return (false);
                }
                
                middle = AfterAtRate.substring(0, AfterAtRate.indexOf("."));
                last = AfterAtRate.substring(AfterAtRate.indexOf(".") + 1,AfterAtRate.length);
                
                if (BeforeAtRate.length == 0 || middle.length == 0 || last.length == 0)
                {
                        alert("Please enter a valid email-id");
                        document.dataform.billing_cust_email.focus();
                        return (false);
                }
                if (document.dataform.S_ccode.value.length == 0)  
                {
                alert ("Kindly enter your country code.");
                document.dataform.S_ccode.focus();
                return false;
                }
                if (isNaN(document.dataform.S_ccode.value))  
                {
                alert ("Kindly enter your country code in numeric only.");
                document.dataform.S_ccode.focus();
                return false;
                }
                if (document.dataform.billing_cust_tel.value.length == 0)  
                {
                alert ("Kindly enter your phone number.");
                document.dataform.billing_cust_tel.focus();
                return false;
                }
		if (isNaN(document.dataform.billing_cust_tel.value))  
                {
                alert ("Kindly enter your phone number in numeric only.");
                document.dataform.billing_cust_tel.focus();
                return false;
                }
		if (document.dataform.billing_cust_address.value.length == 0)  
                {
                alert ("Kindly enter your street address.");
                document.dataform.billing_cust_address.focus();
                return false;
                }
		if (document.dataform.billing_cust_city.value.length == 0)  
                {
                alert ("Kindly enter your city.");
                document.dataform.billing_cust_city.focus();
                return false;
                }
		if (document.dataform.billing_cust_state.value.length == 0)  
                {
                alert ("Kindly enter your state.");
                document.dataform.billing_cust_state.focus();
                return false;
                }
		if (document.dataform.billing_zip_code.value.length == 0)  
                {
                alert ("Kindly enter your pin code.");
                document.dataform.billing_zip_code.focus();
                return false;
                }
		if (document.dataform.billing_zip_code.value.length > 10)  
                {
                alert ("Please ensure that the Zip Code should not exceed 10 characters.");
                document.dataform.billing_zip_code.focus();
                return false;
                }
                if (document.dataform.billing_cust_country.selectedIndex == "")  
                {
                alert ("Kindly select your country name.");
                document.dataform.billing_cust_country.focus();
                return false;
                }
		if (document.dataform.Amount.value.length == 0)  
                {
                alert ("Kindly enter the amount you want to donate.");
                document.dataform.Amount.focus();
                return false;
                }
                if (isNaN(document.dataform.Amount.value))  
                {
                alert ("Kindly enter your amount in numeric only.");
                document.dataform.Amount.focus();
                return false;
                }
		if (document.dataform.captcha_text.value.length == 0)  {
				alert ("Kindly enter the code as appearing in the Image.");
				document.dataform.captcha_text.focus();
				return false;
		}
                newCookie = document.dataform.billing_cust_name.value;
                newCookie +="|"+document.dataform.billing_cust_email.value;
                newCookie +="|"+document.dataform.billing_cust_tel.value;
                newCookie +="|"+document.dataform.S_fax.value;
                newCookie +="|"+document.dataform.S_streetaddress.value;
                newCookie +="|"+document.dataform.S_city.value;
                newCookie +="|"+document.dataform.S_pin.value;
                newCookie +="|"+document.dataform.billing_cust_country.value;
                newCookie +="|"+document.dataform.S_organization.value;
                setCookie("newImeshID",newCookie);
                return true;
        }
        
        function get()
        {
                var captcha_txt = document.getElementsByName("captcha_text");
                var captcha_txt_len = captcha_txt.length;

      if( (cookie = getCookie("newImeshID")) > "")
                {
                        Values = cookie.split("|");
                        if (Values.length >= 7)
                        {
                                if (document.dataform.billing_cust_name.value.length == 0) document.dataform.billing_cust_name.value = Values[0];
                                if (document.dataform.billing_cust_email.value.length == 0)    document.dataform.billing_cust_email.value = Values[1];
                                if (document.dataform.billing_cust_tel.value.length == 0)    document.dataform.billing_cust_tel.value=Values[2];
                                if (document.dataform.S_fax.value.length == 0)      document.dataform.S_fax.value=Values[3];
                                if (document.dataform.S_streetaddress.value.length == 0) document.dataform.S_streetaddress.value=Values[4];
                                if (document.dataform.S_city.value.length == 0)  document.dataform.S_city.value=Values[5];
                                if (document.dataform.S_pin.value.length == 0)   document.dataform.S_pin.value=Values[6];
                                if (document.dataform.billing_cust_country.value.length == 0) document.dataform.billing_cust_country.value=Values[7];
                                if (document.dataform.S_organization.value.length == 0) document.dataform.S_organization.value = Values[8];
                        }
                }
                return true;
        }
        
function setCookie(name, value)
{
	expires = new Date();
	expires.setTime (expires.getTime() + 24 * 60 * 60 * 150 * 1000);

	if (value.length > 0)
	document.cookie = name + "=" + escape(value)+ ";"+"path=/;"+"expires=" + expires.toGMTString()+";"
}
        
function getCookie(Name) 
{
	var search = Name + "="
	if (document.cookie.length > 0)
	{ // if there are any cookies
		offset = document.cookie.indexOf(search)
		if (offset != -1)
		{ // if cookie exists
			offset += search.length
			// set index of beginning of value
			end = document.cookie.indexOf(";", offset)
			// set index of end of cookie value
			if (end == -1) end = document.cookie.length
			return unescape(document.cookie.substring(offset, end))
		}
	}

	return "";
}

if( (cookie = getCookie("newImeshID")) > "")
{
	Values = cookie.split("|");
	if (Values.length >= 7)
	{
		if (Values[0]) document.dataform.billing_cust_name.value  = Values[0];
		if (Values[1]) document.dataform.billing_cust_email.value = Values[1];
		if (Values[2]) document.dataform.billing_cust_tel.value = Values[2];
		if (Values[3]) document.dataform.S_fax.value=Values[3];
		if (Values[4]) document.dataform.S_streetaddress.value=Values[4];
		if (Values[5]) document.dataform.S_city.value=Values[5];
		if (Values[6]) document.dataform.S_pin.value=Values[6];
		if (Values[7]) document.dataform.billing_cust_country.options[Values[7]].selected=true;
        if (Values[8]) document.dataform.S_organization.value = Values[8];
		if (Values[9]) document.dataform.S_ccode.value = Values[9];
		if (Values[10]) document.dataform.S_acode.value = Values[10];
		if (Values[11]) document.dataform.R_name.value = Values[11];
		if (Values[12]) document.dataform.R_email.value = Values[12];
		if (Values[13]) document.dataform.R_ccode.value = Values[13];
		if (Values[14]) document.dataform.R_acode.value = Values[14];
		if (Values[15]) document.dataform.R_phone.value = Values[15];
		if (Values[16]) document.dataform.R_streetaddress.value = Values[16];
		if (Values[17]) document.dataform.R_city.value = Values[17];
		if (Values[18]) document.dataform.R_pin.value = Values[18];
		if (Values[19]) document.dataform.R_country.options[Values[19]].selected=true;
	}
}

