(function() {
  $('input[placeholder], textarea[placeholder]').placeholder(
    {
      phClass: 'placeholder'
    }
  );

  $k.util.preloadImages('/common/ui3/image/loader_1.gif');
  $('.J_SideBtn').mouseenter(function(){
    $(this).animate({left: 0}, 100);
  }).mouseleave(function(){
    $(this).animate({left: 10}, 100);
  });

  var tool = $('#J_SideTool');
  var noGoTop = true;
  $(window).scroll(function(){
    var l = $(window).scrollTop();
    if (l > 200) {
      if(noGoTop){
        noGoTop = false;
        tool.animate({bottom: 10}, 300);
      }
    }
    if (l <= 200) {
      if(!noGoTop){
        noGoTop = true;
        tool.animate({bottom: -50}, 300);
      }
    }
  });
  $('.J_GoTop').click(function(){
    $('html, body').animate({scrollTop: 0}, 300);
  });
  $('.J_Feedback').overlay({
    mask:{
      color: '#000',
      loadSpeed: 200,
      opacity: 0.5
    }
  });
  var dlgNotice = function(elem, html) {
    elem.fadeOut(100).delay(100).html(html).fadeIn(100);
  }
  $('.J_FbForm').submit(function(){
    var fb = $(this);
    var content = $.trim(fb.find('[name=content]').val());
    var title = $.trim(fb.find('[name=title]').val());
    if (content == '') {
      dlgNotice(fb.parents('.dlg').find('.J_DlgNotice'),
          '<b class="c-red">内容部分必须填写！</b>');
      return false;
    }
    if (title == '') {
      title = '无标题';
    }
    $.post(
      '/index/?a=feedback',
      {
        content: content,
        title: title,
        url: location.href
      },
      function(ret) {
        if (ret.status === 0) {
          $k.util.alert('提交成功，谢谢您宝贵的意见！');
        }
        else {
          mStatus(ret.status);
        }
      },
      'json'
    );
    return false;
  });
}());

