
addEvent(window, 'load', initPopups);

//********************************

function initPopups()
{
	var poplinks = DOMfind('.pop', 'DOMclass')
	var Z = poplinks.length-1

	for (var i=Z; i>=0;i--)
		{
		poplinks[i].target= ''
		poplinks[i].inc = i
		poplinks[i].onclick = popUp;
		}
}

function popUp()
{
	var classes = this.className
	var dims = this.rel.split(',')
	var popWidth = dims[0]
	var popHeight = dims[1]

/*	if (classes.match("pop-small"))
		{
		popWidth = 300
		popHeight = 300
		}
	else if (classes.match("pop-med"))
		{
		popWidth = 500
		popHeight = 500
		}

	else if (classes.match("pop-big"))
		{
		popWidth = 700
		popHeight = 700
		}*/

	if (classes.match('pop-console'))
		{var options = 'resizable,toolbar=no,location=no,scrollbars=no,width='+popWidth+',height='+popHeight+',top=100,left=100';}
	else
		{var options = 'resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width='+popWidth+',height='+popHeight+',top=100,left=100';}

	popWindow = window.open(this.href, 'popWindow' + this.inc, options)
	if (window.focus)
		{popWindow.focus()}
	return false;
}

var newWindow = null;

function closePopUPWin(){
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}

function popUpWin(url, type, strWidth, strHeight){
	closePopUPWin();
	
	if (type == "fullScreen"){
		strWidth = screen.availWidth - 10;
		strHeight = screen.availHeight - 160;
	}

	var tools="resizable,toolbar=no,location=no,width="+strWidth+",height="+strHeight+"";
	var winName ="newWin";
	switch(type)
		{
		case "standard": case "fullscreen": case "extra":
		
			tools = tools + ",scrollbars=yes,menubar=no";
			
			if (type == "extra")
				{
				tools = tools + ",top=200,left=200";
				winName = 'extraWin';
				}
			else
				{
				tools = tools + ",top=100,left=100";			
				}
			break;

		case "console":					
			tools = tools + ",scrollbars=yes,top=0,left=0";
			break;	
		}	

	newWindow = window.open(url, winName, tools);
	newWindow.focus();
}