function Popup(p_url,p_width,p_height,p_scroll,p_name) {	
	var ScrWidth = screen.width;
	var ScrHeight = screen.height;
	var x = ((ScrWidth - p_width)/2);
	var y = ((ScrHeight - p_height)/2);
	if (Popup.arguments.length < 5) {
	    p_name = ("name" + x).replace(/\W*/g, '');
	}
	if (Popup.arguments.length < 4) {
		p_scroll = "yes";
	}
	 
	newwin = window.open(p_url,p_name, "channelmode=no,dependent=no,directories=no,fullscreen=no,location=no,menubar=no,resizable=no,scrollbars="+p_scroll+",status=no,toolbar=no,width="+p_width+",height="+p_height+",screenX="+x+",left="+x+",screenY="+y+",top="+y); 
	if (newwin.focus) newwin.focus();
	if (!newwin.opener) {
		newwin.opener = self;
	}
}

function toggleCheckboxes(isChecked)
{
	var inputs = document.getElementsByTagName("input");
	
	for(i=0; i<inputs.length; i++)
	{
		if(inputs[i].type == "checkbox")
			inputs[i].checked = isChecked;
	}
}


function toggleChecks(scope, masterCheckbox)
{
	children = document.getElementById(scope).getElementsByTagName("input");
	
	for(i=0; i<children.length; i++)
	{
		if(children[i].getAttribute("type") == "checkbox")
		{
			children[i].checked = masterCheckbox.checked;
		}
	}
}

function enableButton(buttonName)
{
	document.getElementById(buttonName).disabled = !atLeastOneCheckboxIsChecked();
}

function enableLink(linkame, url)
{
	var link = document.getElementById(linkame);
	if (atLeastOneCheckboxIsChecked())
	{
		link.href = url;
		link.disabled = false;
		link.style.cursor = "pointer";
	}
	else
	{
		link.href = "#";
		link.disabled = true;
		link.style.cursor = "text";				
	}
}

function atLeastOneCheckboxIsChecked()
{
	var isChecked = false;
	
	var inputs = document.getElementsByTagName("input");

	for(i=0; i<inputs.length; i++)
	{
		if(inputs[i].type == "checkbox")
			if(inputs[i].checked)
			{
				isChecked = true;
				break;
			}
	}
	
	return isChecked;
}

function PopupCentered(p_url, p_width, p_height, p_name) {
    var x = (screen.width - p_width) / 2;
    var y = (screen.height - p_height) / 2;

    newwin = window.open(p_url, p_name, "menubar=no,resizable=no,width=" + p_width + ",height=" + p_height + ",screenX=" + x + ",left=" + x + ",screenY=" + y + ",top=" + y);

    if (newwin.focus) newwin.focus();
    if (!newwin.opener) {
        newwin.opener = self;
    }
}
