// Alex_K, 24.08.2006 08:51:39
// http://alex.fanshop.ru alex@fanshop.ru

function Wopen() {
	// 1 - URL (required, string)
	// 2 - width of the window (required, integer)
	// 3 - height (required, integer)
	// 4 - show scrollbars (yes|no, optional, default no)
	// 5 - allow resize (yes|no, optional, default no)
	// 6 - position of the window (optionl, 0-7, default is 0)
	// 6.0 - center
	// 6.1 - right top
	// 6.2 - right middle
	// 6.3 - right bottom
	// 6.4 - center bottom
	// 6.5 - left bottom
	// 6.6 - left middle
	// 6.7 - left top
	// 7 - window name (optional, fefault is current timestamp)
	
	var today = new Date();
	var wName = arguments[6] || today.getTime();
	var sw = screen.availWidth, sh = screen.availHeight;
	var w = arguments[1], h = arguments[2];
	if (w > sw || !w) w = sw;
	if (h > sh || !h) h = sh;
	if (arguments[3] != 'yes') arguments[3] = 'no';
	if (arguments[4] != 'yes') arguments[4] = 'no';
	if (isNaN(arguments[5])) arguments[5] = 0;
	var l, t;
	var wMargin = 10;

	if ( arguments[5] == 0 ) {
		l = (sw - w) / 2; t = (sh - h) / 2;
	} else if ( arguments[5] == 1 ) {
		l = sw - w - wMargin; t = 0;
	} else if ( arguments[5] == 2 ) {
		l = sw - w - wMargin; t = (sh - h) / 2;
	} else if ( arguments[5] == 3 ) {
		l = sw - w - wMargin; t = sh - h - wMargin;
	} else if ( arguments[5] == 4 ) {
		l = (sw - w) / 2; t = sh - h - wMargin;
	} else if ( arguments[5] == 5 ) {
		l = 0; t = sh - h - wMargin;
	} else if ( arguments[5] == 6 ) {
		l = 0; t = (sh - h) / 2;
	} else if ( arguments[5] == 7 ) {
		l = 0; t = 0;
	}
	open(arguments[0], wName, "left=" + l + ", top=" + t + ", width=" + w + ", height=" + h + ", scrollbars=" + arguments[3] + ", resizable=" + arguments[4]);
}

