// JavaScript Document
var active_nav_li = 0;
jQuery(document).ready(function($){
	
	var mmw = parseInt($("#content .submenu").width());
	$("#content .submenu>ul>li").each(function(i){
		mmw -= parseInt($(this).width());
	});
	$("#content .submenu>ul>li>a").css("padding", "0px " + Math.floor(4 + mmw / $("#content .submenu>ul>li").length / 2) + "px");
	
	/*********************************************************
							MS IE 6
	*********************************************************/
	if($.browser.msie && $.browser.version < 7) {
		/*$("img[src$='.png']").each(function(i){
			$(this)
				.css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src='" + $(this).attr("src") + "')")
				.attr("src", "img/spacer.gif");
		});*/
	}
	
	
	/*********************************************************
							...
	*********************************************************/
	
	if($(".ads-p-6").length) {
		$(".ads-p-6").hide();
		$(".ads-p-6").each(function(){
			var b = $(this).html();
			$(this).replaceWith(
				'<div id="scrollingText-margin"></div>' + 
				'<div id="scrollingText">' + 
					'<div class="scrollingHotSpotLeft"></div>' + 
					'<div class="scrollingHotSpotRight"></div>' + 
					'<div class="scrollWrapper">' + 
						'<div class="scrollableArea">' + 
							b + b + b + 
						'</div>' + 
					'</div>' + 
				'</div>'
			);
		});
		
		$("div#scrollingText").smoothDivScroll({		
			autoScroll: "always",		
			autoScrollDirection: "endlessloopright",		
			autoScrollInterval: 40,//20,		
			autoScrollStep: 1//2		
		});		
				
		$("div#scrollingText").bind("mouseover", function(){		
			$("div#scrollingText").smoothDivScroll("stopAutoScroll");		
		});		
				
		$("div#scrollingText").bind("mouseout", function(){		
			$("div#scrollingText").smoothDivScroll("startAutoScroll");		
		});
	}
	
	/*********************************************************
							...
	*********************************************************/
	$(".top-list ol li").mouseover(function(){
		$(this).addClass("hover");
	}).mouseout(function(){
		$(this).removeClass("hover");
	});
	
	$("body.oevma #sidebar ul li a").append('<span></span>');
	if($("body.oevma #sidebar").length && $("body.oevma #sidebar").height() < $("body.oevma .content-r").height()) {
		$("body.oevma #sidebar").height(parseInt($(".content-r").height()) - 10);
		if($.browser.msie && $.browser.version < 7) {
			$("body.oevma #sidebar .border-rd").height($("body.oevma #sidebar").height());
		}
	}
	
	if($("#header2 .slider-nav li").length > 1) {
		$("#header2 .slider-nav li a").each(function(i){
			var src = $(this).attr("onclick");
			if(typeof(src) != 'undefined') {
				src = src.replace(/^.*?'/, '');
				src = src.replace(/'.*?$/, '');
				
				var img = new Image();
				img.src = src;
			}
			
			$(this).attr("nav-index", i);
		});
		setInterval("autoChangeBackground()", 10000);
	}
	
	if($(".oevma-nominations ul li").length) {
		$(".oevma-nominations ul li").each(function(){
			$("ul li:lt(" + ($("ul li", this).length - 1) + ")", this).append(',');
		});
	}
	
	$(".schedule ul li:last").addClass("last");
});

function changeBackground(background, url, a) {
	if(!background){
		return false;
	}
	jQuery("body").css("background-image", "url(" + background + ")");
	jQuery(".background-url").attr("href", url);
	if(url) {
		jQuery(".background-url").show();
	} else {
		jQuery(".background-url").hide();
	}
	if(a) {
		jQuery("li", jQuery(a).parent().parent()).removeClass("active");
		jQuery(a).parent().addClass("active");
		active_nav_li = parseInt(jQuery(a).attr("nav-index"));
	}
}

function autoChangeBackground(){
	lic = jQuery("#header2 .slider-nav li").length;
	jQuery("#header2 .slider-nav li:eq(" + (active_nav_li + 1 >= lic ? 0 : active_nav_li + 1) + ") a").click();
}
