//\//////////////////////////////////////////////////////////////////////////////////
//\  Test and Jump 1.001  
//\  ------------------------------  
//\  This notice must remain untouched at all times.
//\
//\  Copyright Colin Nynn 2001. All rights reserved.
//\
//\  By Colin Nunn (colin.nunn@clearcurve.com).  Last modified 2001-08-30.
//\
//\
//\  Get the latest version at http://www.clearcurve.com
//\
//\  This script is published under an open source license. Please read the license
//\  agreement online at: http://www.clearcurve.com/license.html
//\  If you have questions regarding the license please contact colin.nunn@clearcurve.com.
//\
//\  This script library was originally created for corporate use by e-Financial Management
//\  By request it haslater been made public. This is free software. 
//\
//\  Do not sell this as your own
//\  work, or remove this copyright notice. For full details on copying or changing
//\  this script please read the license agreement at the link above.
//\
//\  Please give credit on sites that use ClearCurve and submit changes of the script
//\  so other people can use them as well. This script is free to use, don't abuse.
//\//////////////////////////////////////////////////////////////////////////////////

var windowHandle

// ****************************************************************************************************************
//
// Screen Details
//
// ****************************************************************************************************************
function screenDetails() {
	alert(	"Screen details\n" + "-----------------\n" + 
		"screen.Height: " + screen.Height + ", \n" + 
		"screen.Width: " + screen.Width + ", \n" +
		"\n" +
		"screen.availHeight: " + screen.availHeight + ", \n" + 
		"screen.availWidth: " + screen.availWidth + ", \n" +
		""
	);
	return true;
}

// ****************************************************************************************************************
//
// Maximise
//
// ****************************************************************************************************************
function maximiseWindow(winRef) {
	winRef.window.moveTo(0,0);
	if (document.all) {
		winRef.window.resizeTo(screen.availWidth,screen.availHeight);
	}
	else if (document.layers||document.getElementById) {
		if (winRef.window.outerHeight<screen.availHeight||winRef.window.outerWidth<screen.availWidth){
			winRef.window.outerHeight = screen.availHeight;
			winRef.window.outerWidth = screen.availWidth;
		}
	}
	return true;
}

// ****************************************************************************************************************
//
// Maximise and OnTop
//
// ****************************************************************************************************************
function alterWindow(winRef) {
  	maximiseWindow(winRef);
  	winRef.focus();
	return true;
}



// ****************************************************************************************************************
//
// Test browser and jump accordingly
//
// ****************************************************************************************************************
function testandjump (okHTML,notokHTML,windowSTATE)	{

	debug = false;
	(debug) ? alert("Hello, I am in debug mode.") : true;

	(debug) ? alert(windowSTATE) : true;

	var calculator_window = ''

	NS4 = (document.layers) ? 1 : 0;
	IE4 = (document.all) ? 1 : 0;
	ver4 = (NS4 || IE4) ? 1 : 0;



	if (!ver4) {

		alert("Sorry: This page is designed, as a basic requirement, for browsers higher than version 4.0. \n\nYou may wish to download the newest version of the MS Internet Explorer Browser \nfrom the www.microsoft.com website.");

	} else {

		manufacturer=navigator.appName;
		version=navigator.appVersion;

		if (manufacturer.indexOf('Netscape') >=0) {

			alert("Sorry: This page does not support any version of the Netscape browser. \n\nYou may wish to download the newest version of the MS Internet Explorer Browser \nfrom the www.microsoft.com website.");
		}

		if (manufacturer.indexOf('Microsoft') >=0) {


			loc = self.location;
			loc = loc.toString();        
			k = loc.lastIndexOf('/');
			loc = loc.substring(0,k+1);

			nloc = loc.substring(0,k+1) + okHTML;

			(debug) ? alert("Screen sizes: " + screen.width + "<=800 " + screen.height+ "<=600") : true;

			if (screen.width<=800 && screen.height<=600){
				alert("This site is designed for a screen size greater than 800x600 resolution. \n\nYou may wish to increase your screen resolution. \n\nIf not, the page may not display all of its features and you will need to scroll.");

			}

			bCompatible=false

			if (version.indexOf('MSIE 5.') >=0) {bCompatible=true}
			if (version.indexOf('MSIE 6.') >=0) {bCompatible=true}

			if (!bCompatible) { 
				alert("Sorry: The version of the MS Internet Explorer is not recognised as 5.0+ to 6.0. \n\nYou may have a very new browser. \n\nTherefore the browser may display all of the page features.");
			} 
			
			(debug) ? alert("Location set " + nloc) : true;
			(debug) ? alert(version) : true;
			(debug) ? alert(version.indexOf('MSIE 5.')) : true;
			(debug) ? alert(version.indexOf('MSIE 6.')) : true;

			// Open window depending on the form of windowSTATE
			// -------------------------------------------------
			if (windowSTATE.indexOf('OLD') >=0) {
				self.location=nloc;
				window.name='calculator_old'
				windowHandle = calculator_old
			} else {
				if (windowSTATE.indexOf('NEW')  >=0 ) {
					if (windowSTATE.length == 3) {
						(debug) ? alert("NEW SELF window") : true;
						windowHandle = window.open(nloc, 'calculator_new');
					} else {
						(debug) ? alert("NEW BARE window") : true;
						windowHandle = window.open(nloc, 'calculator_new', 'toolbar=0,location=0,directories=0,menubar=0,scrollbars=1,status=1,resizable=1');
					}
				} else {
					alert("Error: Sorry: The browser has encountered the error - 'Calculator:#0001'.\n\n Please inform administrator@e-financial-management.com");
					return false;
				}
			}

			// Arrange window depending on the form of windowSTATE
			// ---------------------------------------------------
			if (windowSTATE.indexOf('MAXIMAL') >=0) {
				(debug) ? alert("Arrange MAXIMAL window (" + windowHandle + ")") : true;
				setTimeout('alterWindow(windowHandle)', 1);
			}
		}
		
		if (manufacturer.indexOf('Microsoft') <0 && manufacturer.indexOf('Netscape') <0) {
			alert("Sorry: Unrecognised browser, this page is not compatible with the browser you are using to view this page.");
			nloc = loc.substring(0,k+1) + notokHTML;
			(debug) ? alert("Location set" + nloc) : true;
			self.location=nloc;
		}
	}
	return true;
}
