jQuery.fn.hint = function (blurClass) {if (!blurClass) { blurClass = 'blur';}
  return this.each(function () {
    var $input = jQuery(this), title = $input.attr('title'), $form = jQuery(this.form), $win = jQuery(window);
    function remove() {
      if ($input.val() === title && $input.hasClass(blurClass)) {$input.val('').removeClass(blurClass);}
    }
    if (title) { $input.blur(function () {if (this.value === '') {$input.val(title).addClass(blurClass);}}).focus(remove).blur();
      $form.submit(remove); $win.unload(remove); 
    }
  });
};

 function closeComments(cid){ var cntc = 0;
    var cntc= $.ajax({ type: "GET", url: "index.php?s=aj&do=cmnt&ac=count&cid="+cid, async: false }).responseText;
    $('#comments'+cid).hide(); $('#cmLbl'+cid).html('<a href="#" onclick="getComments(\''+cid+'\'); return false;" class="comments_count">Comments ('+cntc+')</a>&nbsp;&nbsp;');
  }
  function getComments(cid){ 
    $.get("index.php?s=aj&do=cmnt&ac=get&cid="+cid,
    function(data){ //alert(cid);
        $('#comments'+cid).html(data);
        $('#cmLbl'+cid).html('<a href="#" onclick="jQuery.facebox({ajax: \'index.php?postComment='+cid+'\'}); return false;" class="btn"><b>Add new comment</b></a>&nbsp;&nbsp;<a class="comments_count" onclick="closeComments(\''+cid+'\'); return false;" href="#">Hide Comments</a>&nbsp;&nbsp;');
        $('#comments'+cid).show();      
    });
  } 
  
  function postNewComment(cid){ if (!validateCaptcha()) return false;
    $.post("index.php?s=aj&do=cmntAdd&action=get&cid="+cid, { commentUname: $('#commentUname').val(), commentUid: $('#commentUid').val(), comment: $('#comment').val(), recaptcha_challenge_field: $('#recaptcha_challenge_field').val(), recaptcha_response_field: $('#recaptcha_response_field').val() },
    function(data){
        $('#comments'+cid).html(data);
        $('#comments'+cid).show();      
    }); return true;
  }
  function contactUs(){ 
    $.post("index.php?s=aj&do=contactUs&action=get&cid="+cid, { commentUname: $('#commentUname').val(), commentUid: $('#commentUid').val(), comment: $('#comment').val()  },
    function(data){
        $('#comments'+cid).html(data);
        $('#comments'+cid).show();      
    });
  }
  function postNewCoupon(cid){ 
    $.post("index.php?s=aj&do=cpnAdd&action=get&cid="+cid, { commentUname: $('#commentUname').val(), commentUid: $('#commentUid').val(), comment: $('#comment').val()  },
    function(data){
             
    });
  }
  
function voteDeal(cid, userID, vote){ 
    $.post("index.php?s=aj&do=vote&cid="+cid, { cid: cid, userID: userID, vote:vote  },
    function(data){ returned = data.split("||"); var rate; rate =  returned[3]; rate =  rate+'%';
        $('#sukRt'+cid).html(rate);    
        $('#vote_deal'+cid).html('<em class="good_x"><span class="votes_count">'+returned[0]+'</span></em><em class="bad_x"><span class="votes_count">'+returned[1]+'</span></em>');
            
    }); return false;
  }

  function plusDeal(cid, userID, vote){ 
    $.post("index.php?s=aj&do=vote&cid="+cid, { cid: cid, userID: userID, vote:vote  },
    function(data){ returned = data.split("||"); var rate; rate =  returned[3]; rate =  rate+'%';
        $('#sukRt'+cid).html(returned[0]);    
        $('#vote_deal'+cid).html('<em class="good_x"><span class="votes_count">Voted</span></em>');
            
    }); return false;
  }

    function fb(url){
    jQuery.facebox({ajax: url});
  }  

  
function validateCaptcha(){ challengeField = $("input#recaptcha_challenge_field").val(); responseField = $("input#recaptcha_response_field").val();
  var html = $.ajax({ type: "POST", url: "index.php", data: "tst=tst&recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField,
        async: false }).responseText;
  if(html == "OK") { return true; } else {
    $("#captchaStatus").html("The security code you entered did not match. Please try again."); Recaptcha.reload(); return false;
  }
} 

/*
 function closeComments(cid){ var cntc = 0;
    var cntc= $.ajax({ type: "GET", url: "index.php?s=aj&do=cmnt&ac=count&cid="+cid, async: false }).responseText;
    $('#comments'+cid).hide(); $('#cmLbl'+cid).html('<a href="#" onclick="getComments(\''+cid+'\'); return false;">Comments ('+cntc+')</a>&nbsp;&nbsp;');
  }
  function getComments(cid){ 
    $.get("index.php?s=aj&do=cmnt&ac=get&cid="+cid,
    function(data){ //alert(cid);
        $('#comments'+cid).html(data);
        $('#cmLbl'+cid).html('<a href="#" onclick="jQuery.facebox({ajax: \'index.php?postComment='+cid+'\'}); return false;" class="btn"><b>Add new comment</b></a>&nbsp;&nbsp;<a class="comments_count" onclick="closeComments(\''+cid+'\'); return false;" href="#">Hide Comments</a>&nbsp;&nbsp;');
        $('#comments'+cid).show();      
    });
  } 
  
  function postNewComment(cid){ 
    $.post("index.php?s=aj&do=cmntAdd&action=get&cid="+cid, { commentUname: $('#commentUname').val(), commentUid: $('#commentUid').val(), comment: $('#comment').val()  },
    function(data){
        $('#comments'+cid).html(data);
        $('#comments'+cid).show();      
    });
  }
  function contactUs(){ 
    $.post("index.php?s=aj&do=contactUs&action=get&cid="+cid, { commentUname: $('#commentUname').val(), commentUid: $('#commentUid').val(), comment: $('#comment').val()  },
    function(data){
        $('#comments'+cid).html(data);
        $('#comments'+cid).show();      
    });
  }
  function postNewCoupon(cid){ 
    $.post("index.php?s=aj&do=cpnAdd&action=get&cid="+cid, { commentUname: $('#commentUname').val(), commentUid: $('#commentUid').val(), comment: $('#comment').val()  },
    function(data){
             
    });
  }
  function showRecaptcha(element) { Recaptcha.create("{/literal}{$settings.publickey}{literal}", element, {
    theme: "red", callback: Recaptcha.focus_response_field});
  }
  function voteDeal(cid, userID, vote){ 
    $.post("index.php?s=aj&do=vote&cid="+cid, { cid: cid, userID: userID, vote:vote  },
    function(data){ returned = data.split("||"); var rate; rate =  returned[3]; rate =  rate+'%';
        $('#sukRt'+cid).html(rate);    
        $('#vote_deal'+cid).html('<em class="good_x"><span class="votes_count">'+returned[0]+'</span></em><em class="bad_x"><span class="votes_count">'+returned[1]+'</span></em>');
            
    }); return false;
  }
  function fb(url){
    jQuery.facebox({ajax: url});
  }
	
*/	
