
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");
		   document.getElementById("wrongMail").style.display = "block";
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   // alert("Invalid E-mail ID");
		   document.getElementById("wrongMail").style.display = "block";
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    // alert("Invalid E-mail ID");
		    document.getElementById("wrongMail").style.display = "block";
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    // alert("Invalid E-mail ID");
		    document.getElementById("wrongMail").style.display = "block";
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    // alert("Invalid E-mail ID");
		    document.getElementById("wrongMail").style.display = "block";
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    // alert("Invalid E-mail ID");
		    document.getElementById("wrongMail").style.display = "block";
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    // alert("Invalid E-mail ID");
		    document.getElementById("wrongMail").style.display = "block";
		    return false;
		 }

 		 return true;
	}




function validate_form (currentForm)
{

document.getElementById("firstnameError").style.display = "none";
document.getElementById("lastnameError").style.display = "none";
document.getElementById("noMail").style.display = "none";
document.getElementById("wrongMail").style.display = "none";

if (nameOfForm == 'submit_download_request') {
 document.getElementById("noEula").style.display = "none";
}

	
	valid = true;
	
	var nameOfForm=currentForm;
	// alert(nameOfForm);

        if ( document.forms[nameOfForm].firstname.value == "" )
        {
                
               // alert ( "Your first name is required to process your download request." );
                valid = false;
document.forms[nameOfForm].firstname.focus();
document.getElementById("firstnameError").style.display = "block";
                return valid;
     //           break;
        }
        
                if ( document.forms[nameOfForm].lastname.value == "" )
        {
                // alert ( "Your last name is required to process your download request." );
                valid = false;
                document.forms[nameOfForm].lastname.focus();
                document.getElementById("lastnameError").style.display = "block";
                return valid;
 //               break;
        }

                if ( document.forms[nameOfForm].email.value == "" )
        {
                // alert ( "Your e-mail address is required to process your download request." );
                valid = false;
                document.forms[nameOfForm].email.focus();
                document.getElementById("noMail").style.display = "block";

                return valid;
//                break;
        }
        

        

	var emailID=document.forms[nameOfForm].email;
	
	
		if ((emailID.value==null)||(emailID.value=="")){
		// alert("Please Enter your Email ID");
		document.getElementById("noMail").style.display = "block";
		emailID.focus();
		return false;
	}
	if (echeck(emailID.value)==false){
		emailID.value="";
		emailID.focus();
		return false;
	}
	//return true;
	

        if (!document.forms[nameOfForm].accept_eula[0].checked &&
!document.forms[nameOfForm].accept_eula[1].checked || document.forms[nameOfForm].accept_eula[1].checked) {
	// no radio button is selected
	// alert("You need to accept the end user license agreement")
	document.getElementById("noEula").style.display = "block";
	return false;
}

        
     //   return valid;
}



function showEula()
{
document.getElementsByName("darkBackgroundLayer")[0].style.display = "inline";
document.getElementById("EULA").style.display = "inline";
document.getElementById("rs_eula").style.display = "inline";
return false;

}


function hideEula()
{
document.getElementsByName("darkBackgroundLayer")[0].style.display = "none";
document.getElementById("EULA").style.display = "none";
document.getElementById("rs_eula").style.display = "none";
return false;

}
