/****************************************
* 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 Login form
function UnameFocus() 
 {
   document.getElementById('username').style.backgroundColor = '#FFF9EC'; //Make the textbox color lightyellow
   document.getElementById('lbluname').style.color = '#000000'; //Make the label text color black
   document.getElementById('lbluname').innerHTML = 'Username:'; //On error raised textbox focus, assign label default text 
}
function PassWordFocus() 
 {
   document.getElementById('password').style.backgroundColor = '#FFF9EC'; 
   document.getElementById('lblpass').style.color = '#000000';
   document.getElementById('lblpass').innerHTML = 'Password:';
}
// Handle Login Form Validation
function LoginValidate(LogForm) 
 {
   var LoginPass = LogForm.elements['password'].value;
   var LoginName = LogForm.elements['username'].value;
if (LoginName == "" && LoginPass == "") 
  {
     // Change the background color of the textbox,border as well as label text
     document.getElementById('username').style.backgroundColor='#FFF4F4'; 
     document.getElementById('username').style.border = '1px solid #CC0000';
     document.getElementById('lbluname').style.color = '#CC0000';
     document.getElementById('lbluname').innerHTML = 'Empty Field:';
     document.getElementById('password').style.backgroundColor='#FFF4F4'; 
     document.getElementById('password').style.border = '1px solid #CC0000';
     document.getElementById('lblpass').style.color = '#CC0000';
     document.getElementById('lblpass').innerHTML = 'Empty Field:';
     alert("Vyplňte prosím prázdné položky.\n- Username\n- Password");
     return false;
}
// Check Username login
 if (LoginName == "") // if is empty/blank alert
  {
     alert("Please enter your username");
     document.getElementById('username').style.backgroundColor='#FFF4F4'; //Change the background color of the textbox
     document.getElementById('username').style.border = '1px solid #CC0000';
     document.getElementById('lbluname').style.color = '#CC0000';
     document.getElementById('lbluname').innerHTML = 'Empty Field:';
     return false;
  }
// Login Password
 if (LoginPass == "")
  {
     alert("Please enter your password");   
     document.getElementById('password').style.backgroundColor='#FFF4F4'; 
     document.getElementById('password').style.border = '1px solid #CC0000';
     document.getElementById('lblpass').style.color = '#CC0000';
     document.getElementById('lblpass').innerHTML = 'Empty Field:';
     return false;
  }
return true;
}

// Handle Request Password Form Validation
function ReqPassVal(ReqPass) 
 {
 // Email
var UserReqEMail = ReqPass.elements['email'].value;
 if (UserReqEMail == "")
  {
     alert("You must enter an email address");
     ReqPass.elements['email'].style.backgroundColor='#FFF9EC';
     return false;
  }
else if (!(UserReqEMail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1))
 {
    alert("E-mail address is not valid.\n Please enter a valid email address.");
    ReqPass.elements['email'].style.backgroundColor='#FFF9EC';
    return false ;
}
return true;
}

//--------------------------------------------------------//
// 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 = 'Vaše jméno:'; 
}
function UemailContactFocus() 
 {
   document.getElementById('email').style.backgroundColor = '#FFF9EC'; 
   document.getElementById('lblconemail').style.color = '#000000';
   document.getElementById('lblconemail').innerHTML = 'Email:';
}
function UtelephoneContactFocus() 
 {
   document.getElementById('telephone').style.backgroundColor = '#FFF9EC'; 
   document.getElementById('lblcontelephone').style.color = '#000000';
   document.getElementById('lblcontelephone').innerHTML = 'Telefon:';
}
function UcommentContactFocus() 
 {
   document.getElementById('comments').style.backgroundColor = '#FFF9EC'; 
   document.getElementById('lblcomment').style.color = '#000000';
   document.getElementById('lblcomment').innerHTML = 'Zpráva:';
}
// Handle Contact Form Validation
function ContactVal(ConForm) 
 {
 var FirstName = ConForm.elements['fname'].value;
 var UserEMail = ConForm.elements['email'].value;
 var ConTelephone = ConForm.elements['telephone'].value;
 var ConComments = ConForm.elements['comments'].value;
if (FirstName == "" && UserEMail == "" && ConComments =="" && ConTelephone =="" ) 
  {
     // 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 = 'Prázdná položka:';
     document.getElementById('email').style.backgroundColor='#FFF4F4'; 
     document.getElementById('email').style.border = '1px solid #CC0000';
     document.getElementById('lblconemail').style.color = '#CC0000';
     document.getElementById('lblconemail').innerHTML = 'Prázdná položka:'; 
     document.getElementById('telephone').style.backgroundColor='#FFF4F4'; 
     document.getElementById('telephone').style.border = '1px solid #CC0000';
     document.getElementById('lblcontelephone').style.color = '#CC0000';
     document.getElementById('lblcontelephone').innerHTML = 'Prázdná položka:'; 
     document.getElementById('comments').style.backgroundColor='#FFF4F4'; 
     document.getElementById('comments').style.border = '1px solid #CC0000';
     document.getElementById('lblcomment').style.color = '#CC0000';
     document.getElementById('lblcomment').innerHTML = 'Prázdná položka:';
     alert("Vyplňte prosím prázdné položky.\n- Vaše jméno\n- Email\n- Telefon\n- Zpráva");
     return false;
}
// Contact First name
 if (FirstName == "")
  {
     alert("Musíte vyplnit Vaše jméno.");
     document.getElementById('fname').style.backgroundColor='#FFF4F4'; 
     document.getElementById('fname').style.border = '1px solid #CC0000';
     document.getElementById('lblconuname').style.color = '#CC0000';
     document.getElementById('lblconuname').innerHTML = 'Prázdná položka:';
     return false;
  }
// Allow only letters 
else if (FirstName.search(/^[A-Ž ]+$/i) == -1) 
  {
     alert ("Vaše jméno obsahuje číslice. Povolená jsou pouze písmena..\n Prosím zadejte Vaše jméno korektně.");
     document.getElementById('fname').style.backgroundColor='#FFF4F4'; 
     document.getElementById('fname').style.border = '1px solid #CC0000';
     document.getElementById('lblconuname').style.color = '#CC0000';
     document.getElementById('lblconuname').innerHTML = 'Chybné jméno:';
     return false;
} 
 // Contact Email
 if (UserEMail == "")
  {
     alert("Musíte zadat Vaši emailovou adresu.");
     document.getElementById('email').style.backgroundColor='#FFF4F4'; 
     document.getElementById('email').style.border = '1px solid #CC0000';
     document.getElementById('lblconemail').style.color = '#CC0000';
     document.getElementById('lblconemail').innerHTML = 'Prázdná položka:';
     return false;
  }
else if (!(UserEMail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1))
 {
    alert("E-mailová adresa není správně.\n Prosím zadejte Váš Email korektně.");
    document.getElementById('email').style.backgroundColor='#FFF4F4'; 
    document.getElementById('email').style.border = '1px solid #CC0000';
    document.getElementById('lblconemail').style.color = '#CC0000';
    document.getElementById('lblconemail').innerHTML = 'Chybný Email:';
    return false ;
}


 // Contact Telefon
 if (ConTelephone == "")
  {
     alert("Musíte zadat Vaše telefonní číslo.");
     document.getElementById('telephone').style.backgroundColor='#FFF4F4'; 
     document.getElementById('telephone').style.border = '1px solid #CC0000';
     document.getElementById('lblcontelephone').style.color = '#CC0000';
     document.getElementById('lblcontelephone').innerHTML = 'Prázdná položka:';
     return false;
  }
else if (!(ConTelephone.search(/^(\+420)? ?\d{3} ?\d{3} ?\d{3}$/) != -1))
 {
    alert("Telefonní číslo není správně.\n Prosím zadejte Váše telefonní číslo korektně.");
    document.getElementById('telephone').style.backgroundColor='#FFF4F4'; 
    document.getElementById('telephone').style.border = '1px solid #CC0000';
    document.getElementById('lblcontelephone').style.color = '#CC0000';
    document.getElementById('lblcontelephone').innerHTML = 'Chybný telefon:';
    return false;
}


 // Contact Comments Field
 if (ConComments == "")
  {
     alert("Musíte vyplnit text zprávy.");
     document.getElementById('comments').style.backgroundColor='#FFF4F4'; 
     document.getElementById('comments').style.border = '1px solid #CC0000';
     document.getElementById('lblcomment').style.color = '#CC0000';
     document.getElementById('lblcomment').innerHTML = 'Prázdná položka:';
     return false;
  }
 alert("Vaše zpráva byla úspěšně odeslána"); 
return true;
}




























//--------------------------------------------------------//
// Handle Article Submission Form Validation
function ArticleSubmissionVal(ArtForm) 
 {
// Article Title
 var ATitle = ArtForm.elements['arttitle'].value;
 if (ATitle == "")
  {
     alert("You must enter an article title");
     ArtForm.elements['arttitle'].style.backgroundColor='#FFF9EC';
     return false;
}
 // Main Content
var AContent = ArtForm.elements['maincontent'].value;
 if (AContent == "")
  {
     alert("You must enter a main content");
     ArtForm.elements['maincontent'].style.backgroundColor='#FFF9EC';
     return false;
}
 // Summary
var ASummary = ArtForm.elements['summary'].value;
 if (ASummary == "")
  {
     alert("You must enter a summary");
     ArtForm.elements['summary'].style.backgroundColor='#FFF9EC';
     return false;
}
 // Email
var ArtEMail = ArtForm.elements['email'].value;
 if (ArtEMail == "")
  {
     alert("You must enter an email address");
     ArtForm.elements['email'].style.backgroundColor='#FFF9EC';
     return false;
  }
else if (!(ArtEMail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1))
 {
    alert("E-mail address is not valid.\n Please enter a valid email address.");
    ArtForm.elements['email'].style.backgroundColor='#FFF9EC';
    return false ;
}
 // Author
var Aauthor = ArtForm.elements['author'].value;
 if (Aauthor == "")
  {
     alert("You must enter an author/publisher name");
     ArtForm.elements['author'].style.backgroundColor='#FFF9EC';
     return false;
}
return true;
}
