// Proemion JavaScript helper functions // @author Rainer Eschen, Klaus Stake var helpPopup; var popup; var helpPopupExternalSite; var mouseX; var mouseY; // **************************** // // Flash & Flex required vars // // **************************** // Flash Player Version Detection - Rev 1.6 // Detect Client Browser type // Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved. var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false; var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false; // Help popup using traditional window.open() function showHelpPopup(page){ var window_margin = 60; var window_width_percent = 65; var height = self.screen.availHeight - (2 * window_margin); var width = Math.round(self.screen.availWidth * (window_width_percent / 100)); var left = self.screen.availWidth - width - window_margin; helpPopup = window.open(page, "helpPopup", "top=" + window_margin + ",left=" + left + ",height=" + height + ",width=" + width + ",toolbar=yes,menubar=no,status=no,scrollbars=yes,resizable=yes"); helpPopup.focus(); } // Help popup using traditional window.open() function showPopup(page){ var window_margin = 60; var window_width_percent = 65; var height = self.screen.availHeight - (2 * window_margin); var width = Math.round(self.screen.availWidth * (window_width_percent / 100)); var left = self.screen.availWidth - width - window_margin; popup = window.open(page, "EntityVisualization", "top=" + window_margin + ",left=" + left + ",height=" + height + ",width=" + width + ",toolbar=yes,menubar=no,status=no,scrollbars=yes,resizable=yes"); popup.focus(); } // Width of browser content area function browserInnerWidth() { if (self.innerHeight) { // all except Explorer return self.innerWidth; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode return document.documentElement.clientWidth; } else if (document.body) { // other Explorers return document.body.clientWidth; } } // Height of browser content area function browserInnerHeight() { if (self.innerHeight) { // all except Explorer return self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode return document.documentElement.clientHeight; } else if (document.body) { // other Explorers return document.body.clientHeight; } } // Special function to replace image paths in the dhtmlwindow framework // to be independent from the skin that is used function toWebContext(context,image) { var pos = image.lastIndexOf("/"); if (pos > -1) { return context + image.substr(pos); } else { return context + "/" + image; } } // External Site window using div/css, offering move, resize, minimize inside // the browser. http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm // for details. // Help pages have to use javascript:top.external('url') function external(page) { var window_margin = 60; var window_height_percent = 60; // If it is clear that the help menu is open if ((page.indexOf("sorry") > -1) || (page.indexOf("index") > -1)) { window_width_percent = 90; } var width = browserInnerWidth() - (2 * window_margin); var left = window_margin; var height = Math.round(browserInnerHeight() * (window_height_percent / 100)); var top = browserInnerHeight() - height - window_margin; // should already be set by the first help window // calculate references for images // for (var i = 0;i < 4; i++) { // dhtmlwindow.imagefiles[i] = // toWebContext(context,dhtmlwindow.imagefiles[i]); // } helpPopupExternalSite = dhtmlwindow.open("helpExternal", "iframe", page,"Site [" + page + "]", "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width + ",resize=1,scrolling=1"); } // Help window using div/css, offering move, resize, minimize inside // the browser. http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm // for details. // Window is used to show external sites, that are referenced by the help // window to prevent access denied exceptions when reseting HTMLhelp frames in // the help windows. function showDHTMLHelpPopup(page,title,context) { var window_margin = 60; var window_width_percent = 90; // If it is clear that the help menu is open if ((page.indexOf("sorry") > -1) || (page.indexOf("index") > -1)) { window_width_percent = 90; } var height = browserInnerHeight() - (2 * window_margin); var width = Math.round(browserInnerWidth() * (window_width_percent / 100)); var left = browserInnerWidth() - width - window_margin; // calculate references for images for (var i = 0;i < 4; i++) { dhtmlwindow.imagefiles[i] = toWebContext(context,dhtmlwindow.imagefiles[i]); } helpPopup = dhtmlwindow.open("help", "iframe", page,title, "top=" + window_margin + ",left=" + left + ",height=" + height + ",width=" + width + ",resize=1,scrolling=1"); } // Calcualate width of middle header image to get a dynamic behavior // for non-fullscreen presentations in the browser // not used yet function sizeHeader(image,imageSizable,width,height,pageWidth) { if (pageWidth > browserInnerWidth()) { width = pageWidth - browserInnerWidth(); if (width < 0) { width = 0; } image = imageSizable; } return ""; } /** * http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html */ function f_clientWidth() { return f_filterResults ( window.innerWidth ? window.innerWidth : 0, document.documentElement ? document.documentElement.clientWidth : 0, document.body ? document.body.clientWidth : 0 ); } function f_clientHeight() { return f_filterResults ( window.innerHeight ? window.innerHeight : 0, document.documentElement ? document.documentElement.clientHeight : 0, document.body ? document.body.clientHeight : 0 ); } function f_scrollLeft() { return f_filterResults ( window.pageXOffset ? window.pageXOffset : 0, document.documentElement ? document.documentElement.scrollLeft : 0, document.body ? document.body.scrollLeft : 0 ); } function f_scrollTop() { return f_filterResults ( window.pageYOffset ? window.pageYOffset : 0, document.documentElement ? document.documentElement.scrollTop : 0, document.body ? document.body.scrollTop : 0 ); } function f_filterResults(n_win, n_docel, n_body) { var n_result = n_win ? n_win : 0; if (n_docel && (!n_result || (n_result > n_docel))) n_result = n_docel; return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result; } /* Begin */ var submitcount=0; function checkSubmit() { if (submitcount == 0) { submitcount++; document.Surv.submit(); } } function wordCounter(field, countfield, maxlimit) { wordcounter=0; for (x=0;x 250) {field.value = field.value.substring(0, x);} else {countfield.value = maxlimit - wordcounter;} } } function textCounter(field, countfield, maxlimit) { //alert("countfield.value:"+countfield.value); if (field.value.length > maxlimit) {field.value = field.value.substring(0, maxlimit);} else {countfield.value = maxlimit - field.value.length;} } /* End */ /* * Floating Menu script- Roy Whittle (http://www.javascript-fx.com/) Script * featured on/available at http://www.dynamicdrive.com/ This notice must stay * intact for use */ function JSFX_FloatTopDiv() { var startX = 3 // f_scrollLeft() + browserInnerWidth() - 100; startY = 5 // browserInnerHeight() - 60; var ns = (navigator.appName.indexOf("Netscape") != -1); var d = document; /* * position left/ top startX = 3 / startY = 5 position left/ bottom startX = * 3 / startY = browserInnerHeight() - 60; position right/ top startX = * f_scrollLeft() + browserInnerWidth() - 100 / startY = 5 position right/ * bottom startX = f_scrollLeft() + browserInnerWidth() - 100 / startY = * browserInnerHeight() - 60 * */ function ml(id) { var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id]; if(d.layers)el.style=el; el.sP=function(x,y){ this.style.left=x;this.style.top=y; }; el.x = startX; if (verticalpos=="fromtop") el.y = startY; else { el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight; el.y -= startY; } return el; } window.stayTopLeft=function() { if (verticalpos=="fromtop"){ var pY = ns ? pageYOffset : document.body.scrollTop; ftlObj.y += (pY + startY - ftlObj.y)/8; } else { var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight; ftlObj.y += (pY - startY - ftlObj.y)/8; } ftlObj.sP(ftlObj.x, ftlObj.y); setTimeout("stayTopLeft()", 10); } ftlObj = ml("divStayTopLeft"); stayTopLeft(); } // Manages a global key on forms. The form has to set the // "onkeydown" attribute. Based on // http://www.icefaces.org/JForum/posts/list/3572.page // Tests have shown that this doesn't work in any case. Maybe the order // of form elements is the problem or the "submit" type is not set correctly. // We now explicitly label the button that shall react on using its // "id" attribute. If the id has a "ENTER_FOCUS" in it, this method will match. function submitOnEnter(evt){ /* See comment at POI-164 before enabling this again if(!evt) evt = event; if( evt.keyCode==13 ){ var eventSrc = null; if(!evt.target) eventSrc = evt.srcElement; else eventSrc = evt.target; // does only work in edit fields if (eventSrc.className == "iceInpTxt") { var formElements = eventSrc.form.elements; for(var i = 0; i <= formElements.length; i += 1){ var formElement = formElements[i]; if((formElement!=null) && (formElement.type != null) && (formElement.id.indexOf('ENTER_FOCUS') > -1)) { formElement.click(); break; } } } } */ } function getWebContext(path) { var webContext = "/"; pathArray = path.split( '/' ); webContext += pathArray[1]; return webContext; } function createCookie(name,value,days) { if (days != -1) { eraseCookie(name); } if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; _cookie = name+"="+value+expires+"; path="+getWebContext(window.location.pathname); document.cookie = _cookie; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { createCookie(name,"",-1); } function grepParameter(name) { name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]"+name+"=([^&#]*)"; var regex = new RegExp( regexS ); var results = regex.exec( window.location.href ); if( results == null ) return ""; else return results[1]; } function getLang(defaultlang) { var lang = defaultlang; // check for cookie var cookielang = readCookie('loginlang'); // check for url parameter var loginlang_param = grepParameter( 'loginlang' ); if (loginlang_param && loginlang_param != '') { createCookie('loginlang', loginlang_param, 1); lang = loginlang_param; } else { if (cookielang) { lang = cookielang; } } return lang; } function getSkin(defaultskin) { var skin = defaultskin; // check for cookie var cookieskin = readCookie('loginskin'); // check for url parameter var loginskin_param = grepParameter( 'loginskin' ); if (loginskin_param && loginskin_param != '') { createCookie('loginskin', loginskin_param, 1); skin = loginskin_param; } else { if (cookieskin) { skin = cookieskin; } } return skin; } function getMouseXY(e) { var IE = document.all?true:false; if (IE) { // grab the x-y pos.s if browser is IE tempX = event.clientX + document.body.scrollLeft; tempY = event.clientY + document.body.scrollTop; } else { // grab the x-y pos.s if browser is NS tempX = e.pageX; tempY = e.pageY; } if (tempX < 0){ tempX = 0; } if (tempY < 0){ tempY = 0; } mouseX = tempX; mouseY = tempY; return true; } function getViewPortHeight() { // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight var viewportheight; if (typeof window.innerWidth != 'undefined') { viewportheight = window.innerHeight } // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document) else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) { viewportheight = document.documentElement.clientHeight } // older versions of IE else { viewportheight = document.getElementsByTagName('body')[0].clientHeight } return viewportheight-285; } function getViewPortWidth() { // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight var viewportwidth; if (typeof window.innerWidth != 'undefined') { viewportwidth = window.innerWidth } // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document) else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) { viewportwidth = document.documentElement.clientWidth } // older versions of IE else { viewportwidth = document.getElementsByTagName('body')[0].clientWidth } return viewportwidth; } //********************************************************************* // // Adobe Flex & Flash required JavaScript Content // // ********************************************************************* // Major version of Flash required var requiredMajorVersion = 10; // Minor version of Flash required var requiredMinorVersion = 0; // Minor version of Flash required var requiredRevision = 0; function ControlVersion() { var version; var axo; var e; // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the // registry try { // version will be set for 7.X or greater players axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); version = axo.GetVariable("$version"); } catch (e) { } if (!version) { try { // version will be set for 6.X players only axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); // installed player is some revision of 6.0 // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29, // so we have to be careful. // default to the first public version version = "WIN 6,0,21,0"; // throws if AllowScripAccess does not exist (introduced in 6.0r47) axo.AllowScriptAccess = "always"; // safe to call for 6.0r47 or greater version = axo.GetVariable("$version"); } catch (e) { } } if (!version) { try { // version will be set for 4.X or 5.X player axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); version = axo.GetVariable("$version"); } catch (e) { } } if (!version) { try { // version will be set for 3.X player axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); version = "WIN 3,0,18,0"; } catch (e) { } } if (!version) { try { // version will be set for 2.X player axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); version = "WIN 2,0,0,11"; } catch (e) { version = -1; } } return version; } // JavaScript helper required to detect Flash Player PlugIn version information function GetSwfVer(){ // NS/Opera version >= 3 check for Flash plugin in plugin array var flashVer = -1; if (navigator.plugins != null && navigator.plugins.length > 0) { if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) { var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : ""; var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description; var descArray = flashDescription.split(" "); var tempArrayMajor = descArray[2].split("."); var versionMajor = tempArrayMajor[0]; var versionMinor = tempArrayMajor[1]; var versionRevision = descArray[3]; if (versionRevision == "") { versionRevision = descArray[4]; } if (versionRevision[0] == "d") { versionRevision = versionRevision.substring(1); } else if (versionRevision[0] == "r") { versionRevision = versionRevision.substring(1); if (versionRevision.indexOf("d") > 0) { versionRevision = versionRevision.substring(0, versionRevision.indexOf("d")); } } var flashVer = versionMajor + "." + versionMinor + "." + versionRevision; } } // MSN/WebTV 2.6 supports Flash 4 else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4; // WebTV 2.5 supports Flash 3 else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3; // older WebTV supports Flash 2 else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2; else if ( isIE && isWin && !isOpera ) { flashVer = ControlVersion(); } return flashVer; } // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) { versionStr = GetSwfVer(); if (versionStr == -1 ) { return false; } else if (versionStr != 0) { if(isIE && isWin && !isOpera) { // Given "WIN 2,0,0,11" tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"] tempString = tempArray[1]; // "2,0,0,11" versionArray = tempString.split(","); // ['2', '0', '0', '11'] } else { versionArray = versionStr.split("."); } var versionMajor = versionArray[0]; var versionMinor = versionArray[1]; var versionRevision = versionArray[2]; // is the major.revision >= requested major.revision AND the minor // version >= requested minor if (versionMajor > parseFloat(reqMajorVer)) { return true; } else if (versionMajor == parseFloat(reqMajorVer)) { if (versionMinor > parseFloat(reqMinorVer)) return true; else if (versionMinor == parseFloat(reqMinorVer)) { if (versionRevision >= parseFloat(reqRevision)) return true; } } return false; } } function AC_AddExtension(src, ext) { if (src.indexOf('?') != -1) return src.replace(/\?/, ext+'?'); else return src + ext; } function AC_Generateobj(objAttrs, params, embedAttrs, target) { var str = ''; if (isIE && isWin && !isOpera) { str += ' '; str += ''; } else { str += '= 0){ compareText = testElement.id.substr(separatorIndex + 1); } else{ compareText = testElement.id } if (testElement.id && compareText!='' && text == compareText) { return testElement; } } return null; } // Deletes all children like text- or password field values for the given form (cw1009) function clearForm(formIdent) { var form, elements, i, elm; form = document.getElementById ? document.getElementById(formIdent) : document.forms[formIdent]; if (document.getElementsByTagName) { elements = form.getElementsByTagName('input'); for( i=0, elm; elm=elements.item(i++); ) { if (elm.getAttribute('type') == "text" || elm.getAttribute('type') == "password") { elm.value = ''; } } } } // Google Maps functions var streetElementId; var cityElementId; var countyElementId; var stateElementId; var countryElementId; function geocodeStreet(lat,lng,elementId) { streetTextId = elementId; // Create new geocoding object geocoder = new GClientGeocoder(); direction = new GDirections(); direction.loadFromWaypoints([new GLatLng(lat,lng),new GLatLng(lat,lng)],{getPolyline:true}); GEvent.addListener(direction,"load", function() { var point=direction.getPolyline().getVertex(0); geocoder.getLocations(point, geocodeStreetComplete); }); // Retrieve location information, pass it to addToMap() } // This function adds the point to the map function geocodeStreetComplete(response) { // Retrieve the object find(streetTextId).value = "-"; if(response.Placemark[0].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare!='undefined' || response.Placemark[0].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare.ThoroughfareName!='') { find(streetTextId).value = response.Placemark[0].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare.ThoroughfareName; } } function geocodeCity(lat,lng,elementId) { cityTextId = elementId; // Create new geocoding object geocoder = new GClientGeocoder(); // Retrieve location information, pass it to addToMap() geocoder.getLocations(new GLatLng(lat,lng), geocodeCityComplete); } // This function adds the point to the map function geocodeCityComplete(response) { // Retrieve the object find(cityTextId).value = "-"; if(response.Placemark[0].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName!='undefined' || response.Placemark[0].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName!='') { find(cityTextId).value = response.Placemark[0].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName; } } function geocodeCounty(lat,lng,elementId) { countyTextId = elementId; // Create new geocoding object geocoder = new GClientGeocoder(); // Retrieve location information, pass it to addToMap() geocoder.getLocations(new GLatLng(lat,lng), geocodeCountyComplete); } // This function adds the point to the map function geocodeCountyComplete(response) { // Retrieve the object find(countyTextId).value = "-"; if(response.Placemark[0].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName!='undefined' || response.Placemark[0].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName!='') { find(countyTextId).value = response.Placemark[0].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName; } } function geocodeState(lat,lng,elementId) { stateTextId = elementId; // Create new geocoding object geocoder = new GClientGeocoder(); // Retrieve location information, pass it to addToMap() geocoder.getLocations(new GLatLng(lat,lng), geocodeStateComplete); } // This function adds the point to the map function geocodeStateComplete(response) { // Retrieve the object find(stateTextId).value = "-"; if(response.Placemark[0].AddressDetails.Country.AdministrativeArea.AdministrativeAreaName!='undefined' || response.Placemark[0].AddressDetails.Country.AdministrativeArea.AdministrativeAreaName!='') { find(stateTextId).value = response.Placemark[0].AddressDetails.Country.AdministrativeArea.AdministrativeAreaName; } } function geocodeCountry(lat,lng,elementId) { countryTextId = elementId; // Create new geocoding object geocoder = new GClientGeocoder(); // Retrieve location information, pass it to addToMap() geocoder.getLocations(new GLatLng(lat,lng), geocodeCountryComplete); } // This function adds the point to the map function geocodeCountryComplete(response) { // Retrieve the object find(countryTextId).value = "-"; if(response.Placemark[0].AddressDetails.Country.CountryName!='undefined' || response.Placemark[0].AddressDetails.Country.CountryName!='') { find(countryTextId).value = response.Placemark[0].AddressDetails.Country.CountryName; } } function checkForFlashPlayer(fieldToSet) { find(fieldToSet).value = DetectFlashVer(6, 0, 65); } // This function change the background color of the table at the proemion login page function changeColor(number) { // *************************************************************************** // * Method.....: changeColor() // * Description: Change color - Metamenu // *************************************************************************** document.getElementById("top" + number).bgColor="#000000"; document.getElementById("bottom" + number).bgColor="#5bbf21"; } function removeColor(number) { // *************************************************************************** // * Method.....: changeColor() // * Description: Change color - Metamenu // *************************************************************************** document.getElementById("top" + number).bgColor="#000000"; document.getElementById("bottom" + number).bgColor="#CCCCCC"; }