//Window resize
function getWindowHeight()
	{
	var windowHeight=0;
	if (typeof(window.innerHeight)=='number')
		{
		windowHeight=window.innerHeight;
		}
	else
		{
		if (document.documentElement&&
		document.documentElement.clientHeight)
		{
		windowHeight=document.documentElement.clientHeight;
		}
	else
		{
		if (document.body&&document.body.clientHeight)
			{
			windowHeight=document.body.clientHeight;
			}
		}
	}
return windowHeight;
}



function setFooter()
	{
	//alert(document.getElementById('contentcontainer').offsetHeight);
	var main = document.getElementById('contentcontainer').offsetHeight;
	var head = document.getElementById('header').offsetHeight;

	var total = main+head;
	var windowHeight=getWindowHeight();

	if (total < windowHeight)
		{
		var newheight=windowHeight-total-document.getElementById('contentfooter').offsetHeight;
		var footerElement=document.getElementById('contentfooter');
		var footerHeight=footerElement.offsetHeight;
		footerElement.style.position='relative';
		footerElement.style.top=(newheight)+'px';
		}
	}



// this is a keypress handler that only reacts to return-keypresses
// if "return" is pressed it *tries* to submit the currently focused form
// or the last form on the page
// 12.10.06, tax: This function could have been used to submit forms with IE which
//                do not have a "Submit" button.
function enterKeyHandler(eventOrSource) {
    eventSource = (window.event) ?	window.event.srcElement : eventOrSource.target;

    if(eventSource.type == "textarea")
        return;

    key = (window.event) ? window.event.keyCode : eventOrSource.keyCode;

    if(key == 13) {
        var form;
        if(eventSource["form"]) {
            form = eventSource["form"];
        } else if ( document.forms.length > 0 ) {
            form = document.forms[document.forms.length-1];
        } else {
            return;
        }

        form.submit();
    }
}
// 28.09.06 tax: deactivated the enterKeyHandler since it caused the IE to submit forms twice, sometimes!
//document.onkeypress = enterKeyHandler;

function submitThisForm(myForm) {
	myForm.submit();
}

function submitForm() {
	document.forms[0].submit();
}

function popupOpener(URLtoOpen, windowName, windowFeatures) {
   mov = window.open(URLtoOpen, windowName, windowFeatures);
}

function overwriteNavLabel(title) {
   document.getElementById('midpictext').innerHTML=title;
}

function setVisual(clazz) {
   //elename = 'mid';
   var element =document.getElementById("mid");
   if (element!=null) {
       element.className=clazz;
       //alert(element + " " +element.className );
   } else {
       //alert('Element '+elename+' could not be located!');
   }
}

/***
 * Used to correct the #-problem in URLs of the JSR-168 portlet calls
 * of remote devices.
 */
function correctUrlWithQueryAndFragmentPart(url) {
	var indexOfFragment = url.indexOf("#");
	var indexOfQuery = url.indexOf("?");
	var now = new Date();
	if (indexOfFragment > 0 && indexOfQuery > indexOfFragment) {
		/*  url: http://host/path#fragment?query 
		    reorder the url to
		    url: http://host/path?query#fragment
		 */
		var tmp = url.split("#");
		url = tmp[0];     /* http://host/path   
                                   */
		tmp = tmp[1].split("?"); // fragment?query 
		url = url + "?" + tmp[1]+ "&req_uid=" + now.getTime() + "#" + tmp[0];
	} else if (indexOfQuery > 0) {
		url = url + "&req_uid=" + now.getTime();
	}
	return url;
}

function noenter() {
   if (window.event && window.event.keyCode == 13) {
      window.event.keyCode=0;
   }
}