/* behavioursAOSurgery.js
Theme: AOSurgery2008-P6
update 2009-10-16 (hea) */

/* ACHTUNG: 
Die Funktionen werden ueber die unten notierte startFunctions() aufgerufen */
/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */



/* 2005-11-29 msc */
/* Dieses Script weist dem IE die Hoehe des body dynamisch zu, damit der Text
wieder markierbar wird - Internet Explorer only - proprietaerer Code: */

function makeTextMarkIE(){
	if ((document.all) && (navigator.userAgent.indexOf("MSIE") != -1) && (document.getElementById("maincontent"))){

		var content_hoehe = document.getElementById("maincontent").scrollHeight;
		var benoetigte_hoehe = content_hoehe + 80;
		var neue_body_hoehe = "height:" + benoetigte_hoehe + "px;";
		document.body.style.cssText = neue_body_hoehe;
		}
} 



function resizePopUp(numberWidth){

	A = null;

	if (window.innerHeight != undefined) {
		A= [window.outerWidth,window.outerHeight]; // most browsers
	} else { // IE varieties
		var D= document.documentElement;
		A= [D.clientWidth,D.clientHeight]; 
	}

	if (A != null && numberWidth > (A[0]-30) && numberWidth < (A[0]+30)) {
	} else {
		window.resizeTo(numberWidth, 690);
	}

	self.focus();
}


// not used at the moment.(rsc)
function openPopup(popupLink, popupWidth) {
  window.open(popupLink,'popup','left=10,top=10,width='+popupWidth+',height=690,toolbar=no,location=no,status=no,menubar=no,resizable=no,scrollbars=yes');
}

// 2009-09: Surgery Discussion Portlet, innerHTML-Clipping
function thisToTarget(){
	if (document.getElementById("sdpSource") && document.getElementById("sdpTarget")){
		var sdpSource = document.getElementById("sdpSource").innerHTML;
		var sdpTarget = document.getElementById("sdpTarget");
		sdpTarget.innerHTML = sdpSource;
		}
	}

/* 2009-10-16 hea */
/* Dieses Script "schiebt" die Loginpage dazwischen und leitet nach erfolgreichem Login zur angeforderten URL weiter */
function changeURL2Login(sURL){
	var sHost = window.location.hostname;
	var iIndexPWPS = sURL.indexOf("/portal/wps/");
	var iIndexWPS = sURL.indexOf("/wps/portal");
	if (iIndexPWPS < 0){
		sURL = sURL.substring(0, iIndexWPS) + "/wps/my" + sURL.substring(iIndexWPS + 5);
	}else{
		sURL = sURL.substring(0, iIndexPWPS) + "/wps/my" + sURL.substring(iIndexPWPS + 12);
	}
	/* change to https if the environment is not development */
	if (sHost.indexOf("192.168.110.20") == -1) {
		if (sURL.indexOf("http:") >= 0){
			sURL = "https:" + sURL.substring(5);
		} else {
			sURL = "https://" + sHost + sURL;
		}
	}
	// encoding the comma is needed, because otherwise the parameter list of the forward after the login screen will end
	// by the comma!!!!
	var encodedURL = sURL.replace(",", "%2C");
	
	window.location.href = encodedURL;
}

function changeToDarkImage(obj, newSrc) {
	obj.src = newSrc;
}
function changeToBrightImage(obj, newSrc) {
	obj.src = newSrc;
}

/* Suchfelder beim Fokus leeren : */
function changeSearchValue(){
	if(!document.getElementById("searchFor")) return false;
	var textField = document.getElementById("searchFor");
	var defaultValue = textField.getAttribute("value");
	var empty = "";
	
	textField.onfocus = function(){
		textField.setAttribute("value",empty);
		}
		
	textField.onblur = function(){
		if(textField.value=='')
		textField.setAttribute("value",defaultValue);
		}
}
function changeSearchGlossaryValue(){
	if(!document.getElementById("glossaryquery")) return false;
	var textField = document.getElementById("glossaryquery");
	var defaultValue = textField.getAttribute("value");
	var empty = "";
	
	textField.onfocus = function(){
		textField.setAttribute("value",empty);
		}
		
	textField.onblur = function(){
		if(textField.value=='')
		textField.setAttribute("value",defaultValue);
		}
}

/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */
/* ruft oben notierte Funktionen auf via body onLoad="startFunctions();"  */
function startFunctions(){
	makeTextMarkIE();
	thisToTarget();
	// ** 02.09.2010 hea ** The following method calls should be set productive when the SR search goes productive!
	//changeSearchValue();
	//changeSearchGlossaryValue();
}

