// Runs when the DOM is ready
$(document).ready(function () {
	// Check we're on the team page
	if ( document.location.toString().indexOf("team.aspx") > -1 ) { 
			if ( ( document.location.toString().indexOf("myPlayer") > -1 ) || ( document.location.toString().indexOf("confirmTransfer") > -1 ) || ( document.location.toString().indexOf("rCaptain") > -1 ) || ( document.location.toString().indexOf("page=") < 1 ) || ( document.location.toString().indexOf("view") > -1 ) ) { 
				window.onbeforeunload = confirmBrowseAwayTeam;
			}
		}
});
function confirmBrowseAwayTeam() {
	if ( Config.TeamChangedState ) {
		return Config.TeamChangedText;
	}
}
function cancelNotification(status) {
	Config.TeamChangedState = status;
}

function ShowTransferPop(menu) {
	try {
		document.getElementById('menu0').style.display = 'NONE';
		document.getElementById('menu1').style.display = 'NONE';
		document.getElementById('menu2').style.display = 'NONE';
		document.getElementById('menu3').style.display = 'NONE';
		alertTransferSize(menu);
	} catch (ex) { /* no error */ }
}

function CloseTransferPop() {
	try {
		document.getElementById('menu0').style.display = 'NONE';
		document.getElementById('menu1').style.display = 'NONE';
		document.getElementById('menu2').style.display = 'NONE';
		document.getElementById('menu3').style.display = 'NONE';
	} catch (ex) { /* no error */ }
}

function alertTransferSize(menu) {
	var myWidth = 0, myHeight = 0,notIe = false;
	if( typeof( window.innerWidth ) == 'number' ) {
		// Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		notIe = true;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		// IE 6+ in 'standards compliant mode' - nothing could be further from the truth
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		// IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}

	// put the menu somewhere
	var left;
	var t = 40;

	if ( menu == 0 ) {
		left = 0;
	}
	else if ( menu == 1 ) {
		left = -250;
	}
	else if ( menu == 2 ) {
		left = 160;
	}
	else if ( menu == 3 ) {
		left = 170;
	}

	document.getElementById('menu' + menu).style.top = t;
	document.getElementById('menu' + menu).style.left = left;
	document.getElementById('menu' + menu).style.display = 'BLOCK';
}
