
var email_filter=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var num_filter =/^([0-9])[0-9\-_\.\s]{2,}$/;

function CountLeft(field, count, max) {
 // if the length of the string in the input field is greater than the max value, trim it 
 if (field.value.length > max){
    field.value = field.value.substring(0, max);
    alert('Please enter data, at the maximum of 30 characters.');
 }
 else
 // calculate the remaining characters  
 count.value = max - field.value.length;
}

function validate()
{
    if(document.getElementById("pop_confirm") && (document.getElementById("pop_confirm").style.display == '') || (document.getElementById("pop_confirm").style.display == 'none')){
			alert("Please select a child to sponsor.");
			document.getElementById('div01').style.display = 'block';
		return false;
	}
    if(document.forms.donateform.Title.selectedIndex == 0){
        alert ('Please choose your Title.');
        document.forms.donateform.Title.focus();
        return false;
    }
    if(!(document.forms.donateform.FName.value.length > 1) || (document.forms.donateform.FName.value=="First Name"))
	{
        alert ('Please type your First Name.');
        document.forms.donateform.FName.focus();
        return false;
    }
    if(!(document.forms.donateform.LName.value.length > 1) || (document.forms.donateform.LName.value=="Last Name"))
	{
        alert ('Please type your Last Name.');
        document.forms.donateform.LName.focus();
        return false;
    }
    if (!email_filter.test(document.forms.donateform.Email.value)) 
	{
        alert ('Invalid Email ID. Please Rectify.');
        document.forms.donateform.Email.focus();
        return false;
    }
    if (! (document.forms.donateform.Add1.value.length > 3) || (document.forms.donateform.Add1.value=="Address1")) 
	{
        alert ('Please type your Address.');
        document.forms.donateform.Add1.focus();
        return false;
    }
    if (! (document.forms.donateform.PIN.value.length > 3)) {
        alert ('Please type your Pincode. As per RBI Guidelines while making online payment pincode is must');
        document.forms.donateform.PIN.focus();
        return false;
    }
    if (!(num_filter.test(document.forms.donateform.Mobile.value )&& (document.forms.donateform.Mobile.value.length)>1) || (document.forms.donateform.Mobile.value=="Mobile No"))
	{
        alert ('Please input a valid mobile number.');
        document.forms.donateform.Mobile.focus();
        return false;
    }
    if (!(document.forms.donateform.FC[0].checked || document.forms.donateform.FC[1].checked))
	{
        document.forms.donateform.FC[0].focus();
        alert ('We need your Nationality for FCRA compliance with Govt.of India.');
        return false;
    }
    if (!(document.forms.donateform.PG[0].checked || document.forms.donateform.PG[1].checked || document.forms.donateform.PG[2].checked || document.forms.donateform.PG[3].checked)) 	  {
        document.forms.donateform.PG[1].focus();
        alert ('Please choose your mode of payment.');
        return false;
    }
}

function popwin()
{
	if(window.screenTop>10000)
	{
window.open("./popupwindow.php", "_wv","directories=0, height=250, width=300, scrollbars=no, left=10, top=200");
    }
}

function popsamewindow(url)
{

	var newwindow=window.open(url,'name',"directories=0, height=630, width=800, scrollbars=yes");
	if (window.focus) {newwindow.focus()}

}
function showamt()
{
	//document.getElementById("displayamt").innerHTML='Rs.'+document.getElementById("sponamt").value*<?php echo $default_child_sponsorship_amount; ?>+'/-';
}

function pop_pj(pcode)
{
	window.open("/ecom/prjdetails.php?pcode="+pcode, "_wv","directories=0, height=350, width=450, scrollbars=no, left=150, top=100");
}

