$(document).ready(initLoad);
var interval = 0;
function initLoad() {
	if($.browser.msie && parseInt(jQuery.browser.version)<=6) {
		$("#firstPageIcons a").hover(
			function(){$(this).find("span.hover").show();},
			function(){$(this).find("span.hover").hide();}
		);
		$("#firstPageIcons a").each(function(){
			img = $(this).find("img");
			img.after("<span class=\"pngfix\" style=\"_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+img.attr("src")+"',sizingMethod='scale');\"></span>");
			img.remove();
		});
		$("#scrollerArea a").hover(
			function(){$(this).find("span img").css("margin-top","-125px");},
			function(){$(this).find("span img").css("margin-top","0px");}
		);
		$(window).resize(hideLoginForm);
	}
	$("div.footerBlocks div.menu table td").hover(
		function(){$(this).addClass("hovered");},
		function(){$(this).removeClass("hovered");}
	);
    
    if($("#scrollerArea").attr('id')) {
    	$("#scrollerArea .arrowLeft").click(goRight);
        $("#scrollerArea .arrowLeft").click(stopScroller);
    	$("#scrollerArea .arrowRight").click(goLeft);
        $("#scrollerArea .arrowRight").click(stopScroller);
        
        interval = setInterval("goLeft()","4000");
    }
}

function stopScroller() {
    if(interval != 0) {
        clearInterval(interval);
        interval = 0;    
        setTimeout("runScroller()","6000");
    }
}

function runScroller() {
    interval = setInterval("goLeft()","4000");
}

function showLoginForm(l) {
	$("#loginForm").css({left:$(l).offset().left-24+"px",top:$(l).offset().top-29+"px"}).show();
	if($.browser.msie && parseInt($.browser.version)<=6) {
		$("#overlayer").css({height:$("body").height()+"px"}).show();
	}
	else {
		$("#overlayer").show();
	}
}

function hideLoginForm() {
	$("#loginForm").hide();
	$("#overlayer").hide();
}

var isScrolling = false;
function goRight() {
	if(isScrolling==false) {
		isScrolling = true;
		lp = $("#scrollerArea div.scroller").position().left;
		if(lp<0) {
			$("#scrollerArea div.scroller").animate({left:lp+326+"px"},function(){isScrolling = false;});
		}
		else {
			isScrolling = false;
		}
	}
}
function goLeft() {
	if(isScrolling==false) {
		isScrolling = true;
		lp = $("#scrollerArea div.scroller").position().left;
		bc = $("#scrollerArea div.scroller a").length;
		if((bc+lp/326)>3) {
			$("#scrollerArea div.scroller").animate({left:lp-326+"px"},function(){isScrolling = false;});
		}
		else {
			isScrolling = false;
            $('#scrollerArea > .inner > .scroller').append($('#scrollerArea > .inner > .scroller > .scritems').html());
            goLeft();
		}
	}
}
