try { 
var lastChar = __APPLICATION_PATH__.charAt( __APPLICATION_PATH__.length - 1 );
if ( lastChar != "/" ) __APPLICATION_PATH__ += "/";
} catch( exception ) {
var __APPLICATION_PATH__ = "./";
}
navigator.isChrome     = navigator.appVersion.indexOf( "Chrome" ) > -1;
navigator.isFirefox    = navigator.appName.indexOf( "Netscape" ) > -1;
navigator.isInternetExplorer = navigator.appVersion.indexOf( "MSIE" ) > -1;
Object.prototype.extendPrototype = function ( newMembers, replace ) {
for( member in newMembers ) {
if ( this.prototype.member && ! replace ) continue;
this.prototype[ member ] = newMembers[ member ];
}
}
Object.extendPrototype( {
extendClass : function ( childPrototype ) {
var newType = function() {
if ( this.initialize ) this.initialize.apply( this, arguments );
}
newType.prototype = new this();
for( member in childPrototype ) newType.prototype[ member ] = childPrototype[ member ]; 
return newType;
},
extendObject : function(childObject) {
for(var member in this)
childObject[member] = this[member];
return childObject;
},
clone : function (){
if ( typeof(this) != 'object' ) return this;
var temporaryObject = new this.constructor();
for( var key in this ) temporaryObject[key] = (typeof(this[key]) == 'object' ? this[key].clone() : this[key]);
return temporaryObject;
}
});
Array.extendPrototype( {
contains : function( value ) {
for( var i=0; i<this.length; i++ ) {
if ( value == this[i] ) return true;
}
return false;
}
} );
function createAjaxObject(){
if( window.XMLHttpRequest ) { 
return new XMLHttpRequest();            
} else if ( window.ActiveXObject ) {
try {
return new ActiveXObject("Msxml2.XMLHTTP");        
} catch (e) {
return new ActiveXObject("Microsoft.XMLHTTP");       
}
} else {
throw new Exception( "This web browser can't support Ajax components" ); 
}
}
var __importedPackages__ = new Array();
__importedPackages__.push( "corelib/services/web/javascript/Core.js" );
if ( typeof( importPackage ) == "undefined"  ) {    
function importPackage( packagedTypeName ) {
if ( __importedPackages__.contains( packagedTypeName ) == false ) {
__importedPackages__.push( packagedTypeName );
try {              
var ajaxObject = createAjaxObject();
ajaxObject.open( "GET", __APPLICATION_PATH__ + packagedTypeName, false );
ajaxObject.send( null );
window.document.write( "<script language='javascript'><!--\n" + ajaxObject.responseText + "\n//--></script>\n" );
} catch( exception ) {      
window.document.write( "<script language='javascript' src='" + __APPLICATION_PATH__ + packagedTypeName + "'></script>\n" );         
}
}
}
}
importPackage( "corelib/services/web/javascript/Exception.js" );
importPackage( "corelib/services/web/javascript/Form.js" );
importPackage( "corelib/services/web/javascript/Debug.js" );
importPackage( "corelib/services/web/javascript/L10N.js" );
importPackage( "corelib/services/web/javascript/jwt/JwtUtility.js" );   
function addEventHandler( node, eventName, handler ) {
if ( node == null ) throw new Exception( "addEventHandler: Bad node" );
if ( typeof( eventName ) != "string" ) throw new Exception( "addEventHandler: Bad eventName" ); 
if ( typeof( handler ) != "function" ) throw new Exception( "addEventHandler: Bad event handler" ); 
var handlerArray = node[ eventName + "_handlers" ];
if ( handlerArray == null ) {
handlerArray = node[ eventName + "_handlers" ] = new Array(); 
var __temp = null;
eval( 
"__temp = function( event ) {" +
"    var result = true;" +
"    var handlerArray = this['" + eventName + "_handlers'];" +
"    event = ( event ? event : (window.event ? window.event : null ) );" +
"    try { if ( event.target ) event.srcElement = event.target; } catch( exception ) {} " +  
"    for( var i=0; i<handlerArray.length; i++ ) {" +
"        this.__temp__handler__ = handlerArray[i];" +           
"        var returnCode = this.__temp__handler__( event );" +
"        result = result && returnCode;" +            
"    }" +
"    return result;" +
"}"
);
node[ eventName ] = __temp;                 
}
handlerArray[ handlerArray.length ] = handler;
}
function removeEventHandler( node, eventName, handler ) {
throw new Exception( "Not implemented" );
}
addEventHandler( window, "onload", function( event ) {
if ( document.body.className != null && document.body.className != "" ) document.body.className += " "; 
if ( navigator.isInternetExplorer ) document.body.className += "CSS_IE";
else if ( navigator.isFirefox ) document.body.className += "CSS_FF";
else if ( navigator.isChrome ) document.body.className += "CSS_CH";
});
function attachClickMethod( node ) {
if ( node.click ) return;
node.click = function() {
var clickEvent = document.createEvent( "MouseEvents" );
clickEvent.initMouseEvent( 'click', true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null );
this.dispatchEvent( clickEvent );
}
}
function updateAllAreasForOnContextMenuEvent() {
if ( window.document.all ) {
var areaNodes = window.document.getElementsByTagName( "area" );
for( var i=0; i<areaNodes.length; i++ ) {
areaNodes[i].onmousedown = function() {
if ( window.event.button != 2 ) return;
this.fireEvent( 'oncontextmenu' );
window.event.cancelBubble = true;
}
areaNodes[i].imageNode = null;
var mapName = "#" + areaNodes[i].parentNode.name;
var imageNodes = document.getElementsByTagName( "img" );
for (var imgIndex=0; imgIndex<imageNodes.length; imgIndex++ )
if (imageNodes[imgIndex].usemap == mapName) areaNodes[i].imageNode = imageNodes[imgIndex];     
}
}
return true;
}
addEventHandler( window, "onload", updateAllAreasForOnContextMenuEvent );
function CookieManager() {
this.cookies = new Array();
var tempCookies = document.cookie.split(";");
for(var i=0; i<tempCookies.length; i++) {
var currentCookie = tempCookies[i].split("=");
this.cookies[i] = currentCookie;
}
this.getValue = function CookiesManager_getValue(name) {
for(var i=0;i<this.cookies.length; i++) {
if (this.cookies[i][0].indexOf(name) > -1) {
return this.cookies[i][1];
}
}
return null; 
}
this.setValue = function CookieManager_setValue(key, value, expirationDate) {
if (arguments.length != 3) {
expirationDate = new Date();
expirationDate.setTime( expirationDate.getTime()*1 + (365*24*60*60*1000) );
}
document.cookie = key + "=" + value + ";expires=" + expirationDate.toGMTString();
}
}
String.extendPrototype( {
left : function ( length ) {
var strLength = this.length;
if ( length > strLength ) throw new Exception( "Bad length for left function" );
return this.substring( 0, length );    
},
right : function ( length ) {
var strLength = this.length;
if ( length > strLength ) throw new Exception( "Bad length for left function" );
return this.substring( strLength - length );    
},
trim : function() {
if ( this == "" ) return this;
var begin = 0;
var theChar = this.charAt( begin );
while( theChar == ' ' || theChar == '\t' || theChar == '\r' || theChar == '\n' ) {
begin ++;
if ( begin == this.length ) return "";
theChar = this.charAt( begin );
}
var end = this.length-1;
theChar = this.charAt( end );
while( theChar == ' ' || theChar == '\t' || theChar == '\r' || theChar == '\n' ) {
end --;
theChar = this.charAt( end );
}
return this.substring( begin, end+1 );
},
format: function() {
var isprototype = (this == String.prototype);
var index = (!isprototype ? 0 : 1);
var value = (!isprototype ? this : arguments[0]);
for(var i = index; i < arguments.length; i++)
value = value.replace("\{" + (i - index) + "}", arguments[i].toString());
return value;
}
} );
Date.extendPrototype( {
addDays: function( n)
{
this.setTime( this.getTime() + (n * 86400000));
return this.getTime();
},
getWeek : function() {
var firstDay = new Date( this.getFullYear(), 0, 1 );
return Math.ceil( ( ( (this - firstDay ) / 86400000) + firstDay.getDay() ) / 7 );
},
toLocaleFormat : function(format) {
switch(format) {
case "%a":
return this.toString().left(3); 
default:
throw new Exception("the specified formatting is not currently supported");
}
},
toURIString: function() {
var index = 0;
if((new Date(1970, 12, 1)).getMonth() == 0) 
index++;
return "" + this.getUTCFullYear() + (this.getUTCMonth() + index).toFixedString(2) + this.getUTCDate().toFixedString(2) + "T" + this.getUTCHours().toFixedString(2) + this.getUTCMinutes().toFixedString(2) + this.getUTCSeconds().toFixedString(2) + "Z";
}
} );
Number.extendPrototype( {
toFixedString: function(digits)
{
var value = this.toString();
if(!isNaN(digits) && digits > value.length)
for(var i = value.length; i < digits; i++)
value = "0" + value;
return value;
}
});
var Locale = Object.extendClass( {
initialize : function( language, country ) {
this._language = language;
this._country = country;
},
getLanguage : function () { return this._language; },
getCountry : function () { return this._country; } 
});
