this.VersionDate = '01-06-2004,1';
this.Develop = true;
this.ReloadAll	= false;

var bName = navigator.appName;
var bVer = navigator.appVersion;

var ns4 = false;
var ns6 = false;
var ns7 = false;
if( bName == "Netscape" ){
	ns4 = ( parseInt( bVer ) == 4 );
	ns6 = ( parseInt( bVer ) == 6 );
	ns7 = ( parseInt( bVer ) == 7 );
}
var ie4 = false;
var ie5 = false;
var W3C = document.getElementById ? true:false;
if( bName == "Microsoft Internet Explorer" ){
//	alert( bVer ) ;
	ie4 = ( bVer.search( 'MSIE 4' ) > 0 ? true:false );
	ie5 = ( bVer.search( 'MSIE 5' ) > 0 ? true:false );
}

/* This function/object checks for Internet Security software */
function checkIS( opWindow, lpConstruct ){
	if( !lpConstruct )
		return ( new checkIS( opWindow, true ) );
	else{
		opWindow = ( typeof opWindow == 'object' ? opWindow : window );
		this.IS = false; this.Continue = true;
		var cOnError = new String( opWindow.onerror ), cOpen = new String( opWindow.open );
		if( opWindow.onerror && cOnError.search( 'native' ) <= -1 && cOnError.search( 'fdOnError' ) <= -1 ){
			this.IS				= true;
			opWindow.onerror	= null;
		}
		if( opWindow.open && ( ( !Browser.safari && cOpen.search( 'native' ) <= -1 ) || ( Browser.safari && cOpen != '[function]' ) ) ){
			this.IS				= true;
			if( opWindow.SymRealWinOpen )
				opWindow.open	= opWindow.SymRealWinOpen;
			else
				this.Continue	= false;
		}
	}
}

function objBrowser(){
	this.Name = navigator.appName; this.Version = navigator.appVersion; this.VersionNr = parseInt( this.Version );
	
	this.win = navigator.userAgent.search( 'Windows' ) > 0;
	this.linux = navigator.userAgent.search( 'Linux' ) > 0;
	this.mac = navigator.userAgent.search( 'Macintosh' ) > 0;
	
	this.opera = ( navigator.userAgent.search( 'Opera' ) > 0 );
	this.gecko = ( navigator.userAgent.search( 'Gecko/' ) > 0 );
	this.ns = ( navigator.userAgent.search( 'Netscape' ) > 0 );
	this.ns4 = false; this.ns6 = false; this.ns7 = false; this.ns8 = false;
	if( this.ns ){
		this.VersionNr = parseFloat(navigator.userAgent.match( /Netscape(\d)?\/(.*)/ )[2]);
		this.ns4 = ( parseInt( this.Version ) == 4 );
		this.ns6 = ( navigator.userAgent.search( 'Netscape6' ) > 0 ); //parseInt( this.Version ) >= 5 );
		this.ns7 = ( navigator.userAgent.search( 'Netscape/7' ) > 0 );
		this.ns8 = ( navigator.userAgent.search( 'Netscape/8' ) > 0 );
	}
	
	this.ie = ( this.Name == "Microsoft Internet Explorer" ); this.ie4 = false; this.ie5 = false; this.ie6 = false;
	if( this.ie ){
		this.VersionNr = parseFloat(this.Version.match( /MSIE (\d+.\d+)/ )[1]);
		this.ie4 = ( this.Version.search( 'MSIE 4' ) > 0 );
		this.ie5 = ( this.Version.search( 'MSIE 5' ) > 0 );
		this.ie6 = ( this.Version.search( 'MSIE 6' ) > 0 );
	}
	
	this.safari = ( this.mac && navigator.userAgent.search( 'Safari' ) > 0 );
	if( this.safari )
		this.VersionNr = parseFloat(this.Version.match( /Safari\/(\d+.\d+)/ )[1]);
	this.camino = ( navigator.userAgent.search( 'Camino' ) > 0 );
	if( this.camino )
		this.VersionNr = parseFloat(navigator.userAgent.match( /Camino\/(.*)/ )[1]);
	
	
	this.W3C = document.getElementById ? true:false;
	
	this.isComp = function(npLvl){
		var lComp = false;
		if( npLvl > 0 ){
			lComp = this.gecko && ( !this.ns || this.VersionNr >= 7 );
			if( !lComp && this.win ) lComp = ( this.ie && this.VersionNr >= 5.5 );
		}
		return lComp;
	}
}

this.Browser = new objBrowser();

function setStatus( cpStatus, opWnd ){
	var lGlobal = ( isObject( top.Global ) );
	opWnd = opWnd || window;
	opWnd.status = ( ( lGlobal ) ? top.Global.Status : '' ) + ( ( typeof cpStatus == 'string' && cpStatus != '' ) ? ( ( lGlobal ) ? ': ' : '' ) + cpStatus : '' );
	return true;
}

function addActionVar( opForm, cpVar, lpReplace ){
	var aAction = opForm.action.split( '?' );
	var cAction = aAction[ 0 ] + ( ( lpReplace || aAction.length == 1 ) ? '?' : aAction[ 1 ] + '&' ) + cpVar;
	opForm.action = cAction;
}

function getCookies( cpCookies ){
	var aCookies = cpCookies.split( '; ' );
	
	// de cookies en waarden scheiden
	var i		= 0;
	for( i = 0; i < aCookies.length; i++ ){
		aCookies[ i ] = aCookies[ i ].split( '=' );
		if( aCookies[ i ][ 0 ] == 'undefined' ) aCookies[ i ][ 0 ] = '';
		if( aCookies[ i ][ 1 ] == 'undefined' ) aCookies[ i ][ 1 ] = '';
	}
	return aCookies;
}

function getCookie( cpCookies, cpCookie ){
	var aCookies = getCookies( cpCookies );
	var nIndex = arraySearch( aCookies, cpCookie, 0 );
	if( nIndex >= 0 )
		return aCookies[ nIndex ][ 1 ];
	else
		return false;
}

function setCookies( cpCookies, apCookies ){
	// cookies van elkaar scheiden
	var aCookies	= getCookies( cpCookies );

	// zoeken en vervangen/toevoegen van de meegegeven cookie/waarde array
	if( typeof apCookies != 'undefined' ){
		var nIndex, i;
		for( i = 0; i < apCookies.length; i = i + 2 ){
			nIndex = arraySearch( aCookies, apCookies[ i ], 0 )
			nIndex = ( nIndex > -1 ) ? nIndex : aCookies.length;
			aCookies[ nIndex ] = new Array( apCookies[ i ], apCookies[ i + 1 ] );
		}
	}
	
	cpCookies = '';
	for( i = 0; i < aCookies.length; i++ ){
		cpCookies = cpCookies + ( ( i > 0 ) ? '; ' : '' ) +
			aCookies[ i ][ 0 ] + ( ( aCookies[ i ][ 0 ].length > 0 ) ? '=' : '' ) + aCookies[ i ][ 1 ];
	}
	return cpCookies;
}

function getLocationVars( cpLocation ){
	// de pagina en de parameters scheiden
	var aLocation = cpLocation.split( '?' ), cBookmark = '';
	// de parameters scheiden
	if( aLocation.length > 1 ){
		var nBM = aLocation[ 1 ].search( '#' );
		if( nBM >= 0 ){
			cBookmark = aLocation[ 1 ].substr( nBM );
			aLocation[ 1 ] = aLocation[ 1 ].substr( 0, nBM );
		}
		aLocation[ 1 ] = aLocation[ 1 ].split( '&' );
	}else
		aLocation[ 1 ] = new Array();
	
	// de parameters en de waarden scheiden
	var i = 0;
	for( i = 0; i < aLocation[ 1 ].length; i++ ){
		aLocation[ 1 ][ i ] = aLocation[ 1 ][ i ].split( '=' );
		if( typeof aLocation[ 1 ][ i ][ 0 ] == 'undefined' ) aLocation[ 1 ][ i ][ 0 ] = '';
		if( typeof aLocation[ 1 ][ i ][ 1 ] == 'undefined' ) aLocation[ 1 ][ i ][ 1 ] = '';
	}
	if( cBookmark.length > 0 )
		aLocation[ 1 ][ i ] = new Array( cBookmark );
	
	return aLocation;
}

function getLocationVar( cpLocation, cpVar ){
	var aLocation = getLocationVars( cpLocation );
	var nIndex = arraySearch( aLocation[ 1 ], cpVar, 0 );
	if( nIndex >= 0 )
		return aLocation[ 1 ][ nIndex ][ 1 ];
	else
		return false;
}

function setLocationVars( cpLocation, apVars, lpNoBookmark ){
	// de pagina en de parameters scheiden
	var aLocation = getLocationVars( cpLocation ), cBookmark = '';
	
	// zoeken en vervangen/toevoegen van de meegegeven parameter/waarde array
	if( apVars ){
		var nIndex, i;
		for( i = 0; i < apVars.length; i = i + 2 ){
			nIndex = arraySearch( aLocation[ 1 ], apVars[ i ], 0 )
			nIndex = ( nIndex > -1 ) ? nIndex : aLocation[ 1 ].length;
			aLocation[ 1 ][ nIndex ] = new Array( apVars[ i ], apVars[ i + 1 ] );
		}
	}
	
	// de locatiestring weer opbouwen
	cpLocation = aLocation[ 0 ] + '?';
	for( i = 0; i < aLocation[ 1 ].length; i++ ){
		if( aLocation[ 1 ][ i ][ 0 ].charAt( 0 ) != '#' ){
			if( aLocation[ 1 ][ i ][ 0 ] != 'undefined' )
				cpLocation = cpLocation + ( ( i > 0 ) ? '&' : '' ) +
					aLocation[ 1 ][ i ][ 0 ] + ( ( aLocation[ 1 ][ i ][ 0 ].length > 0 ) ? '=' : '' ) + aLocation[ 1 ][ i ][ 1 ];
		}else
			cBookmark = aLocation[ 1 ][ i ][ 0 ];
	}
	
	return ( cpLocation + ( !lpNoBookmark ? cBookmark : '' ) );
}

function delLocationVars( cpLocation, apVars ){
	// de pagina en de parameters scheiden; de parameters scheiden
	var aLocation = cpLocation.split( '?' ), aQueryVars = ( aLocation.length > 1 ) ? aLocation[ 1 ].split( '&' ) : new Array();
	
	// de parameters en de waarden scheiden
	var i = 0, nIndex = -1;
	for( i = 0; i < aQueryVars.length; i++ )
		aQueryVars[ i ] = aQueryVars[ i ].split( '=' );
	
	// de locatiestring weer opbouwen
	cpLocation = aLocation[ 0 ] + '?';
	for( i = 0; i < aQueryVars.length; i++ ){
		if( arraySearch( apVars, aQueryVars[ i ][ 0 ], 0 ) == -1 ){
			cpLocation = cpLocation + ( ( i > 0 ) ? '&' : '' ) +
				aQueryVars[ i ][ 0 ] + ( ( aQueryVars[ i ][ 0 ].length > 0 ) ? '=' : '' ) + aQueryVars[ i ][ 1 ];
		}
	}
	return cpLocation;
}

function arraySearch( apArray, vpSearchFor, npColumn, npColumns, npStart ){
	if( apArray.length == 0 ) return -1;
	npColumn = ( typeof npColumn == 'undefined' ) ? 0 : npColumn;
	npColumns = ( typeof npColumns == 'undefined' ) ? 1 : npColumns;
	npStart = ( typeof npStart == 'undefined' ) ? 0 : npStart;
	var i = 0, l2d = ( isObject( apArray[ 0 ] ) && typeof apArray[ 0 ][ 0 ] != 'undefined' );
	if( l2d ){
		for( i = npStart; i < apArray.length; i++ ){
			if( ( typeof apArray[ i ][ npColumn ] == 'string' && apArray[ i ][ npColumn ].toUpperCase() == String( vpSearchFor ).toUpperCase() ) || apArray[ i ][ npColumn ] == vpSearchFor )
				return i;
		}
	}else{
		for( i = npStart + npColumn; i < apArray.length; i = i + npColumns ){
			if( ( typeof apArray[ i ] == 'string' && apArray[ i ].toUpperCase() == String( vpSearchFor ).toUpperCase() ) || apArray[ i ] == vpSearchFor )
				return i;
		}
	}
	return -1;
}

function arrayDelete( apArray, npIndexFrom, npIndexTo ){
	if( npIndexFrom < 0 ) return apArray;
	npIndexTo = npIndexFrom + ( typeof npIndexTo == 'undefined' ? 1 : npIndexTo );
	var aTemp = null;
	if( apArray.length == 1 && npIndexFrom == 0 )
		aTemp = new Array();
	else {
		if( npIndexFrom > 0 )
			aTemp = apArray.slice( 0, npIndexFrom );
		if( npIndexFrom >= 0 && npIndexFrom < apArray.length - 1 )
			aTemp = ( aTemp != null ? aTemp.concat( apArray.slice( npIndexTo ) ) : apArray.slice( npIndexTo ) );
	}

	return ( aTemp );
}

function arrayMove( apArray, npFrom, npTo ){
	if( npFrom == npTo ) return apArray;
	
	var vElement = apArray[ npFrom ], i = 0;
	if( npFrom < npTo ){
		for( i = npFrom; i < npTo; i++ )
			apArray[ i ] = apArray[ i + 1 ];
	} else {
		for( i = npFrom; i > npTo; i-- )
			apArray[ i ] = apArray[ i - 1 ];
	}
	apArray[ npTo ] = vElement;
	
	return apArray;
}

function arraySort( apArray, npColl ){
	var i = 0, j = 0, nIndex = 0, lColl = typeof( npColl ) == 'number';
	for( i = 0; i < apArray.length; i++ ){
		nIndex = i;
		for( j = i; j < apArray.length - 1; j++ ){
			if( lColl ){
				if( apArray[ j + 1 ][ npColl ] < apArray[ nIndex ][ npColl ] ) nIndex = j + 1;
			}else if( apArray[ j + 1 ] < apArray[ nIndex ] ) nIndex = j + 1;
		}
		arrayMove( apArray, nIndex, i );
	}
	
	return apArray;
}

function URLEncode( cpString, cpSAFECHARS, lpUrl ){
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()" + ( cpSAFECHARS || '' ); // RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var cEncoded = "";
	for( var i = 0; i < cpString.length; i++ ){
		var ch = cpString.charAt(i);
		if (ch == " ") {
			cEncoded += ( lpUrl ? "%20" : "+" );				// x-www-urlencoded, rather than %20
		}else if( SAFECHARS.indexOf(ch) != -1 ){
			cEncoded += ch;
		}else{
			var charCode = ch.charCodeAt(0);
			cEncoded += "%";
			cEncoded += HEX.charAt((charCode >> 4) & 0xF);
			cEncoded += HEX.charAt(charCode & 0xF);
		}
	} // for

	return cEncoded;
}
function URLEncodeFull( cpString ){
	var aUrl = cpString.match(/(http(s?)\:\/\/)?([^\?]+)(\?(.*))?/); // MSIE 5.0 compatible
	// ((?:http(?:s?))\:\/\/)?([^\?]+)(?:\?(.*))? // MSIE 5.5+ compatible
	if( aUrl ) return ( aUrl[1] + URLEncode( aUrl[3], '/%', true ) + ( aUrl[5] && aUrl[5].length > 0 ? '?' + URLEncode( aUrl[5], '&=' ) : '' ) );
	else return ( '' );
}
function URLDecode( cpString ){
   // Replace + with ' '
   // Replace %xx with equivalent character
   var cDecoded = "", i = 0;
   while( i < cpString.length ){
       var ch = cpString.charAt(i);
	   if( ch == "+" ){
	       cDecoded += " ";
		   i++;
	   }else if( ch == "%" && cpString.charAt( i + 1 ) != "%" ){
	       cDecoded += unescape( cpString.substr( i, 3 ) );
		   i += 3;
		}else{
		   cDecoded += ch;
		   i++;
		}
	} // while
	if( i < cpString.length ){
	    cDecoded += cpString.substr( i, cpString.length - i );
	}
	
	return unescape( cDecoded );
}

function OpenWindow( opWindow, cpPage, npWidth, npHeight, cpScroll, cpStatus, cpToolbar, cpName, opParentProp, lpDialog, vpArg ){
	var lParent = ( typeof opParentProp == 'object' ), cScroll = ( cpScroll ? cpScroll : 'yes' );
	var cStatus = ( cpStatus ? cpStatus : 'yes' ), cToolbar = ( cpToolbar ? cpToolbar : 'no' );
	var nAvailWidth = 0, nAvailHeight = 0, oDim = new getWindowDim( window, true );
	//if( window.screen ){
		nAvailWidth = oDim.availWidth; //window.screen.availWidth;
		nAvailHeight = oDim.availHeight; //window.screen.availHeight;
	//}
	var nWidth = 0, nHeight = 0, nTop = 0, nLeft = 0;
	npWidth = ( typeof npWidth == 'undefined' ? ( lParent ? 0 : nAvailWidth ) : ( npWidth > nAvailWidth ? nAvailWidth : npWidth ) );
	npHeight = ( typeof npHeight == 'undefined' ? ( lParent ? 0 : nAvailHeight ) : ( ( npHeight + 32 ) >= nAvailHeight ? nAvailHeight - 50 : npHeight ) );
	lpDialog = lpDialog && Browser.ie;
	
	if( lParent ){
		var oWnd = opParentProp.Window;
		oDim = new getWindowDim( oWnd, true );
		nWidth = oDim.outerWidth, nHeight = oDim.outerHeight, nTop = oDim.Top, nLeft = oDim.Left;

		nWidth	= nWidth - opParentProp.offsetWidth - 12 - ( Browser.ie ? 6 : 0 ); //scrollbar;  && cScroll != 'yes'
		nHeight	= nHeight - opParentProp.offsetHeight - 26 - ( cStatus == 'yes' ? 37 : 0 );
		nTop	= nTop + ( opParentProp.offsetHeight / 2 );
		nLeft	= nLeft + ( opParentProp.offsetWidth / 2 );
	}
	nWidth	= Math.max( nWidth, npWidth );
	nHeight	= Math.max( nHeight, npHeight );
	
	if( !lParent || ( nLeft + nWidth > nAvailWidth ) )
		nLeft	= ( nAvailWidth / 2 ) - ( ( nWidth + ( cScroll == 'yes' ? 8 : 0 ) ) / 2 );
	if( !lParent || ( nTop + nHeight > nAvailHeight ) )
		nTop	= ( nAvailHeight / 2 ) - ( nHeight / 2 ) - 25;
	if( nTop < 0 ) nTop = 0;
	var oFromWindow = ( ( isObject( opWindow ) ) ? opWindow : window ), oWindow = null, vReturn;
	if( lpDialog )
		vReturn = oFromWindow.showModalDialog( cpPage, ( vpArg ? vpArg : window ), 'dialogWidth:' + nWidth + 'px;dialogHeight:' + nHeight + 'px;center:yes;scroll:' + cScroll + ';status:' + cStatus );
	else
		oWindow = oFromWindow.open( cpPage, ( cpName ? cpName : '' ), 'toolbar=' + cToolbar + ',directories=no,menubar=no,status=' + cStatus + ',resizable=yes,scrollbars=' + cScroll + ',top=' + nTop + ',left=' + nLeft + ',width=' + nWidth + ',height=' + nHeight ) ;

	return ( lpDialog ? vReturn : ( isObject( oWindow, 'document' ) ? oWindow : null ) );
}

function maximizeWindow( npMaxWidth, npMaxHeight ){
	var nAvailWidth = window.screen.availWidth, nAvailHeight = window.screen.availHeight;
	var nWidth = ( npMaxWidth > nAvailWidth ) ? nAvailWidth : npMaxWidth;
	var nHeight = ( ( npMaxHeight + 32 ) >= nAvailHeight ) ? nAvailHeight - 50 : npMaxHeight;
	var nLeft = ( nAvailWidth / 2 ) - ( nWidth / 2 );
	var nTop = ( nAvailHeight / 2 ) - ( nHeight / 2 ) - 25;
	if( nTop < 0 ) nTop = 0;
	window.moveTo( nLeft, nTop );
	window.resizeTo( nWidth, nHeight );
}

function centerWindow( opWnd ){
	var oDim = new getWindowDim( opWnd, true );
	var nTop = Math.max( ( oDim.availHeight / 2 ) - ( oDim.outerHeight / 2 ) - ( Browser.ie ? 25 : 0 ), 0 );
	var nLeft = Math.max( ( oDim.availWidth / 2 ) - ( oDim.outerWidth / 2 ), 0 );
	opWnd.moveTo( nLeft, nTop );
//	oDim = new getWindowDim( opWnd, true );
//	alert(oDim.availWidth+ '; '+nTop+', ' + nLeft+'; '+oDim.Top+', '+oDim.Left + ', ' + oDim.outerWidth+', ' + opWnd.scrollbars);
}

function getWindowDim( opWnd, lpCreated ){
	if( !lpCreated ) return ( new getWindowDim( opWnd, true ) );

	this.outerWidth=0,this.outerHeight=0,this.clientWidth=0,this.clientHeight=0,this.scrollTop=0,this.scrollLeft=0;
	this.Top=0,this.Left=0,this.availWidth=opWnd.screen.availWidth,this.availHeight=opWnd.screen.availHeight;
	with( this ){
		if( Browser.gecko || Browser.safari ){
			availHeight		= availHeight - 56;
			Top				= opWnd.screenY;
			Left			= opWnd.screenX;
			outerWidth		= opWnd.outerWidth;
			outerHeight		= opWnd.outerHeight + 2;
			clientWidth		= opWnd.innerWidth;
			clientHeight	= opWnd.innerHeight;
			scrollTop		= opWnd.pageYOffset;
			scrollLeft		= opWnd.pageXOffset;
		}else if( Browser.ie ){
			availHeight		= availHeight - 60;
			Top				= opWnd.screenTop;
			Left			= opWnd.screenLeft;
			if( opWnd.document.body ){
				outerWidth		= opWnd.document.body.offsetWidth + 6; // -6 voor de scrollbar
				outerHeight		= opWnd.document.body.offsetHeight;
				clientWidth		= opWnd.document.body.clientWidth;
				clientHeight	= opWnd.document.body.clientHeight;
				scrollTop		= opWnd.document.body.scrollTop;
				scrollLeft		= opWnd.document.body.scrollLeft;
			}
		}
	}
}

function Select( opDocument, vpElement, lpNoError ){
	var oElement = getElement( opDocument, vpElement );
	if( typeof oElement[0] != 'undefined' && ( typeof oElement.tagName == 'undefined' || oElement.tagName != 'SELECT' ) ) oElement = oElement[0];
	if( typeof oElement.type != 'undefined' && oElement.type == 'hidden' ) return;
	if( ( typeof oElement.disabled == 'undefined' || !oElement.disabled ) && ( typeof oElement.readOnly == 'undefined' || !oElement.readOnly ) ){
		if( Browser.W3C ){
			try{
				if( typeof oElement.focus != 'undefined' ) oElement.focus() ;
				if( typeof oElement.select != 'undefined' ) oElement.select() ;
			}catch(e){
				alert( 'Error selecting/focussing element with ID: ' + vpElement );
			}
		}else{
			if( typeof oElement.focus != 'undefined' ) oElement.focus() ;
			if( typeof oElement.select != 'undefined' ) oElement.select() ;
		}
	}
	else if( !lpNoError ){
		var cMessage = 'Er is een fout opgetreden!.%0D%0DWij verzoeken u de volgende gegevens door te geven:%0D';
		cMessage += 'De focus kan niet verplaatst worden naar het besturingselement met de naam \'';
		if( typeof vpElement == 'string' )
			cMessage += vpElement;
		if( typeof vpElement == 'object' ){
			if( typeof vpElement.name != 'undefined' && typeof vpElement.name == 'string' )
				cMessage += vpElement.name;
			else
				cMessage += '<niet bekend>';
		}
		cMessage += '\'.';
		alert( unescape( cMessage ) );
	}
}

function SwapImage( opDocument, cpImgName, cpImg, cpImgDir ){
	opDocument.images[ cpImgName ].src = ( typeof cpImgDir != 'undefined' ? cpImgDir : 'images/' ) + cpImg ;
}

function isObject( vpEl, cpTest ){
	return ( vpEl != null && ( typeof( vpEl ) == 'object' || typeof( vpEl ) == 'function' ) && ( typeof cpTest == 'undefined' || ( eval( 'typeof vpEl.' + cpTest  ) != 'undefined' && eval( 'typeof vpEl.' + cpTest  ) != 'unknown' ) ) );
}
function isString( a ){
	return ( typeof a == 'string' );
}
function isArray( a ){
    return ( isObject( a ) && a.constructor == Array );
}
function isCollection( a ){
	return ( isObject( a ) && typeof( a[0] ) != 'undefined' );
}

// depricated; use isEmpty instead
function CheckEmpty( cpString, lpNoLength ){
	return isEmpty( cpString, lpNoLength );
}
function isEmpty( cpStr, lpNoLength ){
	if( typeof( cpStr ) == 'undefined' || cpStr == null ) return true;
	var cStr = cpStr, cChar = '';
	if( cStr.length == 0 ){
		if( lpNoLength ) return false;
		return true;
	}
	var i = 0;
	for( i = 0; i < cStr.length; i++ ){
		cChar = cStr.charAt( i );
		if( cChar != ' ' && escape( cChar ) != '%0D' && escape( cChar ) != '%0A' )
			return false;
	}
	return true;
}
function isEmptyVal( opDoc, vpEl ){
	var oEl = getElement( opDoc, vpEl );
	if( !isObject( oEl ) ) return true;
	if( typeof oEl.tagName == 'undefined' && typeof oEl[0] != 'undefined' )
		return getSelectedOption( null, oEl, 2 ) == -1;
	else return isEmpty( oEl.value );
}

function inList(){
	var vValue = arguments[ 0 ];
	for( var i = 1; i < arguments.length; i++ ){
		if( vValue == arguments[ i ] )
			return true;
	}
	return false;
}
function inBetween( npTestVal, npLowVal, npHighVal ){
	return ( npTestVal >= npLowVal && npTestVal <= npHighVal );
}

function getElement( opDocument, vpElement ){
	var oElement = null;
	if( isObject( vpElement ) ) return vpElement;
	if( !isObject( opDocument ) ) return oElement;
	
	if( this.Browser.W3C ){
		if( typeof opDocument.getElementsByName == 'function' ){
			oElement = opDocument.getElementsByName( vpElement );
		}
		if( !isObject( oElement ) || oElement.length == 0 ){ //|| oElement[ 0 ].name == 'undefined'
			//alert('getbyid: ' + vpElement+ ', ' + oElement.length);
			oElement = ( typeof opDocument.getElementById == 'function' ) ? opDocument.getElementById( vpElement ) : null;
		}else{
			if( oElement.length == 1 )
				oElement = oElement[ 0 ];
		}
	}
	
	if( isObject( oElement ) )
		return oElement;
	
	if( typeof opDocument.forms != 'undefined' && opDocument.forms.length > 0 )
		oElement = opDocument.forms[ 0 ].elements[ vpElement ];
	
	if( isObject( oElement ) )
		return oElement;
	if( this.Browser.ie )
		oElement = opDocument.all[ vpElement ];
	if( this.Browser.ns4 ){
		var i = 0;
		if( typeof opDocument.layers != 'undefined' ){
			for( i = 0; i < opDocument.layers.length; i++ ){
				if( opDocument.layers[ i ].id == vpElement )
					oElement = opDocument.layers[ i ];
			}
		}
	}
	
	return oElement;
}

function getElementByIndex( opElementFrom, npIndex ){
	var oElement = null;
	if( this.Browser.W3C ){ //this.Browser.ie && this.Browser.VersionNr >= 4 ){
		if( opElementFrom.all )
			oElement = opElementFrom.all[ npIndex ];
		else if( opElementFrom.elements )
			oElement = opElementFrom.elements[ npIndex ];
	}
	if( this.Browser.ns ){
		if( opElementFrom.elements )
			oElement = opElementFrom.elements[ npIndex ];
		else if( opElementFrom.forms && opElementFrom.forms.length > 0 && npIndex <= opElementFrom.forms[0].elements.length )
			oElement = opElementFrom.forms[0].elements[ npIndex ];
	}
	return oElement;
}

function focusElement( opElFrom, vpEl ){
	if( opElFrom.forms && opElFrom.forms.length == 0 ) return;
	var oEl, i, lFocus = false;
	if( typeof vpEl == 'string' )
		oEl = getElement( opElFrom, vpEl );
	else if( typeof vpEl == 'number' ){
		var nEl = ( vpEl < 0 ) ? 0 : vpEl, l;
		oEl = getElementByIndex( opElFrom, nEl );
		while( isObject( oEl ) ){
			//alert(oEl.name);
			if( typeof oEl[0] != 'undefined' && ( typeof oEl.tagName == 'undefined' || oEl.tagName != 'SELECT' ) ){
				while( i < oEl.length && !l )
					l = checkFocus( oEl[i], vpEl );
				if( l ) break;
			}else{
				if( checkFocus( oEl, vpEl ) ) break;
			}
			nEl++;
			oEl = getElementByIndex( opElFrom, nEl );
		}
	}else
		oEl = vpEl;
	if( isObject( oEl ) ){
		if( typeof oEl[0] != 'undefined' && ( typeof oEl.tagName == 'undefined' || oEl.tagName != 'SELECT' ) ){
			while( i < oEl.length && !( lFocus = focusElement( opElFrom, oEl[i] ) ) )
				i++;
		}else if( typeof oEl.focus != 'undefined' ){
			l = !oEl.disabled && ( !oEl.style || ( oEl.style.display != 'hide' && oEl.style.visibility != 'hidden' ) );
			if( l ){
				if( Browser.ns && Browser.VersionNr < 5 ){
					oEl.focus();
					lFocus = true;
				}else{
					eval( 
						"try{" +
							"oEl.focus(); lFocus = true;" +
						"}catch(e){ lFocus = false; }"
					);
				}
			}
		}
	}
	return ( lFocus );
}
function checkFocus( opEl, npEl ){
	var l = !opEl.disabled && ( !opEl.style || ( opEl.style.display != 'hide' && opEl.style.visibility != 'hidden' ) );
	if( npEl < 0 && ( typeof opEl.value != 'undefined' || typeof opEl.checked != 'undefined' ) && l )
		return true;
	if( npEl >= 0 && typeof opEl.focus != 'undefined' && l )
		return true;
	return false;
}

function setDisabled( opDocument, vpObject, lpDisabled, lpAdvanced, lpDontEmptyValue, cpBgColor, lpNoEvents ){
	if( typeof cpBgColor != 'string' ) cpBgColor = '#E1E1E1';
	if( isArray( vpObject ) ){
		for( var i = 0; i < vpObject.length; i++ )
			setDisabled( opDocument, vpObject[ i ], lpDisabled, lpAdvanced, lpDontEmptyValue, cpBgColor );
		return;
	}
	var oEl = getElement( opDocument, vpObject ), lArray = ( oEl && typeof oEl[0] != 'undefined' );
	if( isObject( oEl ) ){ //&& ( lArray || typeof oEl.disabled != 'undefined' ) ){
		if( lArray && ( typeof oEl.tagName == 'undefined' || oEl.tagName != 'SELECT' ) ){
			var i;
			for( i = 0; i < oEl.length; i++ ){
				if( typeof oEl[ i ].disabled != 'undefined' && oEl[ i ].disabled != lpDisabled ){
					oEl[ i ].disabled = lpDisabled;
					if( typeof oEl[ i ].type != 'undefined' && ( oEl[ i ].type == 'checkbox' || oEl[ i ].type == 'radio' ) ){
						if( !lpDontEmptyValue ){
							if( lpDisabled ){
								oEl[ i ].oldValue = oEl[ i ].checked;
								oEl[ i ].checked = false;
							}else
								oEl[ i ].checked = oEl[ i ].oldValue;
							if( oEl[ i ].onclick && !lpNoEvents )
								fireEvent( oEl[ i ], 'onclick' );
							
						}
						if( i == oEl.length - 1 )
							setDisabled( document, 'alt' + oEl[ i ].name, lpDisabled || !oEl[ i ].checked, true );
					}
					//if( lpAdvanced )
					//	setDisabledStyle( oEl[ i ], lpDisabled, cpBgColor );
				}
			}
		}else{
			if( oEl.disabled != lpDisabled && ( typeof oEl.disabled != 'undefined' || lpDisabled ) ){
				oEl.disabled = lpDisabled;
				if( typeof oEl.tagName != 'undefined' ){
					if( oEl.tagName == 'IMG' || oEl.tagName == 'TD' ){
						var cClass = oEl.getAttribute( 'fdClassD' );
						if( cClass ){
							if( lpDisabled ){
								oEl.oldClass = oEl.className;
								oEl.className = cClass;
								oEl.focus = '0';
							}else{
								if( oEl.getAttribute( 'fdClass' ) )
									oEl.className = oEl.getAttribute( 'fdClass' );
								else
									oEl.className = oEl.oldClass;
							}
						}
						if( lpDisabled ){
							oEl.oldClick = oEl.onclick; oEl.oldMouseOver = oEl.onmouseover; oEl.oldMouseOut = oEl.onmouseout;
							oEl.onclick = null; oEl.onmouseover = null, oEl.onmouseout = null;
						}else{
							oEl.onclick = oEl.oldClick; oEl.onmouseover = oEl.oldMouseOver; oEl.onmouseout = oEl.oldMouseOut;
							oEl.oldClick = null; oEl.oldMouseOver = null; oEl.oldMouseOut = null;
						}
					}else if( !lpDontEmptyValue ){
						if( oEl.tagName == 'SELECT' ){
							if( lpDisabled ){
								oEl.oldValue = oEl.selectedIndex;
								oEl.selectedIndex = -1;
							}else if( typeof oEl.oldValue != 'undefined' )
								oEl.selectedIndex = oEl.oldValue;
							if( !lpNoEvents )
								fireEvent( oEl, 'onchange' );
						}else if( ( oEl.tagName == 'INPUT' && oEl.type == 'text' ) || oEl.tagName == 'TEXTAREA' ){
							if( lpDisabled ){
								oEl.oldValue = oEl.value;
								oEl.value = '';
							}else if( typeof oEl.oldValue != 'undefined' )
								oEl.value = oEl.oldValue;
							if( !lpNoEvents )
								fireEvent( oEl, 'onchange' );
						}else if( oEl.tagName == 'INPUT' && ( oEl.type == 'checkbox' || oEl.type == 'radio' ) ){
							if( lpDisabled ){
								oEl.oldValue = oEl.checked;
								oEl.checked = false;
							}else if( typeof oEl.oldValue != 'undefined' )
								oEl.checked = oEl.oldValue;
							if( !lpNoEvents )
								fireEvent( oEl, 'onclick' );
						}
					}
				}
				if( lpAdvanced )
					setDisabledStyle( oEl, lpDisabled, cpBgColor );
			}
		}
	}
}
function setDisabledStyle( opEl, lpDisabled, cpBgColor ){
	if( !opEl.style ) return;
	if( typeof opEl.styleInit == 'undefined' )
		opEl.styleInit = opEl.style.cssText;
	if( !lpDisabled && isString( opEl.styleReadonly ) )
		opEl.style.cssText = opEl.styleReadonly;
	else if( !Browser.opera && !lpDisabled && isString( opEl.styleInit ) ){
		opEl.style.cssText = opEl.styleInit;
		if( opEl.style.display == 'none' ) opEl.style.display = '';
	}else{
		if( !Browser.gecko || typeof opEl.tagName == 'undefined' || opEl.tagName != 'SELECT' ){
			setBorderStyle( opEl, ( lpDisabled ? 'solid' : '' ) );
			setBorderWidth( opEl, ( lpDisabled ? '2px' : '' ) );
			setBorderColor( opEl, ( lpDisabled ? 'silver' : '' ) );
			setBackgroundColor( opEl, ( lpDisabled ? cpBgColor : '' ) );
		}
	}
	opEl.styleDisabled = ( lpDisabled ? opEl.style.cssText : null );
}

function setReadonly( opDoc, vpObject, lpReadonly, lpAdvanced, cpBgColor, lpKeepSize ){
	var oEl = getElement( opDoc, vpObject );
	if( !isObject( oEl ) ) return;
	var lArray = typeof oEl[0] != 'undefined';
	if( isObject( oEl ) && ( lArray || typeof oEl.readOnly != 'undefined' ) ){
		if( lArray && ( typeof oEl.tagName == 'undefined' || oEl.tagName != 'SELECT' ) ){
			var i, lRadio, nChk = -1;
			lRadio = typeof oEl[0].type != 'undefined' && oEl[0].type == 'radio';
			if( lRadio ){
				for( i = 0; i < oEl.length; i++ ){
					if( oEl[ i ].checked ){
						nChk = i; break;
					}
				}
			}
			for( i = 0; i < oEl.length; i++ ){
				if( oEl[ i ].readOnly != lpReadonly ){
					if( lpReadonly ){
						oEl[ i ].oldClick = oEl[ i ].onclick;
						oEl[ i ].oldValue = ( lRadio ? nChk : oEl[ i ].checked );
						if( lRadio )
							oEl[ i ].onclick = function(){
								if( this.oldValue > -1 ) getElement( document, this.name )[ this.oldValue ].checked = true;
								else this.checked = false;
							}
						else
							oEl[ i ].onclick = function(){ this.checked = this.oldValue; }
					}else{
						oEl[ i ].onclick = oEl[ i ].oldClick;
						oEl[ i ].oldClick = null;
					}
				}
				oEl[ i ].oldValue = ( lRadio ? nChk : oEl[ i ].checked );
				oEl[ i ].readOnly = lpReadonly;
				oEl[ i ].unselectable = ( lpReadonly ? 'on' : 'off' );
				if( lpAdvanced )
					setReadonlyStyle( oEl, lpReadonly, cpBgColor );
			}
		}else{
			if( oEl.readOnly != lpReadonly && typeof oEl.tagName != 'undefined' ){
				if( oEl.tagName == 'INPUT' && oEl.type == 'checkbox' ){
					oEl.oldValue = oEl.checked ;
					if( lpReadonly ){
						oEl.oldClick = oEl.onclick ;
						oEl.onclick = function(){ this.checked = this.oldValue; }
					}else{
						oEl.onclick = oEl.oldClick;
						oEl.oldClick = null;
					}
				}else if( oEl.tagName == 'SELECT' ){
					oEl.oldValue = oEl.value;
					if( lpReadonly ){
						oEl.oldChange = oEl.onchange;
						oEl.onchange = function(){ this.value = this.oldValue; }
					}else if( oEl.oldChange ){
						oEl.onchange = oEl.oldChange;
						oEl.oldChange = null;
					}
				}
			}
			oEl.readOnly = lpReadonly;
			//oEl.unselectable = ( lpReadonly ? 'on' : 'off' );
			if( lpAdvanced ){
				if( lpKeepSize ){
					oReadonlyElements[ oEl.id ] = oEl;
					oEl.orgValue = oEl.value;
					oEl.value = '';
				}
				setReadonlyStyle( oEl, lpReadonly, cpBgColor );
				if( lpKeepSize )
					window.setTimeout( 'resetReadonlyVal( "' + oEl.id + '" )', 0 );
			}
		}
	}
}
var oReadonlyElements = {};
function resetReadonlyVal( cpId ){
	oReadonlyElements[ cpId ].value = oReadonlyElements[ cpId ].orgValue;
	fireEvent(oReadonlyElements[ cpId ],'onchange');
	oReadonlyElements[ cpId ] = null;
}
function setReadonlyStyle( opEl, lpReadonly, cpBgColor ){
	if( !opEl.style ) return;
	if( typeof opEl.styleInit == 'undefined' )
		opEl.styleInit = opEl.style.cssText;
	if( !lpReadonly && isString( opEl.styleDisabled ) )
		opEl.style.cssText = opEl.styleDisabled;
	else if( !lpReadonly && isString( opEl.styleInit ) )
		opEl.style.cssText = opEl.styleInit;
	else{
		//alert(opEl.style.height + ', '+opEl.offsetHeight+ ', '+opEl.offsetWidth);
		if( typeof opEl.offsetHeight != 'undefined' ){
			if( opEl.offsetHeight > 0 ){
				opEl.style.height = opEl.offsetHeight;
				if( opEl.style.width == '' ) opEl.style.width = opEl.offsetWidth;
			}else{
				opEl.onresize = function(){ if( this.style ){ if( this.style.height == '' && this.offsetHeight > 0 ) this.style.height = this.offsetHeight + 3; if( this.style.width == '' && this.offsetWidth > 0 ) this.style.width = this.offsetWidth + 4; } }; //alert('resize: '+this.offsetHeight+', '+this.offsetWidth);
			}
		}
		opEl.style.padding = ( lpReadonly ? ( Browser.ie ? '3px' : '2px' ) : '' );
		//opEl.style.paddingLeft = ( lpReadonly ? '3px' : '' );
		setBorderStyle( opEl, ( lpReadonly ? 'none' : '' ) );
		opEl.style.borderBottom = ( lpReadonly ? '1px silver dotted' : '' );
		//setBorderWidth( opEl, ( lpReadonly ? '1px' : '' ) );
		//setBorderColor( opEl, ( lpReadonly ? 'silver' : '' ) );
		if( typeof cpBgColor == 'string' ) setBackgroundColor( opEl, ( lpReadonly ? cpBgColor : '' ) );
	}
	opEl.styleReadonly = ( lpReadonly ? opEl.style.cssText : null );
}
var oResizeElements = { elements: new Array(), listen: false };
oResizeElements.addElement = function(id){
	if( arraySearch(this.elements,id) == -1 )
		this.elements[ this.elements.length ] = id;
	if( !this.listen ){
		alert('setevent');
		addEventHandler(window,'onresize',resizeElements);
		this.listen = true;
	}
}
oResizeElements.resizeElements = function(){
	alert('resize: '+this.elements.length);
	var i, oEl;
	for( i = 0; i < this.elements.length; i++ ){
		oEl = getElement( document, this.elements[ i ] );
		alert(this.elements[ i ]+', '+oEl);
		if( oEl && oEl.style ){
			alert(oEl.id + ', ' + oEl.offsetHeight+', '+oEl.style.border);
			if( oEl.style.height == '' && oEl.offsetHeight > 0 ) oEl.style.height = oEl.offsetHeight + ( oEl.style.border == 'none' ? 3 : 0 );
			if( oEl.style.width == '' && oEl.offsetWidth > 0 ) oEl.style.width = oEl.offsetWidth;
		}
	}
}
function resizeElements(){ oResizeElements.resizeElements(); }

// depricated; use getSelectedOption instead;
function getCheckedRadio( opDoc, vpObject, vpExpr ){
	return getSelectedOption( opDoc, vpObject, vpExpr );
}
function getSelectedOption( opDoc, vpObject, vpExpr ){
	var oEl = getElement( opDoc, vpObject ), vRetVal = null, i = -1;
	if( isObject( oEl ) ){
		if( typeof oEl[0] != 'undefined' ){
			for( i = 0; i < oEl.length; i++ ){
				if( oEl[ i ].checked ){
					vRetVal = oEl[ i ];
					break;
				}
			}
		}else if( oEl.checked ){
			vRetVal = oEl; i = 0;
		}
	}
	if( vpExpr == 2 )
		vRetVal = ( vRetVal != null ? i : -1 );
	else if( vpExpr )
		vRetVal = ( vRetVal != null ? vRetVal.value : '' );
		
	return vRetVal;
}

function isSelectedOption( opDoc, vpEl, vpOption ){
	var oEl = getElement( opDoc, vpEl ), lSel = false, i;
	if( isObject( oEl ) ){
		if( isCollection( oEl ) ){
			if( typeof( vpOption ) == 'Number' )
				lSel = isBetween( vpOption, 0, oEl.length - 1 ) && oEl[ vpOption ].checked;
			else{
				for( i = 0; i < oEl.length; i++ ){
					if( oEl[ i ].value == vpOption ){
						lSel = oEl[ i ].checked;
						break;
					}
				}
			}
		}else if( typeof( oEl.tagName ) != 'undefined' && oEl.tagName == 'INPUT' && typeof( oEl.checked ) != 'undefined' ){
			if( typeof( vpOption ) == 'Number' )
				lSel = vpOption == 0 && oEl.checked;
			else
				lSel = oEl.value == vpOption && oEl.checked;
		}
	}
	return lSel;
}

function setCheckedRadio( opDoc, vpObj, vpVal ){
	var oEl = getElement( opDoc, vpObj );
	if( isObject( oEl ) ){
		for( i = 0; i < oEl.length; i++ ){
			if( oEl[ i ].value == vpVal )
				oEl[ i ].checked = true;
		}
	}
}

function removeOptions( opDoc, vpEl ){
	var oEl = getElement( opDoc, vpEl ), i = 0;
	for( i = oEl.options.length - 1; i >= 0 ; i-- ){
		if( Browser.ie || Browser.W3C ) oEl.remove( i );
		else{
			oEl.options[ i ].value = '';
			oEl.options[ i ].text	= '';
		}
	}
}
function removeOption( opDoc, vpEl, npIndex ){
	var oEl = getElement( opDoc, vpEl );
	if( Browser.ie || Browser.W3C ){
		oEl.remove( npIndex );
		/* Mozilla workaround
			Remove an option before the selected option.
			The value and selectedIndex do change.
			Firefox probably keeps track of the previous value to see if a change has occured.
			Presumably this tracking value does not change automatically. Below the workaround.
		*/
		var i = oEl.selectedIndex;
		oEl.selectedIndex = -1, oEl.selectedIndex = i;
	}else{
		oEl.options[ i ].value = '';
		oEl.options[ i ].text	= '';
	}
}

function copyOptions( opFrom, opTo ){
	for( var i = 0; i < opFrom.options.length; i++ )
		addOption( null, opTo, opFrom.options[ i ].value, opFrom.options[ i ].text );
}

function addOptions( apFrom, opTo, lp2D ){
	var nCnt = ( lp2D ? 2 : 1 );
	for( var i = 0; i < apFrom.length; i+=nCnt )
		addOption( null, opTo, unescape( apFrom[ i ] ), unescape( apFrom[ i + ( nCnt - 1 ) ] ) );
}

function addOption( opDocument, vpElement, vpValue, cpText ){
	opDocument = opDocument || document;
	var oElement = getElement( opDocument, vpElement ), oOption = null
	if( Browser.ie || Browser.W3C ){
		oOption = opDocument.createElement( 'OPTION' );
		oOption.value	= vpValue;
		oOption.text	= cpText;
		if( Browser.ie )
			oElement.add( oOption );
		else if( Browser.W3C )
			oElement.add( oOption, null );
	}else{
		oElement.options.length++;
		oOption = oElement.options[ oElement.options.length - 1 ];
		oOption.value	= vpValue;
		oOption.text	= cpText;
	}
	return oOption;
}

function searchOption( opDoc, vpEl, vpValue, cpText ){
	var oElement = getElement( opDoc, vpEl );
	var lValue = typeof vpValue != 'boolean', lText = typeof cpText != 'undefined';
	var lFoundV = false, lFoundT = false;
	for( var i = 0; i < oElement.options.length; i++ ){
		lFoundV = ( lValue && oElement.options[ i ].value == vpValue );
		lFoundT = ( lText && oElement.options[ i ].text == cpText );
		if( ( lValue && lFoundV && !lText ) || ( lText && lFoundT && !lValue ) || ( lValue && lText && lFoundV && lFoundT ) )
			return i;
	}
	return -1;
}

function sortOptions( opDocument, vpElement ){
	var oElement = getElement( opDocument, vpElement ), cValue = oElement.value;
	var nLength	= oElement.options.length;
	nIndex	= 0;
	var aSort	= new Array( nLength );
	var aValues	= new Array( nLength * 2 );
	for( i = 0; i < nLength; i++ ){
		aSort[ i ]				= oElement.options[ i ].text.toLowerCase();
		aValues[ nIndex ]		= oElement.options[ i ].text;
		aValues[ nIndex + 1 ]	= oElement.options[ i ].value;
		nIndex = nIndex + 2;
	}
	aSort.sort();
	nIndex = 0;
	for( i = 0; i < nLength; i++ ){
		for( j = 0; j < nLength * 2; j = j + 2 ){
			if( aValues[ j ] != null && aValues[ j ].toLowerCase() == aSort[ i ] ){
				oElement.options[ nIndex ].text = aValues[ j ];
				oElement.options[ nIndex ].value = aValues[ j + 1 ];
				aValues[ j ] = null;
				break;
			}
		}
		nIndex++;
	}
	aSort = null;
	aValues = null;
	oElement.value = cValue;
}

function setBorderStyle( opEl, cpStyle ){
	if( isObject( opEl ) && ( this.Browser.ie || this.Browser.W3C ) ){
		if( typeof opEl.style != 'undefined' ){
			with (opEl.style){
				borderTopStyle = cpStyle;
				borderBottomStyle = cpStyle;
				borderLeftStyle = cpStyle;
				borderRightStyle = cpStyle;
			}
		}
	}
}

function setBorder( opEl, cpBorder ){
	if( isObject( opEl ) && ( this.Browser.ie || this.Browser.W3C ) ){
		if( typeof opEl.style != 'undefined' )
			opEl.style.border = cpBorder;
	}
}
function setBorderColor( opEl, cpColor ){
	if( isObject( opEl ) && ( this.Browser.ie || this.Browser.W3C ) ){
		if( typeof opEl.style != 'undefined' ){
			with (opEl.style){
				borderTopColor = cpColor;
				borderBottomColor = cpColor;
				borderLeftColor = cpColor;
				borderRightColor = cpColor;
			}
		}
	}
}
function setBackgroundColor( opEl, cpColor ){
	if( isObject( opEl ) && ( this.Browser.ie || this.Browser.W3C ) ){
		if( typeof opEl.style != 'undefined' ){
			opEl.style.backgroundColor = cpColor;
		}
	}
}
function setBorderWidth( opEl, vpWidth ){
	if( isObject( opEl ) && ( this.Browser.ie || this.Browser.W3C ) ){
		if( typeof opEl.style != 'undefined' ){
			vpWith = vpWidth + ( typeof vpWidth == 'number' ? 'px' : '' );
			with (opEl.style){
				borderTopWidth = vpWidth;
				borderBottomWidth = vpWidth;
				borderLeftWidth = vpWidth;
				borderRightWidth = vpWidth;
			}
		}
	}
}

function setVisibility( opDoc, vpEl, lpVisible ){
	var oEl = getElement( opDoc, vpEl );
	if( !isObject( oEl ) ) return;
	if( this.Browser.ie || this.Browser.W3C ){
		var cValue = lpVisible ? 'visible' : 'hidden';
		oEl.style.visibility = cValue;
	}
	if( this.Browser.ns4 ){
		var cValue = lpVisible ? 'show' : 'hide';
		oEl.visibility = cValue;
	}
}

function setDisplay( opDoc, vpEl, vpDisplay ){
	var oEl = getElement( opDoc, vpEl );
	if( !isObject( oEl ) || typeof oEl.style == 'undefined' ) return;
	if( this.Browser.ie || this.Browser.W3C ){
		var cValue = ( typeof( vpDisplay ) == 'string' ? vpDisplay : ( vpDisplay ? '' : 'none' ) );
		oEl.style.display = cValue;
	}
	return ( oEl );
}

function setOpacity( opDoc, vpEl, npOpacity ){
	npOpacity = ( npOpacity == 100 ) ? 99.999 : npOpacity;
	var oEl = getElement( opDoc, vpEl );
	if( typeof oEl.style == 'undefined' ) return;
	if( typeof oEl.style.filter != 'undefined' ) // IE/Win
		oEl.style.filter = ( npOpacity == 99.999 ? "" : "alpha(opacity:"+npOpacity+")" );
	else if( typeof oEl.style.MozOpacity != 'undefined' )// Older Mozilla and Firefox
		oEl.style.MozOpacity = npOpacity/100;
	else if( typeof oEl.style.opacity != 'undefined' ) // Safari 1.2, newer Firefox and Mozilla, CSS3
		oEl.style.opacity = npOpacity/100;
	else if( typeof oEl.style.KHTMLOpacity != 'undefined' ) // Safari&lt;1.2, Konqueror
		oEl.style.KHTMLOpacity = npOpacity/100;
}
function getOpacity( opDoc, vpEl ){
	var oEl = getElement( opDoc, vpEl ), nOpacity = 100;
	if( typeof oEl.style == 'undefined' ) return ( nOpacity );
	if( oEl.style.filter ){
		var cFilter = oEl.style.filter, nPos = cFilter.search( /opacity:/ );
		if( nPos > -1 ){
			cFilter = cFilter.substr( nPos + 8 );
			nOpacity = parseFloatEx( cFilter.substr( 0, cFilter.search( /\)/ ) ) );
		}
	}else if( oEl.style.MozOpacity )
		nOpacity = oEl.style.MozOpacity * 100;
	else if( oEl.style.opacity )
		nOpacity = oEl.style.opacity * 100;
	else if( oEl.style.KHTMLOpacity )
		nOpacity = oEl.style.KHTMLOpacity * 100;
	if( nOpacity == 99.999 ) nOpacity = 100;
	return ( nOpacity );
}


function layerMove( opDoc, vpEl, npX, npY ){
	var oEl = getElement( opDoc, vpEl );
	if( !isObject( oEl ) ) return;
	if( this.Browser.ie || this.Browser.W3C )
		oEl = oEl.style;
	oEl.left = npX;
	oEl.top = npY;
}
// depricated; use layerMove instead
function moveLayer( opDoc, vpEl, npX, npY ){
	top.status = 'Function moveLayer is depricated. Please, use layerMove instead.';
	layerMove( opDoc, vpEl, npX, npY );
}

function layerWrite( opDoc, vpEl, cpHTML ){
	var oEl = getElement( opDoc, vpEl );
	if( !isObject( oEl ) ) return;
	if( typeof oEl[0] == 'object' ){
		for( var i = 0; i < oEl.length; i++ )
			layerWrite( null, oEl[i], cpHTML );
	}else{
		if( this.Browser.ns4 && isObject( oEl, 'write' ) ){
			oEl.document.write( cpHTML );
			oEl.document.close();
		}
		if( ( this.Browser.ie || this.Browser.W3C ) && isObject( oEl, 'innerHTML' ) )
			oEl.innerHTML = cpHTML;
	}
}
// depricated; use layerWrite instead
function WriteToLayer( opDocument, vpElement, cpHTML ){
	top.status = 'Function WriteToLayer is depricated. Please, use layerWrite instead.';
	layerWrite( opDocument, vpElement, cpHTML );
}

function maxLength( e, npMax, lpChk ){
	var el = null;
	if( lpChk ) el = e;
	else el = checkEvent( e );
	if( !isObject( el ) ) return;
	if( el.value.length >= npMax && ( lpChk || !inList( e.keyCode,8,9,16,17,18,35,36,37,38,39,40,46 ) ) ){
		if( !lpChk ){
			if( Browser.ie ) e.returnValue = false;
			else if( typeof e.preventDefault != 'undefined' ) e.preventDefault();
			else el.value = el.value.substr( 0, npMax - 1 );
		}else if( el.value.length > npMax ){
			el.value = rTrim( el.value.substr( 0, npMax - 1 ) );
			fireEvent( el, 'onkeyup' );
		}
	}
}

function onPaste( npCurr, npMax ){
	var cClip, nClipLength, nAvailLength, lReturn;

	lReturn = true;
	cClip = window.clipboardData.getData( "Text" );
	nClipLength = cClip.length;
	nAvailLength = npMax - npCurr;

	if( nAvailLength > 0 ){
		if( nAvailLength > nClipLength ){
			cClip = cClip.substr( 0, nAvailLength );
			window.clipboardData.setData( "Text", cClip );
		}
	}else
		lReturn = false;

	return lReturn;
}


var aCharCodes = new Array( 32,33,35,36,37,38,40,41,43,45,46,64,94,95,255 );
//32 = ' '
function FillArray( apCharCodes, npStart, npEnd ){
	var aRestCodes = new Array( npEnd - npStart + 1 ), i = 0, j = 0;
	for( i = npStart; i <= npEnd; i++ ){ aRestCodes[ j ] = i; j++; }
	return ( apCharCodes = apCharCodes.concat( aRestCodes ) );
}

aCharCodes = FillArray( aCharCodes, 48, 57 );
aCharCodes = FillArray( aCharCodes, 97, 122 );
aCharCodes = FillArray( aCharCodes, 224, 229 );
aCharCodes = FillArray( aCharCodes, 231, 246 );
aCharCodes = FillArray( aCharCodes, 248, 253 );

function CheckChars( cpString, npOptions, apCharCodes ){
	var cString = cpString.toLowerCase(), lFound = false, i = 0, nCharCode;
	if( typeof apCharCodes == 'undefined' || !isObject( apCharCodes ) ) apCharCodes = aCharCodes;
	for( i = 0; i < cString.length; i++ ){
		
		if( i == 0 && ( ( npOptions & 1 && cString.charAt( 0 ) == ' ' ) || ( npOptions & 2 && !isNaN( cString.charAt( 0 ) ) ) ) )
			return 0;
		
		nCharCode = cString.charCodeAt( i ); lFound = false;
		for( j = 0; j < apCharCodes.length; j++ ){
			if( apCharCodes[ j ] == nCharCode ){ lFound = true; break; }
		}
		if( !lFound ){ return i; }
	}
	return -1;
}

function isValidDate( vpDates, cpFormat, npRange ){
	// checks if date passed is in valid cpFormat format
	if( isObject( vpDates ) ) var oStripDate = vpDates;
	else{
		if( vpDates.length == 0 ) return 0;
		var aDates = vpDates.split( ',' ), oStripDate = new stripDate( aDates[ 0 ], cpFormat );
	}
	if( oStripDate.Error ) return -1

	if( oStripDate.Time )
		var dDate = new Date( oStripDate.Year, oStripDate.Month - 1, oStripDate.Day, oStripDate.Hours, oStripDate.Minutes, oStripDate.Seconds );
	else
		var dDate = new Date( oStripDate.Year, oStripDate.Month - 1, oStripDate.Day );

	if( ( oStripDate.Year == dDate.getFullYear() ) && ( oStripDate.Month - 1 == dDate.getMonth() ) && ( oStripDate.Day == dDate.getDate() ) && ( !oStripDate.Time || ( oStripDate.Hours == dDate.getHours() && oStripDate.Minutes == dDate.getMinutes() && oStripDate.Seconds == dDate.getSeconds() ) ) ){
		var dCheckDate;
		if( aDates.length > 1 ){
			oStripDate	= new stripDate( aDates[ 1 ], cpFormat );
			if( oStripDate.Time )
				dCheckDate	= new Date( oStripDate.Year, oStripDate.Month - 1, oStripDate.Day, oStripDate.Hours, oStripDate.Minutes, oStripDate.Seconds );
			else
				dCheckDate	= new Date( oStripDate.Year, oStripDate.Month - 1, oStripDate.Day );
		}else{
			dCheckDate = new Date();
			dCheckDate = new Date( dCheckDate.getFullYear(), dCheckDate.getMonth(), dCheckDate.getDate() );

		}

		if( npRange == 1 && dDate > dCheckDate ) return -2;
		if( npRange == 2 && dDate < dCheckDate ) return -3;
		if( npRange == 3 && dDate >= dCheckDate ) return -4;
		if( npRange == 4 && dDate <= dCheckDate ) return -5;
		if( npRange == 5 && dDate <= dCheckDate && dDate >= dCheckDate ) return -6;
		return 0;
	}else{
		//return 'valid format but an invalid date';
		return -1;
	}
}

function stripDate( cpDate, cpFormat ){
	var nSepPos, cTmp, cChar, nLen;
	this.Date = cpDate;	this.Format = cpFormat;	this.Separator = getDateSeparator( cpFormat ); this.Time = cpDate.search( ' ' ) > 0;
	this.Day = 0; this.Month = 0; this.Year = 0; this.Date = null;
	for( var i = 1; i <= 3; i++ ){
		nSepPos		= cpDate.search( ( i < 3 ? ( this.Separator == '.' ? '\\.' : this.Separator ) : ' ' ) );
		this.Error	= this.Error || ( nSepPos == 0 && i < 3 );
		cTmp		= ( i < 3 || this.Time ? cpDate.substring( 0, nSepPos ) : cpDate );
		this.Error	= this.Error || ( parseFloat( cTmp ) < 0 );
		cChar		= cpFormat.charAt( 0 );
		nLen		= cpFormat.search( ( this.Separator == '.' ? '\\.' : this.Separator ) );
		if( nLen < 0 ) nLen = cpFormat.length;
		this.Error	= this.Error || cTmp.length > nLen;
		cpFormat	= cpFormat.substring( nLen + 1 );
		if( cChar.match( /d|t|g|j/ ) != null && nLen == 2 )
			this.Day = cTmp;
		else if( cChar == 'm' && nLen == 2 )
			this.Month = cTmp;
		else{
			this.Year = cTmp;
			this.Error = this.Error || ( this.Year.length != 4 );
		}
		cpDate = cpDate.substr( nSepPos + 1, cpDate.length );
	}
	
	this.Hours = 0; this.Minutes = 0; this.Seconds = 0;
	if( this.Time ){
		var cTime	= cpDate.substr( cpDate.search( ' ' ) + 1 );
		nSepPos		= cTime.search( ':' );
		cTmp		= ( nSepPos > 0 ? cTime.substr( 0, nSepPos ) : cTime );
		this.Error	= this.Error || ( cTmp.length > 0 && isNaN( cTmp ) );
		this.Hours	= parseIntEx( cTmp );
		cTime		= ( nSepPos > 0 ? cTime.substr( nSepPos + 1 ) : '0' );
		nSepPos		= cTime.search( ':' );
		cTmp		= ( nSepPos > 0 ? cTime.substr( 0, nSepPos ) : cTime );
		this.Error	= this.Error || ( cTmp.length > 0 && isNaN( cTmp ) );
		this.Minutes	= parseIntEx( cTmp );
		cTime			= ( nSepPos > 0 ? cTime.substr( nSepPos + 1 ) : '0' );
		nSepPos			= cTime.search( ':' );
		cTmp			= ( nSepPos > 0 ? cTime.substr( 0, nSepPos ) : cTime );
		this.Error		= this.Error || ( cTmp.length > 0 && isNaN( cTmp ) );
		this.Seconds	= parseIntEx( cTmp );
	}
	
	if( !this.Error ){
		if( this.Time )
			this.Date = new Date( this.Year, this.Month - 1, this.Day, this.Hours, this.Minutes, this.Seconds );
		else
			this.Date = new Date( this.Year, this.Month - 1, this.Day );
	}
	
}

function getLastDayOfMonth( dpDate ){
	if( typeof dpDate != 'object' ) dpDate = new Date();
	dpDate.setMonth( dpDate.getMonth() + 1 );
	dpDate.setDate( 1 );
	dpDate.setDate( dpDate.getDate() - 1);
	return dpDate.getDate();
}

/*--> http://www.irt.org/script/914.htm
	edited to have iso (europe) and the other calc in one function
*/
function _y2k(number) { return (number < 1000) ? number + 1900 : number; }
function getWeek( year, month, day, iso ){
	var when = new Date( year, month, day );
	var newYear = new Date( year, 0, 1 );
	var modDay = newYear.getDay();
	if( modDay == 0 ) modDay=6; else modDay--;

	var daynum = ((Date.UTC(_y2k(year),when.getMonth(),when.getDate(),0,0,0) -
					Date.UTC(_y2k(year),0,1,0,0,0)) /1000/60/60/24) + 1;

	if( iso && modDay < 4 ){
		var weeknum = Math.floor((daynum+modDay-1)/7)+1;
	}else {
		var weeknum = Math.floor((daynum+modDay-1)/7);
		if (weeknum == 0) {
			year--;
			var prevNewYear = new Date(year,0,1), prevmodDay;
			if( iso ){
				prevmodDay = prevNewYear.getDay();
				if( prevmodDay == 0 ) prevmodDay = 6; else prevmodDay--;
				if( prevmodDay < 4 ) weeknum = 53; else weeknum = 52;
			}else{
				prevmodDay = 7 + 1 - prevNewYear.getDay();
				if( prevmodDay == 2 || prevmodDay == 8 ) weeknum = 53; else weeknum = 52;
			}
		}
	}

	return weeknum;
}
//<-- http://www.irt.org/script/914.htm

/*--> http://www.merlyn.demon.co.uk/weekcalc.htm
	edited to simplify; npDOW specifies the day of week te return (0-6);
*/
function getWeekToDate( npWeek, npDOW ){
	npDOW = npDOW || 0;
	var dDate = new Date();
	var DOb = new Date( dDate.getFullYear(), 0, 4 );
	var D = DOb.getDay(); if( D == 0 ) D = 7 ;
	var Off = -( D - npDOW );
	DOb.setDate( DOb.getDate() + Off + 7 * ( npWeek - 1 ) )
	return DOb;
}

function getDateSeparator( cpFormat ){
	var cSeparators = '-/.';
	for( var i = 0; i < cpFormat.length; i++ ){
		if( cSeparators.search( cpFormat.charAt( i ) ) > -1 )
			return cpFormat.charAt( i );
	}
	return '';
}

function formatDate( dpDate, cpFormat ){
	var cDate = '', cSeparator = getDateSeparator( cpFormat ), cChar, nLen;
	for( var i = 1; i <= 3; i++ ){
		cChar	= cpFormat.charAt( 0 );
		nLen	= cpFormat.search( ( cSeparator == '.' ? '\\.' : cSeparator ) );
		if( nLen < 0 ) nLen = cpFormat.length;
		if( cChar.match( /d|t|g|j/ ) != null && nLen <= 2 )
			cDate += padOut( dpDate.getDate() );
		else if( cChar == 'm' && nLen == 2 )
			cDate += padOut( dpDate.getMonth() - 0 + 1 );
		else
			cDate += dpDate.getFullYear();
	
		if( i < 3 ) cDate += cSeparator;
		cpFormat = cpFormat.substring( nLen + 1 );
	}
	return cDate;
}

function padOut( npNumber ) { return ( npNumber < 10 ) ? '0' + npNumber : npNumber; }

function splitChar( cpString, lpEscaped ){
	return ( 
		(
			cpString.search( ( !lpEscaped ? unescape( '%0D%0A' ) : '%0D%0A' ) ) >= 0 ?
			'%0D%0A' :
			(
				cpString.search( ( !lpEscaped ? unescape( '%0D' ) : '%0D' ) ) >= 0 ?
				'%0D' :
				'%0A'
			)
		)
	);
}

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
function emailCheck(emailStr){
	if( emailStr.length == 0 ) return 0;
	emailStr = rTrim( emailStr, true );
	var nPos = CheckChars( emailStr, 1 );
	if( nPos >= 0 ) return nPos + 1;
	
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

	var matchArray=emailStr.match(emailPat)
	if (matchArray==null)
		return -1

	var user=matchArray[1], domain=matchArray[2];
	// See if "user" is valid 
	if (user.match(userPat)==null)
	    return -2

	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		for (var i=1;i<=4;i++) {
		    if (IPArray[i]>255) {
		        //alert("Destination IP address is invalid!")
				return -3
		    }
	    }
	    return 0
	}

	// Domain is symbolic name
	var domainArray=domain.match(domainPat)
	if (domainArray==null)
	    return -4

	var atomPat=new RegExp(atom,"g"), domArr=domain.match(atomPat), len=domArr.length;
	if (domArr[domArr.length-1].length<2)
	   return -5

	// Make sure there's a host name preceding the domain.
	if (len<2)
	   return -6

	// If we've gotten this far, everything's valid!
	return 0;
}

function checkColor( cpColorString ){
	if( cpColorString.charCodeAt( 0 ) != 35 && cpColorString.length != 7 ) return false;
	var aColorCodes = new Array();
	aColorCodes[ 0 ] = 35;
	aColorCodes = FillArray( aColorCodes, 48, 57 );
	aColorCodes = FillArray( aColorCodes, 97, 102 );
	var nPos = CheckChars( cpColorString.toLowerCase(), true, aColorCodes );
	return ( nPos == -1 );
}

// deprecated
function colorCheck( cpColorString ){
	return checkColor( cpColorString );
}

function checkUrl( cpUrl ){
	var cUrl = cpUrl.toLowerCase()
	if( cUrl.search( 'http://' ) == -1 && cUrl.search( 'https://' ) == -1 && cUrl.substr( 0, 1 ) != '#' )
		cpUrl = 'http://' + cpUrl;
	return cpUrl;
}

function checkCSS( cpUrl, lpRetVal ){
	var cUrl = cpUrl.toLowerCase(), lRetVal = cUrl.match( /(.+\/){1}.+(\.css|\.asp|\.php)/ ) != null;
	return ( lpRetVal ? ( lRetVal ? cpUrl : '' ) : lRetVal );
}

function emptyStr( cpString ){
	var cString = new String( cpString ), cChar	= '', i = 0;
	if( cString.length == 0 || typeof cpString == 'undefined' )
		return true;
	for( i = 0; i < cString.length; i++ ){
		cChar = cString.charAt( i );
		if( cChar != ' ' && escape( cChar ) != '%0D' && escape( cChar ) != '%0A' )
			return false;
	}
	return true;
}

function emptyNum( npNumber ){
	return parseFloat( npNumber ) == 0;
}

function allTrim( cpString, lpCRLF ){
	cpString = lTrim( cpString, lpCRLF );
	cpString = rTrim( cpString, lpCRLF );
	return cpString;
}

function rTrim( cpString, lpCRLF ){
	var cCharCode = cpString.charCodeAt( cpString.length - 1 );
	while( cCharCode == 32 || ( ( lpCRLF ) ? ( cCharCode == 13 || cCharCode == 10 ) : false ) ){
		cpString = cpString.substring( 0, cpString.length - 1 );
		cCharCode = cpString.charCodeAt( cpString.length - 1 );
	}
	return cpString;
}

function lTrim( cpString, lpCRLF ){
	var cCharCode = cpString.charCodeAt( 0 );
	while( cCharCode == 32 || ( ( lpCRLF ) ? ( cCharCode == 13 || cCharCode == 10 ) : false ) ){
		cpString = cpString.substring( 1, cpString.length );
		cCharCode = cpString.charCodeAt( 0 );
	}
	return cpString;
}

function parseIntEx( cpString ){
	var nReturn = parseInt( cpString || '' );
	return ( ( isNaN( nReturn ) || cpString.length == 0 ) ? 0 : nReturn );
}

function parseFloatEx( cpString ){
	cpString = replaceAll( ( cpString == null ? '' : cpString ), ',', '.' )
	var nPos = 0, cChar = ( cpString.length == 0 ? '' : cpString.charAt( nPos ) ), cNextChar = '';
	while( nPos < cpString.length && ( ( isNaN( cChar ) || isEmpty( cChar ) ) && ( ( cChar != '-' && cChar != '.' ) || ( nPos < cpString.length - 1 && ( isNaN( ( cNextChar = cpString.charAt( nPos + 1 ) ) ) || isEmpty( cNextChar ) ) ) ) ) ){
		nPos++;
		cChar = cpString.charAt( nPos );
		cNextChar = '';
	}
	var nReturn = parseFloat( cpString.substr( nPos ) );
	return ( ( cpString.length == 0 || isNaN( nReturn ) ) ? 0 : nReturn );
}

function correctNumber( vpNumber, npRange, lpDecimals, npMin, npMax, lpAllowEmpty, lpOnChange ){
	var cNumber = new String( vpNumber ); //parseFloatEx( new String( vpNumber ) )
	cNumber = replaceAll( cNumber, ',', '.' );

	if( cNumber.match( /[^0-9.-]/ ) || ( lpAllowEmpty && cNumber.length == 0 ) ){
		aNumber = new Array( '', '', '', true );
		return aNumber;
	}

	var aNum = cNumber.split( '.' );
	if( typeof npRange == 'number' && npRange >= 0 && lpDecimals && ( aNum.length > 1 && aNum[ 1 ].length > 0 ) ){
		cNumber = new String( Math.round( parseFloat( cNumber ) * Math.pow( 10, npRange ) ) / Math.pow( 10, npRange ) );
		aNum = cNumber.split( '.' );
	}

	aNum[ 0 ] = allTrim( aNum[ 0 ] );
	aNum[ 2 ] = isNaN( aNum[ 0 ] ) && aNum[ 0 ] != '-';
	aNum[ 3 ] = ( aNum[ 0 ].length > 0 && aNum[ 2 ] );
	aNum[ 0 ] = new String( ( aNum[ 2 ] || aNum[ 0 ].length == 0 ) ? '0' : aNum[ 0 ] );
	aNum[ 1 ] = ( aNum.length > 1 && !emptyStr( aNum[ 1 ], true ) ) ? allTrim( aNum[ 1 ] ) : '';
	aNum[ 2 ] = ( aNum[ 2 ] || isNaN( aNum[ 1 ] ) || ( npRange <= 0 && aNum[ 1 ].length > 0 ) );
	aNum[ 3 ] = ( aNum[ 3 ] || ( aNum[ 1 ].length > 0 && isNaN( aNum[ 1 ] ) ) );
	aNum[ 1 ] = ( isNaN( aNum[ 1 ] ) ? '0' : aNum[ 1 ] );
	
	if( typeof npRange == 'number' && npRange > 0 ){
		var nIndex = ( ( lpDecimals ) ? 1 : 0 );
		aNum[ 2 ] = ( aNum[ 2 ] || aNum[ nIndex ].length > npRange );
		if( aNum[ 1 ].length > npRange ){
			//aNum[ 1 ] = new String( aNum[ 1 ].substr( 0, npRange ) ); 2-4-2004 22:36
			aNum[ 1 ] = aNum[ 1 ].substr( 0, npRange );
		}
		
		if( !lpOnChange ){
			while( aNum[ nIndex ].length < npRange ){
				if( lpDecimals ) aNum[ nIndex ] = aNum[ nIndex ] + '0';
				else aNum[ nIndex ] = '0' + aNum[ nIndex ];
			}
		}
	}

	aNumber = new Array( '', aNum[ 0 ], aNum[ 1 ], aNum[ 2 ] );
	aNumber[ 0 ] = ( aNum[ 3 ] ? '' : ( aNum[ 0 ] + ( ( lpDecimals && aNum[ 1 ].length > 0 || ( lpOnChange && lpDecimals && cNumber.search( /\./ ) >= 0 ) ) ? ( '.' + aNum[ 1 ] ) : '' ) ) );
	if( aNumber[ 0 ].length > 20 ){
		aNumber[ 3 ] = true;
		aNumber[ 0 ] = '';
	}
	if( typeof npMin == 'number' && parseFloat( aNumber[ 0 ] ) < npMin )
		aNumber[ 0 ] = ( lpAllowEmpty ? '' : npMin );
	if( typeof npMax == 'number'  && parseFloat( aNumber[ 0 ] ) > npMax )
		aNumber[ 0 ] = ( lpAllowEmpty ? '' : npMax );

	return aNumber;	
}
function checkNumber( e ){
	if( checkDecimalMark( e ) && !keyCodeIsNumChar( e.keyCode, true ) ){
		if( Browser.ie ) e.returnValue = false;
		else if( typeof e.preventDefault != 'undefined' )
			e.preventDefault();
		else if( typeof e.target != 'undefined' )
			e.target.value = correctNumber( e.target.value, 0, true );
	}
}
function keyCodeIsNumChar( keyCode, lpSpecChars ){
	//top.status=keyCode;
	return ( ( inBetween( keyCode, 48, 57 ) || inBetween( keyCode, 96, 105 ) || inList( keyCode, 189, 190, 110 ) ) || ( lpSpecChars && inList( keyCode,8,9,16,17,18,35,36,37,38,39,40,46 ) ) );
}
function checkDecimalMark( e ){
	var lRetVal = true;
	if( e.keyCode == 188 && typeof e.shiftKey != 'undefined' && !e.shiftKey ){
		lRetVal = false;
		if( Browser.ie ){
			document.selection.createRange().text = '.';
			e.returnValue = false;
		}else if( typeof e.preventDefault != 'undefined' )
			e.preventDefault();
	}
	return ( lRetVal );
}

function replaceAll( cpString, cpWhat, cpWith, lpICase ){
	//while( cpString.search( cpWhat ) >= 0 )
	//	cpString = cpString.replace( cpWhat, cpWith );
	var re = new RegExp( cpWhat , ( lpICase ? "i" : "" ) + "g" );
	if( cpString )
		return cpString.replace( re, cpWith );
	else
		return '';
}

function stripHTML( cpStr ){
	var oRe = /<\S[^><]*>/g; ///<(.*)([ ].*)?>((.*(?:[\n\r]).*)*)<\/\1>/i;
	return ( cpStr.replace( oRe, "" ) );
	
	while( cpStr.match( oRe ) != null ){
		cpStr = cpStr.replace( oRe, "$3" );
		alert(cpStr);
	}
	return cpStr;
}

function closeHelp(){
	if( isObject( window.helpWindow, 'document' ) )
		window.helpWindow.close();
	window.helpWindow = null;
}

function helpObj( cpTitle, cpCloseText, cpClickHere, npShow ){
	this.Title = cpTitle; this.CloseText = cpCloseText;	this.ClickHere = cpClickHere; this.Show = npShow;
	this.Help = new Array(); this.HelpCount = 0;
	
	this.addHelp = function( npHelpId, cpTitle, cpText ){
		this.Help[ this.HelpCount ] = new Array( npHelpId, cpTitle, cpText );
		this.HelpCount++;
	};
	this.helpIndex = function( npHelpId ){
		return arraySearch( this.Help, npHelpId, 0 );
	};
	this.showHelp	= function( npHelpId ){
		if( this.Show == 0 && !Browser.ns4 ) return;
		npHelpId = this.helpIndex( npHelpId );
		if( npHelpId == -1 ) return;
		var lIsOpen = isObject( window.helpWindow, 'document' );
		var cTitle	= unescape( this.Help[ npHelpId ][ 1 ] );
		cTitle		= ( cTitle.length > 50 ) ? cTitle.substr( 0, 47 ) + '...' : cTitle;
		var cText	= unescape( this.Help[ npHelpId ][ 2 ] );
	
		var cHTML = '<html><head><title>' + this.Title + '</title>' +
				'<style type="text/css">.txt { font-family:arial,verdana;width:100%;height:100%;overflow:scroll;padding:4px;border-style:inset;border-width:2px }</style>' +
				'</head><body topmargin=0 leftmargin=0 rightmargin=0 onload=""><table cellpadding="0" cellspacing="0" width="100%" height="100%"><tr><td><form style="height:100%">' + 
				'<table border=0 width=100% height=100% cellspacing=0 cellpadding=0>' + 
				'<tr><td valign=top>' + 
				'<table border=0 width=100% cellspacing=0 cellpadding=4 bgcolor=#c0c0c0 style="border-style:outset;border-width:2px">' +
				'<tr><td><font face="Arial, Verdana" size=3 color=#0000BB><b>' + cTitle + '</b></font></td></tr></table></td></tr>' + 
				'<tr><td valign=top height=100%>' +
				'<table border=0 width=100% height=100% cellpadding=0 cellspacing=0><tr><td valign=top align=left>' +
				'<textarea class=txt readonly>' + cText + '</textarea></td></tr></table></td></tr>';
		if( this.CloseText != '' )
			cHTML = cHTML + '<tr><td>&nbsp;</td></tr><tr><td valign=middle align=center>' +
				'<input type=button value="' + this.CloseText + '" onclick="window.opener.closeHelp()"></td></tr><tr><td>&nbsp;</td></tr>';
		cHTML = cHTML + '</table></form></td></tr></table></body></html>';
//window.opener.doResize(window)				
		if( true ){ //!lIsOpen 
			window.helpWindow = OpenWindow( null, '/empty.htm', 410, 310, 'yes', 'no', true, 'fdhelp' );
			window.helpWindow.focus();
		}else
			window.helpWindow.focus();
		window.helpWindow.document.open( 'text/html', 'replace' );
		window.helpWindow.document.write( cHTML );
		window.helpWindow.document.close();
		//alert('help');
	};
	this.mouseHelp	= function( npHelpId ){
		npHelpId = this.helpIndex( npHelpId );
		var cTitle	= ( ( this.Show > 0 || Browser.ns4 ) ? '' : this.Help[ npHelpId ][ 1 ] );
		var cText	= ( ( this.Show > 0 || Browser.ns4 ) ? this.ClickHere : this.Help[ npHelpId ][ 2 ] );
		if( npHelpId > -1 )
			window.dlb( window, 'help' + this.Help[ npHelpId ][ 0 ], cText, cTitle );
		return true;
	};
}

//--> http://www.faqts.com/knowledge_base/view.phtml/aid/13562
function setSelectionRange(el, selectionStart, selectionEnd ){
	if( el.setSelectionRange ){
		el.focus();
		el.setSelectionRange( selectionStart, selectionEnd );
	}else if( el.createTextRange ){
		var range = el.createTextRange();
		range.collapse( true );
		range.moveEnd( 'character', selectionEnd );
		range.moveStart( 'character', selectionStart );
		range.select();
	}
}
function setCaretToEnd( el ){
	setSelectionRange( el, input.value.length, input.value.length );
}
function setCaretToBegin( el ){
	setSelectionRange( el, 0, 0 );
}
function setCaretToPos( el, pos ){
	setSelectionRange( el, pos, pos );
}
function selectString( el, string ){
	var match = new RegExp( string, "i" ).exec( el.value );
	if( match ){
		setSelectionRange( el, match.index, match.index + match[0].length );
	}
}
//<--

function removeAttribute( el, prop ){
	if( el.removeAttribute ){
		if( Browser.ie )
			el.removeAttribute( prop, 0 );
		else
			el.removeAttribute( prop );
	}else if( el.removeProperty )
		el.removeProperty( prop );
}
function setAttribute( el, prop, value ){
	if( el.setAttribute ){
		if( Browser.ie )
			el.setAttribute( prop, value, 0 );
		else
			el.setAttribute( prop, value );
	}else if( el.setProperty )
		el.setProperty( prop, value, "" );
}

function fireEvent( opEl, cpName, opEvent, lpCreate ){
	if( cpName == 'onresize' ){
		window.resizeBy(0,1); window.resizeBy(0,-1);
	}else{
		if( Browser.ie ){
			if( Browser.VersionNr >= 5.5 ){
				if( lpCreate ){
					opEvent = document.createEventObject();
					opEvent.fdElement = opEl;
					opEvent.type = cpName.substr(2);
				}else{
					opEl.fireEvent( cpName, ( opEvent ? opEvent : null ) );
				}
			}else
				opEvent = fireEventFD( opEl, cpName, opEvent, lpCreate );
		}else if( Browser.W3C ){
			if( !opEvent ) opEvent = opEl.ownerDocument.createEvent( ( Browser.safari ? "UIEvents" : "Events" ) );
			opEvent.initEvent(cpName.substr(2), true, false);
			if( lpCreate )
				opEvent.fdElement = opEl;
			else
				opEl.dispatchEvent(opEvent);
		}else
			opEvent = fireEventFD( opEl, cpName, opEvent, lpCreate );
	}
	return ( opEvent );
}
function fireEventFD( opEl, cpName, opEvent, lpCreate ){
	opEvent = new Object();
	opEvent.srcElement = opEl;
	opEvent.fdElement = opEl;
	opEvent.type = cpName.substr(2);
	if( !lpCreate ){
		window.fdEvent = opEvent;
		if( eval( 'opEl.' + cpName ) )
			eval( 'opEl.' + cpName + '();' );
	}
	return ( opEvent );
}
function checkEvent( e ){
	if( !e ) e = window.fdEvent || window.event;
	window.fdEvent = null;
	var el = null;
	if( e ){
		if( e.fdElement )
			el = e.fdElement;
		else if( Browser.ie ){
			el = e.srcElement;
		}else
			el = e.target;
	}	
	return ( el );
}
function cancelEvent( e ){
	if( !e ) return;
	if( Browser.ie ) e.returnValue = false;
	else if( typeof e.preventDefault != 'undefined' )
		e.preventDefault();
}
function stopEvent( e ){
	if( !e ) return;
	if( Browser.ie ) e.cancelBubble = true;
	else if( typeof e.stopPropagation != 'undefined' )
		e.stopPropagation();
}
function addEventHandler( opEl, cpType, ppListener, useCapture ){
	if( opEl.addEventListener )
		opEl.addEventListener( cpType.substr(2), ppListener, useCapture );
	else if( opEl.attachEvent )
		opEl.attachEvent( cpType, ppListener );
}
function removeEventHandler( opEl, cpType, ppListener, useCapture ){
	if( opEl.removeEventListener )
		opEl.removeEventListener( cpType.substr(2), ppListener, useCapture );
	else if( opEl.detachEvent )
		opEl.detachEvent( cpType, ppListener );
}

function setRowDisplay( opEl, lpRec ){
	if( !isObject( opEl ) || typeof opEl.tagName == 'undefined' || !inList( opEl.tagName, 'TABLE', 'TR' ) ) return;
	var i, lDisp = true, oCell, nIndex = ( Browser.ie ? 0 : 1 );
	if( opEl.tagName == 'TABLE' ){
		for( i = 0; i < opEl.rows.length; i++ ){
			lDisp = setRowDisplay( opEl.rows[ i ], true );
			if( lDisp ) break;
		}
	}else{
		for( i = 0; i < opEl.cells.length; i++ ){
			oCell = opEl.cells[ i ];
			lDisp = oCell.style.display != 'none';
			if( lDisp && oCell.childNodes.length > nIndex && oCell.childNodes[ nIndex ].nodeType == 1 && oCell.childNodes[ nIndex ].tagName == 'TABLE' )
				lDisp = setRowDisplay( oCell.childNodes[ nIndex ], true );
			if( lDisp ) break;
		}
		if( !lpRec )
			opEl.style.display = ( lDisp ? '' : 'none' );
	}
	return lDisp;
}

function toggleOption( e, vpEl, npIndex ){
	if( checkEvent(e).tagName != 'INPUT' ){
		var oEl = getElement( document, vpEl );
		if( typeof npIndex != 'undefined' && oEl.length > 1 ) oEl = oEl[ npIndex ];
		if( ( typeof oEl.disabled == 'undefined' || !oEl.disabled ) && ( typeof oEl.readOnly == 'undefined' || !oEl.readOnly ) ){
			oEl.checked = ( oEl.type == 'radio' ? true : !oEl.checked );
			if( oEl.onclick ) oEl.onclick(e);
		}
	}	
}
// short function call to toggleOption
function to( e, vpEl, npIndex ){
	toggleOption( e, vpEl, npIndex );
}

function getElementByTagName( opFrom, cpTagName ){
	var oEl = null, oChild;
	if( typeof opFrom.tagName != 'undefined' && opFrom.tagName == cpTagName ) return opFrom;
	if( typeof opFrom.childNodes == 'undefined' ) return null;
	for( var i = 0; i < opFrom.childNodes.length; i++ ){
		oEl = getElementByTagName( opFrom.childNodes[ i ], cpTagName );
		if( oEl ) return oEl;
	}
	return oEl;
}

function preloadImage( cpImage, apArray ){
	var oImg = new Image();
	oImg.src = cpImage;
	if( typeof( apArray ) == 'undefined' )
		if( typeof( window.preloadImg ) == 'undefined' )
			window.preloadImg = new Array( oImg );
		else
			window.preloadImg[ window.preloadImg.length ] = oImg;
	else
		apArray[ apArray.length ] = oImg;
	return oImg;
}

function getIDoc( opDoc, cpFrm ){
	var oDoc;
	opDoc = opDoc || document;
	if( Browser.ie ) oDoc = opDoc.frames( cpFrm ).document;
	else oDoc = getElement( document, cpFrm ).contentDocument;
	return oDoc;
}