///--------------------------
       ///CLASS MODALDIALOGOPENER
       ///--------------------------
       
            //KONSTRUKTOR für einen Opener, der den Rückgabewert
            //in ein Textfeld schreibt.
            function ModalOpener(url,width,height,top,left,targetControlId)
            {
                //PROPERTIES
                this.Window = null;
            	this.url = url;
            	this.width = width;
            	this.height = height;
            	this.top = top;
            	this.left = left;
            	
                this.TargetControlId = targetControlId;
                
                //METHODEN
                this.OpenDialog = ModalOpener_OpenDialog;
                
                //EVENTS
		        this.ClickEvent = ModalOpener_FinishDialog;
                this.CancelEvent = ModalOpener_CancelDialog;
            }
                
           function ModalOpener_OpenDialog()
           {
                
               this.Window = window.open(this.url,'Modal','top=' + this.top + ',left=' + this.left + ',height=' + this.height + ',width=' + this.width + ',toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,modal=yes');
               this.Window.focus();
    		   currentOpener = this;
           }
        ///--------------------------
       ///ENDCLASS
       ///--------------------------

///--------------------------
//GLOBALE FUNKTIONEN
///--------------------------
//DIALOG RUFT SETEVENTS AUF
var currentOpener;
function SetEvents()
{
    currentOpener.Window.RegisterEventHandler(currentOpener.ClickEvent,currentOpener.CancelEvent);
}       

function ModalOpener_FinishDialog()
{
    if(currentOpener != null)
    {
        if(currentOpener.Window != null)
        {
            if(currentOpener.TargetControlId) //WURDE EIN ZIELFELD DEFINIERT?
            {
                targetControl = window.document.getElementById(currentOpener.TargetControlId);
                if(targetControl) //EXISTIERT DAS ZIELFELD?
                    targetControl.value = currentOpener.Window.GetValue(); //WERT SCHREIBEN
            }
            currentOpener.Window.close(); //DIALOG SCHLIEßEN
            currentOpener.Window = null; //DIALOG AUF INAKTIV SETZEN
        }
    }
}

function ModalOpener_CancelDialog()
{
    if(currentOpener != null)
    {
        if(currentOpener.Window != null)
        {
        	currentOpener.Window.close(); //DIALOG SCHLIEßEN
            currentOpener.Window = null; //DIALOG AUF INAKTIV SETZEN
        }
    }
}


function FocusOnDialog()
{
    if(currentOpener != null)
    {
        if(currentOpener.Window != null)
        {
            try
            {
                currentOpener.Window.focus();
            }
            catch(e)
            {
                currentOpener.Window = null;
            }
        }
    }
}