
function insertActiveContent(currentActiveContent) 
{
	//This function is used to insert ActiveX controls (like a flash object) which are 
	//only active in IE 6 if they are inserted via an external javascript function call. 
	//It is necessary for Internet Explorer due to its ActiveX Control Activation (security) update. 
	if (null != currentActiveContent) 
	{
		document.write(currentActiveContent);
		//Test-Output: 
		//alert(currentActiveContent);
	}
}

function openImageViewer( myhref, popupName, height, width ) 
{
	
	var intWidth=parseInt( width);
	if (intWidth < 270)
	{intWidth="270";}
	
	var intHeight=parseInt(height);
	if (intHeight < 174)
	{intHeight="174";}
	
	var newHeight=parseInt(intHeight) +84;
	var newWidth=parseInt(intWidth) +36;
	


	window.open(myhref, popupName, "toolbar=no,location=no,status=no,menubar=no,resizable=yes,scrollbars=auto,height=" + newHeight + ",width=" + newWidth + ",");
}

function setDesc(elementId, classname, txt) 
{
	var foo = document.getElementById(elementId);
	if (foo != null) {
		foo.className = classname;
		foo.style.display = "block";
		foo.innerHTML = txt;
	}
}

function doConfirmSubmit(f, question) 
{
	if (confirm(question)) 
	{
		f.submit();
	}
}

function navBarRollover(theCell, hoverFlag) 
{
	if (hoverFlag) 
	{
		theCell.className = 'rollOver';
	} 
	else 
	{
		theCell.className = 'rollOut';
	}
}

function doConfirmSubmit(f, question) 
{
	if (confirm(question)) 
	{
		f.submit();
	}
}

function showDiv(thisDiv) 
{
	if (document.layers) 
	{
		if (document != null && document.layers[thisDiv] != null) 
		{
			document.layers[thisDiv].visibility = "show";
		}
	} 
	else if (document.all) 
	{
		if (document != null && document.all[thisDiv] != null && document.all[thisDiv].style != null) 
		{
			document.all[thisDiv].style.visibility = "visible"; 
		}
	} 
	else if (document.getElementById) 
	{
		if (document != null && document.getElementById(thisDiv) != null) 
		{
			document.getElementById(thisDiv).style.visibility = "visible"; 
		}
	}
}

function hideDiv(thisDiv) 
{
	if (document.layers) 
	{
		if (document != null && document.layers[thisDiv] != null) 
		{
			document.layers[thisDiv].visibility = "hide";
		}
	} 
	else if (document.all) 
	{
		if (document != null && document.all[thisDiv] != null && document.all[thisDiv].style != null) 
		{
			document.all[thisDiv].style.visibility = "hidden";
		}
	} 
	else if (document.getElementById) 
	{
		if (document != null && document.getElementById(thisDiv) != null) 
		{
			document.getElementById(thisDiv).style.visibility = "hidden";
		}
	}
}

function goToChangeLocationFunction(selectForm, redirectURL)
{
	//alert (selectForm);
	//alert (redirectURL);
	
	//Check if a selectForm parameter has been passed: 
	if(null != selectForm) 
	{
		
		//Do not submit the form if an entry with a null value has been chosen:
		if(null != redirectURL) 
		{
			//Do not submit the form if an entry without a valid value has been chosen:
			if(0 < redirectURL.length)
			{
				//selectForm.action="SMRedirect";
				//selectForm.submit();
				
				//alert (redirectURL);
		
				if (redirectURL.indexOf('external_') == 0)
				{
					// non-siemens link --> show disclaimer for US market
					if (redirectURL.toLowerCase().indexOf("siemens") == -1) {
						externalLinkHandler();
					}
					
					//External link: 
					redirectURL=redirectURL.substring(9);
					var theWindow = window.open(redirectURL,'_blank','toolbar=yes,location=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes');
					theWindow.focus();
					return false;
				}
				else if (redirectURL.indexOf('internal_') == 0)
				{
					//Internal link:
					redirectURL=redirectURL.substring(9);
					window.location.href=redirectURL;
					return false;
				}
				else if ("-1" == redirectURL)
				{
					//No link value passed (for example dropdown default selector value):
					return false;
				}
				else
				{
					return false;
				}
			}
		}
	}
	
	return false;
	
} // javascript function goToChangeLocationFunction	

function goToChangeCountry(selectForm, redirectURL, currentURL)
{
	//alert ("selectForm=" + selectForm + ";redirectURL=" + redirectURL + ";currentURL=" + currentURL );
	
	//Check if a selectForm parameter has been passed: 
	if(null != selectForm) 
	{
		//Do not submit the form if an entry with a null value has been chosen:
		if(null != redirectURL) 
		{
			//Do not submit the form if an entry without a valid value has been chosen:
			if(0 < redirectURL.length)
			{
				if(redirectURL == currentURL)
				{
					return false;
				}
				else
				{
					selectForm.submit();
				}
			}
		}
	}
	
	return false;
	
} // javascript function goToChangeCountry(selectForm, redirectURL)



function getPrintURL(contextPath, locale) 
{
	var fullPath = location.pathname;

	var path = 	fullPath.substring(contextPath.length);
	var relativeURL = path + location.search;
	
	// search for tabId hash
	if (window.location.hash.search(/tabId/)) {
		var hash = window.location.hash.match(/\d+$/);
		if (hash != null && hash.length > 0 ) {
			relativeURL.sub('tabId', '_tabId');			
			relativeURL += '&tabId=' + hash;
		} 
	}

	printURL = contextPath + '/PrintableView?locale=' + locale + '&url=' + relativeURL;
	return printURL;
}

function getEmailURL(contextPath) 
{

	var fullPath = location.pathname;

	var path = 	fullPath.substring(contextPath.length);
	var relativeURL = path + location.search;

	emailURL = relativeURL; 
	
	emailURL=escape(emailURL); 
   
	return emailURL; 
	
} 

function CreateRefPopupWindow(windowname, url, width, height, addressLine, browserMenu, browserStatus,
	closeWithCallingWindow, allowKeyboardCommand, resize, toolBar, scrollBars,
	popupExtRefObjektId)
{
	var href, left, top;
	var params = "";
        
        if (width > screen.width)
		width = screen.width;
	if (height > screen.height)
		height = screen.height;

	// center popup window
	left = (screen.width - width) / 2;
	top = (screen.height - height) / 2;

	if (typeof(url) == 'string')
		href=url;
	else
		href=url.href;

	if (width > 0)
	{
		left = (screen.width - width) / 2;
		params += "width=" + width + ", left=" + left + ", ";
	}

	if (height > 0)
	{
		top = (screen.height - height) / 2;
		params += "height=" + height + ", top=" + top + ", ";
	}

	if (addressLine)
		params += "location=yes" + ", ";
	else
		params += "location=no" + ", ";

	if (browserMenu)
		params += "menubar=yes" + ", ";
	else
		params += "menubar=no" + ", ";

	if (browserStatus)
		params += "status=yes" + ", ";
	else
		params += "status=no" + ", ";

	if (closeWithCallingWindow)	// geht nicht
		params += "dependent=yes" + ", ";
	else
		params += "dependent=no" + ", ";

	if (allowKeyboardCommand)	// geht nicht
		params += "hotkeys=yes" + ", ";
	else
		params += "hotkeys=no" + ", ";

	if (resize)
		params += "resizable=yes" + ", ";
	else
		params += "resizable=no" + ", ";

	if (toolBar)
		params += "toolbar=yes" + ", ";
	else
		params += "toolbar=no" + ", ";

	if (scrollBars)
		params += "scrollbars=yes" + ", ";
	else
		params += "scrollbars=no" + ", ";

	if (params.length > 0)
		params = params.substring(0, params.length - 2);
	// alert(params);

	// alert(url);
	if (url.indexOf("http://") == -1)
	{
		if (url.indexOf("http:\\") != -1)
		{
			// for the case of EXTREFERENZ.FILEPATH = for example 'http:\\www.kleine.at'
			url = url.replace("http:\\", "http://");
		}
		else
		{
			if (url.indexOf("http:") != -1)
			{
				// for the case of EXTREFERENZ.FILEPATH = for example 'http:\www.kleine.at'
				url = url.replace("http:", "http://");
			}
		}
	}
	if(popupExtRefObjektId==1)
	{
		if (url.substring(0,4).toLowerCase()=="www.")
		{
			url="http://" + url;
		}
  	}
	//alert(url);

	var winName = windowname + "_" +
		width + height + addressLine + browserMenu + browserStatus +
		closeWithCallingWindow + allowKeyboardCommand + resize + toolBar + scrollBars +
		"_" + popupExtRefObjektId;
	// alert(winName);
	var popup = window.open(url, winName, params);
	popup.focus();

}



/**
 * Functions needed for the survey page
 */
// Creates a browser popup (size 800 x 600) and displayes it in the center of screen.
function openSmedWindow(url) {

  var wndName = "eHealtPopupWnd";

  var width = 800;
  var height = 600;
  var params = "dependent=1,scrollbars=1,location=1,directories=0,status=1,menubar=1,toolbar=1,resizable=1";

  var left = (screen.availWidth-width)/2;
  var top = (screen.availHeight-height)/2;
  
  params = params + "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;

  if (window.popupWnd && !window.popupWnd.closed) {
  	//window.popupWnd.close();
  } else {
		window.popupWnd = window.open(url, wndName, params, true);
  }
  window.popupWnd.focus();
}
// send the userdata to the e-news server
function sendUserData(serverName) {
if (hasOptin() && serverName !="")
	{
    	var url = serverName;
        var queryString="?";
        var userForm = document.forms["SMSurvey"];
        var userFields = new Array("billingFirstName", "billingLastName", "billingAddress1", "billingCity", 
         		                       "billingState", "billingZipCode", "companyName", "billingCountry", "emailAddress");
        var params = new Array("fn", "ln", "add", "c", "s", "z", "org", "cn", "e");
        for (var i=0; i<userFields.length; i++)
        {
        	var field = userForm.elements[userFields[i]];
         	if (field != undefined)
         	{	// we must have a parameter already so add an ampersand
         		if(queryString.length > 1)
         		{
         			queryString += "&";
         		}
         		queryString += params[i];
         		queryString += "=";
         		queryString += field.value;
         	}
         }
         openSmedWindow(url + queryString);
    }
}
// checks if the form has an optin field and if it is checked 	
function hasOptin() {
	var hasOptin = false;
 
	if (document.forms["SMSurvey"].elements["optin"] != undefined)
	{
		hasOptin = document.forms["SMSurvey"].elements["optin"].checked;
   	}
   	return hasOptin;
}



function globalheaderVisualChange(visualChangeParameter)
{
	//This function shows and hides the currently active BP7 and E4A modules in the globalheader if available: 
	var visualChangePairsArray = visualChangeParameter.split(";");
	var visualChangePairsArrayLength = visualChangePairsArray.length;
	
	for(var visualChangePairsArrayCounter = 0; visualChangePairsArrayCounter < visualChangePairsArrayLength; visualChangePairsArrayCounter++)
	{
		var visualChangePairArray = visualChangePairsArray[visualChangePairsArrayCounter].split("=");
		if(null != visualChangePairArray[0] && null != visualChangePairArray[1])
		{
			if(0 < visualChangePairArray[0].length && 0 < visualChangePairArray[1].length)
			{
				if(document.getElementById(visualChangePairArray[0]) && document.getElementById(visualChangePairArray[1]))
				{
					document.getElementById(visualChangePairArray[0]).style.display='none';
					document.getElementById(visualChangePairArray[1]).style.display='block';
				}
			}
		}
	}
}



// redirects to URL passed in destination
// can be used for callbacks
function redirect_to (destination) {
	window.location.href = destination;
}


var smIELayerDocumentTitleFixInterval;

function loadOptionSellingVideo(url, headerText, width, height){
	// set layer to right size
	var myWidth = eval(width) + 12;
	$('layer-content').setStyle({
							margin: '12px 0 12px 44px',
							paddingLeft: '12px',
							paddingBottom: '12px',
							width: myWidth + 'px'
						});
	$('layer-header').update(headerText);
	$('layer-header').setStyle({
							paddingTop: '20px', 
							paddingBottom: '16px', 
							font: '18px Siemens Slab, Arial',
							color: '#333333'
						});
	$('layer-body').setStyle({
		paddingLeft: '0px',
		paddingRight: '0px',
		paddingBottom: '0px'
	});
	$('layer-body').update("<div id='layer-body-swf'/>");

	var flashvars = {};
	var params = {wmode: 'transparent'};
	var attributes = {styleclass: 'videoLayerBackground'};
	swfobject.embedSWF(url, "layer-body-swf", width, height, "9.0.0", false, flashvars, params, attributes);
	
	var documentTitleBackupForIE6 = document.title;
	jQuery('#layer-zone').toggle();
	//Correct the title for IE6: 
	document.title = documentTitleBackupForIE6;
	smIELayerDocumentTitleFixInterval= window.setInterval("smIELayerDocumentTitleFix('"+documentTitleBackupForIE6+"')", 10);
}



function loadOptionSellingVideoWithOmniture(url, headerText, width, height)
{
	loadOptionSellingVideo(url, headerText, width, height);
	TrackURL(url);
}



function smIELayerDocumentTitleFix(documentTitleBackupForIE6)
{
	document.title = documentTitleBackupForIE6;
	window.clearInterval(smIELayerDocumentTitleFixInterval);
}



function closeLayerZone()
{
	// close any tooltip that might be visible
	if ($('cluetip'))
		jQuery('#cluetip-close').trigger('click');
		
	
	// close any tooltip that might be visible
	if ($('popup_bg'))
		jQuery('#popup_close').trigger('click');
	
	jQuery('#layer-zone').toggle();
	
	$('layer-body').setStyle({
		paddingLeft: '0px',
		paddingRight: '0px',
		paddingBottom: '0px'
	});
	//All seem to work: 
	//$('layer-header').innerHTML = "";
	//$('layer-header').firstChild.nodeValue = "";
	//$('layer-header').update("");
	$('layer-header').empty();

	var currentSfw = document.getElementById("layer-body-swf");
	if (currentSfw) 
	{
		swfobject.removeSWF("layer-body-swf");
		$('layer-body').update("<div id='layer-body-swf' />");					
		//alert("removed");
	}
	$('layer-zone').fire('layer-zone:closed');
		
	// IK_00003465
	// I.E. forgets the document title
	// let's help this old lady
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
			document.title = jQuery('h1.header').text();
	}	
}



function showFlashLayer(imageName, flashvars, width, height){

	// CHARM IK 3507	
	// bring layer in correct position
	var marginTop = getScrollPosition();
	if (marginTop > 0)
		marginTop = marginTop - 167;
	if (marginTop < 0)
		marginTop = 0;
	marginTop = marginTop + 12;

	// set layer to right size		
	var marginLeft = (document.viewport.getWidth() - eval(width)) / 2;
	var contentWidth = eval(width) + 12;
	var flashVars = false;
	var flashAttributes = false;
	// EE 2009-05-11 Bugfix:
	// for IE autostart=true must be replaced by autostart=false
	// and player is started via setTimeout()
	if(navigator.userAgent.toLowerCase().indexOf('msie') != -1){
		// find autostart parameter within flashvars
		var begin = flashvars.indexOf('autostart=');
		var end = flashvars.indexOf('&', begin);
		// see if autostart is set to true
		if (flashvars.substring(begin, end).indexOf('true') != -1){
			var isAutostart = true;
			flashvars = flashvars.replace('autostart=true', 'autostart=false')
		}
	}
	
	if(flashvars.length > 0)
	{
		flashvars=flashvars+"&id=layer-body-swf";
	}
	else
	{
		//Should not happen. 
	}
	
	var flashParams = {flashvars: flashvars};
	

	$('layer-content').setStyle({ margin: marginTop + 'px 0 12px ' + marginLeft + 'px', 
								  paddingLeft: '12px', 
								  paddingBottom: '12px', 
								  width: contentWidth + 'px'});

	// IK_3502 - no-flash-active
	$('layer-body').update("<div id='layer-body-swf'>" +
								"<div ID='bp8-swf-no-flash-active' " +
									" style='width: " + width + "px; height:" + 
									height + "px; background-color:#222222;'>" +
									"<div style=' text-align:center; padding:" + 
										(height/2) + "px 20px 0px 20px; color:#ffffff;'>" +
										jQuery('#sm_no_flash_player_activated_msg').html() +
									"<\/div>" +
								"<\/div>" +
							"<\/div>");
	
	swfobject.embedSWF(imageName, "layer-body-swf", width, height,"9.0.0", flashVars, flashParams, flashAttributes);
	
	// start player
	if(isAutostart)
		setTimeout("document.getElementById('layer-body-swf').sendEvent('PLAY')",500);
	jQuery('#layer-zone').toggle();
	//$('layer-zone').scrollTo();
}

function setImage(element, image){
	$(element).writeAttribute("src", image);
}
	
	
function openBP8swf( url, locale, closeText, width, height, href, options ) {
	
	//Necessary for IE6: 
	jQuery('body').css('height', '99%'); 
	jQuery('body').css('overflow', 'visible'); 
	
	// CHARM IK_3444	
	// cut the swf's
	var _width = width;
	if ( url.match(/_hhf\./i)) 
		_width = 960;		
	
	// CHARM IK 3507 	
	// bring layer in correct position
	var marginTop = getScrollPosition();
	if (marginTop > 0)
		marginTop = marginTop - 115;
	if (marginTop < 0)
		marginTop = 0;
	marginTop = marginTop + 115;
		
	jQuery('#bp8-layer-content').css('margin', marginTop + 'px 0px 0px 14px'); 
	jQuery('#bp8-layer-content').css('width', _width + 'px'); 
	jQuery('#bp8-layer-content').css('height', height + 'px'); 
	
	// fix I.E 6 Bug
	jQuery('#bp8-layer-content').bgiframe();	
	
	var _height = parseInt(height) + 2;
	$('bp8-layer-left').setStyle({ height: _height + 'px' }); 
	$('bp8-layer-right').setStyle({ height: _height + 'px' }); 
	$('bp8-layer-close').update( closeText );
	
	
	// give the I.E. a hardcoded width for the close button
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
		jQuery('#bp8-layer-close').ready(function(){
			$('bp8-layer-close-background').setStyle({ width: '50px' });
		});
	}	
	
	// check the FlashPlayerVersion
	var playerVersion = swfobject.getFlashPlayerVersion();
	if ( url.match(/swf$/i) || url.match(/flv$/i)) {
		if (playerVersion.major >= 10 ) {
		
			//jQuery's append can append swf+alternative content that is processed by the browser: 
			// CR 424: allow fullscreen for layer-based flash applications
			//
			if ( url.match(/swf$/i)) {
				jQuery('#bp8-layer-content').ready(function(){
					jQuery('#bp8-layer-content').append("<OBJECT ID='bp8-swf' " +
								"WIDTH='" + width + "' " + 
								"HEIGHT='" + height + "' " + 
								"ALIGN='middle' " +
								"DATA='" + url + "' " +
								"TYPE='application/x-shockwave-flash'>" +
								print_param( 'MOVIE', url ) +
								print_param( 'PLAY', 'true' ) +	
								print_param( 'LOOP', 'true' ) + 
								print_param( 'QUALITY', 'high' ) +				
								print_param( 'allowFullScreen', 'true' ) +
								print_param( 'wmode', 'transparent' ) +
								print_param( 'menu', 'false' ) +
								print_param( 'allowScriptAccess', 'sameDomain' ) +
								print_param( 'FlashVars', 'scontentlocation=' + locale + '%2Fcontent.xml' ) +
								print_param( 'BASE', url.substring(0, url.lastIndexOf("/"))) +
								
								"<div ID='bp8-swf-no-flash-active' " +
								" style='width: " + width + "px; height:" + height + "px; background-color:#222222;'>" +
								"<div style=' text-align:center; padding:" + (height/2) + "px 20px 0px 20px; color:#ffffff;'>" +
								jQuery('#sm_no_flash_player_activated_msg').html() +
								"<\/div><\/div>" +
								
								"<\/OBJECT>");
								});
			}
			if ( url.match(/flv$/i)) {
				jQuery('#bp8-layer-content').ready(function(){
					jQuery('#bp8-layer-content').append("<OBJECT ID='bp8-swf' " +
									"WIDTH='" + width + "' " + 
									"HEIGHT='" + height + "' " + 
									"ALIGN='middle' " +
									"ID='" + url + "' " +
									"DATA='/siemens/player.swf?file=" + url + "' " +
									"TYPE='application/x-shockwave-flash'>" +
									print_param( 'MOVIE', '/siemens/player.swf?file=' + url ) +
									print_param( 'PLAY', 'true' ) +	
									print_param( 'QUALITY', 'high' ) +	
									print_param( 'allowFullScreen', 'true' ) +			
									print_param( 'wmode', 'transparent' ) +
									print_param( 'allowScriptAccess', 'sameDomain' ) +
									print_param( 'FlashVars', '&autostart=true&amp;controlbar=over&amp;repeat=none&amp;screencolor=#000000&amp;abouttext=Siemens Healthcare&amp;aboutlink=http://www.healthcare.siemens.com' ) +
									
									"<div ID='bp8-swf-no-flash-active' " +
									" style='width: " + width + "px; height:" + height + "px; background-color:#222222;'>" +
									"<div style=' text-align:center; padding:" + (height/2) + "px 20px 0px 20px; color:#ffffff;'>" +
									jQuery('#sm_no_flash_player_activated_msg').html() +
									"<\/div><\/div>" +
									
									"<\/OBJECT>");
									});				
			}											
			if ( url.match(/_hhf\./i)) {
				// CHARM IK_3444
				// hide 13px if the left and right border of the swf
				jQuery('#bp8-swf').css(	'z-index', '499' );
				jQuery('#bp8-swf').css(	'position', 'relative' ); 	
				jQuery('#bp8-swf').css(	'top', '0px' ); 	 	
				jQuery('#bp8-swf').css(	'left', '-16px' ); 									
			}	

		} else {
			// Charm 3395
			$('bp8-layer-content').insert("<div ID=bp8-swf " +
								" style='width: " + width + "px; height:" + height + "px; background-color:#222222;'>" +
								"<div style=' text-align:center; padding:" + (height/2) + "px 20px 0px 20px; color:#ffffff;'>" +
								jQuery('#sm_no_flash_player_msg').html() +
								"<\/div><\/div>");	
		}
	}
	if ( url.match(/htm$/i) || url.match(/html$/i)) {
		var _iframe =  "<iframe ID=bp8-swf " +
					" src='" + url + "'" +
					" style='width: " + width + "px; height:" + height + "px;" +
					" border:0px; overflow:hidden;'><\/iframe>";
					
		$('bp8-layer-content').insert( _iframe );	
	}			
		
	if ( url.match(/jpg$/i) || url.match(/gif$/i) || url.match(/png$/i)) {
		var _img =  "<div ID=bp8-swf " +
					" style='width: " + 
					width + "px; height:" + 
					height + "px;'>";
		if ( href ) 
			_img += "<a href=" + 
					href + " " + options + ">";
		_img += "<img src=" + 
				url + " border='0'>";
		if ( href ) 
			_img += "<\/a>";
		_img += "<\/div>";
		$('bp8-layer-content').insert( _img );	
	
	}			

	// maximize it, if set as fullscreen
	if( url.match(/_fullscreen_/)) 
		maximizeBP8SwfLayer();
	
	jQuery('#bp8-layer-zone').toggle();	

	// give the I.E. the document.title back and remind it from time to time
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {	
		var _title = jQuery('h1.header').text();
		document.title = _title;
		
		for (_time = 1000; _time < 6000; _time += 1000) {
			setTimeout("setBrowserTitle()", _time);
		}
	}	
}

function setBrowserTitle() {
	document.title = jQuery('h1.header').text();
}

	
function maximizeBP8SwfLayer(min_width, min_height, options) { 
	
	var height = '100%';
	var width = '100%';
	
	// check screnn for minimal dimensions
	if (min_height) {
		// get window size
		var screen_width = window.innerWidth;
		var screen_height = window.innerHeight;
		
		// and now for I.E.
		if(!screen_width) {
			if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
				screen_width = document.documentElement.clientWidth;
				screen_height = document.documentElement.clientHeight;	
			} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
				screen_width = document.body.clientWidth;
				screen_height = document.body.clientHeight;
			}	
		}
		
		// some calculations
		if(screen_width && screen_width < min_width) 
			width = min_width + 'px';
		if(screen_height && screen_height < min_height) 	
			height = min_height + 'px';	
	} 
	
	jQuery('#bp8-layer-content').css('margin', '0px'); 
	jQuery('#content-zone').css('display', 'none'); 
	jQuery('#footer-position-placeholder').css('display', 'none'); 
	jQuery('#footer-zone').css('display', 'none'); 

	jQuery('#bp8-swf').attr('width', '100%'); 
	jQuery('#bp8-swf').attr('height', '100%'); 
	jQuery('#bp8-swf').css(	'left', '0px' ); 	
	
	jQuery('#bp8-layer-left').css('height', '100%'); 
	jQuery('#bp8-layer-right').css('height', '100%'); 

	jQuery('#bp8-layer-content').css('height', height ); 
	jQuery('#bp8-layer-content').css('width', width ); 
 
	// options
	if (!options || !options.match(/show-logo/))
		jQuery('#logo').css('z-index', '498');
			
	// give the I.E. the document.title back and remind it from time to time
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {	
		var _title = jQuery('h1.header').text();
		document.title = _title;
		
		for (_time = 1000; _time < 2000; _time += 1000) {
			setTimeout("setBrowserTitle(\'" + escape(_title) + "\')", _time);
		}
	}	
}; 

function add_param( name, value ) {
	var _param = document.createElement('param');
		_param.setAttribute('value', value);
		_param.setAttribute('name', name);
	return _param;
}

function print_param( name, value ) {
	return "<PARAM NAME='" + name + "' VALUE='" + value + "'/>";
}

function closeBP8swf() {
	
	//Reset all bp8 swf flash applications when closed: 
	jQuery('#footer-position-placeholder').css('display', 'block'); 
	jQuery('#footer-zone').css('display', 'block'); 
	jQuery('#content-zone').css('display', 'block');
	 
	if( jQuery('#bp8-swf')) {
		jQuery('#bp8-swf').remove();					
	}
	
	jQuery('#logo').css('z-index', '600');
	jQuery('#bp8-layer-content').hide();
	jQuery('#bp8-layer-zone').fadeOut('500', function(){
				  	jQuery('#bp8-layer-content').show();
	});	
	
	// I.E. forgets the document title
	// let's help this old lady
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
			document.title = jQuery('h1.header').text();
	}	
}


function maximizeWindow() 
{	
	var screenAvailWidth = screen.availWidth;
	var screenAvailHeight = screen.availHeight;
	var browserWidth, browserHeight;
	var innerBrowserHeight;
	if (document.layers)
	{
		browserWidth=window.outerWidth;
		browserHeight=window.outerHeight;
		innerBrowserHeight=window.innerHeight;
	}
	if (document.all)
	{
		browserWidth=document.body.clientWidth;
		browserHeight=document.body.clientHeight;
		innerBrowserHeight=document.body.clientHeight;
	}
	
	if (screenAvailWidth != browserWidth|| screenAvailHeight != browserHeight) 
	{
		window.resizeTo(screenAvailWidth, screenAvailHeight);
		window.moveTo(0, 0);
	}
}

function goBack(formName){
	jQuery('#submitBack').removeAttr('disabled');
	document.forms[formName].submit();
}

//Use: Call function goto_top()
var goto_top_type = -1;
var goto_top_itv = 0;

function goto_top_timer() {
	var y = goto_top_type == 1 ? document.documentElement.scrollTop : document.body.scrollTop;
	var moveby = 15; // set this to control scroll seed. minimum is fast
	
	y -= Math.ceil(y * moveby / 100);
	if (y < 0)
		y = 0;
	
	if (goto_top_type == 1)
		document.documentElement.scrollTop = y;
	else
		document.body.scrollTop = y;
	
	if (y == 0) {
		clearInterval(goto_top_itv);
		goto_top_itv = 0;
	}
}

function goto_top() {
	if (goto_top_itv == 0) {
		if (document.documentElement && document.documentElement.scrollTop)
			goto_top_type = 1;
		else if (document.body && document.body.scrollTop)
			goto_top_type = 2;
		else
			goto_top_type = 0;
	
		if (goto_top_type > 0)
			goto_top_itv = setInterval('goto_top_timer()', 25);
	}
}

function toggle_IK_dropdown( element ) {
	if ( $( element ).style.display == 'none') {
		jQuery('div.IK_dropdown_content').hide();
	 	$( element ).show();
	} else {
	 	$( element ).hide();
	}	
}	

function addT8toHeader( pageType ) {
	// get content of the T8.jsp
	if (!jQuery("#content-zone div.T8").html()) {
		var T8content = jQuery("#hiddenT8 div.column").html();	
		if ( T8content != null && T8content.match(/\w/)) { 
			if(jQuery("h1.header:first") && !jQuery("h1.header:first").hasClass("noPageTool")) {
				jQuery( T8content ).insertBefore("h1.header:first"); 
				jQuery('div.T8').css('float', 'right');
				jQuery('div.T8').css('display', 'inline');	
				jQuery('div.T8').next('div.hruler4').remove();	
			}	
		}
		// have at least a non-braking space in the header
		var header = jQuery("h1.header:first").text();
		if (header.length == 0)
			jQuery("h1.header:first").html("&nbsp;");
			
		// extend the header if required
		if(!pageType) {
			if (parseInt(jQuery("h1.header").width()) < 510) {
				jQuery("div.T8").css('position', 'relative');
				jQuery("div.T8").css('left',  '320px');				
			}
		}			
	} 		
}	

function addT8toRightColumn() {
	// get content of the T8.jsp
	if (!jQuery("#content-zone div.T8").html()) {
		var T8content = jQuery("#hiddenT8").html();
		if ( T8content != null && T8content.match(/\w/)) {
			if (jQuery("div.right-content").html()) {
				if(!jQuery("div.right-content").hasClass("noPageTool")) 
					jQuery("div.right-content").prepend( T8content );
			} else {
				jQuery("div.T8anchor").replaceWith( T8content );			
			}	
		} 
	} 
}	
function fontsize_plus() {
		jQuery("#content-zone div.T8").ready(function() {
			var size = jQuery.cookie('fontsize'); 
			if (!size || parseInt(size) >= 15)
				setFontsize( 15 );	
			else	
				setFontsize( parseInt(size)+2 );
		});		
}		
function fontsize_minus() {
		jQuery("#content-zone div.T8").ready(function() {
			var size = jQuery.cookie('fontsize'); 
			if (!size || parseInt(size) <= 11)
				setFontsize( 11 );	
			else	
				setFontsize( parseInt(size)-2 );
		});				
}	

function setFontsize( size ) {
		if (!size) {
			var sc_size = jQuery.cookie('text-size');
			if (!sc_size)
				return;
			if(sc_size == 'A+')	
				size = 13;
			if(sc_size == 'A++')	
				size = 15;
		}	
		if (size != 11 && size != 13 && size != 15)
			size = 11;
			
	    var linkElems = document.getElementsByTagName("link");   
	    for (var k=0; k<linkElems.length; k++) {
	        if (linkElems[k].rel == "stylesheet" && linkElems[k].title == "textsizes") {
	            linkElems[k].href = '/siemens/css/textsizes_' + size + '.css';
	            break;
	        }
	    } 
	    jQuery.cookie('fontsize', size, { expires: 7 });
	    
	    // CHARM IK 3531 - no jQuery().ready() any more
		if(jQuery("#content-zone div.T8") != null) {	
		    adaptPageTool( size );
		}
}	
function addUrlToMail( obj )	{			
			if ($(obj))  {
				var mailto = $(obj).readAttribute('href');
		
				//replace placeholder {0} with current url
				mailto = mailto.replace(/\{0\}/, encodeURIComponent(window.location));
				$(obj).writeAttribute("href", mailto );
					
				//replace placeholder {1} with current page title
				mailto = mailto.replace(/\{1\}/, encodeURIComponent(document.title));
				$(obj).writeAttribute("href", mailto );	
				
				//location.href = mailto;
				
				//omniture tracking
				omnitureTabTracking( 0, 'Email this Page' );								
			}	
}
function adaptPageTool( size ) {		
			// CHARM IK 3531	
			jQuery("#content-zone").find('img#fontsize_minus').removeClass('inactive');		
			if (parseInt(size) == 11)
				jQuery("#content-zone").find('img#fontsize_minus').addClass('inactive');
					
			jQuery("#content-zone").find('img#fontsize_plus').removeClass('inactive');
			if (parseInt(size) == 15)	
				jQuery("#content-zone").find('img#fontsize_plus').addClass('inactive');
}

// CR 334: Page Rating
function submitPageRating(type) {
	if (type){
		jQuery('#rating-input').hide();
		jQuery('#rating-confirm').show();
		jQuery(type).show();
		jQuery('#rating-comment').slideToggle('slow', recalculateFooterPosition(true));
	} else {
		jQuery('#rating-comment').slideToggle('slow', recalculateFooterPosition(true));
	}

	new Ajax.Request( 'SMPageRating', {
		parameters:  jQuery('#rating-submit').serialize(true) ,
		requestHeaders: ['Connection', 'close'],
		
		onComplete: function(transport){
			var response = transport.responseText;
			if (response.length > 0){	// round 1, feedback added to DB
				var _input = document.createElement('input');
					_input.setAttribute('type', 'hidden');
		   		 	_input.setAttribute('name', 'feedbackId' );
		   		 	_input.setAttribute('value', response );
				jQuery('#rating-submit').append( _input );
			} else { 					// round 2, comment added to feedback
				jQuery('#rating-input').remove();
				jQuery('#rating-comment').remove();
			}
		},
		onFailure: function(){
			alert('something went wrong');
		}
	});
}

function recalculateFooterPosition(scroll){

	// CHARM IK_3532 - close all toolbar-layer first
	if(jQuery("div.toolbar-layer").hasClass('active-layer')) {
		HeaderAnimation.augment();		
		jQuery("div.toolbar-layer").removeClass('active-layer');
		jQuery("iframe.iframeLining").parent().hide();
	}

	// recalculate footer position
	var footerHeight = 32; // fixed value, should correspond with stylesheets!!
	var feedbackHeight = jQuery('#page-rating').outerHeight(true);
	jQuery('#footer-zone').height(footerHeight + feedbackHeight);
	// now use new footer height as margin and placeholder
	var newFooterHeight = jQuery('#footer-zone').outerHeight(true);
	jQuery('#footer-position-wrapper').css('marginBottom', (newFooterHeight) * -1);
	jQuery('#footer-position-placeholder').height(newFooterHeight);
	if(scroll){
		setTimeout("document.getElementById('page-tools').scrollIntoView(false)", 600);
	}
}

function getScrollPosition() {
	var scrOfY = 0;

	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
	}
	return scrOfY;
}



