var newsPage = null;
var newsLimit = null;

$(document).ready(function () {
  newsPage = $('.topnews_headline').attr('id').replace('topnews_', '');
  newsLimit = $('.topnews_limit').attr('id').replace('topnews_limit_', '');
  $('.topnews_title')
    .live('mouseover', function() { $(this).parent().css('background', '#FFF'); })
    .live('mouseout', function() { $(this).parent().css('background', 'transparent'); })
    .live('click', function() {
      if ($(this).siblings('.topnews_button_up').css('display') == 'none') {
        $(this).siblings('div.topnews_body').css('display', 'block');
        $(this).siblings('.topnews_button_up').css('display', 'block');
        $(this).siblings('.topnews_button_down').css('display', 'none');
      } else {
        $(this).siblings('div.topnews_body').css('display', 'none');
        $(this).siblings('.topnews_button_up').css('display', 'none');
        $(this).siblings('.topnews_button_down').css('display', 'block');
      }
  });
  $('.topnews_button_down').live('click', function() { $(this).siblings('div.topnews_body').css('display', 'block'); $(this).siblings('.topnews_button_up').css('display', 'block'); this.style.display = 'none'; });
  $('.topnews_button_up').live('click', function() { $(this).siblings('div.topnews_body').css('display', 'none'); $(this).siblings('.topnews_button_down').css('display', 'block'); this.style.display = 'none'; });
  $('.topnews_button').live('mouseover', function() { this.style.cursor = 'pointer'; });
  $('.topnews_headline_top_left_single_arrow')
    .live('mouseover', function() { this.style.cursor = 'pointer'; this.style.background = 'url(/images/news_helper/news_helper-arrow_left_single-glow.jpg)'; })
    .live('mouseout', function() { this.style.background = 'url(/images/news_helper/news_helper-arrow_left_single-normal.jpg)'; })
    .live('click', function() {
      id = $('.topnews_headline_number_active').html().replace('.', '');
      $.get("/portal_includes/topnews_helper_ajax.php", { topnews_pageid: id, news_helper_page: "prev", news_helper_limit: newsLimit, topnews_helper: "true" }, function(data) {
        $('#topnews').html(data);
      });
    });
  $('.topnews_headline_top_left_double_arrow')
    .live('mouseover', function() { this.style.cursor = 'pointer'; this.style.background = 'url(/images/news_helper/news_helper-arrow_left_double-glow.jpg)'; })
    .live('mouseout', function() { this.style.background = 'url(/images/news_helper/news_helper-arrow_left_double-normal.jpg)'; })
    .live('click', function() {
      $.get("/portal_includes/topnews_helper_ajax.php", { news_helper_page: "first", news_helper_limit: newsLimit, topnews_helper: "true" }, function(data) {
        $('#topnews').html(data);
      });
    });
  $('.topnews_headline_top_right_single_arrow')
    .live('mouseover', function() { this.style.cursor = 'pointer'; this.style.background = 'url(/images/news_helper/news_helper-arrow_right_single-glow.jpg)'; })
    .live('mouseout', function() { this.style.background = 'url(/images/news_helper/news_helper-arrow_right_single-normal.jpg)'; })
    .live('click', function() {
      id = id = $('.topnews_headline_number_active').html().replace('.', '');
      $.get("/portal_includes/topnews_helper_ajax.php", { topnews_pageid: id, news_helper_page: "next", news_helper_limit: newsLimit, topnews_helper: "true" }, function(data) {
        $('#topnews').html(data);
      });
    });
  $('.topnews_headline_top_right_double_arrow')
    .live('mouseover', function() { this.style.cursor = 'pointer'; this.style.background = 'url(/images/news_helper/news_helper-arrow_right_double-glow.jpg)'; })
    .live('mouseout', function() { this.style.background = 'url(/images/news_helper/news_helper-arrow_right_double-normal.jpg)'; })
    .live('click', function() {
      $.get("/portal_includes/topnews_helper_ajax.php", { news_helper_page: "last", news_helper_limit: newsLimit, topnews_helper: "true" }, function(data) {
        $('#topnews').html(data);
      });
    });
  $('.topnews_bottomline_left_single_arrow')
    .live('mouseover', function() { this.style.cursor = 'pointer'; this.style.background = 'url(/images/news_helper/news_helper-arrow_bottom_left_single-glow.jpg)'; })
    .live('mouseout', function() { this.style.background = 'url(/images/news_helper/news_helper-arrow_bottom_left_single-normal.jpg)'; })
    .live('click', function() {
      id = id = $('.topnews_headline_number_active').html().replace('.', '');
      $.get("/portal_includes/topnews_helper_ajax.php", { topnews_pageid: id, news_helper_page: "prev", news_helper_limit: newsLimit, topnews_helper: "true" }, function(data) {
        $('#topnews').html(data);
      });
    });
  $('.topnews_bottomline_left_double_arrow')
    .live('mouseover', function() { this.style.cursor = 'pointer'; this.style.background = 'url(/images/news_helper/news_helper-arrow_bottom_left_double-glow.jpg)'; })
    .live('mouseout', function() { this.style.background = 'url(/images/news_helper/news_helper-arrow_bottom_left_double-normal.jpg)'; })
    .live('click', function() {
      $.get("/portal_includes/topnews_helper_ajax.php", { news_helper_page: "first", news_helper_limit: newsLimit, topnews_helper: "true" }, function(data) {
        $('#topnews').html(data);
      });
    });
  $('.topnews_bottomline_right_single_arrow')
    .live('mouseover', function() { this.style.cursor = 'pointer'; this.style.background = 'url(/images/news_helper/news_helper-arrow_bottom_right_single-glow.jpg)'; })
    .live('mouseout', function() { this.style.background = 'url(/images/news_helper/news_helper-arrow_bottom_right_single-normal.jpg)'; })
    .live('click', function() {
      id = id = $('.topnews_headline_number_active').html().replace('.', '');
      $.get("/portal_includes/topnews_helper_ajax.php", { topnews_pageid: id, news_helper_page: "next", news_helper_limit: newsLimit, topnews_helper: "true" }, function(data) {
        $('#topnews').html(data);
      });
    });
  $('.topnews_bottomline_right_double_arrow')
    .live('mouseover', function() { this.style.cursor = 'pointer'; this.style.background = 'url(/images/news_helper/news_helper-arrow_bottom_right_double-glow.jpg)'; })
    .live('mouseout', function() { this.style.background = 'url(/images/news_helper/news_helper-arrow_bottom_right_double-normal.jpg)'; })
    .live('click', function() {
      $.get("/portal_includes/topnews_helper_ajax.php", { news_helper_page: "last", news_helper_limit: newsLimit, topnews_helper: "true" }, function(data) {
        $('#topnews').html(data);
      });
    });
  $('.topnews_headline_number div').live('click', function() {
    id = $(this).html().replace('.', '');
    $.get("/portal_includes/topnews_helper_ajax.php", { news_helper_page: id, news_helper_limit: newsLimit, topnews_helper: "true" }, function(data) {
      $('#topnews').html(data);
    });
  });
});

