// ==============================================================================================================================
// Class Interface1
// ==============================================================================================================================
Interface1.prototype = new InterfaceElement1;
Interface1.prototype.constructor = Interface1;
Interface1.superclass = InterfaceElement1.prototype;

function Interface1 (sId) {
	if ( arguments.length > 0 ) this.construct(sId);
}

//-----------------------------------------------------------------
// Method Interface1.construct()
//-----------------------------------------------------------------
Interface1.prototype.construct = function (sId) {
	
	if ( !window['INTERFACES'] )
		INTERFACES = [];
	INTERFACES.push(this);
	this.jsName = 'INTERFACES[' + (INTERFACES.length-1) + ']';

	this.__is_interface = true;
	Interface1.superclass.construct.call(this, sId);
	// this.id = sId;
	this.buttonSet = false;
	this._objList = new Array();
	this._jsInitExecute = '';
	this.loaded = false;
	this.submitElements = new Array();
	this.elements = new Array();
	this.panes = new Array();
	this.unlockOtherPanes = true;
	this.submitting = false;
	this.dom = new DOM1;
	this.uniqueId = false;
	this.formName = 'pageform';
	this.cmd = 'cmd';

	this.overlay = new Array();
	this.overlayImg = new Array();
	this.activeOverlay = false;
	this.overlayWidth = '100%';
	this.overlayHeight = '100%';
	this.checkOnload();
	
	this.window = window;

	this.dialogHandler = new DialogHandler1(this);
	
}

//-----------------------------------------------------------------
// Method Interface1.load()
//-----------------------------------------------------------------
Interface1.prototype.load = function (sURL) {
	document.location.href = sURL;
}

//-----------------------------------------------------------------
// Method Interface1.getUniqueId()
//-----------------------------------------------------------------
Interface1.prototype.getUniqueId = function () {
	if ( !this.uniqueId ) {
		var oDate = new Date();
		this.uniqueId = this.id + '_' + oDate.getTime();
	}
	return this.uniqueId;
}

//-----------------------------------------------------------------
// Method Interface1.setAction()
//-----------------------------------------------------------------
Interface1.prototype.setAction = function (sURL) {
	document[this.formName].action = sURL;
}

//-----------------------------------------------------------------
// Method Interface1.getArgument()
//-----------------------------------------------------------------
Interface1.prototype.getArgument = function (sArg) {
	var aInput = document.getElementsByName(sArg);
	if ( aInput.length > 0 ) {
		
		var Value;
		
		for ( var i = 0; i < aInput.length; i++ ) {
			switch ( aInput[i].type ) {
				case 'checkbox':
					if ( i == 0 )
						Value = new Array();
					if ( aInput[i].checked )
						Value.push(aInput[i].value);
					break;
				case 'radio':
					if ( aInput[i].checked )
						Value = aInput[i].value;
					break;
				default:
					Value = aInput[i].value;
					break;
			}
		}
		return Value;
				
	} else {
		return false;
	}
}

//-----------------------------------------------------------------
// Method Interface1.hasArgument()
//-----------------------------------------------------------------
Interface1.prototype.hasArgument = function (sArg) {
	var aInput = document.getElementsByName(sArg);
	return (aInput.length > 0);
}

//-----------------------------------------------------------------
// Method Interface1.setTarget()
//-----------------------------------------------------------------
Interface1.prototype.setTarget = function (sTarget) {
	document[this.formName].target = sTarget;
}

//-----------------------------------------------------------------
// Method Interface1.setArgument()
//-----------------------------------------------------------------
Interface1.prototype.setArgument = function (sArg, Value) {
	var aInput = document.getElementsByName(sArg);
	if ( aInput.length > 0 ) {
		
		for ( var i = 0; i < aInput.length; i++ ) {
			switch ( aInput[i].type ) {
				case 'checkbox':
					if ( typeof(Value) == 'object' ) {
						var bFound = false;
						for ( var j = 0; j < Value.length; j++ ) {
							if ( aInput[i].value == Value[j] ) {
								bFound = true;
								break;
							}
						}
						aInput[i].checked = bFound;
					} else {
						aInput[i].checked = ( aInput[i].value == Value );
					}
					break;
				case 'radio':
					aInput[i].checked = ( aInput[i].value == Value );
					break;
				default:
					aInput[i].value = Value;
					break;
			}
		}
		return true;

	} else if ( document[this.formName][sArg + '[0]'] ) {
		// array property (multiple)
		for ( var i = 0; i < Value.length; i++ ) {
			var oHidden = document.createElement('input');
			oHidden.type = 'hidden';
			oHidden.name = sArg + '[' + (i+1) + ']';
			oHidden.value = Value[i];
			document[this.formName].appendChild(oHidden);
		}
		return true;
	} else {
		alert('argument not found: ' + sArg);
		return false;
	}
}

//-----------------------------------------------------------------
// Method Interface1.getElement()
//-----------------------------------------------------------------
Interface1.prototype.getElement = function (sId) {
	if ( this.elements[sId] )
		return this.elements[sId];
	else
		return false;
}

//-----------------------------------------------------------------
// Method Interface1.onClick()
//-----------------------------------------------------------------
Interface1.prototype.onClick = function () {
	window.event.returnValue = false;
	return false;
}

//-----------------------------------------------------------------
// Method Interface1.getAllPanes()
//-----------------------------------------------------------------
Interface1.prototype.getAllPanes = function () {
	this._getAllPanes(top);
}

//-----------------------------------------------------------------
// Method Interface1._getAllPanes()
//-----------------------------------------------------------------
Interface1.prototype._getAllPanes = function (oFrame) {
	try {
		if ( oFrame.oInterface )
			this.panes[oFrame.oInterface.id] = oFrame.oInterface;
	} catch (e) {
	}
	for ( var i = 0; i < oFrame.frames.length; i++ )
		this._getAllPanes(oFrame.frames[i]);
}

//-----------------------------------------------------------------
// Method Interface1.findPane()
//-----------------------------------------------------------------
Interface1.prototype.findPane = function (sPaneId) {
	this[sPaneId] = this._findPane(top, sPaneId);
	return this[sPaneId];
}

//-----------------------------------------------------------------
// Method Interface1._findPane()
//-----------------------------------------------------------------
Interface1.prototype._findPane = function (oFrame, sPaneId) {
	var oInterface;
	try {
		if ( ( oFrame.oInterface ) && ( oFrame.oInterface.id == sPaneId ) )
			oInterface = oFrame.oInterface;
	} catch (e) {
	}
	if ( oInterface )
		return oInterface;
	else
		for ( var i = 0; i < oFrame.frames.length; i++ ) {
			var oPane = this._findPane(oFrame.frames[i], sPaneId);
			if ( oPane )
				return oPane;
		}
	return false;
}


//-----------------------------------------------------------------
// Method Interface1.addButtonSet()
//-----------------------------------------------------------------
Interface1.prototype.addButtonSet = function () {
	if ( !this.buttonSet )
		this.buttonSet = new ButtonSet1();
}

//-----------------------------------------------------------------
// Method Interface1.getButton()
//-----------------------------------------------------------------
Interface1.prototype.getButton = function (sName) {
	if ( this.buttonSet )
		return this.buttonSet.getButton(sName);
	else
		return false;
}

//-----------------------------------------------------------------
// Method Interface1.cancelSubmit()
//-----------------------------------------------------------------
Interface1.prototype.cancelSubmit = function () {
	this.submitCancelled = true;
}

//-----------------------------------------------------------------
// Method Interface1.submit()
//-----------------------------------------------------------------
Interface1.prototype.submit = function () {
	if ( !this.submitting ) {
		this.submitting = true;
		window.onunload = '';
		if ( window.SUBMIT_STR )
			if ( SUBMIT_STR != '' ) {
				eval(SUBMIT_STR);
				SUBMIT_STR = '';
			}
		this.submitCancelled = false;
		var i;
		for ( i in this.submitElements )
			if ( this.submitElements[i] && ! this.submitElements[i].submitted ) {
				this.submitElements[i].submit();
				this.submitElements[i].submitted = true;
			}
		if ( !this.submitCancelled ) {
			document[this.formName].submit();
		} else
			this.submitting = false;
	}
}

//-----------------------------------------------------------------
// Method Interface1.callOnSubmit()
//-----------------------------------------------------------------
Interface1.prototype.callOnSubmit = function (oElement) {
	this.submitElements.push(oElement);
}

//-----------------------------------------------------------------
// Method Interface1.refresh()
//-----------------------------------------------------------------
Interface1.prototype.refresh = function () {
	this.setBusy();
	this.setArgument(this.cmd, 'refresh');
	this.submit();
}

//-----------------------------------------------------------------
// Method Interface1.refreshPane()
//-----------------------------------------------------------------
Interface1.prototype.refreshPane = function (sPaneId) {
	if ( this.findPane(sPaneId) )
		this[sPaneId].refresh();
}

//-----------------------------------------------------------------
// Method Interface1.addElement()
//-----------------------------------------------------------------
Interface1.prototype.addElement = function (oElement) {
	if ( this.elements[oElement.id] )
		alert('Interface::addElement - element conflict with id \'' + oElement.id + '\'');
	else
		this.elements[oElement.id] = oElement;
	return oElement
}

//-----------------------------------------------------------------
// Method Interface1.handleError()
//-----------------------------------------------------------------
Interface1.prototype.handleError = function (oError) {
	if ( oError.type == 'no_session' ) 
		this.refresh();
	else
		this.showMessage(oError.type, oError.text, oError.subText, 'OK');
}

//-----------------------------------------------------------------
// Method Interface1._getMessageURL()
//-----------------------------------------------------------------
Interface1.prototype._getMessageURL = function () {
	return CUSTOMER_URL + '/api/interface/message/index.php';
}

//-----------------------------------------------------------------
// Method Interface1.showMessage()
//-----------------------------------------------------------------
Interface1.prototype.showMessage = function (sType, sText, sSubText) {
	var sURL = this._getMessageURL();
	sURL += '?text=' + escape(sText);
	sURL += '&subtext=' + escape(sSubText);
	sURL += '&msg_type=' + sType;
	var iNumButtons = 0;
	for ( var i = 3; i < arguments.length; i++ ) {
		sURL += '&buttons[]=' + escape(arguments[i]);
		iNumButtons++;
	}
	sURL += '&' + Math.random();
	var Arguments = this.interfaceObject;
	if ( window.showModalDialog ) {
		var sOptions = 'dialogWidth:400px; dialogHeight:200px; scroll:yes; help:no; status:no; center:yes; unadorned:yes;';
		return window.showModalDialog(sURL, Arguments, sOptions);
	} else {
		if ( sSubText )
			sText += ' ' + sSubText;
		if ( iNumButtons > 1 )
			return confirm(sText);
		else
			return alert(sText);
	}
}

//-----------------------------------------------------------------
// Method Interface1.createDialog()
//-----------------------------------------------------------------
Interface1.prototype.createDialog = function () {
	var oDialog = new Dialog1(this);
	return oDialog;
}

//-----------------------------------------------------------------
// Method Interface1.createMessageDialog()
//-----------------------------------------------------------------
Interface1.prototype.createMessageDialog = function () {
	var oDialog = new Dialog1(this);
	oDialog.setWidth(400);
	oDialog.setHeight(200);
	oDialog.setURL('message.php');
	return oDialog;
}

//-----------------------------------------------------------------
// Method Interface1.createReference()
//-----------------------------------------------------------------
Interface1.prototype._createReference = function(oObj) {
	if ( !oObj._objIndex ) {
		oObj._objIndex = this._objList.length;
		this._objList[oObj._objIndex] = oObj;
	}
    return this.jsName + '._objList[' + oObj._objIndex + ']';
}

//-----------------------------------------------------------------
// Method Interface1.toString()
//-----------------------------------------------------------------
Interface1.prototype.toString = function() {
	return 'interface:' + this.id;
}

//-----------------------------------------------------------------
// Method Interface1.self()
//-----------------------------------------------------------------
Interface1.prototype.self = function() {
	return this._createReference(this);
}

//-----------------------------------------------------------------
// Method Interface1.showOverlay()
//-----------------------------------------------------------------
Interface1.prototype.showOverlay = function(sName) {
	if ( this.activeOverlay != sName )
		this.hideOverlay();
	if ( this.overlay[sName] ) {
		this.overlay[sName].show();
		this.activeOverlay = sName;
	}
}

//-----------------------------------------------------------------
// Method Interface1.hideOverlay()
//-----------------------------------------------------------------
Interface1.prototype.hideOverlay = function() {
	if ( this.activeOverlay ) {
		if ( this.overlay[this.activeOverlay] )
			this.overlay[this.activeOverlay].hide();
		this.activeOverlay = false;
	}
}

//-----------------------------------------------------------------
// Method Interface1.setBusy()
//-----------------------------------------------------------------
Interface1.prototype.setBusy = function() {
	this.getAllPanes();
	for ( sPaneId in this.panes ) 
		if (  this.panes[sPaneId] ) 
			try { 
				this.panes[sPaneId].showOverlay('busy'); 
			} catch(error) {
			}
}

//-----------------------------------------------------------------
// Method Interface1.unsetBusy()
//-----------------------------------------------------------------
Interface1.prototype.unsetBusy = function() {
	this.hideAllOverlays();
}

//-----------------------------------------------------------------
// Method Interface1.hideAllOverlays()
//-----------------------------------------------------------------
Interface1.prototype.hideAllOverlays = function() {
	this.getAllPanes();
	for ( sPaneId in this.panes )
		if ( this.panes[sPaneId] )
			try { 
				this.panes[sPaneId].hideOverlay(); 
			} catch (error) {
			}
}

//-----------------------------------------------------------------
// Method Interface1.checkOnload()
//-----------------------------------------------------------------
Interface1.prototype.checkOnload = function () {

	if ( window.onload )
		var sOnload = window.onload.toString().replace(/\n/g, ' ').replace(/\r/g, ' ');
	else
		var sOnload = '';
	var aMatch = sOnload.match(/^\s*function anonymous\(\)\s*\{(.*)\}\s*$/);
	if ( aMatch ) {
		sOnload = aMatch[1];
	} else {
		var aMatch = sOnload.match(/^\s*function ([^ ]*\([^\)]*\))\s*\{.*\}\s*$/);
		if ( aMatch ) 
			sOnload = aMatch[1] + ';';
	}
	if ( !sOnload.match(/oInterface\.onload/) ) {
		// sOnload = 'oInterface.onload(); ' + sOnload;
		// window.onload = new Function(sOnload);
		addEventHandler(window, 'load', this, 'onload');
	}
}
	
//-----------------------------------------------------------------
// Method Interface1.onload()
//-----------------------------------------------------------------
Interface1.prototype.onload = function () {
	if ( !this.loaded ) {
		this.loaded = true;	
		// document.onclick = new Function('return ' + this.self() + '.onClick();');
	
		this.overlay['busy'] = new Overlay1(this);
		this.overlay['busy'].setCursor('wait');
	
		this.overlay['blocked'] = new Overlay1(this);
		this.overlay['blocked'].setCursor('default');
		this.overlay['blocked'].setColor('#ffffff');
		this.overlay['blocked'].setOpacity(50);
	
		this.overlay['disabled'] = new Overlay1(this);
		this.overlay['disabled'].setCursor('default');
	
		if ( this.unlockOtherPanes ) {
			this.hideAllOverlays();
		}
	
		// for backward compatibility
		this._jsInitExecute = INIT_FIRST_STR + this._jsInitExecute;
		this._jsInitExecute += INIT_STR;
	
		if ( this._jsInitExecute != '' )
			eval(this._jsInitExecute);
	}
}


//-----------------------------------------------------------------
// Method Interface1.initExecute(sJavaScriptCode)
//-----------------------------------------------------------------
Interface1.prototype.initExecute = function () {
	if ( !window.onload ) {
		window.onload = new Function(this.jsName + '.onload();');
	}
	switch ( arguments.length ) {
		case 1:		this._initExecute1(arguments[0]); break;
		default:		this._initExecute2(arguments[0], arguments[1], arguments); break;
	}
}

//-----------------------------------------------------------------
// Method Interface1._initExecute1()
//-----------------------------------------------------------------
Interface1.prototype._initExecute1 = function (sJavaScriptCode) {
	if ( this.loaded )
		eval(sJavaScriptCode);
	else
		this._jsInitExecute += sJavaScriptCode + '\n';
}

//-----------------------------------------------------------------
// Method Interface1._initExecute2()
//-----------------------------------------------------------------
Interface1.prototype._initExecute2 = function (oObject, sMethod, aAllArgs) {
	if ( aAllArgs.length > 2 ) {
		var aArgs = new Array();
		for ( var i = 2; i < aAllArgs.length; i++ )
			aArgs.push("'" + aAllArgs[i] + "'");
		var sArgs = aArgs.join(', ', aArgs);
	} else {
		var sArgs = '';
	}
	var sJavaScriptCode = this._createReference(oObject) + '.' + sMethod + '(' + sArgs + ');\n';
	if ( this.loaded )
		eval(sJavaScriptCode);
	else
		this._jsInitExecute += sJavaScriptCode;
}

//-----------------------------------------------------------------
// Method Interface1.showSource()
//-----------------------------------------------------------------
Interface1.prototype.showSource = function () {
	if ( arguments.length > 0 )
		var sSource = arguments[0];
	else
		var sSource = document.body.outerHTML.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
	var oSource = window.open();
	oSource.document.open();
	oSource.document.write('<pre>');
	oSource.document.write(sSource);
	oSource.document.write('</pre>');
	oSource.document.close();
}	

//-----------------------------------------------------------------
// Method Interface1.showDebug()
//-----------------------------------------------------------------
Interface1.prototype.showDebug = function (sDebug) {
	var oDebug = window.open('', '_blank','height=300,width=500,resizable=yes,scrollbars=yes,directories=no,location=no,menubar=no,status=no,toolbar=no');
	oDebug.document.open();
	// Debug.document.write('<pre>');
	oDebug.document.write(sDebug);
	// Debug.document.write('</pre>');
	oDebug.document.close();
}

//-----------------------------------------------------------------
// Method Interface1.getFormField()
//-----------------------------------------------------------------
Interface1.prototype.getFormField = function (sName) {
	return document[this.formName].elements[sName];
}

//-----------------------------------------------------------------
// Method Interface1.createServerSideObject()
//-----------------------------------------------------------------
Interface1.prototype.createServerSideObject = function (sClass) {
	var oObject = this._newServerSideObject(sClass);
	for ( var i = 1; i < arguments.length; i++ )
		oObject.addConstructorArgument(arguments[i]);
	return oObject;
}

//-----------------------------------------------------------------
// Method Interface1._newServerSideObject()
//-----------------------------------------------------------------
Interface1.prototype._newServerSideObject = function (sClass) {
	return new ServerSideObject1(this, sClass);
}




// ==============================================================================================================================
// Class DialogHandler1
// ==============================================================================================================================
function DialogHandler1 (oInterface) {
	if ( arguments.length > 0 ) this.construct(oInterface);
}

//-----------------------------------------------------------------
// Method DialogHandler1.construct()
//-----------------------------------------------------------------
DialogHandler1.prototype.construct = function (oInterface) {
	this.interfaceObject = oInterface;
	this.reset(); 
	this.dialogWindow = false;
	this.interfaceObject.initExecute(this, 'initWatch');
}

//-----------------------------------------------------------------
// Method DialogHandler1.initWatch()
//-----------------------------------------------------------------
DialogHandler1.prototype.initWatch = function () {
	window.setInterval(this.interfaceObject._createReference(this) + '.watch();', 1000);
}

//-----------------------------------------------------------------
// Method DialogHandler1.reset()
//-----------------------------------------------------------------
DialogHandler1.prototype.reset = function () {
	this.buttons = new Array();
	this.buttonClicked = false;
}

//-----------------------------------------------------------------
// Method DialogHandler1.addButton()
//-----------------------------------------------------------------
DialogHandler1.prototype.addButton = function (sButton, oObject, sMethod, aMethodArgments) {
	this.buttons[sButton] = new DialogButtonHandler1(oObject, sMethod, aMethodArgments);
}

//-----------------------------------------------------------------
// Method DialogHandler1.watch()
//-----------------------------------------------------------------
DialogHandler1.prototype.watch = function () {
	if ( this.dialogWindow ) {
		if ( this.dialogWindow.closed ) {
			this.dialogWindow = false;
			this.interfaceObject.hideAllOverlays();
		}
	}
	if ( this.buttonClicked ) {
		if ( this.buttons[this.buttonClicked] ) {
			var sButton = this.buttonClicked;
			this.buttonClicked = false;
			this.buttons[sButton].execute();
			this.reset();
		} else {
			alert('Don\'t know how to handle button ' + this.buttonClicked);
			this.buttonClicked = false;
		}
	}
}

//-----------------------------------------------------------------
// Method DialogHandler1.closeWindow()
//-----------------------------------------------------------------
DialogHandler1.prototype.closeWindow = function () {
	if ( this.dialogWindow ) {
		if ( !this.dialogWindow.closed ) {
			this.dialogWindow.close();
			this.dialogWindow = false;
			this.interfaceObject.hideAllOverlays();
		}
	}
}

// ==============================================================================================================================
// Class DialogButtonHandler1
// ==============================================================================================================================
function DialogButtonHandler1 (oObject, sMethod, aMethodArgments) {
	this.construct(oObject, sMethod, aMethodArgments);
}

//-----------------------------------------------------------------
// Method DialogButtonHandler1.construct()
//-----------------------------------------------------------------
DialogButtonHandler1.prototype.construct = function (oObject, sMethod, aMethodArgments) {
	this.object = oObject;
	this.method = sMethod;
	this.args = aMethodArgments;
}

//-----------------------------------------------------------------
// Method DialogButtonHandler1.execute()
//-----------------------------------------------------------------
DialogButtonHandler1.prototype.execute = function () {
	if ( this.object )
		this.object[this.method].apply(this.object, this.args);
}



// ==============================================================================================================================
// Class Dialog1
// ==============================================================================================================================
function Dialog1 (oInterface) {
	this.construct(oInterface);
}

//-----------------------------------------------------------------
// Method Dialog1.construct()
//-----------------------------------------------------------------
Dialog1.prototype.construct = function (oInterface) {
	this.interfaceObject = oInterface;
	this.arguments = new Array();
	this.url = 'popup.php';
	this.width = 500;
	this.height = 500;
	this.buttonClicked;
	this.scrolling = false;
	this.modal = true;
	this.buttons = new Array();
}

//-----------------------------------------------------------------
// Method Dialog1.addArgument()
//-----------------------------------------------------------------
Dialog1.prototype.addArgument = function (sVar, sValue) {
	this.arguments[sVar] = sValue;
}

//-----------------------------------------------------------------
// Method Dialog1.addArgument()
//-----------------------------------------------------------------
Dialog1.prototype.addButton = function (sButton, oObject, sMethod) {
	var aMethodArguments = new Array();
	for ( var i = 3; i < arguments.length; i++ )
		aMethodArguments.push(arguments[i]);
	this.interfaceObject.dialogHandler.addButton(sButton, oObject, sMethod, aMethodArguments);
	this.interfaceObject.dialogHandler.addButton('BUTTON_' + this.buttons.length, oObject, sMethod, aMethodArguments);
	this.buttons.push(sButton);
}

//-----------------------------------------------------------------
// Method Dialog1.setModal()
//-----------------------------------------------------------------
Dialog1.prototype.setModal = function (bModal) {
	this.modal = bModal;
}

//-----------------------------------------------------------------
// Method Dialog1.setURL()
//-----------------------------------------------------------------
Dialog1.prototype.setURL = function (sURL) {
	this.url = sURL;
}

//-----------------------------------------------------------------
// Method Dialog1.setScrolling()
//-----------------------------------------------------------------
Dialog1.prototype.setScrolling = function (bScrolling) {
	this.scrolling = bScrolling;
}

//-----------------------------------------------------------------
// Method Dialog1.setWidth()
//-----------------------------------------------------------------
Dialog1.prototype.setWidth = function (iWidth) {
	this.width = iWidth;
}

//-----------------------------------------------------------------
// Method Dialog1.setHeight()
//-----------------------------------------------------------------
Dialog1.prototype.setHeight = function (iHeight) {
	this.height = iHeight;
}

//-----------------------------------------------------------------
// Method Dialog1.show()
//-----------------------------------------------------------------
Dialog1.prototype.show = function () {
	var sURL = this.url;
	var i;
	sURL += '?timestamp=' + Math.random();
	for ( i in this.arguments )
		sURL += '&' + i + '=' + this.arguments[i];
	for ( var i = 0; i < this.buttons.length; i++ )
		sURL += '&buttons[]' + '=' + this.buttons[i];
	this.buttonClicked = this._showDialog(sURL);
	return this.buttonClicked;
}

//-----------------------------------------------------------------
// Method Dialog1.show()
//-----------------------------------------------------------------
Dialog1.prototype.close = function () {
	this.interfaceObject.dialogHandler.closeWindow();
}

//-----------------------------------------------------------------
// Method Dialog1._showDialog()
//-----------------------------------------------------------------
Dialog1.prototype._showDialog = function (sURL) {
	var Arguments = this.interfaceObject;
	if ( this.modal && window.showModalDialog ) {
		var sOptions = '';
		sOptions += 'dialogWidth:' + this.width + 'px; ';
		sOptions += 'dialogHeight:' + this.height + 'px; ';
		sOptions += 'scroll:' + ( this.scrolling ? 'yes' : 'no' ) + '; ';
		sOptions += 'help:no; ';
		sOptions += 'status:no; ';
		sOptions += 'center:yes; ';
		sOptions += 'unadorned:yes;';
		return window.showModalDialog(sURL, Arguments, sOptions);
	} else {
		// alert('not supported in this browser');
		var sOptions = '';
		sOptions += 'width=' + this.width + ', ';
		sOptions += 'height=' + this.height + ', ';
		sOptions += 'left=' + Math.round((screen.width-this.width)/2) + ', ';
		sOptions += 'top=' + Math.round((screen.height-this.height)/2) + ', ';
		sOptions += 'channelmode=no, ';
		sOptions += 'directories=no, ';
		sOptions += 'fullscreen=no, ';
		sOptions += 'location=no, ';
		sOptions += 'menubar=no, ';
		sOptions += 'resizable=' + ( this.resizable ? 'yes' : 'no' ) + ', ';
		sOptions += 'scrollbars=' + ( this.scrolling ? 'yes' : 'no' ) + ', ';
		sOptions += 'status=no, ';
		sOptions += 'titlebar=yes, ';
		sOptions += 'dialog=yes, ';
		sOptions += 'toolbar=no';
		this.interfaceObject.dialogHandler.dialogWindow = window.open(sURL, 'new_dialog', sOptions);
	}
}


// ==============================================================================================================================
// Class Overlay1
// ==============================================================================================================================
function Overlay1 (oInterface) {
	this.construct(oInterface);
}

//-----------------------------------------------------------------
// Method Overlay1.construct()
//-----------------------------------------------------------------
Overlay1.prototype.construct = function (oInterface) {
	this.interfaceObject = oInterface;
	this.div = false;
	this.img = false;
	this.init();
}

//-----------------------------------------------------------------
// Method Overlay1.init()
//-----------------------------------------------------------------
Overlay1.prototype.init = function () {
	this.div = document.createElement('DIV');
	this.div.style.position = 'absolute';
	this.div.style.top = '0px';
	this.div.style.left = '0px';
	this.div.style.width = this.interfaceObject.overlayWidth;
	this.div.style.height = this.interfaceObject.overlayHeight;
	// this.div.style.backgroundColor = '#ffffff';
	// this.div.style.filter = 'alpha(opacity=100)';
	this.div.style.visibility = 'hidden';

	// document.body.insertAdjacentElement('afterBegin', this.div);
	// cross-browser equivalent:
	document.body.insertBefore(this.div, document.body.firstChild);

	this.img = document.createElement('IMG');
	this.img.src = IMAGE_URL + '/empty.gif';
	this.img.style.width = '100%';
	this.img.style.height = '100%';
	this.img.galleryimg = 'no';
	// this.img.style.cursor = 'wait';

	this.div.appendChild(this.img);
}

//-----------------------------------------------------------------
// Method Overlay1.setCursor()
//-----------------------------------------------------------------
Overlay1.prototype.setCursor = function (sCursor) {
	this.div.style.cursor = sCursor;
	this.img.style.cursor = sCursor;
}

//-----------------------------------------------------------------
// Method Overlay1.setColor()
//-----------------------------------------------------------------
Overlay1.prototype.setColor = function (sColor) {
	this.div.style.backgroundColor = sColor;
}

//-----------------------------------------------------------------
// Method Overlay1.setOpacity()
//-----------------------------------------------------------------
Overlay1.prototype.setOpacity = function (iPercentage) {
	this.div.style.filter = 'alpha(opacity=' + iPercentage + ')';
}

//-----------------------------------------------------------------
// Method Overlay1.show()
//-----------------------------------------------------------------
Overlay1.prototype.show = function () {
	this.div.style.visibility = 'visible';
}

//-----------------------------------------------------------------
// Method Overlay1.hide()
//-----------------------------------------------------------------
Overlay1.prototype.hide = function () {
	this.div.style.visibility = 'hidden';
}


// ==============================================================================================================================
// Class Error1
// ==============================================================================================================================

function Error1 (sType, sText, sSubText) {
	if ( arguments.length > 0 ) this.construct(sType, sText, sSubText);
}

//-----------------------------------------------------------------
// Method Error1.construct()
//-----------------------------------------------------------------
Error1.prototype.construct = function (sType, sText, sSubText) {
	this.type = sType;
	this.text = sText;
	this.subText = sSubText;
}