<!--
//***********************************************************************************************************
//# Name                JavaScript.js
//# Version             69.78
//# Modified            01/02/2005 14:30
//# Copyright Rocktime Ltd/Kieron Matthews 2000 - 2005.
//# Not to be used in whole or part without written permission from Rocktime.
//***********************************************************************************************************

//***********************************************************************************************************
// Vars
//***********************************************************************************************************

	var SubmittedOnce;
//	var browser_version;
//	var browser_type;
	var fdRTCCurrentDir;
	var NoMessage;
	SubmittedOnce = 'no';
	NoMessage = false;

//***********************************************************************************************************
// Field Auto Fill
// field = form field, select is array of options,
//***********************************************************************************************************

	function FieldAutoFill (field, select) {
	
		var found = false;
		for (var i = 0; i < select.length; i++)
			if (found = select[i].indexOf(field.value) == 0){
				break;
			}
		if (field.createTextRange) {
			var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;"
			if (cursorKeys.indexOf(event.keyCode+";") == -1) {
				var r1 = field.createTextRange()
				var oldValue = r1.text;
				var newValue = found ? select[i] : oldValue;
				if (newValue != field.value) {
					field.value = newValue
					var rNew = field.createTextRange()
					rNew.moveStart('character', oldValue.length) 
					rNew.select()
				}
			}
		}
		
	}

//***********************************************************************************************************
// Old Versions
//***********************************************************************************************************

	function NewWindow(theURL,winname, w, h, scroll) {
		OpenNewWindow(theURL,winname, w, h, scroll, false)
	}

	function NewWindow2(theURL,winname, w, h, options) {
		OpenNewWindowCentered(theURL,winname, w, h, options, false)
	}

	function NewWindow3(theURL,winname, w, h, winl, wint, options) {
		OpenNewWindowPositioned(theURL,winname, w, h, winl, wint, options, false)
	}

//***********************************************************************************************************
// Open New Window
// called by OpenNewWindow(this.href,'name','400','400','yes', rethandel)
// rethandel = true to return window handel
//***********************************************************************************************************

	function OpenNewWindow(theURL,winname, w, h, scroll, rethandel) {
		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'
		var win = window.open(theURL, winname, winprops)
		win = HandelPopupBlocker(theURL,winname, rethandel, win)
		if (rethandel){return win;}
	}

//***********************************************************************************************************
// Open New Window Centered
// called by OpenNewWindowCentered(this.href,'name','400','400','options-see-below', rethandel)
// options copyhistory,directories,location,menubar,resizable,scrollbars,status,toolbar [include to switch on]
//***********************************************************************************************************

	function OpenNewWindowCentered(theURL,winname, w, h, options, rethandel) {
		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
		var win = window.open(theURL, winname, winprops)
		win = HandelPopupBlocker(theURL,winname, rethandel, win)
		if (rethandel){return win;}
	}

//***********************************************************************************************************
// Open New Window Positioned
// OpenNewWindowPositioned(this.href,'name','400','400','0','0','options-see-below', rethandel)
// options copyhistory,directories,location,menubar,resizable,scrollbars,status,toolbar [include to switch on]
//***********************************************************************************************************

	function OpenNewWindowPositioned(theURL,winname, w, h, winl, wint, options, rethandel) {
		winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',screenX='+winl+',screenY='+wint+','+options
		var win = window.open(theURL, winname, winprops)
		win = HandelPopupBlocker(theURL,winname, rethandel, win)
		if (rethandel){return win;}
	}

//***********************************************************************************************************
// Open New Window Full Screen
// called by OpenNewWindowFullScreen('indexfull.asp','newwindow', rethandel)
//***********************************************************************************************************

	function OpenNewWindowFullScreen(theURL,winname, rethandel) {
		var attribs = "scrollbars"
		attribs += ",width=" + (screen.width-10) + ",height=" + (screen.height-30) + ",top=0,left=0,screenX=0,screenY=0";
		var win = window.open(theURL, winname, attribs);
		win = HandelPopupBlocker(theURL,winname, rethandel, win)
		if (rethandel){return win;}
	}

//***********************************************************************************************************
// HandelPopupBlocker('indexfull.asp','newwindow', rethandel)
// Set NoMessage = true; to stop error message.
//***********************************************************************************************************

	function HandelPopupBlocker(theURL,winname, rethandel, win) {
		if (!win){
			if (NoMessage == false){
				msg = 'You have an popup blocker switched on.\n'
				msg = msg + 'This has prevented this site from working correctly.\n'
				msg = msg + 'You will need to disable it to allow the site to function correctly.\n\n'
				msg = msg + 'Sorry for the inconvenience!'
				alert(msg);
			}
			return false;
		}
		else {
			if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
			if (rethandel){return win;}
		}
		return win;
	}

//***********************************************************************************************************
// 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
// Show confirmation dialog
//***********************************************************************************************************

	function ConfirmDelete (confirmpage) {
		temp = window.confirm('Is it OK to delete this record? \n\nNOTE : This operation is irreversible!');
		if (temp) {
			if (confirmpage == '') {
				return true;
			}
			else {
				document.location = confirmpage;
			}
		}
		if (confirmpage == '') {
			return false;
		}
	}

//***********************************************************************************************************
// confirm delete2
// Show confirmation dialog twice
//***********************************************************************************************************

	function ConfirmDelete2 (confirmpage) {
		temp = window.confirm('Is it OK to delete this record? \n\nNOTE : This operation is irreversible!');

		if (temp) {
			temp2 = window.confirm('Are you REALLY sure you want to delete this record??? \n\nNOTE : This operation REALLY IS irreversible!');
			if (temp2) {
				if (confirmpage == '') {
					return true;
				}
				else {
					document.location = confirmpage;
				}
			}
		}
		if (confirmpage == '') {
			return false;
		}
	}

//***********************************************************************************************************
// confirm delete3
// Show confirmation dialog with custom message
//***********************************************************************************************************

	function ConfirmDelete3 (confirmpage, confirmMessage) {
		temp = window.confirm(confirmMessage);

		if (temp) {
			if (confirmpage == '') {
				return true;
			}
			else {
				document.location = confirmpage;
			}
		}
		if (confirmpage == '') {
			return false;
		}
	}

//***********************************************************************************************************
// confirm delete4
// Show confirmation dialog twice with custom messages
//***********************************************************************************************************

	function ConfirmDelete4 (confirmpage, confirmMessage1, confirmMessage2) {
		temp = window.confirm(confirmMessage1);

		if (temp) {
			temp2 = window.confirm(confirmMessage2);
			if (temp2) {
				if (confirmpage == '') {
					return true;
				}
				else {
					document.location = confirmpage;
				}
			}
		}
		if (confirmpage == '') {
			return false;
		}
	}

//***********************************************************************************************************
// Rollover for tables
// Highlight on
// Highlight Table Cells Script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
// Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
//***********************************************************************************************************

	function changeto(highlightcolor, ee, Count, TDOnly){

		var highlightbehavior=TDOnly?"TD":"TR"
		var ns6=document.getElementById&&!document.all
		var ie=document.all
		var Count=Count?Count:1
		source=ie? event.srcElement : ee.target
		if (source.tagName=="TABLE")
		return
		while(Count>0){
			while(source.tagName!=highlightbehavior && source.tagName!="HTML"){
				source=ns6? source.parentNode : source.parentElement
			}
			Count--;
			if(Count>0){
				source=ns6? source.parentNode : source.parentElement
			}
		}
		if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
		source.style.backgroundColor=highlightcolor

	}

//***********************************************************************************************************
// Rollover for tables
// Highlight off
// Highlight Table Cells Script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
// Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
//***********************************************************************************************************

	function changeback(originalcolor, ee, Count, TDOnly){

		var highlightbehavior=TDOnly?"TD":"TR"
		var ns6=document.getElementById&&!document.all
		var ie=document.all
		var Count=Count?Count:1
		source=ie? event.srcElement : ee.target
		if (source.tagName=="TABLE")
		return
		while(Count>0){
			while(source.tagName!=highlightbehavior && source.tagName!="HTML"){
				source=ns6? source.parentNode : source.parentElement
			}
			Count--;
			if(Count>0){
				source=ns6? source.parentNode : source.parentElement
			}
		}
		if (source.style.backgroundColor!=originalcolor&&source.id!="ignore")
		source.style.backgroundColor=originalcolor

	}

//***********************************************************************************************************
// Highlight off
// Test contains_ns6
// Highlight Table Cells Script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
// Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
//***********************************************************************************************************

	function contains_ns6(master, slave) { //check if slave is contained by master

		while (slave.parentNode)
		if ((slave = slave.parentNode) == master)
		return true;
		return false;

	}

//***********************************************************************************************************
// Form Read Only
//***********************************************************************************************************

	function FormReadOnly(formname, formstate){
		for (ix=0;ix < document.formname.elements.length;ix++){
			document.formname.elements[ix].disabled = formstate;
		}
	}

//***********************************************************************************************************
//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 != ""){
			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;

		if (User){
			TempUser = User.value;
			TempUser = EnCrypt(TempUser, Encryption_KeyU, OutputBase);
			User.value = TempUser;
		}

		if (Pass){
			TempPass = Pass.value;
			TempPass = EnCrypt(TempPass, Encryption_KeyP, OutputBase);
			Pass.value = TempPass;
		}

		return true;
	}

//***********************************************************************************************************
// Diag
//***********************************************************************************************************

	function Diag(tempVar){
		document.UPForm.debug.value = document.UPForm.debug.value + tempVar + "\n";
	}

//***********************************************************************************************************
// 	OverLib HTML Fix
//***********************************************************************************************************

	function OverLibHTMLFix(tempVar){
		tempVar = tempVar.replace(/\n/ig, '<BR>');
		tempVar = tempVar.replace(/(<table[^>]*>)([\n|.]*)(<tr[^>]*>)/ig, '$1$2');
		tempVar = tempVar.replace(/(<tr[^>]*>)([\n|.]*)(<td[^>]*>)/ig, '$1$2');
		tempVar = tempVar.replace(/(<\/tr[^>]*>)([\n|.]*)(<tr[^>]*>|<\/table[^>]*>)/ig, '$1$2');
		tempVar = tempVar.replace(/(<\/td[^>]*>)([\n|.]*)(<td[^>]*>|<\/tr[^>]*>)/ig, '$1$2');
		return tempVar;
	}

//***********************************************************************************************************
// 	FitPic (Call from onload)
//***********************************************************************************************************

	function FitPic(ExtraX, ExtraY) {
		var NS = (navigator.appName=="Netscape")?true:false;
		iWidth = (NS)?window.innerWidth:document.body.clientWidth;
		iHeight = (NS)?window.innerHeight:document.body.clientHeight;
		iWidth = document.images[0].width - iWidth + ExtraX;
		iHeight = document.images[0].height - iHeight + ExtraY;
		window.resizeBy(iWidth, iHeight);
		self.focus();
	};

//***********************************************************************************************************
// 	Resize Page (Call from onload)
//***********************************************************************************************************

	function ResizePage(Wx, Wy) {
		var NS = (navigator.appName=="Netscape")?true:false;
		iWidth = (NS)?window.innerWidth:document.body.clientWidth;
		iHeight = (NS)?window.innerHeight:document.body.clientHeight;
		iWidth = Wx - iWidth;
		iHeight = Wy - iHeight;
		window.resizeBy(iWidth, iHeight);
		self.focus();
	};

//***********************************************************************************************************
// Other JS includes
//***********************************************************************************************************


// -->
