//  Copyright (C) 2001-2003  Schlund + Partner AG
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2.1 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

function __js_Browser() {
  // features
  this.all        = document.all ? true : false;
  this.layers     = document.layers ? true : false;
  this.dom        = document.getElementById ? true : false;
  this.dom2events = (document.addEventListener && document.removeEventListener) ? true : false;
  this.dom2core   = (document.createTextNode && document.firstChild && document.getElementsByTagName &&
                     document.createElement && document.createComment) ? true : false;
  this.dom2       = (this.dom2events && this.dom2core) ? true : false;

  // identification
  this.vendor     = navigator.vendor ? navigator.vendor.toLowerCase() : false;
  this.product    = navigator.product ? navigator.product.toLowerCase() : false;

  // display mode
  this.stdmode    = document.compatMode == "CSS1Compat" ? true : false;

  // browser
  this.ic         = (window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1) ? true : false;

  this.op         = window.opera ? true : false;
  this.op7        = this.op && this.dom2;
  this.op6        = this.op && !this.op7

  this.kq         = (this.vendor == "kde") ? true : false;
  this.sf         = (this.mac && this.vendor == "kde") ? true : false;
  this.gk         = (this.dom2 && document.defaultView && this.product == "gecko") ? true : false;

  this.ie         = (document.all && !this.kq && !this.op) ? true : false;
  this.ie6        = (this.ie && this.dom2 && document.fireEvent && document.createComment) ? true : false;
  this.ie55       = (this.ie && document.fireEvent && !this.dom2) ? true : false;
  this.ie5        = (this.ie && !document.fireEvent) ? true : false
  // We don't detect this so we assume no :-(
  this.ie5mac     = false;
  this.ie4        = (this.ie && !this.ie6 && !this.ie55 && !this.ie5 && !this.ie5mac) ? true : false;
}

__Browser = new __js_Browser();

//
// BUTTONS
//

__js_allButtons = new Array();

function __js_button(pic, picomo) {
    this.pic = new Image();
    this.pic.src = pic;
    this.pic_active = new Image();
    this.pic_active.src = picomo;
}

function __js_moveover(doc, id) {
    doc[id].src = __js_allButtons[id].pic_active.src;
}

function __js_moveout(doc, id) {
    doc[id].src = __js_allButtons[id].pic.src;
}

//
// LAYERS
//

var __js_allLayers  = new Array();

function __js_getLayer(id) {
    if (__js_allLayers[id] != null) {
        return __js_allLayers[id];
    } else {
        var temp = new __js_Layer(id);
        __js_allLayers[id] = temp;
        return temp;
    }
}

function __js_toggleLayers() {
    for (var i = 0; i < __js_toggleLayers.arguments.length; i++) {
        var layer = __js_getLayer(__js_toggleLayers.arguments[i]);
        if (layer.visible) {
            layer.hide();
            layer.hideChildren();
        } else {
            layer.show();
        }
    }
}

function __js_showLayers() {
    for (var i = 0; i < __js_showLayers.arguments.length; i++) {
        var layer = __js_getLayer(__js_showLayers.arguments[i]);
        if (!layer.visible) {
            layer.show();
        }
    }
}

function __js_hideLayers() {
    for (var i = 0; i < __js_hideLayers.arguments.length; i++) {
        var layer = __js_getLayer(__js_hideLayers.arguments[i]);
        if (layer.visible) {
            layer.hide();
            layer.hideChildren();
        }
    }
}

function __js_Layer(layer_id) {
    this.initialized = false;
    this.parents     = new Array();
    this.children    = new Array();
    this.switch_on   = new Array();
    this.switch_off  = new Array();
    this.visible     = true;
    this.frame       = null;
    this.store       = null;
    this.id          = layer_id;
    this.element     = null;

    this.init = function (visible, frame, store) {
        this.store   = store;
        this.frame   = frame;
        this.element = frame.document.getElementById(this.getId());

        var fromcookie =  "nocookie";
        if (navigator.cookieEnabled == true && store != "false") {
            var cookie = document.cookie;
            if (cookie.indexOf("LR_" + this.getId() + "=true") >= 0) {
                fromcookie =  "true";
            } else if (cookie.indexOf("LR_" + this.getId() + "=false") >= 0) {
                fromcookie = "false";
            }
        }
        if (fromcookie == "true") {
            this.show();
        } else if (fromcookie == "false") {
            this.hide();
        } else {
            if (visible == 'false') {
                this.hide();
            } else {
                this.show();
            }
        }
        this.initialized = true;
    };

    this.getId       = function () { return this.id; };
    this.getFrame    = function () { return this.frame; };
    this.getChildren = function () { return this.children; };
    this.getParents  = function () { return this.parents; };

    this.addChild    = function (child) { this.children[this.children.length] = child; };
    this.addParent   = function (parent) { this.parents[this.parents.length] = parent; };

    this.show     = function () { this.__change(true, '', 'none'); };
    this.hide     = function () { this.__change(false, 'none', ''); };
    this.__change = function (cookievis, elemvis, switchoffvis) {
        if (navigator.cookieEnabled == true && this.store != "false") {
            document.cookie = "LR_" + this.getId() + "=" + cookievis + "; path=/";
        }
        this.element.style.display = elemvis;
        this.visible = cookievis;
        if (this.switch_off != null && this.switch_off.length > 0) {
            for (var i = 0; i < this.switch_off.length; i++) {
                var temp = this.switch_off[i];
                temp.style.display = switchoffvis;
            }
        }
        if (this.switch_on != null && this.switch_on.length > 0) {
            for (var i = 0; i < this.switch_on.length; i++) {
                var temp = this.switch_on[i];
                temp.style.display = elemvis;
            }
        }
    };

    this.hideChildren = function () {
        if (this.children != null && this.children.length > 0) {
            for (var i = 0; i < this.children.length; i++) {
                var temp = this.children[i];
                temp.hide();
                temp.hideChildren();
            }
        }
    };

    this.addSwitchOn  = function (switchon) {
        this.switch_on[this.switch_on.length] = switchon;
        if (this.initialized && !this.visible) {
            switchon.style.display = 'none';
        }
    };

    this.addSwitchOff = function (switchoff) {
        this.switch_off[this.switch_off.length] = switchoff;
        if (this.initialized && this.visible) {
            switchoff.style.display = 'none';
        }
    };

    this.moveRight  = function (val) { this.element.style.right = val; };
    this.moveBottom = function (val) { this.element.style.bottom = val; };
    this.moveLeft   = function (val) { this.element.style.left = val; };
    this.moveTop    = function (val) { this.element.style.top = val; };

    this.getRight   = function () { return this.element.style.right; };
    this.getBottom  = function () { return this.element.style.bottom; };
    this.getLeft    = function () { return this.element.style.left; };
    this.getTop     = function () { return this.element.style.top; };

}


// PROGRESS BAR

var __js_progress_begin     = 1;
var __js_progress_handler   = 0;
var __js_progress_frame_idx = 0;

function __js_progress_start_show_work(index) {
    __js_progress_frame_idx = index;
    top.frames[__js_progress_frame_idx].captureEvents(Event.KEYPRESS);
    top.frames[__js_progress_frame_idx].onkeypress = __js_progress_user_abort;
    __js_progress_handler = window.setInterval('__js_progress_show_work()',100);
    obj  = top.frames[__js_progress_frame_idx].document.getElementById("core_progress_wait");
    if (obj != null) {
        obj.style.visibility = "visible";
    }
}

function __js_progress_show_work() {
    obj = top.frames[__js_progress_frame_idx].document.getElementById("core_progress_bar");
    if (obj != null) {
        __js_progress_begin += 2;
        if (__js_progress_begin > 100) {
            __js_progress_begin = 100;
            window.clearInterval(__js_progress_handler);
        }

        obj.style.width = __js_progress_begin + "%";
    }
    return true;
}

function __js_progress_user_abort(Event) {
    obj  = top.frames[__js_progress_frame_idx].document.getElementById("core_progress_wait");
    obj2 = top.frames[__js_progress_frame_idx].document.getElementById("core_progress_bar");
    obj.style.visibility = "hidden";
    obj2.style.width = "0%";
     __js_progress_begin = 1;
    window.clearInterval(__js_progress_handler);
}

//
// Misc
//

function __js_getFormElement(obj, formindex, elemname) {
    var form = obj.forms[formindex];
    for (var i = 0; i < form.length; i++) {
        if (form[i].name == elemname) {
            return form[i];
        }
    }
}

function __js_getFormElementWithValue(obj, formindex, elemname, elemvalue) {
    var form = obj.forms[formindex];
    for (var i = 0; i < form.length; i++) {
        if (form[i].name == elemname && form[i].value == elemvalue) {
            return form[i];
        }
    }
}

function __js_popup(href, title, width, height) {
    child=window.open(href, title,'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+',screenX=100,screenY=100');
}

// This method automates a reload into the _top frame
function __js_switchFrame() {
    if(self.location!=top.location) {
        alert("Killing parent frame");
        top.location.href=self.location.href;
    }
}

// luego specials
function createSpecialForTripId(id) {
	var dataa3="<tr><td colspan='2'><div class='spacelo2'><table border='0' cellspacing='0' cellpadding='0' width='460'><tr><td><img src='img/dot_trans.gif' width='4' height='1'></td><td><img src='img/dot_trans.gif' width='444' height='1'></td><td><img src='img/dot_trans.gif' width='4' height='1'></td></tr><tr><td width='4'><img src='/img/btn_preis_anfang_jr.gif' /></td><td background='/img/btn_preis_midde_jr.gif' class='text-b-standard' width='460' valign='middle'><span class='text-b-standard'>8 x 8% L&auml;nderrabatt:</span><br/></td><td width='4'><img src='/img/btn_preis_ende_jr.gif' /></td></tr><tr><td colspan='2'><img src='img/dot_trans.gif' width='20' height='1'></td></tr><tr><td></td><td><div class='spacelo2'><span class='text-n-standard-big'>";
	var dataa4="</span></div></td></tr></table></div></td></tr>";
	if (id=="1163516497923" || id=="1163515875673"|| id=="1163515563987"|| id=="1163510905647"|| id=="1163510170295"|| id=="1163509255820"|| id=="1163508888354"|| id=="1163508293143"|| id=="1163506684957"|| id=="1163505828622"|| id=="1163503101415"|| id=="1163501207443"|| id=="1163500291048"|| id=="1163499610236"|| id=="1163497156974"|| id=="1163495561707"|| id=="1163494517709"|| id=="1163493780096"|| id=="1163493539052"|| id=="1163492318017"|| id=="1163435259103"|| id=="1163434888038"|| id=="1163434163205"|| id=="1163432642900"|| id=="1163410748882"|| id=="1163408733427"|| id=="1163406847483"|| id=="1162835472310"|| id=="1163431743164"|| id=="1163431312077"|| id=="1163429031078"|| id=="1163427728756"|| id=="1163425449437"|| id=="1163430932470"|| id=="1163430016215"|| id=="1163423390402"|| id=="1163415977533"|| id=="1163415370401"|| id=="1163414852952" || id=="1163412888939") {
		document.write(dataa3);
		document.write("<span class='text-n-standard-error'>In der Woche vom 19.02. - 25.02.07 und 26.03. - 01.04.07 erhaltet ihr bei Buchung dieser Reise 8% Rabatt. Dieser Rabatt ist während der Aktion bereits in dem Grundpreis (siehe Preistabelle) eingerechnet.</span>");
		document.write(dataa4);
	} else if (id=="1171533365552" || id=="1171532004388"|| id=="1162471700113"|| id=="1162467847086"|| id=="1162484213509" || id=="1162482094753") {
		document.write(dataa3);
		document.write("<span class='text-n-standard-error'>In der Woche vom 26.02. - 04.03.07 und 02.04. - 08.04.07 erhaltet ihr bei Buchung dieser Reise 8% Rabatt. Dieser Rabatt ist während der Aktion bereits in dem Grundpreis (siehe Preistabelle) eingerechnet.</span>");
		document.write(dataa4);
	} else if (id=="1164635264408"|| id=="1164633663561"|| id=="1162467116455"|| id=="1162466620686"|| id=="1162466070202"|| id=="1162465355445"|| id=="1162462749420"|| id=="1162393743461"|| id=="1162834733576"|| id=="1162830347146"|| id=="1162479667452"|| id=="1162479116443"|| id=="1162478391610" || id=="1162476999327") {
		document.write(dataa3);
		document.write("<span class='text-n-standard-error'>In der Woche vom 05.03. - 11.03.07 und 09.04. - 15.04.07 erhaltet ihr bei Buchung dieser Reise 8% Rabatt. Dieser Rabatt ist während der Aktion bereits in dem Grundpreis (siehe Preistabelle) eingerechnet.</span>");
		document.write(dataa4);
	} else if (id=="1163581347695"|| id=="1163579874330"|| id=="1163578596856"|| id=="1163518934912"|| id=="1164633084232" || id=="1164631402783") {
		document.write(dataa3);
		document.write("<span class='text-n-standard-error'>In der Woche vom 12.03. - 18.03.07 und 09.04. - 15.04.07 erhaltet ihr bei Buchung dieser Reise 8% Rabatt. Dieser Rabatt ist während der Aktion bereits in dem Grundpreis (siehe Preistabelle) eingerechnet.</span>");
		document.write(dataa4);
	} else if (id=="1164380369337"|| id=="1164378717122"|| id=="1163591773038"|| id=="1163589803363"|| id=="1164383198657"|| id=="1164382138979"|| id=="1164630251824"|| id=="1164629137006"|| id=="1163596328197"|| id=="1163593327626"|| id=="1163588266214"|| id=="1162569130433"|| id=="1162568521483"|| id=="1162567669688"|| id=="1162545644127" || id=="1162488016355") {
		document.write(dataa3);
		document.write("<span class='text-n-standard-error'>In der Woche vom 19.03. - 25.03.07 erhaltet ihr bei Buchung dieser Reise 8% Rabatt. Dieser Rabatt ist während der Aktion bereits in dem Grundpreis (siehe Preistabelle) eingerechnet.</span>");
		document.write(dataa4);
	}
}
