<!--
//*************************
//# Name		JavaScript.js
//# Version		11.00
//# Modified	15/08/2001 11:46
//*************************

//Browser Detection For Style Sheet
//Put into header tags and run as window is loaded

SubmittedOnce = 'no';

browser_version= parseInt(navigator.appVersion);
browser_type = navigator.appName;

if (browser_type == "Netscape" && (browser_version >= 4)) {
document.write("<link REL='stylesheet' HREF='/css/ns.css' TYPE='text/css'>");
}

//*************************
//Pop up centered window
//called by :<a href="http://www.yahoo.com/" onclick="NewWindow(this.href,'name','400','400','yes');return false;">Popup Yahoo.com</a>

function NewWindow(theURL,winname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',screenX='+winl+',screenY='+wint+',scrollbars='+scroll+',resizable'
	win = window.open(theURL, winname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

//*************************
//Pop up centered window as above but with options
//called by :<a href="http://www.yahoo.com/" onclick="NewWindow(this.href,'name','400','400','options-see-below');return false;">Popup Yahoo.com</a>
//options scrollbars=1,menubar=0,status=1,resizeable=0,toolbar=1,location=0,directories=0 0=off 1=on

function NewWindow2(theURL,winname, w, h, options) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',screenX='+winl+',screenY='+wint+','+options
	win = window.open(theURL, winname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

//*************************
//Pop up positioned window
//called by :<a href="http://www.yahoo.com/" onclick="NewWindow(this.href,'name','400','400','0','0','options-see-below');return false;">Popup Yahoo.com</a>
//options scrollbars=1,menubar=0,status=1,resizeable=0,toolbar=1,location=0,directories=0 0=off 1=on

function NewWindow3(theURL,winname, w, h, winl, wint, options) {
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',screenX='+winl+',screenY='+wint+','+options
	win = window.open(theURL, winname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

//*************************
//fullscreen
//called by onload="fullScreen('indexfull.asp','newwindow');"

function fullScreen(theURL,winname) {
	var attribs = "fullscreen,scrollbars"
	attribs += ",width=" + (screen.width-10) + ",height=" + (screen.height-30) + ",top=0,left=0,screenX=0,screenY=0";
	var newWindow = window.open(theURL, winname, attribs);
}

//*************************
//SubmitOnce
//Allow button to be pressed only once

function SubmitOnce(ButtonText, ButtonObject, FormObject) {
	if ( SubmittedOnce == 'no' ){
		ButtonObject.value = ButtonText;
		ButtonObject.disabled = true;
		SubmittedOnce = 'yes';
		document.forms[FormObject].submit();
	}
}

//*************************
//confirm delete
//Allow button to be pressed only once
	function ConfirmDelete (confirmpage) {
		temp = window.confirm('Is it OK to delete this record? \n\nNOTE : This operation is irreversible!');
		
		if (temp) {
			document.location = confirmpage;
		}
	}	
	
	
//*************************
//Rollover for tables
//Highlight on

function changeto(highlightcolor){
	source=event.srcElement
	if (source.tagName=="TR"||source.tagName=="TABLE")
	return
	while(source.tagName!="TR")
	source=source.parentElement
	if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
	source.style.backgroundColor=highlightcolor
}

//Highlight off

function changeback(originalcolor){
	if (event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")
	return
	if (event.toElement!=source)
	source.style.backgroundColor=''
}

//*************************
//Base conversions

//Base n to Dec

var a64 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";

function BaseN2Dec( s, OutputBase) {
	var x = 0, i, t, TempOutputBase, TempArray, packing;
	TempOutPutBase = OutputBase + ",8";
	TempArray = TempOutPutBase.split(",");
	TempOutPutBase = TempArray[0];
	packing = TempArray[1];

	if ((TempOutPutBase < 2) || (TempOutPutBase > a64.length)){
		x = -1;
	}
	else {
		for (i = 0; i < s.length; i++) {
			t = a64.indexOf( s.charAt(i), 0 );
			if ((t >= TempOutPutBase) || (t < 0)){
				x = -1;
				break;
			}
			x = (x * TempOutPutBase) + a64.indexOf( s.charAt(i), 0 );
		}
	}
	return x;
}

//Dec to Base n with x digits (packing=0 no fixed digits)

function Dec2BaseN( x, OutputBase) {
	var s = "", TempOutputBase, TempArray, packing;
	var i, t;
	
	TempOutPutBase = OutputBase + ",8";
	TempArray = TempOutPutBase.split(",");
	TempOutPutBase = TempArray[0];
	packing = TempArray[1];
	
	if ((TempOutPutBase < 2) || (TempOutPutBase > a64.length)){
		s = "-1";
	}
	else {
		if (x == 0){
			s = "0";
		}
		else {
			while (x > 0) {
	            s = a64.charAt( x % TempOutPutBase) + s;
	            x = Math.floor( x / TempOutPutBase );
			}
		}
	}
	if (packing != 0) {
		for (i = s.length; i < packing; i++){
			s = "0" + s;
		}
	} 
	return s;
}

//*************************
//Encrpyt String

function EnCrypt(strCryptThis, Encryption_Key , OutputBase){

		var strChar, iKeyChar, iStringChar, i, TempOutPutBase, TempArray, packing, iCryptChar, strEncrypted, TempKeyChar;
		strEncrypted = "";
		TempOutPutBase = OutputBase + ",8";
		TempArray = TempOutPutBase.split(",");
		TempOutPutBase = TempArray[0];
		packing = TempArray[1];
		
		if (strCryptThis == ""){ 
			strCryptThis = " ";
		}

		out = "\'";
		while (strCryptThis.indexOf(out)>-1) {
			pos= strCryptThis.indexOf(out);
			strCryptThis = "" + (strCryptThis.substring(0, pos) + strCryptThis.substring((pos + 1), strCryptThis.length));
		}
		
		out = "\"";
		while (strCryptThis.indexOf(out)>-1) {
			pos= strCryptThis.indexOf(out);
			strCryptThis = "" + (strCryptThis.substring(0, pos) + strCryptThis.substring((pos + 1), strCryptThis.length));
		}
		
		for (i = 0; i < strCryptThis.length; i++){
			TempKeyChar = Encryption_Key.substr((i*packing), packing);
			iKeyChar = BaseN2Dec(TempKeyChar, OutputBase, packing);
			iStringChar = strCryptThis.charCodeAt(i);
			iCryptChar = iStringChar + iKeyChar;
			if (iCryptChar > 255){
				iCryptChar = iCryptChar - 256;
			}
			iCryptChar = iKeyChar^iStringChar;
			strEncrypted = strEncrypted + Dec2BaseN(iCryptChar, OutputBase);
		}
		return strEncrypted;
}

//*************************
//Encrpyt username and password before send

function PreSend(User, Pass, Encryption_KeyU, Encryption_KeyP, OutputBase){
	
	var TempUser, TempPass;
	
	TempUser = User.value;
	TempPass = Pass.value;
	
	TempUser = EnCrypt(TempUser, Encryption_KeyU, OutputBase);
	TempPass = EnCrypt(TempPass, Encryption_KeyP, OutputBase);
	
	User.value = TempUser;
	Pass.value = TempPass;
	return true;
}

//*************************
//Diag

function Diag(tempVar){
	document.UPForm.debug.value = document.UPForm.debug.value + tempVar + "\n";
}
// -->
