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