// JavaScript Document
function countAreaChars(areaName,counter,description)
{
if (areaName.value.length>description)
areaName.value=areaName.value.substring(0,description);
else
counter.value = description - areaName.value.length;
}

function logincheck(){
  var email=document.memberlogin.email;
  var password=document.memberlogin.password;
  
  if(checkEmail(email,'Enter correct E-mail Id')){
  
  return;
  }
  else if(isEmpty(password,'Enter the Password'))
   {
   return;
   }else{
   
   document.memberlogin.submit();
   
   }

}

function registercheck(){
    var title=document.submission.title;
    var url=document.submission.url;  
    var des=document.submission.description;
    var email=document.submission.email;
    var password=document.submission.password;
    var name=document.submission.name;    
    var category=document.submission.pcat;
    
         if(isEmpty(title,'Enter Your Title'))
         {
         return;
         }else if(checkUrl(url,'Enter the correct URL ')){
        
        return;
        }else if(isEmpty(des,'Enter the Description ')){
        
        return;
        
        } 
        else if(isEmpty(category,'Select the Category ')){
        
        return;
        }
        else if(isEmpty(document.getElementById("scat"),"Select the Sub Category"))
        {
          return;
        }
        
        
        else if(isEmpty(name,'Enter the name ')){
        
        return;
        
        }
        else if(checkEmail(email,'Enter the Correct E-mail Id')){
         
         return;
         }
        else if(isEmpty(password,'Enter Password')){
         
         return;
         }
         
       var code=document.getElementById("security_code").value;
       var url="ajax_process.php?do=checkuserexist&un="+code;
  
       $.get(url, function(data){
        if(data==0){
        
          alert("Sorry, you have provided an invalid security code");
          
          document.getElementById("security_code").value="";
          document.getElementById("security_code").focus();
        } 
        else
        {  
            document.submission.submit();
        }  
        });   
}
function submitListingCheck(){
    var title=document.submission.title;
    var url=document.submission.url;  
    var des=document.submission.description;
    var email=document.submission.email;
    var password=document.submission.password;
    var name=document.submission.name;    
    var category=document.submission.pcat;
    
    
         if(isEmpty(title,'Enter Your Title'))
         {
         return;
         }else if(checkUrl(url,'Enter the correct URL ')){
        
        return;
        }else if(isEmpty(des,'Enter the Description ')){
        
        return;
        
        } else if(isEmpty(category,'Select the Category ')){
        
        return;
        }
        var scategory=document.getElementById("scat").value; 
       
        if (scategory==0)
        {
        alert("Select the Sub Category");
        return;
        }
         
       var code=document.getElementById("security_code").value;
       var url="ajax_process.php?do=checkuserexist&un="+code;
  
       $.get(url, function(data){
        if(data==0){
        
          alert("Sorry, you have provided an invalid security code");
          
          document.getElementById("security_code").value="";
          document.getElementById("security_code").focus();
        } 
        else
        {  
            document.submission.submit();
        }  
        });   
}

function commentcheck()
{
 var name=document.comment.name;
 var email=document.comment.email;
 var url=document.comment.url;
 var com=document.comment.comments;
 
 if(isEmpty(name,"Please Enter Your Name "))
 {
  return;
 }else if(checkEmail(email,"Please Enter Valid Email Id ")){
  return;
 }else if(checkUrl(url,"Please Enter Valid URL ")){
  return;
 }else if(isEmpty(com,"Please Enter Your Valuable Comments ")){
  return;
 }
       var code=document.getElementById("security_code").value;
       var url="ajax_process.php?do=checkuserexist&un="+code;
  
       $.get(url, function(data){
        if(data==0){
        
          alert("Sorry, you have provided an invalid security code");
          
          document.getElementById("security_code").value="";
          document.getElementById("security_code").focus();
          
        } 
        else
        {
           
            document.comment.submit();
        }  
        }); 
}

function contactcheck()
{
 var name=document.contactus.name;
 var email=document.contactus.email;
 var feedback=document.contactus.feedback;
 
 if(isEmpty(name,"Please Enter Your Name "))
 {
  return;
 }else if(checkEmail(email,"Please Enter Valid Email Id ")){
  return;
 }else if(isEmpty(feedback,"Please Enter Your Valuable feedback ")){
  return;
 } 
       var code=document.getElementById("security_code").value;
       var url="ajax_process.php?do=checkuserexist&un="+code;
  
       $.get(url, function(data){
        if(data==0){
        
          alert("Sorry, you have provided an invalid security code");
          
          document.getElementById("security_code").value="";
          document.getElementById("security_code").focus();
          
        } 
        else
        {
           
            document.contactus.submit();
        }  
        }); 
}
