/*
$Id: hr.js,v 1.1 2010/05/21 08:31:52 joy Exp $
vim: set ts=2 sw=2 sts=2 et:
*/

/*
hr_list - id of categories list
hr_menu - id of categories menu
*/

var hr_flag = false;

function hrMenuShow() {
  if (hr_flag) clearTimeout(hr_flag);
  if ($("#hr_menu").css("display") != "none") return;
  $("#hr_menu").hide();
  if (hrMenuCheck() <= 0) return;
  $("#menu_more").attr("src", alt_images_dir + "/custom/menu_more_yellow.gif");
  $("#hr_menu").show();
}

function hrMenuHide() {
  if (hr_flag) clearTimeout(hr_flag);
  hr_flag = setTimeout(function () { 
    $("#hr_menu").hide();
    $("#menu_more").attr("src", alt_images_dir + "/custom/menu_more.gif");
  }, 500);
}

function hrMenuCheck() {
  var len = 0;
  var hr_menu_html = "";
  var count = 0;

  $("#hr_menu").html("");
  a = $("#hr_list li").each(
    function (index) {
      if (index == 0) {
        len = $(this).offset().top;
      } else {
        if ($(this).offset().top > len) {
          count++;
          hr_menu_html += "<li>" + decodeURI($(this).html()) + "</li>";
        }
      }
    });
    $("#hr_menu").html(hr_menu_html);
    if (count == 0) {
      $(".more-categories").hide();
    } else {
      $(".more-categories").show();
    }
    return count;
}

$(window).resize(hrMenuCheck);
$(document).ready(hrMenuCheck);
$(document).ready(function(){

	//$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)

	$("ul.topnav li a").hover(function() { //When trigger is clicked...

		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});

});
jQuery(document).ready(function($){         
  $(".slider").rotator({
  arrows    : {left:".leftarrow",right:".rightarrow"},
  tranSpeed : 10,
  delay   : 5000,
  auto    : true,
  loop    : true,
  backwards : false,
  onChange : homeSliderChange,
  endChange : function(i){}
});



$("#slider-facts li").each(function(e){
  if(e!=0){
	$(this).css({marginLeft:-968});
  }
});

function homeSliderChange(i){
				
  $("#slider-facts li.active").animate({marginLeft:-968},400,function(){
	$("#slider-facts li").removeClass("active");
	$("#slider-facts li").eq(i).animate({marginLeft:0},400).addClass("active");
  });
  
}

$("#slider-facts li").eq(0).addClass("active");
  
});
