// JavaScript Document

var openedWin = null;

var wpercent = 100;



function launch()

{

	var args = launch.arguments;

	var url = args[0];

	var width = args[1];

	var height = args[2];

	

	if (!url || !width || !height) {

		alert('Error in arguments');

	} else {

		var scr_w = screen.availWidth;

		var scr_h = screen.availHeight;

		var target_w = 0;

		var target_h = 0;

		

		wpercent = 100;

		var scr_w = screen.availWidth;

		var scr_h = screen.availHeight;

		

		if (width >= scr_w || height >= scr_h) {

			if (width >= scr_w && height < scr_h) {

				wpercent = Math.floor(((scr_w - 8) * 100) / width);

			} else if (height > scr_h) {

				wpercent = Math.floor(((scr_h - 27) * 100) / height);

			}

			width = Math.floor((width * wpercent) / 100);

			height = Math.floor((height * wpercent) / 100);

		}

		

		_launch(url, width, height, args[3], args[4], args[5], args[6], args[7], args[8], args[9]);

	}

}



function _launch()

{

	closeChild();

	

	var args = _launch.arguments;

	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 = new Array();

	params.push('width=' + width);

	params.push('height=' + height);

	params.push('screenx=' + NewX);

	params.push('screeny=' + NewY);

	params.push('left=' + NewX);

	params.push('top=' + NewY);

	params.push('resizable=' + resizable);

	params.push('scrollbars=' + scrollbars);

	params.push('toolbar=' + toolbar);

	params.push('menubar=' + menubar);

	params.push('status=' + status);

	params.push('location=' + address);

	params.push('directories=' + directories);

	

	openedWin = window.open(url, '', params.join(','));

}



function closeChild()

{

	if (openedWin != null) {

		if (!openedWin.closed) {

			openedWin.close();

		}

	}

}



onunload = closeChild;