$(document).ready(function() {    
  $(".jobList").datalist({
    preWievSelector : '.jobListDetail'
  });
  $('div.goToPage form').gotopage();
   
  $('#sortBy').change(function(){
    var url = $(this).attr('name') + '/' + $(this).val();
    document.location = url;
  });
   
  if ($('a.saveJob').length > 0) {
    //show successvindow after monitorJobSearch
    var TBid = $.thickbox.attach(null, {
      contentSelector : '#jobsavesuccess',
      closeTime : 3
    });
    $('a.saveJob').click(function(e){
      e.preventDefault();
      var ad = $(this).nextAll('span.id').text();
      $.json('myjob', 'save', {
        ad : ad
      }, function(j, status){
        if (status == 'success')
          $.thickbox.show(TBid);
                                            
      })
    })
  }
    
  var TBidsuccess = $.thickbox.attach(null, {
    contentSelector : '#TBsuccess',
    closeTime : 3,
    beforeShown : function(target, content) {
      var title = $('#monitorJobSearch').nextAll('span.title:first').html();
      var text = $('#monitorJobSearch').nextAll('span.text:first').html();
      if (title)
        $(content).find('div.kgboxThankYou h2').html(title);
      if (text)
        $(content).find('div.kgboxThankYou p').html(text);
    }
  });

    
  if ($('#monitorAnonymous').length > 0) {
    $('a.monitorJobSearch,#monitorJobSearch').thickbox({
      contentSelector : '#monitorAnonymous'
    });
    $('#monitorAnonymous form').jsonform({
      response : function(j, status){
        if (status == 'success')
          $.thickbox.show(TBidsuccess);
      },
      controller : 'myjob',
      action : 'monitoring',
      extraData : {
        current : 1
      }
    });
                   
  } else {
    $('a.monitorJobSearch,#monitorJobSearch').click(function(e){
      e.preventDefault();
      $.json('myjob', 'monitoring', {
        current : 1
      }, function(j, status){
        if (status == 'success')
          $.thickbox.show(TBidsuccess);
      });
                                        
    });
  }
  if ($('#noactivetotalalert').length) {
    $.thickbox.show($.thickbox.attach(null, {
      contentSelector : '#noactivetotalalert'
    }));
  }

  $('h2.showhidebrowseblock').click(function(e){
    var name = $(this).attr('id') + 'visible';
    if (!getCookie(name)) {
      setCookie(name, 1);
      $(this).removeClass('closed').addClass('opened').next().show();
    } else {
      setCookie(name, 0, -1);
      $(this).removeClass('opened').addClass('closed').next().hide();
    }
  })
  $(".box09").biggerlink({
    "hoverclass" : "hover"
  });
                  
});


