var openedWin = null;
var wpercent = 100;

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function launch() { //v2.0
	var args = launch.arguments;
	var url = args[0];
	var width = args[1];
	var height = args[2];
	var resizable = args[3];
	var scrollbars = args[4];
	 	
	if (width > screen.availWidth || height > screen.availHeight)
	{
		var targetW = screen.availWidth - 8;
		wpercent = Math.floor ((targetW * 100) / width);
		var targetH = Math.floor ((height * wpercent) / 100);
		width = targetW;
		height = targetH;
		_launch (url, width, height, resizable, scrollbars);
	}
	else
	{
		_launch (url, width, height, resizable, scrollbars);
	}
}

function _launch ()
{
	var args = _launch.arguments;
	if(args.length < 3)
	{
		alert('Wrong amount of arguments');
		return
	}
	closeChild ();
	var url = args[0];
	var width = args[1];
	var height = args[2];
	var resizable = args[3] ? "yes" : "no";
	var scrollbars = args[4] ? "yes" : "no";
	var toolbar = args[5] ? "yes" : "no";
	var menubar = args[6] ? "yes" : "no";
	var status = args[7] ? "yes" : "no";
	var address = args[8] ? "yes" : "no";
	var directories = args[9] ? "yes" : "no";
	var NewX = Math.max(0, Math.floor ((screen.availWidth - (width + 8)) / 2));
	var NewY = Math.max(0, Math.floor ((screen.availHeight - (height + 27)) / 2));
	var params = '';
	params += "width=" + width;	// 1
	params += ",height=" + height;	// 2
	params += ",screenx=" + NewX;
	params += ",screeny=" + NewY;
	params += ",left=" + NewX;
	params += ",top=" + NewY;
	params += ",resizable=" + resizable;	// 3
	params += ",scrollbars=" + scrollbars;	// 4
	params += ",toolbar=" + toolbar;	// 5
	params += ",menubar=" + menubar;	// 6
	params += ",status=" + status;	// 7
	params += ",location=" + address;	// 8
	params += ",directories=" + directories;	// 9
	openedWin = window.open (url, "", params);
}
function closeChild ()
{
	if (openedWin != null)
	{
		if (!openedWin.closed)
		{
			openedWin.close ();
		}
	}
}
onunload = closeChild;


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
   d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}