 function FillBillDetails(chk){
	 
	 		var SAMESD=document.getElementById('SAMESD').checked;
			var billing=document.getElementById('billing');	
			if(SAMESD==false)	
			{
			document.getElementById('billing').style.display = 'block';
			}else
			{
			//document.getElementById('billing').style.display = 'none';
			}
	 
            if (chk.checked == 1){
				
				document.form1.billfirstname.value=document.form1.firstname.value;
				document.form1.billlastname.value=document.form1.lastname.value;	
				document.form1.billaddress.value=document.form1.address.value;				
                document.getElementById("billcountry").value=document.getElementById("country").value;
				document.form1.billstate.value=document.form1.state.value;
				document.form1.billcity.value=document.form1.city.value;
				document.form1.billzipcode.value=document.form1.zipcode.value;
				//document.form1.billmobile.value=document.form1.mobile.value;
				document.form1.billphone.value=document.form1.phone.value;
            }
            else{
				document.form1.billfirstname.value='';
				document.form1.billlastname.value='';
				document.form1.billaddress.value='';				
				document.getElementById("billcountry").value=''; 				
				document.form1.billstate.value='';
				document.form1.billcity.value='';
				document.form1.billzipcode.value='';
				document.form1.billphone.value='';	
				//document.form1.billmobile.value='';
				}
        }


function emailCheck (emailStr) 
{

	var checkTLD=1;

	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

	var emailPat=/^(.+)@(.+)$/;
	
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	
	var validChars="\[^\\s" + specialChars + "\]";

	var quotedUser="(\"[^\"]*\")";

	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

	var atom=validChars + '+';

	var word="(" + atom + "|" + quotedUser + ")";

	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

	var matchArray=emailStr.match(emailPat);

	if (matchArray==null) 
	{
		alert("Email address seems incorrect.");
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];

	for (i=0; i<user.length; i++) 
	{
		if (user.charCodeAt(i)>127) 
		{
			alert("Ths username contains invalid characters.");
			return false;
		}
	}
	for (i=0; i<domain.length; i++) 
	{
		if (domain.charCodeAt(i)>127) 
		{
			alert("Ths domain name contains invalid characters.");
			return false;
		}
	}

	if (user.match(userPat)==null) 
	{
		alert("The username doesn't seem to be valid.");
		return false;
	}
	 
/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) 
	{
		for (var i=1;i<=4;i++) 
		{
			if (IPArray[i]>255) 
			{
				alert("Destination IP address is invalid!");
				return false;
			}
		}
	}
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) 
	{
		if (domArr[i].search(atomPat)==-1) 
		{
			alert("The domain name does not seem to be valid.");
			return false;
   		}
	}
	
	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1)
	{
		alert("The address must end in a well-known domain or two letter " + "country.");
		return false;
	}
	if (len<2)
	{
		alert("This address is missing a hostname!");
		return false;
	}
	return true;
}


function Validate()
{
var ERROR='1';

var firstpagediv=document.getElementById('firstpagediv');
var nextpagediv=document.getElementById('nextpagediv');

var giftamount=document.form1.giftamount;
var gamount=document.form1.gamount;
var gname=document.form1.gname;
var gaddress=document.form1.gaddress;
var gcity=document.form1.gcity;
var gstate=document.form1.gstate;
var gcountry=document.form1.gcountry;
var gzip=document.form1.gzip;
var gphone=document.form1.gphone;
var gemail=document.form1.gemail;
var gcomments=document.form1.gcomments;
var security_code=document.form1.security_code;
var captchacode=document.form1.captchacode;

	
		for (var i=0; i < document.form1.giftamount.length; i++)
		   {
		   		if (document.form1.giftamount[i].checked)
				  {
				  var selectedvalue = document.form1.giftamount[i].value;				  
				  		  if (selectedvalue == 6)
							{
										if(gamount.value=='')
										{
										ERROR='1';
										alert("Please enter a value for the \"Amount\" field.");
										gamount.focus();	
										gamount.className ='inp1-error';
										return (false);
										}else
										{
											var ramount=isInteger(gamount.value);
											if(ramount==false)
											{
											alert("Please enter a valid value for the \"Amount\" field.");
											gamount.focus();	
											gamount.className ='inp1-error';
											return (false);
											}else
											{
											gamount.className ='inp1'; 
											ERROR='';											
											}
										}							
							}							
						
				  }
		   }		
	
	if (gname.value == "")
	{
	ERROR='1';
	alert("Please enter a value for the \"Full Name\" field.");
	gname.focus();	
	gname.className ='inp1-error';
	return (false);
	}else
	{
	gname.className ='inp1'; 
	ERROR='';
	}
	
	if (gaddress.value == "")
	{
	ERROR='1';
	alert("Please enter a value for the \"Address \" field.");
	gaddress.focus();
	gaddress.className ='inp1-error';
	return (false);
	}else
	{
	gaddress.className ='inp1';
	ERROR='';
	}	
	
	if (gcity.value == "")
	{
	ERROR='1';
	alert("Please enter a value for the \"City\" field.");
	gcity.focus();
	gcity.className ='inp1-error';
	return (false);
	}else
	{
	gcity.className ='inp1';
	ERROR='';
	}
	
	if (gstate.value == "")
	{
	ERROR='1';
	alert("Please Select \"State\" field.");
	gstate.focus();
	gstate.className ='inp1-error';
	return (false);
	}else
	{
	gstate.className ='inp1';  
	ERROR='';
	}
	
	if (gcountry.value == "")
	{
	ERROR='1';
	alert("Please enter a value for the \"Country\" field.");
	gcountry.focus();
	gcountry.className ='inp1-error';
	return (false);
	}else
	{
	gcountry.className ='inp1'; 
	ERROR='';
	}
	
	
	var gzip=alphanumeric(gzip.value);
	
	if (gzip == false)
	{
	ERROR='1';
	alert("Please enter a valid value for the \"Zip Code\" field.");
	gzip.focus();
	gzip.className ='inp1-error';
	return (false);
	}else
	{
	gzip.className ='inp1';
	ERROR='';
	}
	
	
	if (gphone.value == "")
	{
	ERROR='1';
	alert("Please enter a value for the \"Phone / Mobile\" field.");
	gphone.focus();
	gphone.className ='inp1-error';
	return (false);
	}else
	{
	gphone.className ='inp1'; 
	ERROR='';
	}
	
/***********************email validation ***********************/
	/*
	if (gemail.value == "")
	{
	ERROR='1';
	alert("Please enter a value for the \"Email\" field.");
	gemail.focus();
	gemail.className ='inp1-error';
	return (false);
	}else
	{
	gemail.className ='inp1';
	ERROR='';
	}
	*/
	
	if (!emailCheck(gemail.value))
	{
	gemail.focus();
	gemail.className ='inp1-error';
	return false;	 
	}else
	{
	gemail.className ='inp1';  
	}
	
/**********************end of email validation**************/
	
	if (gcomments.value == "")
	{
	ERROR='1';
	alert("Please enter a value for the \"Message\" field.");
	gcomments.focus();
	gcomments.className ='inp1-error';
	return (false);
	}else
	{
	gcomments.className ='inp1';
	ERROR='';
	}
	
/*	if (captchacode.value == "")
	{
	ERROR='1';
	alert("Please enter a value for the \"Word Verification\" field.");
	captchacode.focus();
	captchacode.className ='inp1-error';
	return (false);
	}else
	{
	captchacode.className ='inp1';
	ERROR='';
	}*/
	if (security_code.value != captchacode.value)
	{
	ERROR='1';
	alert("Please enter a valid value for the \"Word Verification\" field.");
	security_code.focus();
	security_code.className ='inp1-error';
	return (false);
	}else
	{
	security_code.className ='inp1';
	ERROR='';
	}	

if(ERROR=='')	
{
	firstpagediv.style.display="none";	
	nextpagediv.style.display="";
	
}

return(true);
}

function Validate_next()
{
var ERROR='1';
var fromname=document.form1.fromname;
var fromaddress=document.form1.fromaddress;
var fromcity=document.form1.fromcity;
var fromstate=document.form1.fromstate;
var fromzipcode=document.form1.fromzipcode;
var fromphone=document.form1.fromphone;
var fromemail=document.form1.fromemail;
//var frompan=document.form1.frompan;
var fromamount=document.form1.fromamount;
var fromremarks=document.form1.fromremarks;
var nextfocus=document.form1.nextfocus;

//nextfocus.focus();

	if (fromname.value == "")
	{
	ERROR='1';
	alert("Please enter a value for the \"Full Name\" field.");
	fromname.focus();
	fromname.className ='inp1-error';
	return (false);
	}else
	{
	fromname.className ='inp1';
	ERROR='';
	}
	
	if (fromaddress.value == "")
	{
	ERROR='1';
	alert("Please enter a value for the \"Address\" field.");
	fromaddress.focus();
	fromaddress.className ='inp1-error';
	return (false);
	}else
	{
	fromaddress.className ='inp1';
	ERROR='';
	}
	
	if (fromcity.value == "")
	{
	ERROR='1';
	alert("Please enter a value for the \"City\" field.");
	fromcity.focus();
	fromcity.className ='inp1-error';
	return (false);
	}else
	{
	fromcity.className ='inp1';
	ERROR='';
	}
	
	if (fromstate.value == "")
	{
	ERROR='1';
	alert("Please enter a value for the \"State\" field.");
	fromstate.focus();
	fromstate.className ='inp1-error';
	return (false);
	}else
	{
	fromstate.className ='inp1';
	ERROR='';
	}
	
	var zipvalidate=alphanumeric(fromzipcode.value);
	
	if (zipvalidate == false)
	{
	ERROR='1';
	alert("Please enter a valid value for the \"Zip Code\" field.");
	fromzipcode.focus();
	fromzipcode.className ='inp1-error';
	return (false);
	}else
	{
	fromzipcode.className ='inp1';  
	}		
	
	if (fromphone.value == "")
	{
	ERROR='1';
	alert("Please enter a value for the \"Phone / Mobile\" field.");
	fromphone.focus();
	fromphone.className ='inp1-error';
	return (false);
	}else
	{
	fromphone.className ='inp1';
	ERROR='';
	}
	
	if (!emailCheck(fromemail.value))
	{
	fromemail.focus();
	fromemail.className ='inp1-error';
	return false;	 
	}else
	{
	fromemail.className ='inp1';  
	}
	
/*	if (frompan.value == "")
	{
	ERROR='1';
	alert("Please enter a value for the \"PAN Number\" field.");
	frompan.focus();
	frompan.className ='inp1-error';
	return (false);
	}else
	{
	frompan.className ='inp1';
	ERROR='';
	}*/
	
/*	if (fromamount.value == "")
	{
	ERROR='1';
	alert("Please enter a value for the \"Amount\" field.");
	fromamount.focus();
	fromamount.className ='inp1-error';
	return (false);
	}else
	{
	fromamount.className ='inp1';
	ERROR='';
	}*/
	
	if (fromremarks.value == "")
	{
	ERROR='1';
	alert("Please enter a value for the \"Remarks / Instructions\" field.");
	fromremarks.focus();
	fromremarks.className ='inp1-error';
	return (false);
	}else
	{
	fromremarks.className ='inp1';
	ERROR='';
	}


return(true);
	
}

function goback()
{
	var firstpagediv=document.getElementById('firstpagediv');
	var nextpagediv=document.getElementById('nextpagediv');

	firstpagediv.style.display="";	
	nextpagediv.style.display="none";
}

function checkbox_autocheck()
{
var fieldname1=document.getElementById('giftamount6');
fieldname1.checked=true;
}

function Validate_donate()
{
var ERROR='1';

var gamount=document.form1.gamount;
var gname=document.form1.gname;
var gaddress=document.form1.gaddress;
var gcity=document.form1.gcity;
var gcity1=document.form1.gcity1;

var gstate=document.form1.gstate;
var gcountry=document.form1.gcountry;
var gzip=document.form1.gzip;
var gphone=document.form1.gphone;
var gphone_ext=document.form1.gphone_ext;
var gemail=document.form1.gemail;
//var gcomments=document.form1.gcomments;
var security_code=document.form1.security_code;
var captchacode=document.form1.captchacode;

var gdiv=country_change();

	var ramount=isInteger(gamount.value);
	if(ramount==false || gamount.value=='')
	{
	alert("Please enter a valid value for the \"Amount\" field.");
	gamount.focus();	
	gamount.className ='inp1-error';
	return (false);
	}else
	{
	gamount.className ='inp1'; 
	ERROR='';
	}

	if (gname.value == "")
	{
	ERROR='1';
	alert("Please enter a value for the \"Full Name\" field.");
	gname.focus();	
	gname.className ='inp1-error';
	return (false);
	}else
	{
	gname.className ='inp1'; 
	ERROR='';
	}
	
	if (gaddress.value == "")
	{
	ERROR='1';
	alert("Please enter a value for the \"Address \" field.");
	gaddress.focus();
	gaddress.className ='inp1-error';
	return (false);
	}else
	{
	gaddress.className ='inp1';
	ERROR='';
	}	
	
	if(gdiv==false)
	{
		if (gcity1.value == "")
		{
		ERROR='1';
		alert("Please enter a value for the \"City\" field.");
		gcity1.focus();
		gcity1.className ='inp1-error';
		return (false);
		}else
		{
		gcity1.className ='inp1';
		ERROR='';
		}
		
		if (gstate.value == "")
		{
		ERROR='1';
		alert("Please Select \"State\" field.");
		gstate.focus();
		gstate.className ='inp1-error';
		return (false);
		}else
		{
		gstate.className ='inp1';  
		ERROR='';
		}
		
		if(gzip.value == "")
		{
		ERROR='1';
		alert("Please enter a value for the \"Zip Code\" field.");
		gzip.focus();
		gzip.className ='inp1-error';
		return (false);
		}else
		{
		gzip.className ='inp1';
		ERROR='';
		}
		
		var gzip=alphanumeric(gzip.value);
		
		if(gzip == false)
		{
		ERROR='1';
		alert("Please enter a valid value for the \"Zip Code\" field.");
		gzip.focus();
		gzip.className ='inp1-error';
		return (false);
		}else
		{
		gzip.className ='inp1';
		ERROR='';
		}
		
	}
	
	if (gcountry.value == "")
	{
	ERROR='1';
	alert("Please enter a value for the \"Country\" field.");
	gcountry.focus();
	gcountry.className ='inp1-error';
	return (false);
	}else
	{
	gcountry.className ='inp1'; 
	ERROR='';
	}
	
	if (gphone.value == "")
	{
	ERROR='1';
	alert("Please enter a value for the \"Phone\" field.");
	gphone.focus();
	gphone.className ='inp1-error';
	return (false);
	}else
	{
	gphone.className ='inp1'; 
	ERROR='';
	}
	
	if (gphone_ext.value == "")
	{
	ERROR='1';
	alert("Please enter a value for the \"Phone Ext.\" field.");
	gphone_ext.focus();
	gphone_ext.className ='inp1-error';
	return (false);
	}else
	{
	gphone_ext.className ='inp1'; 
	ERROR='';
	}
	
	
	if (!emailCheck(gemail.value))
	{
	gemail.focus();
	gemail.className ='inp1-error';
	return false;	 
	}else
	{
	gemail.className ='inp1';  
	}
	
/**********************end of email validation**************/
	
/*	if (gcomments.value == "")
	{
	ERROR='1';
	alert("Please enter a value for the \"Comments\" field.");
	gcomments.focus();
	gcomments.className ='inp1-error';
	return (false);
	}else
	{
	gcomments.className ='inp1';
	ERROR='';
	}*/
	

	if (security_code.value != captchacode.value)
	{
	ERROR='1';
	alert("Please enter a valid value for the \"Word Verification\" field.");
	security_code.focus();
	security_code.className ='inp1-error';
	return (false);
	}else
	{
	security_code.className ='inp1';
	ERROR='';
	}	
return(true);
}
	

function country_change()
{
var gcity=document.form1.gcity;
var gstate=document.form1.gstate;
var gcountry=document.form1.gcountry;

var div_state=document.getElementById('div_state');
var div_city=document.getElementById('div_city');

var dstate=false;

if(gcountry.value=='United States')
{
div_state.style.display='';	
div_city.style.display='none';	
dstate=false;	
}else
{
div_state.style.display='none';	
div_city.style.display='';	
dstate=true;	
}

return dstate;

}


function alphanumeric(alphane)
{
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || hh==32 || hh==45)
		  {
		  }
		else	{
                  //alert("Your Alpha Numeric Test Failed");
			 return false;
		  }
 		}
 //alert("Your Alpha Numeric Test Passed");
 return true;
}


function showcountrylist(){	
	countrylist.style.visibility="visible";
}

function settotals(){
	var country=document.getElementById('countries').value;
	var g_total=document.getElementById('gtotal').value;
	var logistics1_show=document.getElementById("logistics1");
	var ntotal_show=document.getElementById("ntotal");
	//alert(country);
	var s=new String(country)
	var i=s.indexOf("-")
	var v=eval(s.substr(i+1,s.length))
	document.cookie="shipchg="+v
	
	//logistics.innerHTML=s.substr(0,s.indexOf("="))+"&nbsp;"+v
	logistics1_show.innerHTML=s.substr(0,s.indexOf("="))+"&nbsp;"+v
	var gt=eval(g_total)		
	var nt=eval(gt+v)	
	nt=nt.toString()	
	i=nt.indexOf(".")
    if (i!=-1)
	  nt=nt.substr(0,i+3)
	else
	  nt=nt+".00";
	ntotal_show.innerHTML=s.substr(0,s.indexOf("="))+"<b>&nbsp;"+nt+"</b>"
	}

function updatequantity(updatebagform){
	//alert('asf');
	document.updatebagform.action="shopping_bag.php"
	document.updatebagform.submit()
	}
	

function feedback()
{
		if(document.feedbackfrm.name.value=='')
		{
		alert("Please enter your name");
		document.feedbackfrm.name.focus();
		return false;
		}
		
	if (!emailCheck(document.feedbackfrm.email.value))
	{
	 document.feedbackfrm.email.focus();
	 return false;	 
	}
	
	if(document.feedbackfrm.mobile.value=='')
		{
		alert("Please enter your mobile");
		document.feedbackfrm.mobile.focus();
		return false;
		}
		
		if(!CheckSpecialChar(document.feedbackfrm.mobile.value))
		{
		alert("Invalid mobile number, Please enter a valid mobile number.");
		document.feedbackfrm.mobile.focus();
		return false;
		}
				
		if(window.document.feedbackfrm.mobile.value.length>15)
		{
		alert("Invalid mobile number, Please enter a valid mobile number.");
		document.feedbackfrm.mobile.focus();
		return false;
		}
		
		if(document.feedbackfrm.comments.value=='')
		{
		alert("Please enter your comments");
		document.feedbackfrm.comments.focus();
		return false;
		}
		
		return true;
}

function CheckSpecialChar(strInput) 
{
	if (!strInput) return false;

	var specialChars= "~\\`!@#$%^&*()_=[]{}|:;<,>.?/'abcdefghijklmnopqrstuvwxyz\"";

	for (var i = 0; i < strInput.length; i++)
	{ 
		if (specialChars.indexOf(strInput.charAt(i)) > -1)
			return false;
	}
	return true;
}

function isInteger(s)
{
      var i;
	s = s.toString();
      for (i = 0; i < s.length; i++)
      {
         var c = s.charAt(i);
         if (isNaN(c)) 
	   {
		//alert("Given value is not a number");
		return false;
	   }
      }
      return true;
}
	

/*function isInteger(s,fieldname)
{
    var fieldname=document.getElementById(fieldname);
	var i;
	s = s.toString();
      for (i = 0; i < s.length; i++)
      {
         var c = s.charAt(i);
         if (isNaN(c)) 
	   {
		alert("Given value is not a number");
		fieldname.value='';
		fieldname.className ='inp1-error';
		return false;		
	   }
      }
      return true;
}*/

function noNumbers(e)
{
	var keynum;
	var keychar;
	var numcheck;
	
		if(window.event) // IE
		  {
		  keynum = e.keyCode;
		  }
		else if(e.which) // Netscape/Firefox/Opera
		  {
		  keynum = e.which;
		  }
	keychar = String.fromCharCode(keynum);
	numcheck = /\d/;
	return !numcheck.test(keychar);
}

function bookmark_us(url, title){

if (window.sidebar) // firefox
    window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
    var elem = document.createElement('a');
    elem.setAttribute('href',url);
    elem.setAttribute('title',title);
    elem.setAttribute('rel','sidebar');
    elem.click();
}
else if(document.all)// ie
    window.external.AddFavorite(url, title);
}

function loginValidate()
{
var loginmail=document.form1.loginmail;
var password=document.form1.password;

	if (!emailCheck(loginmail.value))
	{
	loginmail.focus();
	loginmail.className ='inp1-error';
	return false;	 
	}else
	{
	loginmail.className ='inp1';  
	}
	
	if(loginmail.value.indexOf('@')==-1)
	{
	alert('@ is absent in Email ID');
	loginmail.focus();
	loginmail.className ='inp1-error';
	return false;	 
	}else
	{
	loginmail.className ='inp1';  
	}
	
	if(loginmail.value.indexOf('.')==-1)
	{
	alert('Dot is absent in Email ID');
	loginmail.focus();
	loginmail.className ='inp1-error';
	return false;	 
	}else
	{
	loginmail.className ='inp1';  
	}
	
	if (password.value == "")
	{
	alert("Please enter a value for the \"Password\" field.");
	password.focus();
	password.className ='inp1-error';
	return false;	 
	}else
	{
	password.className ='inp1';  
	}
}


