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 getFlashVersion(){try { try { var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');     
        try { axo.AllowScriptAccess = 'always'; } catch(e) { return '6,0,0'; }
          } catch(e) {} return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
        } catch(e) { try { if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){ 
            return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
          }
        } catch(e) {}} return '0,0,0';
      }        
      
function ZCinit() {               
            $('div.ccode').mouseover( function() {  clip = new ZeroClipboard.Client();  clip.setHandCursor( true ); 
                clip.setText( this.innerHTML ); clText = this.innerHTML; clID = this.id; //$('#clr'+clID).show();           //  clip.setText('woot!');   alert(clip.text);
                if (clip.div) { clip.receiveEvent('mouseout', null); clip.reposition(this); } else  clip.glue(this.id,'m'+this.id);
                clip.addEventListener( 'mouseover', function(client) { $('#clr'+clID).show(); } );
                clip.addEventListener( 'mouseout', function(client) { $('#clr'+clID).hide(); } );                
                clip.addEventListener( 'complete', function(client, text) { if (navigator.userAgent.indexOf("MSIE 9") > -1){ window.clipboardData.setData("Text", clText); } 
                  $('#clr'+clID).text(text + ' - copied to the clipboard!').fadeIn("slow").fadeOut(2000);  stGo(clID); 
                } );
                clip.receiveEvent('mouseover', null);
            } );          
        }      
       
