function showSubmenuMore()
{
	$('#submenu-more').css('top', $("#submenu").offset()['top']+$("#submenu").height() + 'px');
	$('#submenu-more').css('left', $("#submenu").offset()['left']+$("#submenu").width()-296 + 'px');
	$('#submenu td.last').addClass('noborder');
	$('.submenu-more-without-subsections').css('border-bottom', 'none');
	$('#submenu-more').show();//fadeIn('fast');
}

function showSubSubmenuMore()
{
	$('#subsubmenu-more').css('top', $("#subsubmenu").offset()['top']+$("#subsubmenu").height() + 'px');
	$('#subsubmenu-more').css('left', $("#subsubmenu").offset()['left']+$("#subsubmenu").width()-296 + 'px');
	// $('#subsubmenu td.last').addClass('noborder');
	$('#subsubmenu-more').show();//fadeIn('fast');
}

function hideSubmenuMore()
{
	if (!hide)
		return;
	$('#submenu-more').hide();//fadeOut('fast');
	$('#submenu td.last').removeClass('noborder');
	$('.submenu-more-without-subsections').css('border-bottom', 'solid 1px #e6e6e6');
}

function hideSubSubmenuMore()
{
	if (!hide_sub)
		return;
	$('#subsubmenu-more').hide();//fadeOut('fast');
	// $('#subsubmenu td.last').removeClass('noborder');
}

function reloadMenu()
{
	$("#menucontainer").html('Refreshing...');
	var url = encodeURIComponent(document.location.href);
	$("#menucontainer").load("/sports-betting/admin/reload/?block=menu&url="+url);
	return false;	
}

show_toggle_object = 0;
function fadeToggle(jquery_selector, speed)
{
	if (!speed)
		speed = 'fast';
	
	if (!show_toggle_object)
	{
		show_toggle_object = 1;
		$(jquery_selector).fadeIn(speed);
	}
	else
	{
		show_toggle_object = 0;
		$(jquery_selector).fadeOut(speed);
	}
}

function selRoundup(id, block_id)
{
	$("#rounduphead").html($("#rupsel_"+id).html());
	var url = encodeURIComponent(document.location);
	$("#roundup").html("Loading...");

	//$("#roundup").load("/sports-betting/admin/reload/?block="+block_id+"&mode="+id+"&url="+url);
	$.get("/sports-betting/admin/reload/",{ block: block_id, mode: id, url: url },function(data){
	   $("#roundup").html($("#roundup",data).html());
	});

	return false;
}

function selTopPosts(id, block_id)
{
	$("#tophead").html($("#top-"+id).html());
	var url = encodeURIComponent(document.location);
	var target = "#top-rated-"+block_id;
	$(target).html("Loading...");
	$.get("/sports-betting/admin/reload/",{ block: block_id, mode: id, url: url },function(data){
	   $(target).html($(target,data).html());
	});
	//$().load("/sports-betting/admin/reload/?block="+block_id+"&mode="+id+"&url="+url);
	return false;
}

/* Footer Ad */
function getCookie(name) {
	var cookieName = name + "=";
	var cookieArray = document.cookie.split(';');
	for(var i=0;i < cookieArray.length;i++) {
		var currentCookie = cookieArray[i];
		while (currentCookie.charAt(0)==' ') currentCookie = currentCookie.substring(1,currentCookie.length);
		if (currentCookie.indexOf(name) == 0) return currentCookie.substring(cookieName.length,currentCookie.length);
	}
	return null;
}

function showFooterAd() {
	if (getCookie('cookieFooterAd') != "hide") {
		$("#footer-ad-wrapper").animate({"bottom":"0px"}, "slow", "easeInOutExpo");
	}
}

function hideFooterAd() {
	$("#footer-ad-wrapper").animate({"bottom":"-140px"}, "slow", "easeInOutExpo");
	var expiryDateFooterAd = new Date();
	expiryDateFooterAd.setDate(expiryDateFooterAd.getDate()+30);
	document.cookie = "cookieFooterAd=hide; expires="+expiryDateFooterAd+"; path=/";
}
/* Footer Ad */

$(document).ready(function(){

	$("body").append($("#submenu-more").clone());
	$("#submenu-more").remove();
	$("body").append($("#subsubmenu-more").clone());
	$("#subsubmenu-more").remove();

	//Fix up top padding when submenu is present.
	$("#content").css("padding-top",(91 + $("#menucontainer").height()) + "px");
	
	/* Footer Ad */
	delay=setTimeout(showFooterAd,5000);
	$("#footer-ad-close").click(hideFooterAd);	
	/* Footer Ad */

});

