﻿/****************************************************************************************
Product         : PowerVolt Website Phase I.
Copyright	    : Edify Technologies Inc.
Source	        : AjaxImageVerification.js
Created Date	: 03/17/2009
Created By	    : Rajesh Daniel
Modified Date   : 08/28/2009
Modified By     : John Jeya Aneston
Version	        : 1.0.7
Description	    : Ajax script to validate username and password

CR / Issue No      Modified By       Modified On       Version         Reason
****************************************************************************************/

var ImageVerificationClientID;

// Sets the prefix tabSubjectClientID for each page
function SetImageVerificationClientID(ID)
{
  if(ID.lastIndexOf("_") > 0)  
    ImageVerificationClientID = ID.substring(0,ID.lastIndexOf("_") + 1);     
}


function ImageVerification(obj)
{
   //Added by saravanan Bug Id:1185; 
   document.getElementById('img').style.display = "block";
   var ctrl = document.getElementById(obj);
      
   if ($get(ImageVerificationClientID + "errorImgaeVerification").innerHTML != "")
    {
        $get(ImageVerificationClientID + "errorImgaeVerification").innerHTML = ""
    }
    if(ctrl.value.trim() != "")     //to check whether Textbox field is empty or not
     {
   // alert("yes");
         PageMethods.ImageVerification(ctrl.value, OnImageVerificationSucceed, OnImageVerificationDontSucceed);
     }
     //Added by saravanan Bug Id:1185;
     document.getElementById('img').style.display = "none";
}

 function OnImageVerificationSucceed() 
 {
   // Dispaly "already exist"
   //alert("DontExist");
    $get(ImageVerificationClientID + "errorImgaeVerification").innerHTML = "";
    document.getElementById(ImageVerificationClientID + 'btnSubmit').disabled = false;
    //Added by saravanan Bug Id:1185;
    document.getElementById(ImageVerificationClientID + 'btnSubmit').focus();
   
 }

function OnImageVerificationDontSucceed(error) 
{
   //alert("Exist");
   $get(ImageVerificationClientID + "errorImgaeVerification").innerHTML = "<table border='0' width='670px' cellspacing='0' cellpadding='0' class='validation'><tr><td style='color:red;font-size:10px;font-family: verdana, arial; '>" + InvalidImgVerify + "</td></tr></table>"; 
    document.getElementById(ImageVerificationClientID + 'btnSubmit').disabled = true;
}

