function Survey(){
    this.id;
    this.questions = [];
    this.theme;
    this.text;
    this.welcomeText;
    this.thanksText;
    this.picture;
    this.sampling;
    this.styleSheet;
    this.progressLevel;
    this.isConfig = false;
    this.timestamp;
    this.autogenerate = false;
    this.isStandard;
    this.version = "1.02";
    this.imagePath;
    this.actualQuestion = 1;
    this.fixedPeriod;
    this.from = 0;
    this.to = 0;
    this.multipleParticipation = false;
    this.userColor;
    this.headline;
}

Survey.prototype.setId = function(id){
    this.id = id;
};

Survey.prototype.setTheme = function(theme){
    if (theme == 'RED') {
        this.setUserColor('790000');
    } else if (theme == 'YELLOW') {
        this.setUserColor('b1ac02');
    } else if (theme == 'GREEN') {
        this.setUserColor('007a24');
    } else if (theme == 'ORANGE') {
        this.setUserColor('7a4a00');
    } else if (theme == 'BLUE') {
        this.setUserColor('00097a');
    }
    this.theme = theme;
};

Survey.prototype.getTheme = function(){
    return this.theme;
};

Survey.prototype.setText = function(text){
    this.text = text;
};

Survey.prototype.setWelcomeText = function(text){
    this.welcomeText = text;
};

Survey.prototype.setThanksText = function(text){
    this.thanksText = text;
};

Survey.prototype.setPicture = function(picture){
    this.picture = picture;
};

Survey.prototype.setSampling = function(sampling){
    this.sampling = sampling;
};

Survey.prototype.setIsConfig = function(isConfig){
    this.isConfig = isConfig;
};

Survey.prototype.setIsAutogenerate = function(isAutogenerate){
    this.autogenerate = isAutogenerate;
};

Survey.prototype.setIsStandard = function(isStandard){
    this.isStandard = isStandard;
};


Survey.prototype.addQuestion = function(question){
    this.questions[this.questions.length] = question;
    question.superClass.survey = this;
};

Survey.prototype.setImagePath = function(imagePath){
    this.imagePath = imagePath;
};

Survey.prototype.getImagePath = function(){
    return this.imagePath;
};

Survey.prototype.setActualQuestionNr = function(actualQuestion){
    this.actualQuestion = actualQuestion
};

Survey.prototype.getActualQuestionNr = function(){
    return this.actualQuestion;
};

Survey.prototype.setFixedPeriod = function(fixedPeriod){
    this.fixedPeriod = fixedPeriod;
};

Survey.prototype.getFixedPeriod = function(){
    return this.fixedPeriod;
};

Survey.prototype.setFrom = function(from){
    var fromDate = new Date();
    var fromArray = from.split('-');
    fromDate.setFullYear(fromArray[0]);
    fromDate.setMonth(parseInt(fromArray[1]) - 1);
    fromDate.setDate(fromArray[2]);
    this.from = fromDate.getTime();
};

Survey.prototype.getFrom = function(){
    return this.from;
};

Survey.prototype.setTo = function(to){
    var toDate = new Date();
    var toArray = to.split('-');
    toDate.setFullYear(toArray[0]);
    toDate.setMonth(parseInt(toArray[1]) - 1);
    toDate.setDate(toArray[2]);
    this.to = toDate.getTime();
};

Survey.prototype.getTo = function(){
    return this.to;
};

Survey.prototype.setMultipleParticipation = function(multipleParticipation){
    this.multipleParticipation = multipleParticipation
};

Survey.prototype.getMultipleParticipation = function(){
    return this.multipleParticipation;
};

Survey.prototype.setUserColor = function(userColor){
    if (this.userColor && userColor == '') {
    } else {
        this.userColor = userColor;
    }
};

Survey.prototype.getUserColor = function(){
    return this.userColor;
};

Survey.prototype.getHeadline = function(){
    return this.headline;
};

Survey.prototype.setHeadline = function(headline){
    this.headline = headline;
};

Survey.prototype.getQuestionById = function(id){
    for (var i = 0; i < this.questions.length; i++) {
        if (this.questions[i].settings.id == id) {
            return this.questions[i];
        }
    }
    return null;
};


Survey.prototype.getCorrectedImagePath = function(){
    var path;
    var scripts = new Array();
    scripts = document.getElementsByTagName("script");
    
    for (var i = 0; i < scripts.length; i++) {
        if (scripts[i].src.indexOf('emos_survey') > 0) {
            path = scripts[i].src.slice(0, scripts[i].src.indexOf('emos_survey') - 1);
        }
    }
    if (path != undefined) {
        this.setImagePath(path);
    } else {
        path = window.location.protocol + '//' + window.location.host;
        
        path += window.location.pathname;
        path = path.slice(0, path.lastIndexOf('/') + 1);
        
        this.setImagePath(path);
    }
    
};

Survey.prototype.init = function(){

    this.timestamp = Math.ceil(Math.random() * new Date().getTime());
    var random = Math.ceil(Math.random() * 100);
    var now = new Date();
    var from = new Date(parseInt(this.from));
    var to = new Date(parseInt(this.to));
    var inTime = from.getTime() < now.getTime() && to.getTime() > now.getTime() && this.fixedPeriod == 'true';
    var isFixPeriod = this.fixedPeriod == 'true';
    var cookieValue = EmooCookie.get('survey_' + this.id);
    var hasSurveyCookie = cookieValue != null && cookieValue == 'locked';
    if (random < this.sampling && !hasSurveyCookie && (inTime || !isFixPeriod) || this.isConfig || random < this.sampling && this.multipleParticipation == 'true') {
    
        this.progressLevel = 0;
        
        if (typeof(this.styleSheet) === 'undefined') {
        
            var stylesheet = new Stylesheet();
            
            stylesheet.insertCssRule('div.ooEc-innerframe', 'text-align: center; padding: 10px; background-color: #ffffff;');
            stylesheet.insertCssRule('table.ooEc-question tr td', 'padding: 10px; font-family:verdana, sans-serif; font-size: 12px; ');
            stylesheet.insertCssRule('.ooEc-td p', 'font-family:verdana, sans-serif; font-size: 12px; font-weight:normal; font-stretch:normal; font-style:normal; font-variant:normal; line-height:normal; text-transform:none; white-space:normal; word-spacing:normal; text-indent: 0; letter-spacing: normal; direction: ltr;');
            stylesheet.insertCssRule('.ooEc-close-pic', 'position: absolute; right:0px; cursor:pointer');
            stylesheet.insertCssRule('.ooEc-footer', 'font-family: Verdana; font-size: 12px; color:white; height: 20px; padding:10px; text-align: center; vertical-align: bottom;');
            stylesheet.insertCssRule('.ooEc-outer-footer', 'font-family: Verdana; font-size: 12px; color:white; text-align: center; ');
            stylesheet.insertCssRule('.ooEc-website', 'position: absolute; left: 25px; text-align: center; vertical-align: bottom; padding-top:2px;');
            stylesheet.insertCssRule('.ooEc-website a:hover, .ooEc-website a:visited, .ooEc-website a:focus, .ooEc-website a:link, .ooEc-website a:active', 'text-decoration: none; color:white; margin-right: 15px; font-size: 11px;');
            stylesheet.insertCssRule('.ooEc-counter', 'position: absolute; right: 230px; text-align: center; vertical-align: bottom; padding-top:2px;');
            stylesheet.insertCssRule('.ooEc-progressbar-outer', 'margin-top:5px; position: absolute; text-align: center; right: 20px; font-family:verdana, sans-serif; font-size: 15px;');
            stylesheet.insertCssRule('.ooEc-progressbar', 'text-align: left; width: 200px; height: 10px; border-width: 0px; background-image: url("' + this.getImagePath() + '/background-progress-bar.png"); background-repeat: x-repeat;');
            stylesheet.insertCssRule('.ooEc-progress-level', 'width: 0%; height: 10px; font-size: 1px; background-image: url("' + this.getImagePath() + '/background-progress-level.png"); background-repeat: no-repeat;');
            stylesheet.insertCssRule('.ooEc-next-div', 'padding-top:10px; padding-bottom: 40px; background-color: #ffffff;');
            stylesheet.insertCssRule('.ooEc-next-button[disabled]', 'cursor:default; background-color:#ffffff');
            stylesheet.insertCssRule('.ooEc-logo-div', 'margin-top: 20px; margin-left: 25px; padding-bottom:18px; text-align:left;');
            stylesheet.insertCssRule('.ooEc-logo-img', '');
            stylesheet.insertCssRule('.ooEc-text', 'position: absolute; color: white; font-family: Arial; font-size : 20px; font-weigth : bold; font-family :Arial; font-size : 20px; font-weigth : bold; right: 60px; font-size: 20px; font-weigth: bold; font-family: Arial; font-size: 20px;font-weigth: bold;');
            stylesheet.insertCssRule('.ooEc-img', 'position: absolute; right: 235px;');
            
            
            switch (this.theme) {
                case "RED":
                    if (this.getUserColor() == '' || this.getUserColor() == '790000') {
                        stylesheet.insertCssRule('div.ooEc-frame', 'padding-top: 0px; padding-bottom: 0px; margin:0px; position:absolute; background-image:url("' + this.getImagePath() + '/verlauf-rot.png"); background-repeat: repeat-y; background-color: #790000; z-index:32000;');
                        stylesheet.insertCssRule('.ooEc-close-div', 'background-color: #790000; background-image:url("' + this.getImagePath() + '/verlauf-rot.png"); background-repeat: repeat-y;  height: 18px;');
                        stylesheet.insertCssRule('.ooEc-next-button', 'position:absolute; right: 60px; width: 79px; height: 21px; background-image:url("' + this.getImagePath() + '/next_button_red.png"); background-repeat: no-repeat; cursor: pointer; text-align: center; color: white; border-width: 0px; font-family:Arial; font-size:12px; font-weigth:bold; padding-bottom:2px;');
                        stylesheet.insertCssRule('table.ooEc-question thead tr td', 'text-align: left; padding: 10px; font-family:verdana, sans-serif; font-size: 14px; font-weight: bold; color: #c8260f;');
                        stylesheet.insertCssRule('.ooEc-table-scale-left', 'text-align:left; font-family:verdana, sans-serif;  font-size: 12px; color: #c8260f;');
                        stylesheet.insertCssRule('.ooEc-table-scale-right', 'text-align:right; font-family:verdana, sans-serif; font-size: 12px; color: #c8260f;');
                    } else {
                        stylesheet.insertCssRule('div.ooEc-frame', 'padding-top: 0px; padding-bottom: 0px; margin:0px; position:absolute; background-color: #' + this.getUserColor() + '; z-index:32000;');
                        stylesheet.insertCssRule('.ooEc-close-div', 'background-color: #' + this.getUserColor() + '; height: 18px;');
                        stylesheet.insertCssRule('.ooEc-next-button', 'position:absolute; right: 60px; width: 79px; height: 21px;  cursor: pointer; text-align: center; color: white; border-width: 0px; font-family:Arial; font-size:12px; font-weigth:bold; padding-bottom:2px; background-color: #' + this.getUserColor());
                        stylesheet.insertCssRule('table.ooEc-question thead tr td', 'text-align: left; padding: 10px; font-family:verdana, sans-serif; font-size: 14px; font-weight: bold; color: #73736e;');
                        stylesheet.insertCssRule('.ooEc-table-scale-left', 'text-align:left; font-family:verdana, sans-serif;  font-size: 12px; color: #73736e;');
                        stylesheet.insertCssRule('.ooEc-table-scale-right', 'text-align:right; font-family:verdana, sans-serif; font-size: 12px; color: #73736e;');
                    }
                    stylesheet.insertCssRule('div.ooEc-innerframe', 'text-align: center; padding: 10px; background-color: #ffffff;');
                    stylesheet.insertCssRule('table.ooEc-question', 'background-color: #ffffff; margin-left: auto; margin-right: auto; color: #73736e;');
                    stylesheet.insertCssRule('table.ooEc-question * p strong span', 'text-align: left; color: #73736e;');
                    stylesheet.insertCssRule('.ooEc-table-cell-left', 'text-align:left; font-family:verdana, sans-serif;  font-size: 12px; color: #73736e;');
                    stylesheet.insertCssRule('.ooEc-table-cell-right', 'text-align:right; font-family:verdana, sans-serif; font-size: 12px; color: #73736e;');
                    stylesheet.insertCssRule('.ooEc-table-cell-center', 'text-align:center; font-family:verdana, sans-serif; font-size: 12px; color: #73736e;');
                    break;
                case "GREEN":
                    if (this.getUserColor() == '' || this.getUserColor() == '007a24') {
                        stylesheet.insertCssRule('div.ooEc-frame', 'padding-top: 0px; padding-bottom: 0px; margin:0px; position:absolute; background-color: #007a24; z-index:32000;');
                        stylesheet.insertCssRule('.ooEc-close-div', 'background-color: #007a24; height: 18px;');
                        stylesheet.insertCssRule('.ooEc-next-button', 'position:absolute; right: 60px; width: 79px; height: 21px; background-image:url("' + this.getImagePath() + '/next_button_green.png"); background-repeat: no-repeat; cursor: pointer; text-align: center; color: white; border-width: 0px; font-family:Arial; font-size:12px; font-weigth:bold; padding-bottom:2px;');
                        stylesheet.insertCssRule('table.ooEc-question thead tr td', 'text-align: left; padding: 10px; font-family:verdana, sans-serif; font-size: 14px; font-weight: bold; color: #02b124;');
                        stylesheet.insertCssRule('.ooEc-table-scale-left', 'text-align:left; font-family:verdana, sans-serif;  font-size: 12px; color: #02b124;');
                        stylesheet.insertCssRule('.ooEc-table-scale-right', 'text-align:right; font-family:verdana, sans-serif; font-size: 12px; color: #02b124;');
                    } else {
                        stylesheet.insertCssRule('div.ooEc-frame', 'padding-top: 0px; padding-bottom: 0px; margin:0px; position:absolute; background-color: #' + this.getUserColor() + '; z-index:32000;');
                        stylesheet.insertCssRule('.ooEc-close-div', 'background-color: #' + this.getUserColor() + '; height: 18px;');
                        stylesheet.insertCssRule('.ooEc-next-button', 'position:absolute; right: 60px; width: 79px; height: 21px;  cursor: pointer; text-align: center; color: white; border-width: 0px; font-family:Arial; font-size:12px; font-weigth:bold; padding-bottom:2px; background-color: #' + this.getUserColor());
                        stylesheet.insertCssRule('table.ooEc-question thead tr td', 'text-align: left; padding: 10px; font-family:verdana, sans-serif; font-size: 14px; font-weight: bold; color: #73736e;');
                        stylesheet.insertCssRule('.ooEc-table-scale-left', 'text-align:left; font-family:verdana, sans-serif;  font-size: 12px; color: #73736e;');
                        stylesheet.insertCssRule('.ooEc-table-scale-right', 'text-align:right; font-family:verdana, sans-serif; font-size: 12px; color: #73736e;');
                    }
                    stylesheet.insertCssRule('div.ooEc-innerframe', 'text-align: center; padding: 10px; background-color: #ffffff;');
                    stylesheet.insertCssRule('table.ooEc-question', 'background-color: #ffffff; margin-left: auto; margin-right: auto; color: #73736e;');
                    stylesheet.insertCssRule('table.ooEc-question * p strong span', 'text-align: left; color: #73736e;');
                    stylesheet.insertCssRule('.ooEc-table-cell-left', 'text-align:left; font-family:verdana, sans-serif;  font-size: 12px; color: #73736e;');
                    stylesheet.insertCssRule('.ooEc-table-cell-right', 'text-align:right; font-family:verdana, sans-serif; font-size: 12px; color: #73736e;');
                    stylesheet.insertCssRule('.ooEc-table-cell-center', 'text-align:center; font-family:verdana, sans-serif; font-size: 12px; color: #73736e;');
                    break;
                case "BLUE":
                    if (this.getUserColor() == '' || this.getUserColor() == '00097a') {
                        stylesheet.insertCssRule('div.ooEc-frame', 'padding-top: 0px; padding-bottom: 0px; margin:0px; position:absolute; background-color: #00097a; z-index:32000;');
                        stylesheet.insertCssRule('.ooEc-close-div', 'background-color: #00097a; height: 18px;');
                        stylesheet.insertCssRule('.ooEc-next-button', 'position:absolute; right: 60px; width: 79px; height: 21px; background-image:url("' + this.getImagePath() + '/next_button_blue.png"); background-repeat: no-repeat; cursor: pointer; text-align: center; color: white; border-width: 0px; font-family:Arial; font-size:12px; font-weigth:bold; padding-bottom:2px;');
                        stylesheet.insertCssRule('table.ooEc-question thead tr td', 'text-align: left; padding: 10px; font-family:verdana, sans-serif; font-size: 14px; font-weight: bold; color: #0215b1;');
                        stylesheet.insertCssRule('.ooEc-table-scale-left', 'text-align:left; font-family:verdana, sans-serif;  font-size: 12px; color: #0215b1;');
                        stylesheet.insertCssRule('.ooEc-table-scale-right', 'text-align:right; font-family:verdana, sans-serif; font-size: 12px; color: #0215b1;');
                    } else {
                        stylesheet.insertCssRule('div.ooEc-frame', 'padding-top: 0px; padding-bottom: 0px; margin:0px; position:absolute; background-color: #' + this.getUserColor() + '; z-index:32000;');
                        stylesheet.insertCssRule('.ooEc-close-div', 'background-color: #' + this.getUserColor() + '; height: 18px;');
                        stylesheet.insertCssRule('.ooEc-next-button', 'position:absolute; right: 60px; width: 79px; height: 21px;  cursor: pointer; text-align: center; color: white; border-width: 0px; font-family:Arial; font-size:12px; font-weigth:bold; padding-bottom:2px; background-color: #' + this.getUserColor());
                        stylesheet.insertCssRule('table.ooEc-question thead tr td', 'text-align: left; padding: 10px; font-family:verdana, sans-serif; font-size: 14px; font-weight: bold; color: #73736e;');
                        stylesheet.insertCssRule('.ooEc-table-scale-left', 'text-align:left; font-family:verdana, sans-serif;  font-size: 12px; color: #73736e;');
                        stylesheet.insertCssRule('.ooEc-table-scale-right', 'text-align:right; font-family:verdana, sans-serif; font-size: 12px; color: #73736e;');
                    }
                    stylesheet.insertCssRule('div.ooEc-innerframe', 'text-align: center; padding: 10px; background-color: #ffffff;');
                    stylesheet.insertCssRule('table.ooEc-question', 'background-color: #ffffff; margin-left: auto; margin-right: auto; color: #73736e;');
                    stylesheet.insertCssRule('table.ooEc-question * p strong span', 'text-align:left; color: #73736e;');
                    stylesheet.insertCssRule('.ooEc-table-cell-left', 'text-align:left; font-family:verdana, sans-serif;  font-size: 12px; color: #73736e;');
                    stylesheet.insertCssRule('.ooEc-table-cell-right', 'text-align:right; font-family:verdana, sans-serif; font-size: 12px; color: #73736e;');
                    stylesheet.insertCssRule('.ooEc-table-cell-center', 'text-align:center; font-family:verdana, sans-serif; font-size: 12px; color: #73736e;');
                    break;
                case "ORANGE":
                    if (this.getUserColor() == '' || this.getUserColor() == '7a4a00') {
                        stylesheet.insertCssRule('div.ooEc-frame', 'padding-top: 0px; padding-bottom: 0px; margin:0px; position:absolute; background-color: #7a4a00; z-index:32000;');
                        stylesheet.insertCssRule('.ooEc-close-div', 'background-color: #7a4a00; height: 18px;');
                        stylesheet.insertCssRule('.ooEc-next-button', 'position:absolute; right: 60px; width: 79px; height: 21px; background-image:url("' + this.getImagePath() + '/next_button_orange.png"); background-repeat: no-repeat; cursor: pointer; text-align: center; color: white; border-width: 0px; font-family:Arial; font-size:12px; font-weigth:bold; padding-bottom:2px;');
                        stylesheet.insertCssRule('.ooEc-table-scale-left', 'text-align:left; font-family:verdana, sans-serif;  font-size: 12px; color: #b16a02;');
                        stylesheet.insertCssRule('.ooEc-table-scale-right', 'text-align:right; font-family:verdana, sans-serif; font-size: 12px; color: #b16a02;');
                        stylesheet.insertCssRule('table.ooEc-question thead tr td', 'text-align: left; padding: 10px; font-family:verdana, sans-serif; font-size: 14px; font-weight: bold; color: #b16a02;');
                    } else {
                        stylesheet.insertCssRule('div.ooEc-frame', 'padding-top: 0px; padding-bottom: 0px; margin:0px; position:absolute; background-color: #' + this.getUserColor() + '; z-index:32000;');
                        stylesheet.insertCssRule('.ooEc-close-div', 'background-color: #' + this.getUserColor() + '; height: 18px;');
                        stylesheet.insertCssRule('.ooEc-next-button', 'position:absolute; right: 60px; width: 79px; height: 21px;  cursor: pointer; text-align: center; color: white; border-width: 0px; font-family:Arial; font-size:12px; font-weigth:bold; padding-bottom:2px; background-color: #' + this.getUserColor());
                        stylesheet.insertCssRule('.ooEc-table-scale-left', 'text-align:left; font-family:verdana, sans-serif;  font-size: 12px; color: #73736e;');
                        stylesheet.insertCssRule('.ooEc-table-scale-right', 'text-align:right; font-family:verdana, sans-serif; font-size: 12px; color: #73736e;');
                        stylesheet.insertCssRule('table.ooEc-question thead tr td', 'text-align: left; padding: 10px; font-family:verdana, sans-serif; font-size: 14px; font-weight: bold; color: #73736e;');
                    }
                    stylesheet.insertCssRule('div.ooEc-innerframe', 'text-align: center; padding: 10px; background-color: #ffffff;');
                    stylesheet.insertCssRule('table.ooEc-question', 'background-color: #ffffff; margin-left: auto; margin-right: auto; color: #73736e;');
                    stylesheet.insertCssRule('table.ooEc-question * p strong span', 'text-align:left; color: #73736e;');
                    stylesheet.insertCssRule('.ooEc-table-cell-left', 'text-align:left; font-family:verdana, sans-serif;  font-size: 12px; color: #73736e;');
                    stylesheet.insertCssRule('.ooEc-table-cell-right', 'text-align:right; font-family:verdana, sans-serif; font-size: 12px; color: #73736e;');
                    stylesheet.insertCssRule('.ooEc-table-cell-center', 'text-align:center; font-family:verdana, sans-serif; font-size: 12px; color: #73736e;');
                    break;
                case "YELLOW":
                    if (this.getUserColor() == '' || this.getUserColor() == 'b1ac02') {
                        stylesheet.insertCssRule('div.ooEc-frame', 'padding-top: 0px; padding-bottom: 0px; margin:0px; position:absolute; background-color: #b1ac02; z-index:32000;');
                        stylesheet.insertCssRule('.ooEc-close-div', 'background-color: #b1ac02; height: 18px;');
                        stylesheet.insertCssRule('.ooEc-next-button', 'position:absolute; right: 60px; width: 79px; height: 21px; background-image:url("' + this.getImagePath() + '/next_button_yellow.png"); background-repeat: no-repeat; cursor: pointer; text-align: center; color: white; border-width: 0px; font-family:Arial; font-size:12px; font-weigth:bold; padding-bottom:2px;');
                        stylesheet.insertCssRule('.ooEc-table-scale-left', 'text-align:left; font-family:verdana, sans-serif;  font-size: 12px; color: #dcda21;');
                        stylesheet.insertCssRule('.ooEc-table-scale-right', 'text-align:right; font-family:verdana, sans-serif; font-size: 12px; color: #dcda21;');
                        stylesheet.insertCssRule('table.ooEc-question thead tr td', 'text-align: left; padding: 10px; font-family:verdana, sans-serif; font-size: 14px; font-weight: bold; color: #dcda21;');
                    } else {
                        stylesheet.insertCssRule('div.ooEc-frame', 'padding-top: 0px; padding-bottom: 0px; margin:0px; position:absolute; background-color: #' + this.getUserColor() + '; z-index:32000;');
                        stylesheet.insertCssRule('.ooEc-close-div', 'background-color: #' + this.getUserColor() + '; height: 18px;');
                        stylesheet.insertCssRule('.ooEc-next-button', 'position:absolute; right: 60px; width: 79px; height: 21px;  cursor: pointer; text-align: center; color: white; border-width: 0px; font-family:Arial; font-size:12px; font-weigth:bold; padding-bottom:2px; background-color: #' + this.getUserColor());
                        stylesheet.insertCssRule('.ooEc-table-scale-left', 'text-align:left; font-family:verdana, sans-serif;  font-size: 12px; color: #73736e;');
                        stylesheet.insertCssRule('.ooEc-table-scale-right', 'text-align:right; font-family:verdana, sans-serif; font-size: 12px; color: #73736e;');
                        stylesheet.insertCssRule('table.ooEc-question thead tr td', 'text-align: left; padding: 10px; font-family:verdana, sans-serif; font-size: 14px; font-weight: bold; color: #73736e;');
                    }
                    stylesheet.insertCssRule('div.ooEc-innerframe', 'text-align: center; padding: 10px; background-color: #ffffff;');
                    stylesheet.insertCssRule('table.ooEc-question', 'background-color: #ffffff; margin-left: auto; margin-right: auto; color: #73736e;');
                    stylesheet.insertCssRule('table.ooEc-question * p strong span', 'text-align: left; color: #73736e;');
                    stylesheet.insertCssRule('.ooEc-table-cell-left', 'text-align:left; font-family:verdana, sans-serif;  font-size: 12px; color: #73736e;');
                    stylesheet.insertCssRule('.ooEc-table-cell-right', 'text-align:right; font-family:verdana, sans-serif; font-size: 12px; color: #73736e;');
                    stylesheet.insertCssRule('.ooEc-table-cell-center', 'text-align:center; font-family:verdana, sans-serif; font-size: 12px; color: #73736e;');
                    break;
                default:
                    if (this.getUserColor() == '') {
                        stylesheet.insertCssRule('div.ooEc-frame', 'padding-top: 0px; padding-bottom: 0px; margin:0px; position:absolute; background-color: #790000; z-index:32000;');
                        stylesheet.insertCssRule('.ooEc-close-div', 'background-color: #790000; height: 18px;');
                        stylesheet.insertCssRule('.ooEc-next-button', 'position:absolute; right: 60px; width: 79px; height: 21px; background-image:url("' + this.getImagePath() + '/next_button_red.png"); background-repeat: no-repeat; cursor: pointer; text-align: center; color: white; border-width: 0px; font-family:Arial; font-size:12px; font-weigth:bold; padding-bottom:2px;');
                    } else {
                        stylesheet.insertCssRule('div.ooEc-frame', 'padding-top: 0px; padding-bottom: 0px; margin:0px; position:absolute; background-color: #' + this.getUserColor() + '; z-index:32000;');
                        stylesheet.insertCssRule('.ooEc-close-div', 'background-color: #' + this.getUserColor() + '; height: 18px;');
                        stylesheet.insertCssRule('.ooEc-next-button', 'position:absolute; right: 60px; width: 79px; height: 21px;  cursor: pointer; text-align: center; color: white; border-width: 0px; font-family:Arial; font-size:12px; font-weigth:bold; padding-bottom:2px; background-color: #' + this.getUserColor());
                    }
                    stylesheet.insertCssRule('div.ooEc-innerframe', 'text-align: center; padding: 10px; background-color: #ffffff;');
                    stylesheet.insertCssRule('table.ooEc-question', 'background-color: #ffffff; margin-left: auto; margin-right: auto; color: #73736e;');
                    stylesheet.insertCssRule('table.ooEc-question thead tr td', 'padding: 10px; font-family:verdana, sans-serif; font-size: 14px; font-weight: bold; color: #c8260f;');
                    stylesheet.insertCssRule('table.ooEc-question * p strong span', 'text-align:left; color: #73736e;');
                    stylesheet.insertCssRule('.ooEc-table-cell-center', 'text-align:center; font-family:verdana, sans-serif; font-size: 12px; color: #73736e;');
                    stylesheet.insertCssRule('.ooEc-table-scale-left', 'text-align:left; font-family:verdana, sans-serif;  font-size: 12px; color: #c8260f;');
                    stylesheet.insertCssRule('.ooEc-table-scale-right', 'text-align:right; font-family:verdana, sans-serif; font-size: 12px; color: #c8260f;');
                    break;
            }
            
            this.styleSheet = stylesheet;
        }
        
        if (!this.isConfig) {
            EmooCookie.set('survey_' + this.id, 'locked', '', '/', '', '');
        }
        
        if (!this.autogenerate) {
            var welcome = new WelcomeScreen('welcome', {
                id: '0',
                followingQuestionId: ['']
            });
            welcome.superClass.survey = this;
            welcome.init();
        }
        
    }
    
};

Survey.prototype.initThanks = function(){
    var thanks = new ThanksScreen('thanks', {
        id: '0',
        followingQuestionId: ['']
    });
    thanks.superClass.survey = this;
    thanks.init();
};

Survey.prototype.initFirstQuestion = function(){
    if (this.questions.length > 0) {
        var pLevel = Math.floor((1) * 100 / this.questions.length);
        this.progressLevel = pLevel;
        this.setActualQuestionNr(1);
        this.questions[0].init();
    }
};

Survey.prototype.initFollowing = function(questionId){
    for (var i = 0; i < this.questions.length; i++) {
        if (this.questions[i].settings.id == questionId) {
            var pLevel = Math.floor((i + 1) * 100 / this.questions.length);
            this.progressLevel = pLevel;
            this.setActualQuestionNr(i + 1);
            this.questions[i].init();
        }
    }
    
};
Survey.prototype.doRandomSurvey = function(){
    for (var i = 0; i < this.questions.length; i++) {
        //if (Math.random() > 0.1) {
             var waitUntil = new Date().getTime() + 100;
            while(new Date().getTime() < waitUntil){}
            this.questions[i].doRandomAnswer();
        //}
    }
    
};
var emooArrayRemoveItem = function(array, item){

    var j = 0;
    
    while (j < array.length) {
        if (array[j] == item) {
            array.splice(j, 1);
        } else {
            j++;
        }
    }
};

var emooArrayHasItem = function(array, item){
    for (var i = 0; i < array.length; i++) {
        if (array[i] == item) {
            return true;
        }
    }
    return false;
};


EmooCookie = {};
EmooCookie.get = function(check_name){

    var cookies = document.cookie.split(';');
    var temp_cookie = '';
    var cookie_name = '';
    var cookie_value = '';
    var hasCookie = false;
    
    for (var i = 0; i < cookies.length; i++) {
        temp_cookie = cookies[i].split('=');
        cookie_name = temp_cookie[0].replace(/^\s+|\s+$/g, '');
        
        if (cookie_name == check_name) {
            hasCookie = true;
            if (temp_cookie.length > 1) {
                cookie_value = unescape(temp_cookie[1].replace(/^\s+|\s+$/g, ''));
            }
            
            return cookie_value;
            break;
        }
        temp_cookie = null;
        cookie_name = '';
    }
    if (!hasCookie) {
        return null;
    }
};



EmooCookie.set = function(name, value, expires, path, domain, secure){
    // set time, it's in milliseconds
    var today = new Date();
    
    if (expires) {
        expires = expires * 1000 * 60 * 60 * 24;
    } else {
        expires = 1000 * 60 * 60 * 24 * 7;
    }
    var expires_date = new Date(today.getTime() + (expires));
    
    document.cookie = name + "=" + escape(value) +
    ((expires) ? ";expires=" + expires_date.toGMTString() : "") +
    ((path) ? ";path=" + path : "") +
    ((domain) ? ";domain=" + domain : "") +
    ((secure) ? ";secure" : "");
};

function Stylesheet(){
    if (!this.styleSheet) {
        if (document.createStyleSheet) {
            // IE
            try {
                this.styleSheet = document.createStyleSheet();
            } 
            catch (oException) {
                // There is a limit of 30 style tags in Internet Explorer
                this.styleSheet = document.styleSheets[document.styleSheets.length - 1];
            };
                    } else {
            // Others
            this.styleSheet = document.createElement('style');
            this.styleSheet.type = 'text/css';
            var oHead = document.getElementsByTagName('head')[0];
            // If there is no head tag on the page (Opera only)
            if (!oHead) {
                oHead = document.documentElement;
            }
            if (oHead) {
                oHead.appendChild(this.styleSheet);
            }
        }
    }
}

// Return the rules array for this stylesheet.
Stylesheet.prototype.getRules = function(){
    // Use the W3C property if defined; otherwise use the IE property
    return this.styleSheet.cssRules ? this.styleSheet.cssRules : this.styleSheet.rules;
};

// Insert a rule into the stylesheet.
// The rule consists of the specified selector and style strings.
// It is inserted at index n. If n is omitted, it is appended to the end.
Stylesheet.prototype.insertCssRule = function(selector, styles, n){
    if (typeof(n) === 'undefined') {
        var rules = this.getRules();
        if (typeof(rules) === 'undefined') {
            n = 0;
        } else {
            n = rules.length;
        }
    }
    if (document.createStyleSheet) { // Try the IE API first
        // this.styleSheet.addRule(selector, styles, n);
        this.styleSheet.cssText += selector + ' { ' + styles + ' }';
        
    } else {// Otherwise use the W3C API
        // this.styleSheet.sheet.insertRule(selector + "{" + styles + "}", n);
        this.styleSheet.appendChild(document.createTextNode(selector + ' { ' + styles + ' }'));
    }
};
/**
* Create a new instance of Question.
*
* @classDescription This class creates a new Question.
* @return {Object}  Returns a new Question object.
* @constructor  
*/

function Question(){
    this.locked = false;
    this.overlay;
    this.survey;
};


/**
 * @inherits 
 */
Question.prototype.init = function(){

    this.unlock();
};

Question.prototype.setProgressLevel = function(id){
    var progressLevelElement = document.getElementById('progress-level-' + id);
    var level = this.survey.progressLevel;
    if (typeof(level) === 'undefined') {
        level = 0;
    }
    progressLevelElement.style.width = level + '%';
};

Question.prototype.initConcreteDiv = function(questionObj){

    var frameDiv = document.getElementById('frame' + questionObj.settings.id);
    
    if (frameDiv) {
        frameDiv.parentNode.removeChild(frameDiv);
    }
    
    
    frameDiv = document.createElement("div");
    setEmooOpacity(frameDiv, 0);
    
    
    frameDiv.className = 'ooEc-frame';
    // setEmooOpacity(frameDiv,0);
    
    var divId = document.createAttribute("id");
    divId.nodeValue = 'frame' + questionObj.settings.id;
    frameDiv.setAttributeNode(divId);
    
    var closeDiv = document.createElement('div');
    closeDiv.className = 'ooEc-close-div';
    
    var closePic = new Image();
    closePic.className = 'ooEc-close-pic';
    if (questionObj.superClass.survey.isConfig) {
        closePic.src = questionObj.superClass.survey.getImagePath() + '/generated/close_button_' + questionObj.superClass.survey.getUserColor() + '.gif';
    } else {
        closePic.src = questionObj.superClass.survey.getImagePath() + '/close_button.gif';
    }
    closePic.title = 'schlie\u00DFen';
    closePic.onclick = function(evt){
        questionObj.unload();
    };
    closeDiv.appendChild(closePic);
    frameDiv.appendChild(closeDiv);
    
    
    var logoDiv = document.createElement('div');
    logoDiv.className = 'ooEc-logo-div';
    var logo = new Image();
    if (questionObj.superClass.survey.picture == 'null') {
        if (questionObj.superClass.survey.isConfig) {
            logo.src = questionObj.superClass.survey.getImagePath() + '/generated/econda_logo_' + questionObj.superClass.survey.getUserColor() + '.gif';
        } else {
            logo.src = questionObj.superClass.survey.getImagePath() + '/econda_logo.gif';
        }
    } else {
    
        logo.className = 'ooEc-logo-img';
        if (questionObj.superClass.survey.isConfig) {
            if (questionObj.superClass.survey.picture == 'econda_logo.gif') {
                questionObj.superClass.survey.getImagePath() + '/generated/econda_logo_' + questionObj.superClass.survey.getUserColor() + '.gif';
            } else {
                //if(questionObj.superClass.survey.isStandard == 'false') {
                logo.src = questionObj.superClass.survey.getImagePath().replace('images/survey', 'config/survey/edit') + '/getLogo?image=' + questionObj.superClass.survey.picture + '&surveyid=' + questionObj.superClass.survey.id;
                //}
            }
            
        } else {
            logo.src = questionObj.superClass.survey.getImagePath() + '/' + questionObj.superClass.survey.picture;
        }
    }
    var opinionPic = new Image();
    opinionPic.className = 'ooEc-img';
    if (questionObj.superClass.survey.isConfig) {
        opinionPic.src = questionObj.superClass.survey.getImagePath() + '/generated/opinion_logo_' + questionObj.superClass.survey.getUserColor() + '.gif';
        
    } else {
        opinionPic.src = questionObj.superClass.survey.getImagePath() + '/opinion_logo.gif';
    }
    
    var opinionSpan = document.createElement('span');
    opinionSpan.className = 'ooEc-text';
    var opinionText;
    if (questionObj.superClass.survey.getHeadline() != '') {
        if (questionObj.superClass.survey.getHeadline() != 'null') {
            opinionText = document.createTextNode(questionObj.superClass.survey.getHeadline());
        } else {
            opinionText = document.createTextNode("ONLINE OPINION");
        }
    } else {
        opinionText = document.createTextNode("ONLINE OPINION");
    }
    
    opinionSpan.appendChild(opinionText);
    logoDiv.appendChild(opinionSpan);
    logoDiv.appendChild(opinionPic);
    if (logo != 'undefined') {
        logoDiv.appendChild(logo);
    }
    
    frameDiv.appendChild(logoDiv);
    
    var innerFrameDiv = document.createElement("div");
    innerFrameDiv.className = 'ooEc-innerframe';
    innerFrameDiv.appendChild(questionObj.concreteQuestionTable);
    frameDiv.appendChild(innerFrameDiv);
    
    var nextDiv = document.createElement('div');
    nextDiv.className = 'ooEc-next-div';
    var nextButton = document.createElement("button");
    nextButton.className = 'ooEc-next-button';
    
    var closeText = document.createTextNode("weiter");
    nextButton.appendChild(closeText);
    nextButton.onclick = function(event){
        questionObj.unload();
        var emosProperties = questionObj.getEmosProperties();
        
        questionObj.superClass.setEmosProperties(emosProperties);
        var inputId = questionObj.getFollowingQuestionId();
        if (inputId == 0) {
            questionObj.superClass.survey.initFollowing(questionObj.settings.followingQuestionId[0]);
        } else {
            if (questionObj.settings.followingQuestionId[inputId] == '0') {
                var nextQuestion = questionObj.superClass.getNextQuestion(questionObj);
                if (nextQuestion != null) {
                    questionObj.superClass.survey.initFollowing(nextQuestion.settings.id);
                } else {
                    questionObj.superClass.survey.initThanks();
                }
            } else {
                questionObj.superClass.survey.initFollowing(questionObj.settings.followingQuestionId[inputId]);
            }
        }
        if (questionObj.settings.followingQuestionId[0] == '') {
            questionObj.superClass.survey.initThanks();
        }
    };
    nextButton.disabled = true;
    nextButton.id = questionObj.settings.id + '_next';
    setEmooOpacity(nextButton, 8);
    
    nextDiv.appendChild(nextButton);
    
    frameDiv.appendChild(nextDiv);
    
    var opinionOuterDiv = document.createElement('div');
    opinionOuterDiv.style.height = "40px";
    opinionOuterDiv.className = 'ooEc-outerfooter';
    
    var opinionDiv = document.createElement('div');
    opinionDiv.className = 'ooEc-footer';
    
    var opinionWebsiteDiv = document.createElement('div');
    opinionWebsiteDiv.className = 'ooEc-website';
    
    var econdaAnker = document.createElement('a');
    var econdaLink = document.createAttribute('href');
    var econdaTarget = document.createAttribute('target');
    econdaTarget.nodeValue = '_blank';
    econdaLink.nodeValue = 'http://www.econda.de/produkte/online-opinion.html?campaign=OO%2FSurvey';
    econdaAnker.setAttributeNode(econdaLink);
    econdaAnker.setAttributeNode(econdaTarget);
    var opinionWebsiteText;
    if (questionObj.superClass.survey.isStandard == 'true') {
        opinionWebsiteText = document.createTextNode('www.econda.de');
    } else {
        opinionWebsiteText = document.createTextNode('erstellt mit econda Online Opinion');
    }
    econdaAnker.appendChild(opinionWebsiteText);
    
    opinionWebsiteDiv.appendChild(econdaAnker);
    
    var opinionCounterDiv = document.createElement('div');
    opinionCounterDiv.className = 'ooEc-counter';
    var opinionCounterText = document.createTextNode(questionObj.superClass.survey.getActualQuestionNr() + ' von ' + questionObj.superClass.survey.questions.length);
    opinionCounterDiv.appendChild(opinionCounterText);
    
    var progressBarOuterDiv = document.createElement('div');
    progressBarOuterDiv.className = 'ooEc-progressbar-outer';
    var progressBarDiv = document.createElement('div');
    progressBarDiv.className = 'ooEc-progressbar';
    
    var progressLevelDiv = document.createElement('div');
    progressLevelDiv.className = 'ooEc-progress-level';
    progressLevelDiv.id = 'progress-level-' + questionObj.settings.id;
    progressBarDiv.appendChild(progressLevelDiv);
    
    progressBarOuterDiv.appendChild(progressBarDiv);
    
    opinionDiv.appendChild(opinionWebsiteDiv);
    opinionDiv.appendChild(opinionCounterDiv);
    opinionDiv.appendChild(progressBarOuterDiv);
    
    opinionOuterDiv.appendChild(opinionDiv);
    frameDiv.appendChild(opinionOuterDiv);
    
    
    var de = document.documentElement;
    var documentWidth = window.innerWidth || self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
    var documentHeight = window.innerHeight || self.innerHeight || (de && de.clientHeight) || document.body.clientHeight;
    
    document.getElementsByTagName('body')[0].appendChild(frameDiv);
    
    // Fix for IE
    if (questionObj.concreteQuestionTable.clientWidth > 250) frameDiv.style.width = questionObj.concreteQuestionTable.clientWidth + 20 + 'px';
    else frameDiv.style.width = '270px';
    
    
    if (frameDiv.clientWidth < 560) {
        frameDiv.style.width = '560px';
    }
    
    frameDiv.style.left = Math.ceil(documentWidth / 2 - frameDiv.clientWidth / 2) + 'px';
    frameDiv.style.top = Math.ceil(documentHeight / 2 - frameDiv.clientHeight / 2) + 'px';
    questionObj.concreteQuestionDiv = frameDiv;
    // this.addBorder(frameDiv);
    
    emooFadeIn(frameDiv.id, 0, 100);
    this.setProgressLevel(questionObj.settings.id);
};

Question.prototype.getNextQuestion = function(questionObj){
    var questions = this.survey.questions;
    questions = questions.slice(this.survey.getActualQuestionNr());
    var followingQuestions = questionObj.settings.followingQuestionId;
    for (var i = 0; i < followingQuestions.length; i++) {
        var question = this.survey.getQuestionById(followingQuestions[i]);
        if (question != null) {
            if (question.settings.followingQuestionId.length > 1) {
                followingQuestions.concat(question.settings.followingQuestionId);
            }
        }
    }
    for (var j = 0; j < followingQuestions.length; j++) {
        if (this.survey.getQuestionById(followingQuestions[j]) != null) {
            if (emooArrayHasItem(questions, this.survey.getQuestionById(followingQuestions[j]))) {
                emooArrayRemoveItem(questions, this.survey.getQuestionById(followingQuestions[j]));
            }
        }
    }
    if (questions.length > 0) {
        return questions[0];
    } else {
        return null;
    }
};

Question.prototype.setEmosProperties = function(propertyArray){
    if (window.emosPropertiesEvent) {
        for (var i = 0; i < propertyArray.length; i++) {
            var property = propertyArray[i];
        }
        var properties = new Object();
        properties.survey = propertyArray;
        window.emosPropertiesEvent(properties);
    } else {
        if (!this.survey.isConfig) {
            alert("emos.js fehlt, oder ist in einer falschen Version eingebunden");
        }
    }
};

function getEmooBackgroundColor(x){
    if (x.currentStyle) {
        return (x.currentStyle['backgroundColor']);
    }
    if (document.defaultView.getComputedStyle) {
        var rgb = document.defaultView.getComputedStyle(x, '')['backgroundColor'];
        if (rgb == 'transparent') {
            return rgb;
        }
        var hex = "", v;
        var regexp = /([0-9]+)[, ]+([0-9]+)[, ]+([0-9]+)/;
        var h = regexp.exec(rgb);
        for (var i = 1; i < 4; i++) {
            v = parseInt(h[i]).toString(16);
            // v = Math.ceil(v * 8/ 10).toString(16);
            if (v.length == 1) {
                hex += "0" + v;
            } else {
                hex += v;
            }
        }
        return ("#" + hex);
    }
    return (null);
}

Question.prototype.addBorder = function(frameDiv){

    var element = frameDiv.parentNode;
    var c;
    while (element.tagName.toUpperCase() != "HTML" && (getEmooBackgroundColor(element) == "transparent" || getEmooBackgroundColor(element) == null)) {
        element = element.parentNode;
    }
    c = getEmooBackgroundColor(element);
    if (c == "transparent") c = "#FFFFFF";
    
    var d1 = document.createElement("b");
    d1.className = "corners";
    
    d1.style.marginTop = "0px";
    var btype = "tb", lim = 8;
    
    for (i = 1; i <= lim; i++) {
        var x = document.createElement("b");
        x.className = btype + i;
        x.style.backgroundColor = "transparent";
        x.style.borderColor = c;
        d1.appendChild(x);
    }
    frameDiv.style.paddingTop = "0";
    frameDiv.insertBefore(d1, frameDiv.firstChild);
    
    
    var d2 = document.createElement("b");
    d2.className = "corners";
    
    d2.style.marginBottom = "0px";
    d2.style.marginTop = "40px";
    
    var btype = "tb", lim = 8;
    
    for (i = lim; i > 0; i--) {
        var x = document.createElement("b");
        x.className = btype + i;
        x.style.backgroundColor = "transparent";
        x.style.borderColor = c;
        d2.appendChild(x);
    }
    frameDiv.style.paddingBottom = "0";
    frameDiv.appendChild(d2);
    
};

Question.prototype.lock = function(){
    this.locked = true;
    
};

Question.prototype.unlock = function(){
    this.locked = false;
    if (!(typeof(this.inputs) === 'undefined')) {
        for (var i = 0; i < this.inputs.length; i++) {
            this.inputs[i].checked = '';
        }
    }
};


function emooFadeIn(elementId, count, speed){

    count = parseInt(count);
    count++;
    if (count < 11) {
        window.setTimeout("emooFadeIn('" + elementId + "','" + count + "','" + speed + "')", speed);
        setEmooOpacity(document.getElementById(elementId), count);
    }
};

function emooFadeOut(concreteQuestionDivId, concreteQuestionTableId, count, speed){
    var element = document.getElementById(concreteQuestionDivId);
    count = parseInt(count);
    count--;
    if (count > 0) {
        window.setTimeout("emooFadeOut('" + concreteQuestionDivId + "','" + concreteQuestionTableId + "','" + count + "','" + speed + "')", speed);
        setEmooOpacity(element, count);
    } else {
        element.style.visibility = 'hidden';
        element.style.display = '';
        document.getElementById(concreteQuestionTableId).style.visibility = 'hidden';
        document.getElementById(concreteQuestionTableId).style.display = '';
    }
};
/*
 * SingleChoiceQuestion Class
 */
function SingleChoiceQuestion(name, settings){
    this.name = name;
    this.locked = false;
    this.settings = settings;
    this.inputs = [];
    this.concreteQuestionTable;
    this.concreteQuestionDiv;
    this.themeSetting;
    this.emosProperties = [];
    this.textAnswer = {};
};

SingleChoiceQuestion.prototype.superClass = new Question();

SingleChoiceQuestion.prototype.init = function(){
    var that = this;
    that.superClass.init();
    var oldElement = document.getElementById(that.settings.id + '_table');
    
    if (oldElement) {
        oldElement.parentNode.removeChild(oldElement);
    }
    
    var questionTable = document.createElement('table');
    questionTable.className = 'ooEc-question';
    
    var tableId = document.createAttribute("id");
    tableId.nodeValue = that.settings.id + '_table';
    questionTable.setAttributeNode(tableId);
    
    var tbody = document.createElement('tbody');
    
    
    var e = this.settings.answers.length;
    for (var i = 0; i < e; i++) {
        var tr = document.createElement('tr');
        var cell1 = document.createElement('td');
        var cell1Text = document.createTextNode(this.settings.answers[i][1]);
        cell1.appendChild(cell1Text);
        var cell1Align = document.createAttribute('align');
        cell1Align.nodeValue = 'left';
        cell1.setAttributeNode(cell1Align);
        
        var inputElement;
        
        try {
            //IE6 Bug
            inputElement = document.createElement("<input name='" + this.settings.id + "'  />");
        } 
        catch (e) {
            inputElement = document.createElement('input');
        }
        
        this.inputs[i] = inputElement;
        
        inputElement.name = this.settings.id;
        inputElement.style.cursor = 'pointer';
        if (this.settings.answers[i][2] == 'true') {
            inputElement.id = this.settings.answers[i][0];
            inputElement.type = 'text';
            inputElement.onkeyup = function(evt){
                var nextButton = document.getElementById(that.settings.id + '_next');
                nextButton.disabled = '';
                setEmooOpacity(nextButton, 10);
                var elements = document.getElementsByName(that.settings.id);
                for (var j = 0; j < elements.length; j++) {
                    elements[j].checked = '';
                }
                that.textAnswer[this.id] = this.value;
            };
        } else {
            inputElement.value = this.settings.answers[i][0];
            inputElement.type = 'radio';
            inputElement.onclick = function(evt){
                var elements = document.getElementsByName(that.settings.id);
                for (var j = 0; j < elements.length; j++) {
                    if (elements[j].type == 'text') {
                        elements[j].value = '';
                    }
                }
                if (that.superClass.locked) {
                    return;
                }
                this.checked = 'checked';
                var nextButton = document.getElementById(that.settings.id + '_next');
                nextButton.disabled = false;
                setEmooOpacity(nextButton, 10);
                
                
                var eEvent = evt || window.event;
                that.click(eEvent, this.value, that);
                that.superClass.lock();
            };
        }
        
        var cell2 = document.createElement('td');
        var cell2Align = document.createAttribute('align');
        cell2Align.nodeValue = 'left';
        cell2.setAttributeNode(cell2Align);
        cell2.appendChild(inputElement);
        if (this.settings.answers[i][2] != 'true') {
            cell2.firstChild.setAttribute('value', this.settings.answers[i][0]);
        }
        tr.appendChild(cell1);
        tr.appendChild(cell2);
        tbody.appendChild(tr);
    }
    
    questionTable.appendChild(tbody);
    
    var thead = questionTable.createTHead();
    var thtr = thead.insertRow(0);
    var thcell = thtr.insertCell(0);
    
    var thcellText = document.createTextNode(this.settings.question);
    thcell.setAttribute('colspan', 2);
    thcell.appendChild(thcellText);
    
    setEmooOpacity(questionTable, 10);
    
    that.concreteQuestionTable = questionTable;
    
    var frameDiv = that.superClass.initConcreteDiv(that);
    
    
};

SingleChoiceQuestion.prototype.unload = function(){
    emooFadeOut(this.concreteQuestionDiv.id, this.concreteQuestionTable.id, 10, 100);
};

SingleChoiceQuestion.prototype.click = function(event, choice, QuestionObject){
    this.emosProperties = [];
    this.emosProperties.push([QuestionObject.superClass.survey.id, QuestionObject.settings.id, choice, '0', this.superClass.survey.timestamp, '']);
};

SingleChoiceQuestion.prototype.doRandomAnswer = function(){

    var property = new Array(this.superClass.survey.id, this.settings.id, this.settings.answers[Math.floor(Math.random() * (this.settings.answers.length))][0], '0');
    property.push(this.superClass.survey.timestamp);
    property.push('');
    var propertyArray = new Array();
    propertyArray.push(property);
    var properties = new Object();
    properties.survey = propertyArray;
    window.emosPropertiesEvent(properties);
};


SingleChoiceQuestion.prototype.getFollowingQuestionId = function(){
    if (this.settings.followingQuestionId.length == 1) {
        return (0);
    }
    var inputs = this.concreteQuestionTable.getElementsByTagName("input");
    for (var i = 0; i < inputs.length; i++) {
        if (inputs[i].checked) {
            return i;
        }
    }
};

SingleChoiceQuestion.prototype.getEmosProperties = function(){
    if (this.emosProperties.length == 0) {
        for (var answer in this.textAnswer) {
            this.emosProperties.push([this.superClass.survey.id, this.settings.id, answer, '0', this.superClass.survey.timestamp, this.textAnswer[answer]]);
        }
    }
    return this.emosProperties;
};



/*
 * MultipleChoiceQuestion Class
 */
function MultipleChoiceQuestion(name, settings){
    this.name = name;
    this.locked = false;
    this.settings = settings;
    this.inputs = [];
    this.concreteQuestionTable;
    this.concreteQuestionDiv;
    this.themeSetting;
    this.emosProperties = [];
    this.textAnswer = {};
};

MultipleChoiceQuestion.prototype.superClass = new Question();

MultipleChoiceQuestion.prototype.init = function(){
    var that = this;
    that.superClass.init();
    
    var oldElement = document.getElementById(that.settings.id + '_table');
    if (oldElement) {
        oldElement.parentNode.removeChild(oldElement);
    }
    var questionTable = document.createElement('table');
    questionTable.className = 'ooEc-question';
    questionTable.id = that.settings.id + '_table';
    
    var tbody = document.createElement('tbody');
    questionTable.appendChild(tbody);
    
    var e = this.settings.answers.length;
    for (var i = 0; i < e; i++) {
        var tr = questionTable.insertRow(i);
        var cell1 = tr.insertCell(0);
        var cell1Text = document.createTextNode(this.settings.answers[i][1]);
        cell1.appendChild(cell1Text);
        var cell1Align = document.createAttribute('align');
        cell1Align.nodeValue = 'left';
        cell1.setAttributeNode(cell1Align);
        
        var inputElement = document.createElement('input');
        this.inputs[i] = inputElement;
        
        inputElement.name = this.settings.answers[i][1];
        inputElement.style.cursor = 'pointer';
        
        if (this.settings.answers[i][2] == 'true') {
            inputElement.id = this.settings.answers[i][0];
            inputElement.type = 'text';
            inputElement.onkeyup = function(evt){
                var nextButton = document.getElementById(that.settings.id + '_next');
                nextButton.disabled = '';
                setEmooOpacity(nextButton, 10);
                var eEvent = evt || window.event;
                that.textAnswer[this.id] = this.value;
                
            };
        } else {
            inputElement.value = this.settings.answers[i][0];
            inputElement.type = 'checkbox';
            inputElement.onclick = function(evt){
                var nextButton = document.getElementById(that.settings.id + '_next');
                nextButton.disabled = '';
                setEmooOpacity(nextButton, 10);
                var eEvent = evt || window.event;
                that.click(eEvent, this.value, '0', that);
            };
        }
        
        
        var cell2 = tr.insertCell(1);
        
        var cell2Align = document.createAttribute('align');
        cell2Align.nodeValue = 'left';
        cell2.setAttributeNode(cell2Align);
        cell2.appendChild(inputElement);
        if (this.settings.answers[i][2] != 'true') {
            cell2.firstChild.setAttribute('value', this.settings.answers[i][0]);
        }
        
    }
    
    var thead = questionTable.createTHead();
    var thtr = thead.insertRow(0);
    var thcell = thtr.insertCell(0);
    
    var thcellText = document.createTextNode(this.settings.question);
    thcell.setAttribute('colspan', 2);
    thcell.appendChild(thcellText);
    
    that.concreteQuestionTable = questionTable;
    var frameDiv = that.superClass.initConcreteDiv(that);
    
};

MultipleChoiceQuestion.prototype.unload = function(){
    emooFadeOut(this.concreteQuestionDiv.id, this.concreteQuestionTable.id, 10, 100);
    
};

MultipleChoiceQuestion.prototype.click = function(event, choice, text, QuestionObject){
    var removeItem = false;
    var item = [];
    for (var i = 0; i < QuestionObject.emosProperties.length; i++) {
        if (QuestionObject.emosProperties[i][2] == choice) {
            item = QuestionObject.emosProperties[i];
            removeItem = true;
        }
    }
    if (!removeItem) {
        QuestionObject.emosProperties.push([QuestionObject.superClass.survey.id, QuestionObject.settings.id, choice, text, this.superClass.survey.timestamp, '']);
    } else {
        emooArrayRemoveItem(QuestionObject.emosProperties, item);
    }
    return QuestionObject.emosProperties;
};

MultipleChoiceQuestion.prototype.doRandomAnswer = function(){
    var answers = new Array();
    var answerCount = Math.ceil(Math.random() * (this.settings.answers.length));
    for (var i = 0; i < answerCount; i++) {
        var answer = this.settings.answers[Math.floor(Math.random() * (this.settings.answers.length))][0];
        if (!emooArrayHasItem(answers, answer)) {
            answers.push(answer);
        }
    }
    var properties = new Object();
    var propertyArray = new Array();
    
    for (var j = 0; j < answers.length; j++) {
        var property = new Array();
        property.push(this.superClass.survey.id, this.settings.id, answers[j], "0");
        property.push(this.superClass.survey.timestamp);
        for (var k = 0; k < this.settings.answers.length; k++) {
            if (this.settings.answers[k][0] == answers[j]) {
                property.push(this.settings.answers[k][2] == 'true' ? 'text antwort' : '');
            }
        }
        propertyArray.push(property);
    }
    
    if (propertyArray.length > 0) {
        properties.survey = propertyArray;
        window.emosPropertiesEvent(properties);
    }
};


MultipleChoiceQuestion.prototype.getFollowingQuestionId = function(){
    if (this.settings.followingQuestionId.length == 1) {
        return 0;
    }
};

MultipleChoiceQuestion.prototype.getEmosProperties = function(){

    for (var answer in this.textAnswer) {
        this.emosProperties.push([this.superClass.survey.id, this.settings.id, answer, '0', this.superClass.survey.timestamp, this.textAnswer[answer]]);
    }
    return this.emosProperties;
};


/**
* Create a new instance of DichtomousQuestion.
*
* @classDescription This class creates a new DichtomousQuestion.
* @return {DichtomousQuestion}   Returns a new DichtomousQuestion.
* @type {Question}
* @constructor  
*/

function DichtomousQuestion(name, settings){
    this.name = name;
    this.locked = false;
    this.settings = settings;
    this.inputs = [];
    this.concreteQuestionTable;
    this.concreteQuestionDiv;
    this.themeSetting;
    this.emosProperties = [];
};

DichtomousQuestion.prototype.superClass = new Question();

DichtomousQuestion.prototype.init = function(){
    var that = this;
    that.superClass.init();
    
    var oldElement = document.getElementById(that.settings.id + '_table');
    if (oldElement) {
        oldElement.parentNode.removeChild(oldElement);
    }
    var questionTable = document.createElement('table');
    questionTable.className = 'ooEc-question';
    questionTable.id = that.settings.id + '_table';
    
    var tbody = document.createElement('tbody');
    questionTable.appendChild(tbody);
    
    var e = this.settings.answers.length;
    for (var i = 0; i < e; i++) {
        var tr = questionTable.insertRow(i);
        var cell1 = tr.insertCell(0);
        var cell1Align = document.createAttribute('align');
        cell1Align.nodeValue = 'left';
        cell1.setAttributeNode(cell1Align);
        var cell1Text = document.createTextNode(this.settings.answers[i][1]);
        cell1.appendChild(cell1Text);
        
        var inputElement = document.createElement('input');
        inputElement.type = 'radio';
        this.inputs[i] = inputElement;
        inputElement.value = this.settings.answers[i][0];
        inputElement.name = this.name;
        inputElement.style.cursor = 'pointer';
        
        inputElement.onclick = function(evt){
            if (that.superClass.locked) {
                return;
            }
            this.checked = 'checked';
            var nextButton = document.getElementById(that.settings.id + '_next');
            nextButton.disabled = '';
            setEmooOpacity(nextButton, 10);
            var eEvent = evt || window.event;
            that.click(eEvent, this.value, that);
            // that.superClass.lock();
        };
        var cell2 = tr.insertCell(1);
        cell2.appendChild(inputElement);
        cell2.firstChild.setAttribute('value', this.settings.answers[i][0]);
    }
    
    var thead = questionTable.createTHead();
    var thtr = thead.insertRow(0);
    var thcell = thtr.insertCell(0);
    
    var thcellText = document.createTextNode(this.settings.question);
    thcell.setAttribute('colspan', 2);
    thcell.appendChild(thcellText);
    
    that.concreteQuestionTable = questionTable;
    var frameDiv = that.superClass.initConcreteDiv(that);
    
};

DichtomousQuestion.prototype.unload = function(){
    emooFadeOut(this.concreteQuestionDiv.id, this.concreteQuestionTable.id, 10, 100);
};

DichtomousQuestion.prototype.click = function(event, choice, QuestionObject){
    this.emosProperties = [];
    this.emosProperties.push([QuestionObject.superClass.survey.id, QuestionObject.settings.id, choice, '0', this.superClass.survey.timestamp, '']);
};

DichtomousQuestion.prototype.doRandomAnswer = function(){

    var property = new Array(this.superClass.survey.id, this.settings.id, this.settings.answers[Math.floor(Math.random() * (this.settings.answers.length))][0], '0');
    property.push(this.superClass.survey.timestamp);
    property.push('');
    var propertyArray = new Array();
    propertyArray.push(property);
    var properties = new Object();
    properties.survey = propertyArray;
    window.emosPropertiesEvent(properties);
    
};

DichtomousQuestion.prototype.getFollowingQuestionId = function(){
    if (this.settings.followingQuestionId.length == 1) {
        return 0;
    }
    var inputs = this.concreteQuestionTable.getElementsByTagName("input");
    for (var i = 0; i < inputs.length; i++) {
        if (inputs[i].checked) {
            return i;
        }
    }
};

DichtomousQuestion.prototype.getEmosProperties = function(){
    return this.emosProperties;
};


/*
 * LikertScalesQuestion Class
 */
function LikertScalesQuestion(name, settings){
    this.name = name;
    this.locked = false;
    this.settings = settings;
    this.inputs = [];
    this.concreteQuestionDiv;
    this.concreteQuestionTable;
    this.themeSetting;
    this.emosProperties = [];
};

LikertScalesQuestion.prototype.superClass = new Question();


LikertScalesQuestion.prototype.init = function(){
    var that = this;
    that.superClass.init();
    
    var oldElement = document.getElementById(that.settings.id + '_table');
    if (oldElement) {
        oldElement.parentNode.removeChild(oldElement);
    }
    var questionTable = document.createElement('table');
    questionTable.className = 'ooEc-question';
    questionTable.id = that.settings.id + '_table';
    var tbody = document.createElement('tbody');
    questionTable.appendChild(tbody);
    var questions = this.settings.question.split('|');
    var e = this.settings.answers.length;
    
    for (var j = 0; j < questions.length; j++) {
        var tr1 = questionTable.insertRow(j);
        tr1.id = j;
        for (var i = 0; i < e; i++) {
            var inputElement = document.createElement('input');
            inputElement.className = 'likertScaleInput';
            inputElement.type = 'radio';
            this.inputs[i] = inputElement;
            inputElement.value = this.settings.answers[i][0];
            inputElement.name = questions[j];
            inputElement.style.cursor = 'pointer';
            
            inputElement.onclick = function(evt){
                if (that.superClass.locked) {
                    return;
                }
                this.checked = 'checked';
                
                var eEvent = evt || window.event;
                that.click(eEvent, this.value, that);
            };
            var cell2 = tr1.insertCell(i);
            cell2.appendChild(inputElement);
            cell2.firstChild.setAttribute('value', this.settings.answers[i][0]);
            if (i == 0) {
                cell2.className = 'ooEc-table-cell-center';
            } else if (i == (e - 1)) {
                cell2.className = 'ooEc-table-cell-center';
            }
        }
        
        var cell1 = tr1.insertCell(0);
        var cell1Text = document.createTextNode(questions[j]);
        cell1.appendChild(cell1Text);
        cell1.className = 'ooEc-table-cell-left';
    }
    var tr = questionTable.insertRow(0);
    
    for (var i = 0; i < e; i++) {
    
        var cell1 = tr.insertCell(i);
        
        if (i == 0) {
            cell1.className = 'ooEc-table-cell-center';
            
        } else if (i == (e - 1)) {
            cell1.className = 'ooEc-table-cell-center';
        }
        var cell1Text = document.createTextNode(this.settings.answers[i][1]);
        cell1.appendChild(cell1Text);
    }
    
    var cell0 = tr.insertCell(0);
    var cell0Text = document.createTextNode('');
    cell0.appendChild(cell0Text);
    
    var tr2 = questionTable.insertRow(0);
    
    for (var i = 0; i < e; i++) {
        var cell2;
        if (e == 5) {
            if (i != 1 && i != 4) {
                cell2 = tr2.insertCell(-1);
            }
        }
        if (e == 7) {
            if (i != 1 && i != 2 && i != 5 && i != 6) {
                cell2 = tr2.insertCell(-1);
            }
        }
        if (cell2 != null) {
            var cell2Text;
            if (i == 0) {
                cell2Text = document.createTextNode(this.settings.minAnswer);
                cell2.className = 'ooEc-table-scale-left';
                var cell2colspan = document.createAttribute('colspan');
                cell2colspan.nodeValue = '2';
                cell2.setAttributeNode(cell2colspan);
            } else if (i == (e - 2)) {
                cell2Text = document.createTextNode(this.settings.maxAnswer);
                cell2.className = 'ooEc-table-scale-right';
                var cell2colspan = document.createAttribute('colspan');
                cell2colspan.nodeValue = '2';
                cell2.setAttributeNode(cell2colspan);
            } else {
                cell2Text = document.createTextNode('');
            }
            cell2.appendChild(cell2Text);
        }
        
        
    }
    
    var cell2 = tr2.insertCell(0);
    var cell2Text = document.createTextNode('');
    cell2.appendChild(cell2Text);
    var thead = questionTable.createTHead();
    var tr3 = thead.insertRow(0);
    var cell3 = tr3.insertCell(0);
    var cell3colspan = document.createAttribute('colspan');
    cell3colspan.nodeValue = new Number(e) + 1;
    ;
    cell3.setAttributeNode(cell3colspan);
    cell3Text = document.createTextNode(this.name);
    cell3.appendChild(cell3Text);
    
    
    that.concreteQuestionTable = questionTable;
    var frameDiv = that.superClass.initConcreteDiv(that);
};

LikertScalesQuestion.prototype.unload = function(){
    emooFadeOut(this.concreteQuestionDiv.id, this.concreteQuestionTable.id, 10, 100);
};

LikertScalesQuestion.prototype.click = function(evt, choice, QuestionObject){

    var questions = QuestionObject.settings.question.split('|');
    var inputElements = QuestionObject.concreteQuestionTable.getElementsByTagName("input");
    var clickedElements = 0;
    this.emosProperties = [];
    var eEvent = evt || window.event;
    var clickedElement = eEvent.srcElement || eEvent.target;
    var question = clickedElement.name;
    
    for (var k = 0; k < inputElements.length; k++) {
    
        if (inputElements[k].checked && inputElements[k].className == 'likertScaleInput') {
            var tableRow;
            var tmpElement = inputElements[k];
            while (tmpElement.tagName.toLowerCase() != 'tr') {
                tmpElement = tmpElement.parentNode;
            }
            var id = tmpElement.id;
            this.emosProperties.push([QuestionObject.superClass.survey.id, QuestionObject.settings.id, inputElements[k].value, (new Number(id) + 1), this.superClass.survey.timestamp, '']);
            clickedElements++;
        }
    }
    
    if (questions.length == clickedElements) {
        var nextButton = document.getElementById(QuestionObject.settings.id + '_next');
        nextButton.disabled = '';
        setEmooOpacity(nextButton, 10);
    }
};

LikertScalesQuestion.prototype.doRandomAnswer = function(){
    var likertQuestions = this.settings.question.split('|');
    var propertyArray = new Array();
    
    for (var i = 0; i < likertQuestions.length; i++) {
        var property = new Array();
        property.push(this.superClass.survey.id, this.settings.id, this.settings.answers[Math.floor(Math.random() * (this.settings.answers.length))][0], (new Number(i) + 1));
        property.push(this.superClass.survey.timestamp);
        property.push('');
        propertyArray.push(property);
    }
    
    var properties = new Object();
    properties.survey = propertyArray;
    window.emosPropertiesEvent(properties);
};

LikertScalesQuestion.prototype.getFollowingQuestionId = function(){
    if (this.settings.followingQuestionId.length == 1) {
        return 0;
    }
};

LikertScalesQuestion.prototype.getEmosProperties = function(){
    return this.emosProperties;
};

function EmooComment(name, settings){
    this.name = name;
    this.locked = false;
    this.settings = settings;
    this.inputs = [];
    this.concreteQuestionTable;
    this.concreteQuestionDiv;
    this.themeSetting;
    this.emosProperties = [];
};

EmooComment.prototype.superClass = new Question();

EmooComment.prototype.init = function(){
    var that = this;
    that.superClass.init();
    var oldElement = document.getElementById(that.settings.id + '_table');
    
    if (oldElement) {
        oldElement.parentNode.removeChild(oldElement);
    }
    
    var questionTable = document.createElement('table');
    questionTable.className = 'ooEc-question';
    
    var tableId = document.createAttribute("id");
    tableId.nodeValue = that.settings.id + '_table';
    questionTable.setAttributeNode(tableId);
    
    var tbody = document.createElement('tbody');
    
    
    var e = this.settings.answers.length;
    for (var i = 0; i < e; i++) {
        var tr = document.createElement('tr');
        var cell1 = document.createElement('td');
        cell1.className = 'ooEc-table-cell-left';
        var textAreaElement = document.createElement('textarea');
        
        var textAreaWidth = document.createAttribute('cols');
        textAreaWidth.nodeValue = '40';
        textAreaElement.setAttributeNode(textAreaWidth);
        var textAreaHeight = document.createAttribute('rows');
        textAreaHeight.nodeValue = '10';
        textAreaElement.setAttributeNode(textAreaHeight);
        
        textAreaElement.name = this.name;
        textAreaElement.id = this.name + "_comment";
        cell1.appendChild(textAreaElement);
        tr.appendChild(cell1);
        tbody.appendChild(tr);
    }
    
    questionTable.appendChild(tbody);
    
    var thead = questionTable.createTHead();
    var thtr = thead.insertRow(0);
    var thcell = thtr.insertCell(0);
    
    var thcellText = document.createTextNode(this.settings.question);
    
    thcell.appendChild(thcellText);
    
    setEmooOpacity(questionTable, 10);
    
    that.concreteQuestionTable = questionTable;
    
    var frameDiv = that.superClass.initConcreteDiv(that);
    
    var nextButton = document.getElementById(that.settings.id + '_next');
    nextButton.disabled = false;
    setEmooOpacity(nextButton, 10);
};

EmooComment.prototype.unload = function(){
    emooFadeOut(this.concreteQuestionDiv.id, this.concreteQuestionTable.id, 10, 100);
};


EmooComment.prototype.doRandomAnswer = function(){

    var property = new Array(this.superClass.survey.id, this.settings.id, '0', '0');
    property.push(this.superClass.survey.timestamp);
    property.push('This is a comment');
    var propertyArray = new Array();
    propertyArray.push(property);
    var properties = new Object();
    properties.survey = propertyArray;
    window.emosPropertiesEvent(properties);
};


EmooComment.prototype.getFollowingQuestionId = function(){
    if (this.settings.followingQuestionId.length == 1) {
        return (0);
    }
};

EmooComment.prototype.getEmosProperties = function(){
    this.emosProperties = [];
    this.emosProperties.push([this.superClass.survey.id, this.settings.id, '0', '0', this.superClass.survey.timestamp, document.getElementById(this.name + "_comment").value]);
    
    return this.emosProperties;
};

/* Welcome Screen */

function WelcomeScreen(name, settings){
    this.name = name;
    this.locked = false;
    this.settings = settings;
    this.inputs = [];
    this.concreteQuestionTable;
    this.concreteQuestionDiv;
    
};

WelcomeScreen.prototype.superClass = new Question();

WelcomeScreen.prototype.init = function(){
    var that = this;
    that.superClass.init();
    var oldElement = document.getElementById(that.settings.id + '_table');
    
    if (oldElement) {
        oldElement.parentNode.removeChild(oldElement);
    }
    var welcomeTable = document.createElement('table');
    welcomeTable.className = 'ooEc-question';
    
    var tableId = document.createAttribute("id");
    tableId.nodeValue = that.settings.id + '_table';
    welcomeTable.setAttributeNode(tableId);
    
    var tbody = document.createElement('tbody');
    var tr = document.createElement('tr');
    var td = document.createElement('td');
    td.className = 'ooEc-td';
    td.innerHTML = that.superClass.survey.welcomeText;
    
    tr.appendChild(td);
    tbody.appendChild(tr);
    welcomeTable.appendChild(tbody);
    that.concretewelcomeTable = welcomeTable;
    
    var welcomeFrameDiv = document.getElementById('frame' + that.settings.id);
    
    if (welcomeFrameDiv) {
        welcomeFrameDiv.parentNode.removeChild(welcomeFrameDiv);
    }
    innerwelcomeFrameDiv = document.createElement("div");
    innerwelcomeFrameDiv.className = 'ooEc-innerframe';
    
    var welcomeFrameDiv = document.createElement("div");
    welcomeFrameDiv.className = 'ooEc-frame';
    
    var divId = document.createAttribute("id");
    divId.nodeValue = 'frame' + that.settings.id;
    welcomeFrameDiv.setAttributeNode(divId);
    setEmooOpacity(welcomeFrameDiv, 0);
    
    var closeDiv = document.createElement('div');
    closeDiv.className = 'ooEc-close-div';
    
    var closePic = new Image();
    closePic.className = 'ooEc-close-pic';
    closePic.title = 'schlie\u00DFen';
    
    if (that.superClass.survey.isConfig) {
        closePic.src = that.superClass.survey.getImagePath() + '/generated/close_button_' + that.superClass.survey.getUserColor() + '.gif';
    } else {
        closePic.src = that.superClass.survey.getImagePath() + '/close_button.gif';
    }
    
    closePic.onclick = function(evt){
        that.unload();
    };
    closeDiv.appendChild(closePic);
    welcomeFrameDiv.appendChild(closeDiv);
    
    
    var logoDiv = document.createElement('div');
    logoDiv.className = 'ooEc-logo-div';
    var logo = new Image();
    logo.className = 'ooEc-logo-img';
    var logo = new Image();
    if (that.superClass.survey.picture == 'null') {
        if (that.superClass.survey.isConfig) {
            logo.src = that.superClass.survey.getImagePath() + '/generated/econda_logo_' + that.superClass.survey.getUserColor() + '.gif';
        } else {
            logo.src = that.superClass.survey.getImagePath() + '/econda_logo.gif';
        }
    } else {
    
        logo.className = 'ooEc-logo-img';
        if (that.superClass.survey.isConfig) {
            if (that.superClass.survey.picture == 'econda_logo.gif') {
                that.superClass.survey.getImagePath() + '/generated/econda_logo_' + that.superClass.survey.getUserColor() + '.gif';
            } else {
                logo.src = that.superClass.survey.getImagePath().replace('images/survey', 'config/survey/edit') + '/getLogo?image=' + that.superClass.survey.picture + '&surveyid=' + that.superClass.survey.id;
            }
            
        } else {
            logo.src = that.superClass.survey.getImagePath() + '/' + that.superClass.survey.picture;
        }
    }
    
    var opinionPic = new Image();
    opinionPic.className = 'ooEc-img';
    
    if (that.superClass.survey.isConfig) {
        opinionPic.src = that.superClass.survey.getImagePath() + '/generated/opinion_logo_' + that.superClass.survey.getUserColor() + '.gif';
    } else {
        opinionPic.src = that.superClass.survey.getImagePath() + '/opinion_logo.gif';
    }
    
    var opinionSpan = document.createElement('span');
    opinionSpan.className = 'ooEc-text';
    var opinionText;
    
    if (that.superClass.survey.getHeadline() != '') {
        if (that.superClass.survey.getHeadline() != 'null') {
            opinionText = document.createTextNode(that.superClass.survey.getHeadline());
        } else {
            opinionText = document.createTextNode("ONLINE OPINION");
        }
    } else {
        opinionText = document.createTextNode("ONLINE OPINION");
    }
    
    opinionSpan.appendChild(opinionText);
    logoDiv.appendChild(opinionSpan);
    logoDiv.appendChild(opinionPic);
    if (logo != 'undefined') {
        logoDiv.appendChild(logo);
    }
    
    welcomeFrameDiv.appendChild(logoDiv);
    
    
    innerwelcomeFrameDiv.appendChild(welcomeTable);
    welcomeFrameDiv.appendChild(innerwelcomeFrameDiv);
    
    var nextDiv = document.createElement('div');
    nextDiv.className = 'ooEc-next-div';
    var nextButton = document.createElement("button");
    nextButton.className = 'ooEc-next-button';
    var closeText = document.createTextNode("los");
    nextButton.appendChild(closeText);
    nextButton.onclick = function(event){
        that.unload();
        that.superClass.survey.initFirstQuestion();
    };
    nextButton.id = that.settings.id + '_next';
    nextDiv.appendChild(nextButton);
    welcomeFrameDiv.appendChild(nextDiv);
    
    var opinionOuterDiv = document.createElement('div');
    opinionOuterDiv.style.height = "40px";
    opinionOuterDiv.className = 'ooEc-outerfooter';
    
    var opinionDiv = document.createElement('div');
    opinionDiv.className = 'ooEc-footer';
    
    var opinionWebsiteDiv = document.createElement('div');
    opinionWebsiteDiv.className = 'ooEc-website';
    
    var econdaAnker = document.createElement('a');
    var econdaLink = document.createAttribute('href');
    var econdaTarget = document.createAttribute('target');
    econdaTarget.nodeValue = '_blank';
    econdaLink.nodeValue = 'http://www.econda.de/produkte/online-opinion.html?campaign=OO%2FSurvey';
    econdaAnker.setAttributeNode(econdaLink);
    econdaAnker.setAttributeNode(econdaTarget);
    var opinionWebsiteText;
    if (that.superClass.survey.isStandard == 'true') {
        opinionWebsiteText = document.createTextNode('www.econda.de');
    } else {
        opinionWebsiteText = document.createTextNode('erstellt mit econda Online Opinion');
    }
    econdaAnker.appendChild(opinionWebsiteText);
    opinionWebsiteDiv.appendChild(econdaAnker);
    opinionDiv.appendChild(opinionWebsiteDiv);
    opinionOuterDiv.appendChild(opinionDiv);
    welcomeFrameDiv.appendChild(opinionOuterDiv);
    
    var clearDiv = document.createElement('div');
    clearDiv.style.clear = 'both';
    welcomeFrameDiv.appendChild(clearDiv);
    document.getElementsByTagName('body')[0].appendChild(welcomeFrameDiv);
    var de = document.documentElement;
    var documentWidth = window.innerWidth || self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
    var documentHeight = window.innerHeight || self.innerHeight || (de && de.clientHeight) || document.body.clientHeight;
    // Fix for IE
    welcomeFrameDiv.style.width = welcomeTable.clientWidth + 20 + 'px';
    
    // Fix for IE
    if (welcomeFrameDiv.clientWidth < 560) welcomeFrameDiv.style.width = '560px';
    
    welcomeFrameDiv.style.left = Math.ceil(documentWidth / 2 - welcomeFrameDiv.clientWidth / 2) + 'px';
    welcomeFrameDiv.style.top = Math.ceil(documentHeight / 2 - welcomeFrameDiv.clientHeight / 2) + 'px';
    
    that.concreteQuestionDiv = welcomeFrameDiv;
    emooFadeIn(welcomeFrameDiv.id, 0, 100);
};

WelcomeScreen.prototype.unload = function(){
    emooFadeOut(this.concreteQuestionDiv.id, this.concretewelcomeTable.id, 10, 100);
};

WelcomeScreen.prototype.click = function(event, choice, QuestionObject){

};

WelcomeScreen.prototype.getFollowingQuestionId = function(){
    if (this.settings.followingQuestionId.length == 1) {
        return (0);
    }
    var inputs = this.concreteQuestionTable.getElementsByTagName("input");
    for (var i = 0; i < inputs.length; i++) {
        if (inputs[i].checked) {
            return i;
        }
    }
};


/* Thanks Screen */

function ThanksScreen(name, settings){
    this.name = name;
    this.locked = false;
    this.settings = settings;
    this.inputs = [];
    this.concreteQuestionTable;
    this.concreteQuestionDiv;
    
};

ThanksScreen.prototype.superClass = new Question();

ThanksScreen.prototype.init = function(){
    var that = this;
    that.superClass.init();
    var oldElement = document.getElementById(that.settings.id + '_table');
    
    if (oldElement) {
        oldElement.parentNode.removeChild(oldElement);
    }
    var ThanksTable = document.createElement('table');
    ThanksTable.className = 'ooEc-question';
    
    
    var tableId = document.createAttribute("id");
    tableId.nodeValue = that.settings.id + '_table';
    ThanksTable.setAttributeNode(tableId);
    
    var tbody = document.createElement('tbody');
    var tr = document.createElement('tr');
    var td = document.createElement('td');
    td.className = 'ooEc-td';
    td.innerHTML = that.superClass.survey.thanksText;
    
    tr.appendChild(td);
    tbody.appendChild(tr);
    ThanksTable.appendChild(tbody);
    that.concreteThanksTable = ThanksTable;
    
    var ThanksFrameDiv = document.getElementById('frame' + that.settings.id);
    
    if (ThanksFrameDiv) {
        ThanksFrameDiv.parentNode.removeChild(ThanksFrameDiv);
    }
    innerThanksFrameDiv = document.createElement("div");
    innerThanksFrameDiv.className = 'ooEc-innerframe';
    
    var ThanksFrameDiv = document.createElement("div");
    ThanksFrameDiv.className = 'ooEc-frame';
    
    var divId = document.createAttribute("id");
    divId.nodeValue = 'frame' + that.settings.id;
    ThanksFrameDiv.setAttributeNode(divId);
    setEmooOpacity(ThanksFrameDiv, 0);
    
    var closeDiv = document.createElement('div');
    closeDiv.className = 'ooEc-close-div';
    
    var closePic = new Image();
    closePic.className = 'ooEc-close-pic';
    if (that.superClass.survey.isConfig) {
        closePic.src = that.superClass.survey.getImagePath() + '/generated/close_button_' + that.superClass.survey.getUserColor() + '.gif';
    } else {
        closePic.src = that.superClass.survey.getImagePath() + '/close_button.gif';
    }
    closePic.title = 'schlie\u00DFen';
    closePic.onclick = function(evt){
        that.unload();
    };
    closeDiv.appendChild(closePic);
    ThanksFrameDiv.appendChild(closeDiv);
    
    var logoDiv = document.createElement('div');
    logoDiv.className = 'ooEc-logo-div';
    var logo = new Image();
    if (that.superClass.survey.picture == 'null') {
        if (that.superClass.survey.isConfig) {
            logo.src = that.superClass.survey.getImagePath() + '/generated/econda_logo_' + that.superClass.survey.getUserColor() + '.gif';
        } else {
            logo.src = that.superClass.survey.getImagePath() + '/econda_logo.gif';
        }
    } else {
        logo.className = 'ooEc-logo-img';
        if (that.superClass.survey.isConfig) {
            if (that.superClass.survey.picture == 'econda_logo.gif') {
                that.superClass.survey.getImagePath() + '/generated/econda_logo_' + that.superClass.survey.getUserColor() + '.gif';
            } else {
                logo.src = that.superClass.survey.getImagePath().replace('images/survey', 'config/survey/edit') + '/getLogo?image=' + that.superClass.survey.picture + '&surveyid=' + that.superClass.survey.id;
            }
            
        } else {
            logo.src = that.superClass.survey.getImagePath() + '/' + that.superClass.survey.picture;
        }
    }
    var opinionPic = new Image();
    opinionPic.className = 'ooEc-img';
    
    if (that.superClass.survey.isConfig) {
        opinionPic.src = that.superClass.survey.getImagePath() + '/generated/opinion_logo_' + that.superClass.survey.getUserColor() + '.gif';
    } else {
        opinionPic.src = that.superClass.survey.getImagePath() + '/opinion_logo.gif';
    }
    
    var opinionSpan = document.createElement('span');
    opinionSpan.className = 'ooEc-text';
    var opinionText;
    
    if (that.superClass.survey.getHeadline() != '') {
        if (that.superClass.survey.getHeadline() != 'null') {
            opinionText = document.createTextNode(that.superClass.survey.getHeadline());
        } else {
            opinionText = document.createTextNode("ONLINE OPINION");
        }
    } else {
        opinionText = document.createTextNode("ONLINE OPINION");
    }
    opinionSpan.appendChild(opinionText);
    logoDiv.appendChild(opinionSpan);
    logoDiv.appendChild(opinionPic);
    if (logo != 'undefined') {
        logoDiv.appendChild(logo);
    }
    
    ThanksFrameDiv.appendChild(logoDiv);
    
    
    
    innerThanksFrameDiv.appendChild(ThanksTable);
    ThanksFrameDiv.appendChild(innerThanksFrameDiv);
    
    var nextDiv = document.createElement('div');
    nextDiv.className = 'ooEc-next-div';
    var nextButton = document.createElement("button");
    nextButton.className = 'ooEc-next-button';
    nextButton.style.width = '79px';
    var closeText = document.createTextNode("schlie\u00DFen");
    nextButton.appendChild(closeText);
    nextButton.onclick = function(event){
        that.unload();
    };
    nextButton.id = that.settings.id + '_next';
    nextDiv.appendChild(nextButton);
    ThanksFrameDiv.appendChild(nextDiv);
    
    var opinionDiv = document.createElement('div');
    opinionDiv.className = 'ooEc-footer';
    
    var opinionOuterDiv = document.createElement('div');
    opinionOuterDiv.style.height = "40px";
    opinionOuterDiv.className = 'ooEc-outerfooter';
    
    var opinionWebsiteDiv = document.createElement('div');
    opinionWebsiteDiv.className = 'ooEc-website';
    
    var econdaAnker = document.createElement('a');
    var econdaLink = document.createAttribute('href');
    var econdaTarget = document.createAttribute('target');
    econdaTarget.nodeValue = '_blank';
    econdaLink.nodeValue = 'http://www.econda.de/produkte/online-opinion.html?campaign=OO%2FSurvey';
    econdaAnker.setAttributeNode(econdaLink);
    econdaAnker.setAttributeNode(econdaTarget);
    var opinionWebsiteText;
    if (that.superClass.survey.isStandard == 'true') {
        opinionWebsiteText = document.createTextNode('www.econda.de');
    } else {
        opinionWebsiteText = document.createTextNode('erstellt mit econda Online Opinion');
    }
    econdaAnker.appendChild(opinionWebsiteText);
    opinionWebsiteDiv.appendChild(econdaAnker);
    
    opinionDiv.appendChild(opinionWebsiteDiv);
    opinionOuterDiv.appendChild(opinionDiv);
    ThanksFrameDiv.appendChild(opinionOuterDiv);
    
    var clearDiv = document.createElement('div');
    clearDiv.style.clear = 'both';
    ThanksFrameDiv.appendChild(clearDiv);
    document.getElementsByTagName('body')[0].appendChild(ThanksFrameDiv);
    
    var de = document.documentElement;
    var documentWidth = window.innerWidth || self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
    var documentHeight = window.innerHeight || self.innerHeight || (de && de.clientHeight) || document.body.clientHeight;
    // Fix for IE
    ThanksFrameDiv.style.width = ThanksTable.clientWidth + 20 + 'px';
    
    if (ThanksFrameDiv.clientWidth < 560) {
        ThanksFrameDiv.style.width = '560px';
    }
    
    ThanksFrameDiv.style.left = Math.ceil(documentWidth / 2 - ThanksFrameDiv.clientWidth / 2) + 'px';
    ThanksFrameDiv.style.top = Math.ceil(documentHeight / 2 - ThanksFrameDiv.clientHeight / 2) + 'px';
    
    
    that.concreteQuestionDiv = ThanksFrameDiv;
    
    emooFadeIn(ThanksFrameDiv.id, 0, 100);
    
};

ThanksScreen.prototype.unload = function(){
    emooFadeOut(this.concreteQuestionDiv.id, this.concreteThanksTable.id, 10, 100);
};



function setEmooOpacity(element, value){
    element.style.opacity = value / 10;
    element.style.filter = 'alpha(opacity=' + value * 10 + ')';
}

function surveyInit() {
    if (typeof(window.emosSurveyCustomHandler) === 'undefined') {
        survey.init();
    }
}

function internalSurveyInit() {
    if (!(typeof(window.emosSurveyCustomHandler) === 'undefined')) {
        survey.init();
    }
}

function externalSurveyInit(timeout) {
    timeout=(typeof(timeout)==='undefined')?0:timeout;
    var timeoutInSec = parseInt(timeout) * 1000;
    window.setTimeout(internalSurveyInit, timeoutInSec);
}
var survey = new Survey();
survey.setId('798');
survey.setTheme('RED');
survey.setWelcomeText('<p style=\"text-align: left;\"><span style=\"font-size: small;\"><span style=\"font-family: arial,helvetica,sans-serif;\"><strong>Liebe Shopbesucher,<\/strong><br \/><br \/>f&uuml;r Sie bem&uuml;hen wir uns st&auml;ndig darum, unseren Online-Shop Ihren Vorstellungen entsprechend zu optimieren.<br \/><br \/>Wir w&uuml;rden uns freuen, wenn Sie uns dabei durch die Beantwortung der folgenden 4 Fragen unterst&uuml;tzen k&ouml;nnten. <br \/><br \/>Die Beantwortung nimmt lediglich 1 Minute in Anspruch.<br \/><br \/>Vielen herzlichen Dank!<br \/><br \/><strong>Ihr Shopteam<\/strong><br \/><\/span><\/span><\/p>');
survey.setThanksText('<p style=\"text-align: left;\"><span style=\"font-size: small;\"><span style=\"font-family: arial,helvetica,sans-serif;\"><strong>Liebe Shopbesucher,<\/strong><br \/><br \/>durch die Beantwortung der Fragen haben Sie uns sehr geholfen.<br \/><br \/>F&uuml;r Ihre W&uuml;nsche und Anregungen stehen wir immer gerne zur Verf&uuml;gung.<br \/><br \/>Vielen herzlichen Dank!<br \/><br \/><strong>Ihr Shopteam<\/strong><\/span><\/span><\/p>');
survey.setPicture('null');
survey.setSampling('50');
survey.setIsStandard('true');
survey.setFixedPeriod('false');
survey.setFrom('2009-11-03');
survey.setTo('2009-11-03');
survey.setMultipleParticipation('false');
survey.setUserColor('');
survey.setHeadline('null');

survey.addQuestion(new LikertScalesQuestion('Wie beurteilen Sie unseren Online-Shop hinsichtlich der folgenden Aspekte?',{ id:'537',question:'Produkte|Preise|Nutzerfreundlichkeit|Liefermodalit\u00E4ten|Kundenservice|Web 2.0 Dienste',answers: [ [ '1740','0'], [ '1741','1'], [ '1742','2'], [ '1743','3'], [ '1744','4']], minAnswer: 'sehr schlecht',maxAnswer: 'sehr gut',followingQuestionId: ['526'] }));

survey.addQuestion(new EmooComment('Verbesserungsvorschl\u00E4ge',{ id:'526',question:'Welche Verbesserungsvorschl\u00E4ge m\u00F6chten Sie machen?',answers: [ [ '0','0'] ], followingQuestionId: ['396'] }));

survey.addQuestion(new SingleChoiceQuestion('Alter',{ id:'396',question:'Wie alt sind Sie?',answers: [ [ '1203','< 14 Jahre','false'], [ '1204','14-19 Jahre','false'], [ '1205','20-29 Jahre','false'], [ '1206','30-39 Jahre','false'], [ '1207','40-49 Jahre','false'], [ '1208','50-59 Jahre','false'], [ '1209','> 59 Jahre','false']], followingQuestionId: ['397'] })
);

survey.addQuestion(new SingleChoiceQuestion('Geschlecht',{ id:'397',question:'Sie sind',answers: [ [ '1210','m\u00E4nnlich','false'], [ '1211','weiblich','false']], followingQuestionId: [''] })
);

survey.getCorrectedImagePath();
if (window.addEventListener)
    window.addEventListener('load', surveyInit, true); 
else if (window.attachEvent)
    window.attachEvent('onload', surveyInit);
