$(document).ready(function(){
  //MAINGRID ACTIVE TABLE ROW
  $(".maingrid input[type='checkbox']").click(function(){
    if ($(this).parents("tr:eq(0)").hasClass("active")) {$(this).parents("tr:eq(0)").removeClass("active");}
    else {$(this).parents("tr:eq(0)").addClass("active");}
  });
  
  
  //INPUT FOCUS 
  $(".inputFocus span").css('display' , 'block');
  function checknextInput(t, event) {
    nextParent = t.parents("div:eq(0)").next("div");
    nextInput = nextParent.find("input");
    nextSpan = nextParent.find("span");
  
    if (  nextInput.attr("type") == "password" && 
          nextInput.val() == "" && 
          t.find("input").val() == "" && 
          event == "focus") { 
            nextSpan.hide(); 
          }
    if (  nextInput.attr("type") == "password" && 
          nextInput.val() == "" && 
          event == "blur") { 
            nextSpan.show();
          }
  }
  function thisspanHide(t) { t.next("span").hide(); }
  
  
  $(".inputFocus").click(function(){
    $(this).find("span").hide().prev("input").focus();
    $(this).find("textarea").focus();
    checknextInput($(this), "focus");    
    
    return false;    
  });
  $(".inputFocus input").focus(function(){ thisspanHide($(this)); });  
  $(".inputFocus input, .inputFocus textarea").blur(function(){
    checknextInput($(this), "blur");
    
    if ($(this).val() == "") {
      $(this).next("span").show();
    }
  });
  $(window).load(function(){
    $(".inputFocus input, .inputFocus textarea").each(function(){ 
      if ($(this).val() != "" ) { thisspanHide($(this)); }
    });  
    
  })
});
