var newwindow;
/*Open a popup window and loads the specified url in it*/
function popup(url)
{
	newwindow=window.open(url,'name','height=480,width=480,left=400,top=100');
	if (window.focus) {newwindow.focus()}
}
function popup_custom(url,name,width,height)
{
	newwindow=window.open(url,name, "width=" + width + "px, height=" + height + "px, left='+((screen.width -" + width + ") / 2)+', top='+ (screen.height - " + height + ") / 2+'");
	if (window.focus) {newwindow.focus()}
}
function popup_custom_scrollable(url,name,width,height)
{
	newwindow=window.open(url,name, "scrollbars=1,width=" + width + "px, height=" + height + "px, left='+((screen.width -" + width + ") / 2)+', top='+ (screen.height - " + height + ") / 2+'");
	if (window.focus) {newwindow.focus()}
}
/*if Enter is press inside the control, then this script will execute click on the control specified in target_name*/
/*Could not work in Mozzila*/
function button_click(target_name)
{
	if (window.event.keyCode == 13)
	{
		var element = document.getElementById(target_name);
		if (element != null)
			element.click();
	}
}
/*open a dialog and asks for delete schema confirmation. if is ok than it saves the id in an hidden Input and submits the form*/
function deleteSchema( schema_id , schema_name)
{
	if (confirm("Are you sure that you want to delete elertz '" + schema_name + "'"))
	{
		var hid_act = document.getElementById("hidden_action");
		var hid_val = document.getElementById("hidden_value");
		hid_act.value = "delete";
		hid_val.value = schema_id;
		window.document.forms[0].submit();
	}

}
/*copy text from targeted control name to clipboard*/
function ToClipBoard(elementName) 
{
	var control = document.getElementById(elementName)
	if (control != null)
	{
		control.focus();
		control.select();
		Copied = control.createTextRange();
		//Copied.execCommand("RemoveFormat"); //removes HTML format and copy only text
		Copied.execCommand("Copy");
	}
	else
		alert ("The control " + elementName + " can not be found on this Web Page!");
}
/*submits command information from the page*/
function submitInfo( button ,  command , id )
{
	button.disabled = true; // to prevent multiple clicks
	document.getElementById("commandName").value = command;
	document.getElementById("commandId").value = id;
	document.forms(0).submit();
}
/*asks confirmation before switching to standard schema*/
function SwitchToStandardSchema()
{
	if (confirm("WARNING! Switching back to the Standard Schema at this point of the setup would delete the parameters you have now set. Are you sure do you want to continue?"))
	{
		window.location.href = "SchemaWizardStandard1.aspx";
	}
}
/*lock schema waring*/
function schemaLockClick(checkElement)
{
	if (checkElement.checked)
	{
		alert("WARNING! Locking the schema will prevent schema changes in the future.");
	}
}
/*Manage Custom NewsLink box display*/
function RSS_LinkDisplay(check)
{
    if (check.checked)
       document.getElementById("Custom_RSS_Table").style.display="";
    else
       document.getElementById("Custom_RSS_Table").style.display="none";
}
//calls a link from a HTML textarea
function executeLink ( obj)
{
    if (obj.value.length > 0 ) 
    {
        window.location.href = obj.value;
    }
}
/*open a dialog and asks for delete competition confirmation. if is ok than it saves the id in an hidden Input and submits the form*/
function deleteCompetition( comp_id , comp_name)
{
	if (confirm("Are you sure that you want to delete competition '" + comp_name + "'"))
	{
		var hid_act = document.getElementById("hidden_action");
		var hid_val = document.getElementById("hidden_value");
		hid_act.value = "delete";
		hid_val.value = comp_id;
		window.document.forms[0].submit();
	}
}
/*open a dialog and asks for expiration of competition confirmation. if is ok than it saves the id in an hidden Input and submits the form*/
function expireCompetition( comp_id , comp_name)
{
	if (confirm("Are you sure that you want to expire competition '" + comp_name + "'. No subscribtions will be accepted further if you confirm the command."))
	{
		var hid_act = document.getElementById("hidden_action");
		var hid_val = document.getElementById("hidden_value");
		hid_act.value = "expire";
		hid_val.value = comp_id;
		window.document.forms[0].submit();
	}
}