var wWd ; 
var wHt ;
var chromelessFeatures = "toolbar=1,directories=0,status=0,menubar=0,scrollbars=1,resizable=1" ;
var aTop, aLeft, aWidth, aHeight ;

function AddToFavorites ( loc, tit )
{
	if ( navigator.userAgent.indexOf ( "Macintosh" ) != -1 ) 
	{
		alert("Click OK, then press Command and D simultaneously to bookmark this site.");
	}
	else
	if ( navigator.userAgent.indexOf ( "Konqueror" ) != -1 ) 
	{
		alert("Click OK, then press Ctrl and B simultaneously to bookmark this site.");
	}
	else
	if ( navigator.userAgent.indexOf ( "Gecko" ) != -1 ) 
	{
		alert("Click OK, then press Ctrl and D simultaneously to bookmark this site.");
	}
	else
	if ( navigator.userAgent.indexOf ( "MSIE" ) != -1 ) 
	{
		window.external.AddFavorite(loc,tit);
	}
	else
	if ( navigator.userAgent.indexOf ( "Opera" ) != -1 ) 
	{
		alert("Click OK, then press Ctrl and T simultaneously to bookmark this site.");
	}
	else
	{
		alert("Browser not identified; please use the browser's native mechanism for bookmarking a site.");
	}
}

function GetAvailableScreen ( ) 
{
	if ( navigator.userAgent.indexOf ( "MSIE" ) == -1 ) 
	{
		aWidth = screen.availWidth ;
		aHeight = screen.availHeight ;
		aTop = screen.availTop ;
		aLeft = screen.availLeft ;
	}
	else
	{
		var w = screen.width - screen.availWidth ;
		aLeft = w * 2 ;
		
		var h = screen.height - screen.availHeight ;
		aTop = h * 2 ;

		aWidth = screen.width - w * 2 ;
		aHeight = screen.height - h * 2 ;
	}
}

function GetWindowSize(wWn)
{
	if( typeof( innerWidth ) == 'number' ) {
		// not IE
		wWd = wWn.innerWidth;
		wHt = wWn.innerHeight;
	} else {
		if( wWn.document.documentElement &&
		( wWn.document.documentElement.clientWidth || 
		  wWn.document.documentElement.clientHeight ) ) {
			// IE 6+ in 'standards compliant mode'
			wWd = wWn.document.documentElement.clientWidth;
			wHt = wWn.document.documentElement.clientHeight;
		} else {
			if( wWn.document.body && 
				( wWn.document.body.clientWidth || wWn.document.body.clientHeight ) ) {
				// IE 4 compatible
				wWd = wWn.document.body.clientWidth;
				wHt = wWn.document.body.clientHeight;
			}
		}	
	}
	return 0 ;
}

function Password(goodword, tries) {
	var testV = 1;
	var pass1 = prompt('Enter password','');
	var pass2 ;
	var pass3 ;
	while (testV < tries) {
			if ( pass1 == null ) return 0;
			var sindex = 0 ;
			var eindex = 0 ;
			var begstr = "" ;
			var endstr = "" ;
			var whereQ = pass1.indexOf ( "?" ) ;
			if ( whereQ == -1 )
			{
				pass2 = pass1 ;
			}
			else
			{
				pass2 = pass1.substring ( 0, whereQ ) ;
			}
			whereQ = pass2.indexOf ( "." ) ;
			pass3 = pass2.substring ( 0, whereQ ) ;
			sindex = goodword.indexOf ( pass2 ) ;
			eindex = sindex + pass2.length ;
			if ( sindex > 0 ) begstr = goodword.charAt ( sindex - 1 ) ;
			if ( eindex < goodword.length ) endstr = goodword.charAt ( eindex ) ;
			if (
				( sindex == 0 || begstr == ";" ) &&
				( eindex == goodword.length || endstr == ";" )
			){
				window.open ( pass1, pass3, chromelessFeatures ) ;
				return 1;
			} 
		testV+=1;
		pass1 = prompt('Password Incorrect, Please Try Again.','');
	}
	return 0 ;
}						

function CenterWindow ( win, mat )
{
	win.resizeTo ( aWidth - ( 2 * mat ), aHeight - ( 2 * mat ) ) ;
	win.moveTo ( mat + aLeft , mat + aTop ) ;
}

function ULWindow ( win, mat )
{
	win.resizeTo ( aWidth - ( 2 * mat ), aHeight - ( 2 * mat ) ) ;
	win.moveTo ( mat / 4 + aLeft, mat / 4 + aTop ) ;
}

function OpenChromeless ( fname, nam ) 
{
	var mat = 50 ;

	GetAvailableScreen() ;
	var arg = chromelessFeatures + ",width=" + (aWidth - 100) + ",height=" + ( aHeight - 100 ) ;

	var w = window.open ( fname, nam, arg ) ;

	w.resizeTo ( aWidth - ( 2 * mat ), aHeight - ( 2 * mat ) ) ;

	return w ;
}

