﻿
 $(document).ready(function(){

$('#txtPwsLC').bind('paste', function(e)   {
     e.preventDefault();
     alert("You cannot paste text into this textbox!");
});

});


(function ($) {

$.fn.hint = function (blurClass) {
  if (!blurClass) { 
    blurClass = 'blur';
  }
    
  return this.each(function () {
    // get jQuery version of 'this'
    var $input = $(this),
    
    // capture the rest of the variable to allow for reuse
      title = $input.attr('title'),
      $form = $(this.form),
      $win = $(window);

    function remove() {
      if ($input.val() === title && $input.hasClass(blurClass)) {
        $input.val('').removeClass(blurClass);
      }
    }

    // only apply logic if the element has the attribute
    if (title) { 
      // on blur, set value to title attr if text is blank
      $input.blur(function () {
        if (this.value === '') {
          $input.val(title).addClass(blurClass);
        }
      }).focus(remove).blur(); // now change all inputs to title
      
      // clear the pre-defined text when form is submitted
      $form.submit(remove);
      $win.unload(remove); // handles Firefox's autocomplete
    }
  });
};

})(jQuery);


$(function(){
 // find all the input elements with title attributes
 $('input[title!=""]').hint();
 }); 
 
     // function to create XMLHTTP Object
        function loadXmlHttp()
        {
             var xr;
              try
              {    // Firefox, Opera 8.0+, Safari    
                    xr=new XMLHttpRequest();    
              }
              catch (e)
              {    // Internet Explorer    
                    try
                    {      
                        xr=new ActiveXObject("Msxml2.XMLHTTP");      
                    }
                    catch (e)
                    {  
                        try
                        {        
                            xr=new ActiveXObject("Microsoft.XMLHTTP");        
                        }
                        catch (e)
                        {        
                            alert("Your browser does not support AJAX!");        
                            return false;        
                        }      
                    }    
               }
        return xr;
        }
        
        
  //Function To Validate UserName/Email Or Password   
 //Page Globle Variable
 var txtLCUName;
 var txtLCPwd;
 var pLCFlage;
 var xmlHttpLC;
 var LCresponse=false;
 function ValidateLoginControlPage()
 
 {
    $("#msgbox").removeClass().addClass('messagebox').text('Validating....').fadeIn(1000);
      var isValidUser=false;
     txtLCUName=document.getElementById("txtuserIdLC").value
     txtLCPwd=document.getElementById("txtPwsLC").value
     if (txtLCUName=="")
     {
      $("#msgbox").removeClass().addClass('messageboxerror').text('* This field is required').fadeTo(900,1);
      $('#msgbox').fadeOut('slow', function() {/* Animation complete. */});
      $('#txtuserIdLC').val('');
      $('#txtuserIdLC').focus();
    
         
         return false;
     }
     else if (txtLCPwd=="")
     {
         $("#msgbox").removeClass().addClass('messageboxerror').text('* This field is required').fadeTo(900,1);
          $('#msgbox').fadeOut('slow', function() {/* Animation complete. */});
          $('#txtPwsLC').val('');
          $('#txtPwsLC').focus();
        
         return false;
     }
    else
    {
   
        xmlHttp=loadXmlHttp();
        xmlHttp.onreadystatechange=function ()
        {
            
            if(xmlHttp.readyState==4)
            {
                if(xmlHttp.status == 200)
                {
                     
                    if(xmlHttp.responseText=="No")
                    {
                    $("#msgbox").removeClass().addClass('messageboxerror').text('* Wrong User Id & Password. Please re-enter').fadeTo(900,1);
                     $('#msgbox').fadeOut(2000, function() {/* Animation complete. */});
                     $('#txtPwsLC').val('');
                     $('#txtuserIdLC').val('');
                     $('#txtuserIdLC').focus();
                   
                    LCresponse=false;
                    }
                    if(xmlHttp.responseText=="Yes")
                    
                    {
                     
                     $("#msgbox").removeClass().addClass('messageboxok').text('Logging in.....').fadeIn(1000);
                     window.open("dUserProfile.aspx","_parent")  
                     LCresponse=true;
                    }
                    
                }
             }
        }  
        xmlHttp.open("GET","MoveProfiles.aspx?ActionFor=CheckExitingUser" +"&UserName=" + txtLCUName +"&Pws=" + txtLCPwd,true);
        xmlHttp.send(null);  
    }
    
 return LCresponse;
 }



//      Function To Ckeck ProrileId and Open Profile Page Veriable  
  var OtherIdResponse=false;
   function OtherProfileByLoginControl()
      {
$("#msgboxotherprofile").removeClass().addClass('messagebox').text('Validating....').fadeIn(1000);
    var mReqProfileID=document.getElementById("OtherProfileIdtxt").value;
 
      if(mReqProfileID == "")
      {
      $("#msgboxotherprofile").removeClass().addClass('messageboxerror').text('* This field is required').fadeTo(900,1);
      $('#msgboxotherprofile').fadeOut(2000, function() {/* Animation complete. */});
      $('#OtherProfileIdtxt').val('');
      $('#OtherProfileIdtxt').focus();
   
      return false;
      
      }
      else
    {

    
    var xmlHttp=loadXmlHttp();
    xmlHttp.onreadystatechange=function()
      {
    
      if(xmlHttp.readyState==4)
        {
        if(xmlHttp.status == 200)
          {
        
           if(xmlHttp.responseText=="No")
            {
            $("#msgboxotherprofile").removeClass().addClass('messageboxerror').text('* Enter Rigth  Profile Id').fadeTo(900,1);
            $('#msgboxotherprofile').fadeOut(2000, function() {/* Animation complete. */});
            $('#OtherProfileIdtxt').val('');
            $('#OtherProfileIdtxt').focus();
            OtherIdResponse=false;
            }
            var responseStr= ""
           responseStr=xmlHttp.responseText.split(";")
           
            if(responseStr[0]=="Yes")
            {
                $("#msgboxotherprofile").removeClass().addClass('messageboxok').text('Loading .....').fadeIn(1000);
               window.open("dOtherProfile.aspx?OtherPId="+responseStr[1] ,"_parent")  
               OtherIdResponse=false;
            }
            
           
          
         }
      }
    }  
     
      xmlHttp.open("GET","MoveProfiles.aspx?ActionFor=Open Other Profile" +"&RequestId=" + mReqProfileID,true);
   xmlHttp.send(null);  
   }
   return OtherIdResponse;
 }
 
 $("#OtherProfileIdtxt").keyup(function(event){
  if(event.keyCode == 13){
    OtherProfileByLoginControl();
  }
});
$("#txtPwsLC").keyup(function(event){
  if(event.keyCode == 13){
     ValidateLoginControlPage();
  }
})





   
