  
  var tag = /([\<])([^\>]{1,})*([\>])/i;
  var ck_name = /^[A-Za-z ]+$/;
  var ck_email = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
  var chk_user = /^[A-Za-z0-9_]{1,20}$/;


function Validate(form)
{
  var name = form.name.value;
  var email = form.email.value;
  var comment = form.comment.value;
  var web = form.web.value;
  var security_code = form.security_code.value;

  var errors = [];
   if(name == '' || !ck_name.test(name)){
   errors[errors.length] = "Enter Name and Alphabets are Allowed.";
   }
   if(name.charAt(0) == ' '){
   errors[errors.length] = "Please Check is any blank space before name starts.";
   }
   if(name.length > 25){
   errors[errors.length] = "Do not enter name More than 25 charachter.";
   }
   if(email == '' || !ck_email.test(email)){
   errors[errors.length] = "Enter Valid Email Address.";
   }
   if (comment == '' || comment.length < 25) {
   errors[errors.length] = "Enter Beauty tips more than 25 characters.";
   }
   if(tag.test(web)){
   errors[errors.length] = "Do not Enter any Script Tags in Title.";
   }
   if(web.charAt(0) == ' '){
   errors[errors.length] = "Please Check is any blank space before Title starts.";
   }
   if(tag.test(comment)){
   errors[errors.length] = "Do not Enter any Script Tags in Beauty Tips.";
   }
   if(comment.charAt(0) == ' '){
   errors[errors.length] = "Please Check is any blank space before Beauty Tips.";
   }
   if(security_code == ''){
   errors[errors.length] = "Enter Security Code.";
   }
  
   if (errors.length > 0) {
   reportErrors(errors);
   return false;
  }
  return true;
}

function Validate_home(form)
{
  var name = form.name.value;
  var tips = form.tips.value;
  var security_code = form.security_code.value;

  var errors = [];
   if(name == '' || !ck_name.test(name)){
   errors[errors.length] = "Enter Name and Alphabets are Allowed.";
   }
   if(name.charAt(0) == ' '){
   errors[errors.length] = "Please Check is any blank space before name starts.";
   }
   if(name.length > 25){
   errors[errors.length] = "Do not enter name More than 25 charachter.";
   }
   if (tips == '' || tips.length < 25) {
   errors[errors.length] = "Enter Beauty tips more than 25 characters.";
   }
   if(tag.test(tips)){
   errors[errors.length] = "Do not Enter any Script Tags in Beauty Tips.";
   }
   if(tips.charAt(0) == ' '){
   errors[errors.length] = "Please Check is any blank space before Beauty Tips.";
   } 
   if(security_code == ''){
   errors[errors.length] = "Enter Security Code.";
   }

   if (errors.length > 0) {
   reportErrors(errors);
   return false;
  }
  return true;
}

function reportErrors(errors){
 var msg = "Please Enter Valid Data...\n";
 for (var i = 0; i<errors.length; i++) {
 var numError = i + 1;
  msg += "\n" + numError + ". " + errors[i];
}
 alert(msg);
}

 
function showTips(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","beauty_tips/show_home.php?q="+str,true);
xmlhttp.send();
}


function tweetThis(){
    var url = "tweet_beauty.php";
    window.open(url,"Login_to_twitter", "height=370,width=800");
}
