<!-- Common Site JS -->

var g_form_modified = false;

function PopupWindow( url )
{
	winParams='toolbar=no,status=no,resizable=yes,scrollbars=yes';	
	window.open( url, 2, winParams );
}

function DropDownChange(url)
{
	if (url != '')
	{
		window.location = url;
	}
}

function ConfirmDeleteResult(resultid)
{
    var message = "Please confirm that you wish to remove this result.";

    if (confirm(message) == true)
    {
       window.location = 'results.php?deleteresultid=' + resultid;
    }
}

function ConfirmLeaveCompetition(competitionid)
{
    var message = "Please confirm that you wish to leave this competition.";

    if (confirm(message) == true)
    {
       window.location = 'leagues.php?action=remove&competitionid=' + competitionid;
    }
}

function ConfirmRemoveFromCompetition(userid, competitionid, areaid, sex)
{
    var message = "Please confirm that you wish to remove this player from this competition.";

    if (confirm(message) == true)
    {
       window.location = 'adminleagues.php?removefromcompetitionid=' + competitionid + '&removeuserid=' + userid + '&areaid=' + areaid + '&sex=' + sex;
    }
}

function ToggleBlock(elementId)
{
	var element = document.getElementById( elementId )
	if( element.style.display == "block" )
	{
		element.style.display = "none";
		element.style.position = "relative";
	}
	else
	{
		element.style.display = "block";
		element.style.position = "relative";
	}
}

function EnableBlock(elementId)
{
	var element = document.getElementById( elementId )
	element.style.display = "block";
	element.style.position = "relative";
}

function DisableBlock(elementId)
{
	var element = document.getElementById( elementId )
	element.style.display = "none";
	element.style.position = "relative";
}

function HideBlock(elementId)
{
	var element = document.getElementById( elementId )
	element.style.visibility = "hidden";
	element.style.position = "relative";
}

function ShowBlock(elementId)
{
	var element = document.getElementById( elementId )
	element.style.visibility = "visible";
	element.style.position = "relative";
}

function FormModified()
{
	g_form_modified = true;
}

function IsFormModified(form, processorUrl, destinationUrl)
{
	if (g_form_modified)
	{
	    var message = "Would you like to save your changes to this tabpage?";

    	if (confirm(message))
    	{
			var element = document.getElementById(form);
    		element.submit();
	    }
	    else
	    {
	    	g_form_modified = false;
	    }
	}
	else
	{
		window.location = destinationUrl;
	}
}
