function makeWin(url, myname, w, h, scroll) {

	agent = navigator.userAgent;
	windowName = "_blank";
	
	var winl = (screen.width - w) / 2;
	var wint = ((screen.height - h) / 2) - 30;
	params = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=1,'
	params += "toolbar=0,";
	params += "location=0,";
	params += "directories=0,";
	params += "status=1,";
	params += "menubar=0,";
	
	win = window.open(url, windowName , params);
	
	if (agent.indexOf("Mozilla/2") != -1 && agent.indexOf("Win") == -1) {
		win = window.open(url, windowName , params);
	}
	
	if (!win.opener) {
		win.opener = window;
	}
	
	if (win.focus) {
		win.focus() ;
	}

}

function makeWinWithOptions(url, myname, w, h, scroll, rsz, tlbr, loc, drct, sts, menb) {

	agent = navigator.userAgent;
	windowName = "_blank";
	
	// Defaults
	if (w == "?") w = 700;
	if (h == "?") h = 500;
	if (scroll == "?") scroll = "1";
	if (rsz == "?") rsz = "1"; 
	if (tlbr == "?") tlbr = "0"; 
	if (loc == "?") loc = "0"; 
	if (drct == "?") drct = "0"; 
	if (sts == "?") sts = "1"; 
	if (menb == "?") menb = "0"; 
	
	
	var winl = (screen.width - w) / 2;
	var wint = ((screen.height - h) / 2) - 30;
	params = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll + ",";
	params += "resizable=" + rsz + ",";
	params += "toolbar=" + tlbr + ",";
	params += "location=" + loc + ",";
	params += "directories=" + drct + ",";
	params += "status=" + sts + ",";
	params += "menubar=" + menb;
	
	win = window.open(url, windowName , params);
	
	if (agent.indexOf("Mozilla/2") != -1 && agent.indexOf("Win") == -1) {
		win = window.open(url, windowName , params);
	}
	
	if (!win.opener) {
		win.opener = window;
	}
	
	if (win.focus) {
		win.focus() ;
	}

}

function printWindow(){
   bV = parseInt(navigator.appVersion)
   if (bV >= 4) window.print()
}

function autoTab(input, len, e) {
	var isNN = (navigator.appName.indexOf("Netscape")!=-1);
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	if(input.value.length >= len && !containsElement(filter,keyCode)) {
		input.value = input.value.slice(0, len);
		input.form[(getIndex(input)+1) % input.form.length].focus();
		}

	function containsElement(arr, ele) {
		var found = false, index = 0;
		while (!found && index < arr.length)
			if (arr[index] == ele)
				found = true;
			else
				index++;
		return found;
	}
	
	function getIndex(input) {
		var index = -1, i = 0, found = false;
		while (i < input.form.length && index == -1)
			if (input.form[i] == input)
				index = i;
			else
				i++;
		return index;
	}

	return true;
}

function f_open_window_max( aURL, aWinName )
{
   var wOpen;
   var sOptions;

   sOptions = 'status=yes,menubar=yes,scrollbars=yes,resizable=yes,toolbar=yes';
   sOptions = sOptions + ',width=' + (screen.availWidth - 10).toString();
   sOptions = sOptions + ',height=' + (screen.availHeight - 122).toString();
   sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0';

   wOpen = window.open( '', aWinName, sOptions );
   wOpen.location = aURL;
   wOpen.focus();
   wOpen.moveTo( 0, 0 );
   wOpen.resizeTo( screen.availWidth, screen.availHeight );
   return wOpen;
}
