function openWindow(url,name,complex)
{
	openWindow(url,name,complex,800,600);
}

function openWindow(url,name,complex,width,height) {
	if(complex)
	{
		openWin(url,"popupc_"+name,width,height);
	}
	else
	{
		openMetaWin(url,"popup_"+name,width,height);
	}
}

function openWin(url, name, width, height) {
	// limit popup size to visible screen, at most
	// manually tuned values, optimized for IE - dont reason about it
	var x = width;
	var y = height;
	if(screen.availWidth && screen.availWidth-25<x){x=screen.availWidth-25;}
	if(screen.availHeight && screen.availHeight-50<y){y=screen.availHeight-50;}
	win = window.open( url,name,"width="+x+",height="+y+",scrollbars=yes,location=yes,resizable=yes,directories=yes,status=1,menubar=yes,toolbar=yes,left=20,top=50" );
	win.focus();
}

function openMetaWin(url, name, width, height){
	var x = width;
	var y = height;
	if(screen.availWidth && screen.availWidth-25<x){x=screen.availWidth-25;}
	if(screen.availHeight && screen.availHeight-50<y){y=screen.availHeight-50;}
	metaWin = window.open(url,name,"width="+x+",height="+y+",scrollbars=yes,location=no,resizable=no,directories=no,status=0,menubar=0,toolbar=no,left=20,top=10");
	metaWin.focus();
}


function openInfographicPopup(url, name, xdim, ydim) {
	var scrollflag='no';
	var topPos=50;
	if (screen.availHeight && ydim>screen.availHeight-60) {
		ydim=screen.availHeight-60;
		xdim=xdim+20;
		scrollflag='yes';
		topPos=0;
	}
	metaWin = eval("window.open('"+url+"','"+name+"' ,'width="+xdim+", height="+ydim+", scrollbars="+scrollflag+",location=no,resizable=no,directories=no,status=0,menubar=0,toolbar=no,left=20,top="+topPos+"')");		
	metaWin.focus();
}

