/****************************************
* Copyright 2006 Ex-designz.net & Myasp-net.com
* JavaScript written by: Dexter Zafra
****************************************/

//--------------------------------------------------------//
// Handle PopUp Window
//function openWinReqPassword(url) 
// {
// popupWin = window.open(url,'new_page','width=430,height=230,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no')
//}
//--------------------------------------------------------//

// Multiple Functions to handle element OnFocus event on Contact form
function UnameContactFocus() 
 {
   document.getElementById('fname').style.backgroundColor = '#FFF9EC'; 
   document.getElementById('lblconuname').style.color = '#000000';
   document.getElementById('lblconuname').innerHTML = 'Your name:'; 
}
function UemailContactFocus() 
 {
   document.getElementById('email').style.backgroundColor = '#FFF9EC'; 
   document.getElementById('lblconemail').style.color = '#000000';
   document.getElementById('lblconemail').innerHTML = 'Email:';
}
function UcommentContactFocus() 
 {
   document.getElementById('comments').style.backgroundColor = '#FFF9EC'; 
   document.getElementById('lblcomment').style.color = '#000000';
   document.getElementById('lblcomment').innerHTML = 'Message:';
}

// Handle Contact Form Validation
function ContactVal(ConForm) 
 {
 var FullName = ConForm.elements['fname'].value;
 var UserEMail = ConForm.elements['email'].value;
 var ConComments = ConForm.elements['comments'].value;
if (FullName == "" && UserEMail == "" && ConComments == "") 
  {
     // Change the background color of the textbox,border as well as label text
     document.getElementById('fname').style.backgroundColor='#FFF4F4'; 
     document.getElementById('fname').style.border = '1px solid #CC0000';
     document.getElementById('lblconuname').style.color = '#CC0000';
     document.getElementById('lblconuname').innerHTML = 'Empty Field:';
     document.getElementById('email').style.backgroundColor='#FFF4F4'; 
     document.getElementById('email').style.border = '1px solid #CC0000';
     document.getElementById('lblconemail').style.color = '#CC0000';
     document.getElementById('lblconemail').innerHTML = 'Empty Field:';
     document.getElementById('comments').style.backgroundColor='#FFF4F4'; 
     document.getElementById('comments').style.border = '1px solid #CC0000';
     document.getElementById('lblcomment').style.color = '#CC0000';
     document.getElementById('lblcomment').innerHTML = 'Empty Field:';
     alert("Please fill in the empty fields.\n- Your name\n- Email\n- Comments");
     return false;
}
// Contact First name
 if (FullName == "")
  {
     alert("Please enter your name");
     document.getElementById('fname').style.backgroundColor='#FFF4F4'; 
     document.getElementById('fname').style.border = '1px solid #CC0000';
     document.getElementById('lblconuname').style.color = '#CC0000';
     document.getElementById('lblconuname').innerHTML = 'Empty Field:';
     return false;
  }
// Allow only letters 
else if (FullName.search(/^[A-Z ]+$/i) == -1) 
  {
     alert ("Wait a minute -- your name has numbers in it?!. Only letters please...");
     document.getElementById('fname').style.backgroundColor='#FFF4F4'; 
     document.getElementById('fname').style.border = '1px solid #CC0000';
     document.getElementById('lblconuname').style.color = '#CC0000';
     document.getElementById('lblconuname').innerHTML = 'Illegal Char:';
     return false;
} 
 // Contact Email
 if (UserEMail == "")
  {
     alert("Please enter an email address so we can reply --");
     document.getElementById('email').style.backgroundColor='#FFF4F4'; 
     document.getElementById('email').style.border = '1px solid #CC0000';
     document.getElementById('lblconemail').style.color = '#CC0000';
     document.getElementById('lblconemail').innerHTML = 'Empty Field:';
     return false;
  }
else if (!(UserEMail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1))
 {
    alert("E-mail address is not in correct format.\n Please enter a valid email address.");
    document.getElementById('email').style.backgroundColor='#FFF4F4'; 
    document.getElementById('email').style.border = '1px solid #CC0000';
    document.getElementById('lblconemail').style.color = '#CC0000';
    document.getElementById('lblconemail').innerHTML = 'Oops!:';
    return false ;
}
 // Contact Comments Field
 if (ConComments == "")
  {
     alert("Please put something in the box ....");
     document.getElementById('comments').style.backgroundColor='#FFF4F4'; 
     document.getElementById('comments').style.border = '1px solid #CC0000';
     document.getElementById('lblcomment').style.color = '#CC0000';
     document.getElementById('lblcomment').innerHTML = 'Nothing to say??:';
     return false;
  }
return true;
}