
function doNothing() {
	return;
}
function pausecomp(millis)
{
	var date = new Date();
	var curDate = null;

	do { curDate = new Date(); }
	while(curDate-date < millis);
}

function stopBubbling(evnt) {
	var e = (window.event)? window.event : evnt;
	e.cancelBubble = true;
	if (e.stopPropagation)
		e.stopPropagation();
}
// -------------------------------------------------------------------
// hasOptions(obj)
//  Utility function to determine if a select object has an options array
// -------------------------------------------------------------------
function hasOptions(obj) {
	if (obj!=null && obj.options!=null) { return true; }
	return false;
}

// -------------------------------------------------------------------
// addOption(select_object,display_text,value,selected)
//  Add an option to a list
// -------------------------------------------------------------------
function removeAllOptions(from) {
	if (!hasOptions(from)) { return; }
	for (var i=(from.options.length-1); i>=0; i--) {
		from.options[i] = null;
	}
	from.selectedIndex = -1;
}
function printFrame(ViewFrame) {
	ViewFrame.focus();
	ViewFrame.print();
}

// onLoad Function
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
// returns INNER width of window
function getWindowWidth() {
    var myWidth = 0;

    if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myWidth = window.innerWidth;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
    }
    return myWidth;
}

// returns INNER height of window
function getWindowHeight() {
    var myHeight = 0;

    if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myHeight = document.body.clientHeight;
    }
    return myHeight;
}
//********************************************
//** Author : Gabriel Dudek
//** 		  (c) 2008 GDS Design
//********************************************
function iFrameHelper(iframe, percentLabelID) {


    this._Iframe = iframe;
    //this._Iframe.helper		= this;
    //this._Iframe.onload		= undefined;

    this._lblPercentID = percentLabelID;
    this._lblPercent = document.getElementById(percentLabelID);

    this._loadingTimeOut = undefined;

    this.percent = 0;
    this.state = "Start Loading ..";

    //this._Iframe.style.border = '5px solid Red';

    this.onProgressUpdate(this);
};
iFrameHelper.prototype._OnReadyStateChanged = function(e) {
    try {
        var evt = window.event || e;
        var evtTarget = evt.target || evt.srcElement;

        //alert(evtTarget.readyState);

        //if (evtTarget.readyState == "complete") {
        if (evtTarget && (evtTarget.readyState == undefined || evtTarget.readyState == "complete")) {

            evtTarget.helper.percent = 100;
            evtTarget.helper.state = "complete";

            window.clearTimeout(evtTarget.helper._loadingTimeOut);

            evtTarget.helper.onLoadComplete(evtTarget.helper);
        } else {
            if (evtTarget && evtTarget.readyState) {
                evtTarget.helper.state = evtTarget.readyState;
            }
        }
    } catch (ex) {

    }

    //iframe.onreadystatechange = iframeReadyStateChanged(iframe);
    //iframe.readyState = "complete";
};

iFrameHelper.prototype._updatePercentLabel = function() {
    if (this._lblPercent) {
        this._lblPercent.innerHTML = "[" + this.state + "] : " + this.percent + " %";
    }
};

iFrameHelper.prototype._updateLoadingState = function() {
    var newstate = this.state;
    var doc = undefined;

    try {
        if (this._Iframe.contentWindow) {
            doc = this._Iframe.contentWindow.document;
            if (doc != undefined) {
                newstate = "loading";

                //if (ie) {
                newstate = doc.readyState;
                //} else {
                //    newstate = doc.readyState;
                //}

            }
        }

        this.state = newstate;

        return this.state;

    } catch (ex) {
        if (ex.name == 'TypeError') {

            if (this.state != "complete") {
                newstate = "loading";
            } else {
                newstate = this.state;
            }

            this.state = newstate;

        } else {
            this.state = "loading"

            //alert("EXEPTION : " + ex.name);
            //alert("EXEPTION : " + ex.message);
        }

        return this.state;
    }
};

iFrameHelper.prototype._UpdateProgressState = function() {

    this.state = this._updateLoadingState();
    //this.percent 	= percent;

    if (this.percent < 98 && this.state != "complete" && this.state != "unknown") {
        // hier die Progressanzeige aktualisieren

        //this._updatePercentLabel();
        this.onProgressUpdate(this);

        this.percent += 2;
        //try {
        //	this._loadingTimeOut = window.setTimeout(function(thisObj) { thisObj._UpdateProgressState(); }, 400, this);
        //} catch(ex) {
        this._loadingTimeOut = window.setTimeout(function(thisObj) {
            return function() {
                thisObj._UpdateProgressState();
            }
        } (this), 400);
        //alert("Can not set '_UpdateProgressState' timeout object.")
        //}
    } else {
        this.percent = 100;

        this.onLoadComplete(this);

        window.clearTimeout(this._loadingTimeOut);
    }
};

iFrameHelper.prototype.loadUrl = function LoadUrlToIFrame(url, title, scrolling, width, height) {

    this.Init(scrolling, width, height);

    //this._Iframe.setAttribute("src", url);
    //this._Iframe.contentWindow.location.href = url;
    this._Iframe.contentWindow.location.replace(url);
    
    this._UpdateProgressState(0);
};

iFrameHelper.prototype.onProgressUpdate = function(iFrameHelperInstance) {
    var percentLabel = document.getElementById(iFrameHelperInstance._lblPercentID);
    if (percentLabel) {
        percentLabel.innerHTML = "[" + iFrameHelperInstance.state + "] : " + iFrameHelperInstance.percent + " %";
    }
};

iFrameHelper.prototype.onLoadComplete = function(iFrameHelperInstance) {

    //this._updatePercentLabel();
    iFrameHelperInstance.onProgressUpdate(this);

    iFrameHelperInstance._Iframe.style.border = '5px solid Green';

};

iFrameHelper.prototype.Init = function(scrolling, width, height) {
    if (this._Iframe) {
        this._Iframe.helper = this;
        this._Iframe.onreadystatechange = this._OnReadyStateChanged;
        this._Iframe.onload = this._OnReadyStateChanged;
    }

    this.percent = 0;
    this.state = "Start Loading ..";

    if (scrolling) {
        try {
            this._Iframe.setAttribute("scrolling", "auto");
        } catch (ex) {
            this._Iframe.scrolling = 'auto';
        }
    } else {
        try {
            this._Iframe.setAttribute("scrolling", "no");
        } catch (ex) {
            this._Iframe.scrolling = 'no';
        }
    }
    if (width) {
        this._Iframe.style.width = width + "px";
    }
    if (height) {
        this._Iframe.style.height = height + "px";
    }

    this.onProgressUpdate(this);

    //return this;
};

//********************************************
