// Multisport data object
var multisport = {
	/*"isOptedIn": false,*//*(typeof(rewards.isOptedIn)=="undefined" -> check for PHP server response)*/
	"isLoggedIn": false };

// Initialization
var multisportInit = function() {
	// Main initialization
	if(arguments[0]=="main") {
		if(!multisport.isLoggedIn) {
			$("#content .contentBox .btnMulti").each(function() {
				$(this).click(function() {
					if(location.protocol=="https:") SB.base.OpenDivCheckLoginStatus("/LoginBar.mvc/popup?currentPageUrl="+location.href, "popBadSelect1","popVeil1","popLayer1",false);
					else SB.base.deferWindowCommand("https://"+location.hostname+"/LoginBar.mvc/popup?currentPageUrl="+location.href, "popup", false);
					return false;
				});
				$(this).children("strong").eq(0).css("display", "inline"); // inline - IE6 fix
			});
			$("#content .contentBox .messageOpt").css("display", "block").children("strong").eq(0).css("display", "block");
		}
		else {
		// Logged-in and not Opted-in
			if(typeof(multisport.isOptedIn)!="undefined" && !multisport.isOptedIn) $("#content .contentBox .btnMulti").each(function() {
				$(this).click(function() {
					$.post("/php/multisport/opting.php",
						{ sbpin: transUserId, opt: "in" },
						function(data) { location.href=location.href; },
						"script");
					return false;
				});
				$(this).children("strong").eq(1).css("display", "inline"); // inline - IE6 fix
				$("#content .contentBox .messageOpt").css("display", "block").children("strong").eq(1).css("display", "block");
			});
			else $("#content .contentBox .btnMulti").each(function() {
				$(this).attr("href", "/t/promos/multisport-score/weekly-results.aspx");
				$(this).children("strong").eq(2).css("display", "inline"); // inline - IE6 fix
			});
		}
	}
}

$(document).ready(function() {
	if(!multisport.isLoggedIn) multisportInit("main");

	// Top menu
	$("#content .contentBox .topNav > ul > li > a").each( function() {
		if(!$(this).attr("href")) {
			$(this).attr("href", "#").click( function() {
				return false;
				}).mouseover( function() {
					$(this).parent("li").children("ul").stop(true).show().fadeTo(50, 1); 
				}).mouseout( function() {
					$(this).parent("li").children("ul").stop(true).fadeOut(1000);
			});
		}
	});
	
	// Top menu - submenu
	$("#content .contentBox .topNav > ul > li > ul > li > a").each( function() {
		$(this).mouseover( function() {
				$(this).parent("li").parent("ul").stop(true).fadeTo(50, 1); 
			}).mouseout( function() {
				$(this).parent("li").parent("ul").stop(true).fadeOut(1000); 
		});
	});
});
