// ----------------------------------------------------------------------------------- // survey v 0.2 - 2009-07-31 // by Sindre Wimberger - wimberger@echonet.at // v 0.2 - Moeglichkeit mehrere Umfragen auf einer Seite einzubauen, umfrage spezifische StartID eingebaut // ----------------------------------------------------------------------------------- // // Survey.init(x1); // // Configuration // x1 || CustomerID // ----------------------------------------------------------------------------------- var Survey = { css: "http://survey.echonet.at/assets/base/js.css", overlayBg : "", overlayOpacity : "", customstartid : "start-fair-share-fragebogen-frauen", iframe: "http://survey.echonet.at/fair-share-fragebogen-frauen/iframe", host: 'http://survey.echonet.at', init: function(autostart,fixed) { if (autostart) { Survey.autostart = true; } if (fixed) { Survey.fixed = true; } if (Survey.$('surveystart') || Survey.$('surveystart2') || Survey.autostart) { // Wenn Startbutton oder Autostart // Survey.browserCheck(); Survey.CSSload(); Survey.create(); } if (Survey.$('surveystart')) { // Startbutton Survey.starter = Survey.$('surveystart'); Survey.starter.onclick = function() { Survey.start(); return false; } } if (Survey.$('surveystart2')) { // Startbutton 2 Survey.starter = Survey.$('surveystart2'); Survey.starter.onclick = function() { Survey.start(); return false; } } if(Survey.customstartid) { if (Survey.$(Survey.customstartid)) { // Umfragespezifischer Startbutton Survey.CSSload(); Survey.create(); Survey.starter = Survey.$(Survey.customstartid); Survey.starter.onclick = function() { Survey.start(); return false; } } } if (Survey.autostart) { // Autostart Survey.start(); } }, CSSload: function() { if(!Survey.$('echonet-survey-css')) { var headTag = document.getElementsByTagName("head")[0]; // Insert style tag into header var tag = document.createElement("link"); tag.rel = "stylesheet"; tag.type = "text/css"; tag.href = Survey.css; tag.id = "echonet-survey-css"; headTag.appendChild(tag); } }, create: function() { if(!Survey.$('surveyoverlay')) { // The rest of this code inserts html at the bottom of the page that looks similar to this: //
//
//
var objBody = document.getElementsByTagName("body").item(0); var objOverlay = document.createElement("div"); objOverlay.setAttribute('id','surveyoverlay'); objOverlay.style.display = 'none'; if(Survey.overlayOpacity != "") { objOverlay.style.opacity = Survey.overlayOpacity; objOverlay.style.filter = 'alpha(opacity=' + (Survey.overlayOpacity * 100) + ')'; } if(Survey.overlayBg != "") { objOverlay.style.backgroundColor = Survey.overlayBg; } if(!Survey.fixed) { // objOverlay.onclick = function() { Survey.end(); } } objBody.appendChild(objOverlay); var objSurvey = document.createElement("div"); objSurvey.setAttribute('id','survey'); objSurvey.style.display = 'none'; var objSurveyClose = document.createElement("div"); objSurveyClose.setAttribute('id','surveyclose'); objSurveyClose.onclick = function() { Survey.end(); } if(!Survey.fixed) { objSurvey.appendChild(objSurveyClose); } var objSurveyIframe = document.createElement("iframe"); objSurveyIframe.setAttribute('src',Survey.iframe); // objSurveyIframe.setAttribute('id','surveyiframe'); objSurveyIframe.setAttribute('name','surveyiframe'); objSurveyIframe.setAttribute('scrolling','no'); objSurveyIframe.setAttribute('frameBorder','0'); objSurvey.appendChild(objSurveyIframe); objBody.appendChild(objSurvey); } }, start: function() { Survey.hideSelectBoxes(); Survey.hideFlash(); Survey.hideIframe(); var arrayPageSize = Survey.getPageSize(); Survey.setHeight('surveyoverlay', arrayPageSize[1]); Survey.appear('surveyoverlay'); var arrayPageScroll = Survey.getPageScroll(); var SurveyTop = arrayPageScroll[1] + (arrayPageSize[3] / 15); Survey.setTop('survey', SurveyTop); Survey.show('survey'); }, end: function() { if(!Survey.fixed) { Survey.hide('survey'); Survey.fade('surveyoverlay'); Survey.$('surveyoverlay').innerHTML = ''; Survey.showSelectBoxes(); Survey.showFlash(); Survey.showIframe(); } }, addEvent:function( obj, type, fn ) { if (obj.addEventListener) obj.addEventListener( type, fn, false ); else if (obj.attachEvent) { obj["e"+type+fn] = fn; obj[type+fn] = function() { obj["e"+type+fn]( window.event ); } obj.attachEvent( "on"+type, obj[type+fn] ); } }, appear:function(element){ Survey.$(element).style.display = "block"; }, fade:function(element){ Survey.$(element).style.display = "none"; }, hide:function(element){ Survey.$(element).style.display = "none"; }, show:function(element){ Survey.$(element).style.display = "block"; }, browserCheck:function(){ Survey.isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false; Survey.isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; Survey.isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false; }, $:function(strId){ return document.getElementById(strId); }, getPageScroll:function(){ var yScroll; if (self.pageYOffset) { yScroll = self.pageYOffset; } else if (document.documentElement && document.documentElement.scrollTop){ // Explorer 6 Strict yScroll = document.documentElement.scrollTop; } else if (document.body) {// all other Explorers yScroll = document.body.scrollTop; } arrayPageScroll = new Array('',yScroll) return arrayPageScroll; }, getPageSize:function(){ var xScroll, yScroll; if (window.innerHeight && window.scrollMaxY) { xScroll = document.body.scrollWidth; yScroll = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; } var windowWidth, windowHeight; if (self.innerHeight) { // all except Explorer windowWidth = self.innerWidth; windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { // other Explorers windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } if(yScroll < windowHeight){ pageHeight = windowHeight; } else { pageHeight = yScroll; } if(xScroll < windowWidth){ pageWidth = windowWidth; } else { pageWidth = xScroll; } arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) return arrayPageSize; }, setHeight:function(element,h) { element = Survey.$(element); element.style.height = h +"px"; }, setTop:function(element,t) { element = Survey.$(element); element.style.top = t +"px"; }, showFlash:function(){ var flashObjects = document.getElementsByTagName("object"); for (i = 0; i < flashObjects.length; i++) { flashObjects[i].style.visibility = "visible"; } var flashEmbeds = document.getElementsByTagName("embed"); for (i = 0; i < flashEmbeds.length; i++) { flashEmbeds[i].style.visibility = "visible"; } }, hideFlash:function(){ var flashObjects = document.getElementsByTagName("object"); for (i = 0; i < flashObjects.length; i++) { flashObjects[i].style.visibility = "hidden"; } var flashEmbeds = document.getElementsByTagName("embed"); for (i = 0; i < flashEmbeds.length; i++) { flashEmbeds[i].style.visibility = "hidden"; } }, showSelectBoxes:function (){ selects = document.getElementsByTagName("select"); for (i = 0; i != selects.length; i++) { selects[i].style.visibility = "visible"; } }, hideSelectBoxes:function(){ selects = document.getElementsByTagName("select"); for (i = 0; i != selects.length; i++) { selects[i].style.visibility = "hidden"; } }, showIframe:function(){ var iframeObjects = document.getElementsByTagName("iframe"); for (i = 0; i < iframeObjects.length; i++) { var iframe = iframeObjects[i]; if(iframe.name != "surveyiframe") { iframe.style.visibility = "visible"; } } }, hideIframe:function(){ var iframeObjects = document.getElementsByTagName("iframe"); for (i = 0; i < iframeObjects.length; i++) { var iframe = iframeObjects[i]; if(iframe.name != "surveyiframe") { iframe.style.visibility = "hidden"; } } } }; Survey.addEvent(window, 'load', function(){ Survey.init('',''); });