
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;

	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);
	var cln=url; //URL=full URL to file
	AddLinkEvent('event27');
	s.tl(true, 'd', cln);
}



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");
	}
}



function showFlashLayer(imageName, flashvars, width, height){
	// 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')
		}
	}
	var flashParams = {flashvars: flashvars};
	$('layer-content').setStyle({ margin: '12px 0 12px ' + marginLeft + 'px', 
								  paddingLeft: '12px', 
								  paddingBottom: '12px', 
								  width: contentWidth + 'px'});

	$('layer-body').update("<div id='layer-body-swf' />");
	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);
}
	

