// JavaScript Document
function openIT(u,W,H, sc) {
	NewWindow(u, '',"width="+W+",height="+H+",scrollbars="+(sc ? "yes" : "no"));
}

function printImage(img)
{
	openIT('print_img.htm?img='+img,500,590);
}

function popImage(img)
{
	openIT('pop_img.htm?img='+img,500,400);
}

function openWindow(page,w,h){
window.open(page,"_blank","toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,width="+w+",height="+h);
}

function setSize() 
{
var iframeElement = parent.document.getElementById('iframeName'); 
iframeElement.style.height = '100%'; //100px or 100% 
iframeElement.style.width = '100%'; //100px or 100% 
}


function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}


function ResetForm(){
document.form1.reset();
} 



function validateCalendarComments(){
var msg="";
if (document.form1.txtFName.value == "")
  msg +="-First name\n" 
if (document.form1.txtLName.value == "")                                 
  msg +="-Last name\n"                                                                         
if (document.form1.lstCountries.selectedIndex==0)                                 
  msg +="-Country\n"                                                                         
                    
if (document.form1.txtEmail.value == "")
   {                                 
 msg +="-Email address\n"
    }                                             
 else
   {
 if( (document.form1.txtEmail.value.indexOf('@', 0) == -1) || (document.form1.txtEmail.value.indexOf('.') == -1) || (document.form1.txtEmail.value.indexOf(' ') > 0) || (document.form1.txtEmail.value.indexOf('#') > 0)) 
       msg +="-a valid email address\n"                                          
}
if (document.form1.txtTel.value == "")
  msg +="-Tel\n" 

if (document.form1.txtComments.value == "")
  msg +="-Comments\n" 

	            
if (msg!="") {
   msg="Please enter the following information:\n" + msg                                             
   alert(msg);
  return false;                                  
}
} 


function validateCalendarJoin(){
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 (Trim(document.form1.txtEmail.value)==""){
  msg +="-Email address\n"
  }
else{
   var strvalmail=IsValidEmail(document.form1.txtEmail);
   if (strvalmail.length>0){
		 msg1 ="-Invalid email address\n"	
		}                                
}
if (Trim(document.form1.txtConfirmEmail.value)==""){
  msg +="-Confirm Email address\n"
  }
else{
   if (Trim(document.form1.txtConfirmEmail.value) != Trim(document.form1.txtEmail.value)){
		 msg1 ="-Email and Confirm Email do not match\n"	
		}                                
}  
if (document.form1.lstCountries.selectedIndex==0)                                 
  msg +="-Country\n" 
if (document.form1.txtTel.value == "")
  msg +="-Business Phone\n"           
if (msg=="") {
    if (msg1!=""){
		alert(msg1);
		return false;
	}
	else{
	  return true; 
	}
}
else{
   msg="Please enter the following information:\n" + msg                                             
   alert(msg);
  return false;                                  
}
} 

//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 ValidateSendPicture(){
var msg="";
if (document.form1.txtFName.value == "")
  msg +="- First name\n" 
if (document.form1.txtLName.value == "")                                 
  msg +="- Last name\n"                                                                         
                    
if (document.form1.txtEmail.value == "")
   {                                 
 msg +="- Email address\n"
    }                                             
 else
   {
 if( (document.form1.txtEmail.value.indexOf('@', 0) == -1) || (document.form1.txtEmail.value.indexOf('.') == -1) || (document.form1.txtEmail.value.indexOf(' ') > 0) || (document.form1.txtEmail.value.indexOf('#') > 0)) 
       msg +="- A valid email address\n"                                          
}
if (document.form1.txtPicture.value == "")
  msg +="- Picture\n" 

	            
if (msg!="") {
   msg="Please enter the following information:\n" + msg                                             
   alert(msg);
  return false;                                  
}
}


 //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

