var headline_count;
var headline_interval;
var old_headline = 0;
var current_headline = 0;

$(document).ready(function(){
  headline_count = $("div.headline").size();
  $("div.headline:eq("+current_headline+")").css('top', '5px');

  headline_interval = setInterval(headline_rotate,5000);
  $('#newsContainer').hover(function() {
    clearInterval(headline_interval);
  }, function() {
    headline_interval = setInterval(headline_rotate,5000);
    headline_rotate();
  });
});

function headline_rotate() {
  current_headline = (old_headline + 1) % headline_count;
  $("div.headline:eq(" + old_headline + ")")
    .animate({top: -205},"slow", function() {
      $(this).css('top', '210px');
    });
  $("div.headline:eq(" + current_headline + ")")
    .animate({top: 5},"slow");
  old_headline = current_headline;
}

function login_keypress(e, form)
{
        var keynum;
        var keychar;
        var numcheck;

        if(window.event) // IE
                keynum = e.keyCode;


        else if(e.which) // Netscape/Firefox/Opera
                keynum = e.which;

        (keynum == 13)?(form.submit()):("");
}

function menu_hover(item, action){

        var id = item.id.substring(4);

        if(action == 0)
          $("#hover"+id).animate({width: 221}, "fast");
          
        if(action == 1)
          $("#hover"+id).stop().animate({width: 0}, "fast");
          
}

function register_hover(obj, action) {

      if (action == 0) {
        obj.style.backgroundImage="url(template/standard/images/register_bg_over.jpg)";
        obj.style.color = "#ffffff";
      }
        
      if (action == 1) {
        obj.style.backgroundImage = "url(template/standard/images/register_bg.jpg)";
        obj.style.color = "#25B8FF";
      }
      
}

function toggle(id) {

  obj = document.getElementById(id);
  
  if(obj.disabled == true){ obj.disabled = false; obj.value = ""; }
  else { obj.disabled = true; obj.value = "Check Applicable To Edit"; }
  
}

function toggle_new(caller){

  obj = document.getElementById('transport');

  if (caller.value != 'Cairo') obj.disabled = true;
  else obj.disabled = false;
}
