// JavaScript Document

function formValidator_question()
{
    // Make quick references to our fields
    var rpfrmfname = document.getElementById('rpfrmfname');
    var remail = document.getElementById('remail');
    var security_code = document.getElementById('security_code');
    var cemail = document.getElementById('cemail');
    //var phone = document.getElementById('phone');    
	//var time = document.getElementById('time');    
    var captcha3 = document.getElementById('captcha3');
    // Check each input in the order that it appears in the form!        
    if(isNotEmpty(rpfrmfname, "Please enter your name."))	
		if(emailValidator(remail, "Email enter valid email id."))        		                  
			if(isNotEmpty(security_code, "Please Enter security letter code."))														
				return true;                    
    return false;
}

function formValidator_FreeBAMLetter()
{    
    // Make quick references to our fields
    var newsfname = document.getElementById('newsfname');
    var newsremail = document.getElementById('newsremail');
    // Check each input in the order that it appears in the form!        
    if(isNotEmpty(newsfname, "Please enter name."))
		if(emailValidator(newsremail, "Email enter your valid email id."))        
				return true;                    
    return false;
}


function formValidator_conatactUs()
{
    // Make quick references to our fields
    var rpfrmfname2 = document.getElementById('rpfrmfname2');    
    var remail2 = document.getElementById('remail2');
    var security_code = document.getElementById('security_code');
    // Check each input in the order that it appears in the form!        
    if(isNotEmpty(rpfrmfname2, "Please enter your name."))        
        if(emailValidator(remail2, "Email enter your valid email id."))
			if(isNotEmpty(security_code, "Please Enter security letter code."))
				return true;                    
    return false;
}

function isAlphabet(elem, helperMsg){
	var alphaExp = /^[a-zA-Z ]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function emailValidator(elem, helperMsg){    
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}
function isNumeric(elem, helperMsg){
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}
function isNotEmpty(elem, helperMsg)
{        
    if (elem.value.trim()=='')
	{
		alert(helperMsg);
		elem.focus();
		return false;
	}
	else
	{
		return true;
	}
}
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };
function radioValidation(radiosbtn, helperMsg)
{    
    var ctr=0;    
    for(var i=0;i<radiosbtn.length;i++)
    {                
        if(radiosbtn[i].checked)
        {
            ctr=1;
        }
    }        
    if(ctr <= 0)
    {
        alert(helperMsg);
        return false;
    }
    else return true;    
}

function CompairValidator(ele1,ele2, helperMsg)
{        
    var ctr=0;    
    if(ele1.value!=ele2.value)            
    {
        alert(helperMsg);
        return false;
    }
    return true;
}
