$(document).ready(function () {
 $('li.has-submenu').live('mouseover', function (event) {
    $(this).addClass('mouse-is-over');
    i = 0;
    par = $(event.originalTarget).parent();
    while (par != null && par.length > 0) {
      if($(par).hasClass('submenu'))
        return;
      if($(this).get(0) == $(par).get(0)) {
        break;
      }
      par = $(par).parent();
      i++;
      if(i > 100) {
        return;
      }
    }
    pos = $(this).position();
    pos.top += $(this).height();
    $(this).oneTime(10, function () {
      submenu_height = $($(this).children()).filter('.submenu-container').outerWidth();
      max_pos = $('.page_menu_top').offset().left + $('.page_menu_top').width()
      if(pos.left + submenu_height > max_pos) {
        pos.left = max_pos - submenu_height;
      }
      if($(this).hasClass('mouse-is-over'))
        $($(this).children()).filter('.submenu-container').css({position: 'absolute'}).css(pos).slideDown('slow');
    })
  });
  $('li.has-submenu').live('mouseout', function (event) {
    $(this).removeClass('mouse-is-over');
    $(this).oneTime(200, function() {
      if(!$(this).hasClass('mouse-is-over')) {
        $($(this).children()).filter('.submenu-container').fadeOut('slow');
      }
    })
  });
  var run_hot_jobs = true;
  $(document).everyTime(4000, 'jobs1', function() {
    if(!run_hot_jobs)
      return ;
    cont = $('.news_feed ul.news_list');
    children = cont.children(); //cont1 children
    //remove first from first colunm
    cl = $(children[0]).clone();
    cont.append(cl);
    $(children[0]).fadeTo('slow', 0, function() {
    	$(this).slideUp('slow', function() {
        $(this).remove();
      });
    });
  });
  
/*  
   $(document).oneTime(2500, function () {
    $(document).everyTime(5000, 'news', function() {
      $('.news_list').each(function () {
        cont=$(this);
        if(cont.hasClass('mouse-is-over'))
          return ;
        o = children = cont.find('>:first-child'); //cont1 children
        //o = children[0];
        cont.css({height: cont.height(), overflow: 'hidden'});
        cont.append($(o).clone(true).fadeOut(0).fadeIn('slow'));
        $(o).stop(true).fadeTo('slow', 0, function() {
          $(this).css({lineHeight: 1, fontSize: 1, height: $(this).height()});
          $(this).animate({height: 1}, 2000, function () {
            $(this).remove();
            $(this).parents('.news_list:eq(0)').css('height', '');
          })
        });
      });
    });
  });
  $('.newsBox .boxContent').mouseover( function() {
    $(this).find('.news_list').addClass('mouse-is-over');
  });
  $('.newsBox .boxContent').mouseout( function() {
    $(this).find('.news_list').removeClass('mouse-is-over');
  });
*/
});

