/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function unsubscribe1() {
	document.email.unsubscribe.value = "unsubscribe";
	document.email.submit();
	return true;
}
 
function addcampmoney()
{

 document.myform.TotalContribution.value = 0;

 var SplitValue;
 var SplitAmt;
 for (var i = 0; i<document.myform.elements.length; i++) {
        if ((document.myform.elements[i].name.indexOf('camp_amt') > -1)) {
			//alert(document.myform.elements[i].value);
            if (document.myform.elements[i].checked) {
				SplitValue = document.myform.elements[i].value.split("~");
				SplitAmt = SplitValue[1];
				document.myform.TotalContribution.value =  parseInt(document.myform.TotalContribution.value) +  parseInt(SplitAmt);
            }
        }
    }
document.myform.amount.value =  document.myform.TotalContribution.value;  
return true;
}


 function addmoney()
{

document.myform.TotalContribution.value = 0;

if (document.myform.AnnualMembership.checked && document.myform.LongTerm.checked)
   {
    alert("Please select either annual or long term box !");
    document.myform.LongTerm.checked = false;
    document.myform.AnnualMembership.checked = false;
    return false;
   }

if (document.myform.AnnualMembership.checked)
  { 
   document.myform.TotalContribution.value = 300;
  }
if (document.myform.LongTerm.checked)
  { 
   document.myform.TotalContribution.value = 3000;
  }
if (document.myform.activities.value != "")
  { 
   document.myform.TotalContribution.value = parseInt(document.myform.TotalContribution.value) +  parseInt(document.myform.activities.value);
  }
if (document.myform.healthcare.value != "")
  { 
   document.myform.TotalContribution.value = parseInt(document.myform.TotalContribution.value) +  parseInt(document.myform.healthcare.value);
  }
if (document.myform.ChinmayaSewaDan.value != "")
  { 
   document.myform.TotalContribution.value = parseInt(document.myform.TotalContribution.value) +  parseInt(document.myform.ChinmayaSewaDan.value);
  }
if (document.myform.ChinmayaBhaktiPravah.value != "")
  { 
   document.myform.TotalContribution.value = parseInt(document.myform.TotalContribution.value) +  parseInt(document.myform.ChinmayaBhaktiPravah.value);
  }
if (document.myform.TapovanPrasad.checked)
  { 
   document.myform.TotalContribution.value = parseInt(document.myform.TotalContribution.value) + parseInt("150");
  }
if (document.myform.Balavihar.checked)
  { 
   document.myform.TotalContribution.value = parseInt(document.myform.TotalContribution.value) + parseInt("180");
  }
if (document.myform.ChinmayaUdgosh.checked)
  { 
   document.myform.TotalContribution.value = parseInt(document.myform.TotalContribution.value) + parseInt("200");
  }
document.myform.amount.value =  document.myform.TotalContribution.value;  
return true;
}

function MsgConfirm() 
{ 
	var fRet; 
	fRet = confirm('Are you sure the email id entered is correct?'); 
	if (fRet !=0) 
	{
		return true
		}
	else
	{
		return false
		}

} 

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	var emailID=document.email.email_id
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	if (MsgConfirm ()==true)
		{
		return true
		}
	else
			{
		return false
		}
 }
function ValidatemembershipForm(){

	if ((document.myform.membername.value==null)||(document.myform.membername.value=="")){
		alert("Please Enter your name");
		document.myform.membername.focus();
		return false;
	}
	if ((document.myform.age.value==null)||(document.myform.age.value=="")){
		alert("Please Enter your age");
		document.myform.age.focus();
		return false;
	}
	if ((document.myform.address1.value==null)||(document.myform.address1.value=="")){
		alert("Please Enter your address");
		document.myform.address1.focus();
		return false;
	}
	if ((document.myform.emailaddress.value==null)||(document.myform.emailaddress.value=="")){
		alert("Please Enter your email address");
		document.myform.emailaddress.focus();
		return false;
	}
	if (echeck(document.myform.emailaddress.value)==false){
		document.myform.emailaddress.value="";
		document.myform.emailaddress.focus();
		return false;
	}
	if (document.myform.mop[0].checked && document.myform.mop[0].value=="CHEQUE/DRAFT")
	 {
	  if ((document.myform.chequedraftno.value==null)||(document.myform.chequedraftno.value=="")){
	   alert("Please Enter cheque/draft no");
	   document.myform.chequedraftno.focus();
	   return false;
	  }
	  if ((document.myform.chequedate.value==null)||(document.myform.chequedate.value=="")){
	   alert("Please Enter cheque/draft date");
	   document.myform.chequedate.focus();
	   return false;
	  }
	  if ((document.myform.bankname.value==null)||(document.myform.bankname.value=="")){
	   alert("Please Enter bank name");
	   document.myform.bankname.focus();
	   return false;
	  }
	 }
document.myform.amount.disabled=false; 
document.myform.TotalContribution.disabled=false; 

return true;
 }


function ValidateCampForm(){
	if ((document.myform.membername.value==null)||(document.myform.membername.value=="")){
		alert("Please Enter your name");
		document.myform.membername.focus();
		return false;
	}
	if ((document.myform.age.value==null)||(document.myform.age.value=="")){
		alert("Please Enter your age");
		document.myform.age.focus();
		return false;
	}
	if ((document.myform.address1.value==null)||(document.myform.address1.value=="")){
		alert("Please Enter your address");
		document.myform.address1.focus();
		return false;
	}
	if ((document.myform.emailaddress.value==null)||(document.myform.emailaddress.value=="")){
		alert("Please Enter your email address");
		document.myform.emailaddress.focus();
		return false;
	}
	if (echeck(document.myform.emailaddress.value)==false){
		document.myform.emailaddress.value="";
		document.myform.emailaddress.focus();
		return false;
	}
	if (document.myform.mop[0].checked && document.myform.mop[0].value=="CHEQUE/DRAFT")
	 {
	  if ((document.myform.chequedraftno.value==null)||(document.myform.chequedraftno.value=="")){
	   alert("Please Enter cheque/draft no");
	   document.myform.chequedraftno.focus();
	   return false;
	  }
	  if ((document.myform.chequedate.value==null)||(document.myform.chequedate.value=="")){
	   alert("Please Enter cheque/draft date");
	   document.myform.chequedate.focus();
	   return false;
	  }
	  if ((document.myform.bankname.value==null)||(document.myform.bankname.value=="")){
	   alert("Please Enter bank name");
	   document.myform.bankname.focus();
	   return false;
	  }
	 }
    if (document.myform.TotalContribution.value=="")
    {
		alert("Please check the donation box");
		return false;
    }

	 
document.myform.amount.disabled=false; 
document.myform.TotalContribution.disabled=false; 

return true;
 }

function disableEnableCheque(str) {
if (str == "D")
	{
	document.myform.bankname.value=""; 
	document.myform.chequedate.value="";
	document.myform.chequedraftno.value="";
	document.myform.bankname.disabled=true; 
	document.myform.chequedate.disabled=true; 
	document.myform.chequedraftno.disabled=true;
	}
else
	{
	document.myform.bankname.disabled=false; 
	document.myform.chequedate.disabled=false; 
	document.myform.chequedraftno.disabled=false; 
	}
return true;
 }


