// JavaScript Document
function PopPrint(url){
	openIT('/DCV/English/Templates/Print.aspx?url='+url,550,600,'yes');
	return false;
	}
	
function PopForward(url){
	openIT('/DCV/English/Templates/Forward.aspx?url='+url,550,600);
	return false;
	}
	
function openIT(u,W,H, sc) {
		var x = (screen.width - W) / 2;
		var y = (screen.height - H) / 2;
		//window.moveBy(left, top);
		window.open(u, '',"width="+W+",height="+H+",scrollbars="+(sc ? "yes" : "no")+", left="+250+",top="+200);
}

function ValidateForward(){
	var msg="";
	var msg1="";
	var strvalmail=""
	if (document.Form1.txtSender.value=="")
		msg+="Sender Name\n";
	if (document.Form1.txtSenderMail.value=="")
		msg+="Sender Email\n";
	else{
		strvalmail=IsValidEmail(document.Form1.txtSenderMail);
	    if (strvalmail.length>0)
			msg1+="Invalid Sender Email Address\n";
	    } 
	if (document.Form1.txtReceiver.value=="")
		msg+="Receiver Name\n";
	if (document.Form1.txtReceiverMail.value=="")
		msg+="Receiver Email\n";
	else{
		strvalmail=IsValidEmail(document.Form1.txtReceiverMail);
	    if (strvalmail.length>0)
			msg1+="Invalid Receiver Email Address\n";
	    } 
	if (document.Form1.txtSubject.value=="")
		msg+="Subject\n";
	
	if (msg==""){
		if (msg1=="")
		   return true
        else
		{
			alert(msg1);
			return false;}
	}
	else{  
	   alert("The following fields are required,\n please be sure to fill them and try again:\n\n" + msg )
		return false;
		}	
}

function ValidateJoinNL(txtEmail){
	var msg="";
	if (document.getElementById(txtEmail).value==""){
		alert("- The email address is required");
		return false;
	}
	else{
		var strvalmail=IsValidEmail(document.getElementById(txtEmail));
	    if (strvalmail.length>0){
			alert(strvalmail)
			return false;
		}
		else
			return true;
	}
}

function ValidateJoinForm(){
	var msg="";
	var msg1="";
	if (Trim(document.Form1.txtFirstName.value)=="")
		msg+=" - First Name \n"
	if (Trim(document.Form1.txtLastName.value)=="")
		msg+=" - Last Name \n"
	if (document.Form1.lstCountry.selectedIndex==0)
	    msg+=" - Country \n"
	if (Trim(document.Form1.txtTel.value)=="")
		 msg+=" - Telephone \n"
	if (CheckRadioButtons(document.Form1.rdGender)==false)
		 msg+=" - Gender \n"
	
	if (msg==""){
		if (msg1=="")
		   return true
        else
		{
			alert(msg1);
			return false;}
	}
	else{  
	   alert("Please check the following and submit again:\n" + msg )
		return false;
		}
	}
	
//validate ForgotPassword form
function ValidateForgot()
{
	if (document.Form1.txtEmail.value==""){
		alert("Please enter your email");
		return false;
	}
	else{
		var strvalmail=IsValidEmail(document.Form1.txtEmail);
	    if (strvalmail.length>0){
			alert("Please enter a valid email address");
			return false;
	     }
	     else
			return true;
		}
}


//validate Email
function IsValidEmail(txt){
    var stremail="";
	if(txt.value !=""){ 
		var goodEmail = txt.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
		if (goodEmail){
		    return true;
		} else {
			stremail="- The email address is not valid\n";
			return stremail;
		}
	}
}

function CheckRadioButtons(rbtn){
   var check=false;
   var i=0;
   
   for (i=0;i<rbtn.length;i++){
       if(rbtn[i].checked==true) 
       check=true
   } 
  
   if (check==false)
      return false;
   else
      return true;
}

 //TRIM Functions
function Trim(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
} //End Function

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function