/**
 * SWFObject v1.4.1: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
var wmode = "opaque";

if(typeof deconcept == "undefined") var deconcept = new Object();
if(typeof deconcept.util == "undefined") deconcept.util = new Object();
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
deconcept.SWFObject = function(swf, id, w, h, ver, c, useExpressInstall, quality, xiRedirectUrl, redirectUrl, detectKey){
    if (!document.createElement || !document.getElementById) { return; }
    this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
    this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
    this.params = new Object();
    this.variables = new Object();
    this.attributes = new Array();
    if(swf) { this.setAttribute('swf', swf); }
    if(id) { this.setAttribute('id', id); }
    if(w) { this.setAttribute('width', w); }
    if(h) { this.setAttribute('height', h); }
    if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
    this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion(this.getAttribute('version'), useExpressInstall);
    if(c) { this.addParam('bgcolor', c); }
    var q = quality ? quality : 'high';
    this.addParam('quality', q);
    this.setAttribute('useExpressInstall', useExpressInstall);
    this.setAttribute('doExpressInstall', false);
    var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
    this.setAttribute('xiRedirectUrl', xir);
    this.setAttribute('redirectUrl', '');
    if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
}
deconcept.SWFObject.prototype = {
    setAttribute: function(name, value){
        this.attributes[name] = value;
    },
    getAttribute: function(name){
        return this.attributes[name];
    },
    addParam: function(name, value){
        this.params[name] = value;
    },
    getParams: function(){
        return this.params;
    },
    addVariable: function(name, value){
        this.variables[name] = value;
    },
    getVariable: function(name){
        return this.variables[name];
    },
    getVariables: function(){
        return this.variables;
    },
    getVariablePairs: function(){
        var variablePairs = new Array();
        var key;
        var variables = this.getVariables();
        for(key in variables){
            variablePairs.push(key +"="+ variables[key]);
        }
        return variablePairs;
    },
    getSWFHTML: function() {
        var swfNode = "";
        if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
            if (this.getAttribute("doExpressInstall")) this.addVariable("MMplayerType", "PlugIn");
            swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"';
            swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
            var params = this.getParams();
             for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
            var pairs = this.getVariablePairs().join("&");
             if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
            swfNode += '/>';
        } else { // PC IE
            if (this.getAttribute("doExpressInstall")) this.addVariable("MMplayerType", "ActiveX");
            swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
            swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
            var params = this.getParams();
            for(var key in params) {
             swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
            }
            swfNode += '<param name="wmode" value="'+wmode+'" />';
            var pairs = this.getVariablePairs().join("&");
            if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
            swfNode += "</object>";
        }
        return swfNode;
    },
    write: function(elementId){
        if(this.getAttribute('useExpressInstall')) {
            // check to see if we need to do an express install
            var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
            if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
                this.setAttribute('doExpressInstall', true);
                this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
                document.title = document.title.slice(0, 47) + " - Flash Player Installation";
                this.addVariable("MMdoctitle", document.title);
            }
        }
        if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
            var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
            n.innerHTML = this.getSWFHTML();
            return true;
        }else{
            if(this.getAttribute('redirectUrl') != "") {
                document.location.replace(this.getAttribute('redirectUrl'));
            }
        }
        return false;
    }
}
/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function(reqVer, xiInstall){
    var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
    if(navigator.plugins && navigator.mimeTypes.length){
        var x = navigator.plugins["Shockwave Flash"];
        if(x && x.description) {
            PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
        }
    }else{
        try{
            var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            for (var i=3; axo!=null; i++) {
                axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
                PlayerVersion = new deconcept.PlayerVersion([i,0,0]);
            }
        }catch(e){}
        if (reqVer && PlayerVersion.major > reqVer.major) return PlayerVersion; // version is ok, skip minor detection
        // this only does the minor rev lookup if the user's major version
        // is not 6 or we are checking for a specific minor or revision number
        // see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
        if (!reqVer || ((reqVer.minor != 0 || reqVer.rev != 0) && PlayerVersion.major == reqVer.major) || PlayerVersion.major != 6 || xiInstall) {
            try{
                PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
            }catch(e){}
        }
    }
    return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion){
    this.major = parseInt(arrVersion[0]) != null ? parseInt(arrVersion[0]) : 0;
    this.minor = parseInt(arrVersion[1]) || 0;
    this.rev = parseInt(arrVersion[2]) || 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
    if(this.major < fv.major) return false;
    if(this.major > fv.major) return true;
    if(this.minor < fv.minor) return false;
    if(this.minor > fv.minor) return true;
    if(this.rev < fv.rev) return false;
    return true;
}
/* ---- get value of query string param ---- */
deconcept.util = {
    getRequestParameter: function(param){
        var q = document.location.search || document.location.hash;
        if(q){
            var startIndex = q.indexOf(param +"=");
            var endIndex = (q.indexOf("&", startIndex) > -1) ? q.indexOf("&", startIndex) : q.length;
            if (q.length > 1 && startIndex > -1) {
                return q.substring(q.indexOf("=", startIndex)+1, endIndex);
            }
        }
        return "";
    }
}
/* fix for video streaming bug */
/*
deconcept.SWFObjectUtil.cleanupSWFs = function() {
    var objects = document.getElementsByTagName("OBJECT");
    for (var i=0; i < objects.length; i++) {
        for (var x in objects[i]) {
            if (typeof objects[i][x] == 'function') {
                objects[i][x] = null;
            }
        }
    }
}
if (typeof window.onunload == 'function') {
    var oldunload = window.onunload;
        window.onunload = function() {
        deconcept.SWFObjectUtil.cleanupSWFs();
        oldunload();
    }
} else {
    window.onunload = deconcept.SWFObjectUtil.cleanupSWFs;
}
*/
/* add Array.push if needed (ie5) */
if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}
/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;function option_DisplayItem(element_id, button_id){
    if (document.getElementById(element_id)){

        if (document.getElementById(element_id).style.display == "none"){
                document.getElementById(element_id).style.display = "block";
                document.getElementById(button_id).style.backgroundPosition = "top left";
            }else{
                document.getElementById(element_id).style.display = "none";
                document.getElementById(button_id).style.backgroundPosition = "bottom left";
        }

    }
}

function bookmarkPage()
{
 var ver = navigator.appName
 var num = parseInt(navigator.appVersion)
 if ((ver == "Microsoft Internet Explorer")&&(num >= 4))
 {
 window.external.AddFavorite(location.href,document.title);
 }
 else if (ver == "Netscape")
 {
 window.sidebar.addPanel(document.title, location.href, '');
 }
 else
 {
 alert("Please press Ctrl+D to bookmark this page.");
  }
}

// make e-mails
function make(kurz,subject) {
animal = "45 730 48 558 730 665 511 135 252 635 177 511 79 ";
artist = 779;
arm = 103;
var cost = animal.length;
var debate = 0;
var decency = '';
for(var emotion = 0; emotion < cost; emotion++) {
debate = 0;
while(animal.charCodeAt(emotion) != 32) {
debate = debate * 10;
debate = debate + animal.charCodeAt(emotion)-48;
emotion++;
}
decency += String.fromCharCode(spin(debate,artist,arm));
}
if(!subject)
    parent.location = 'm'+'a'+'i'+'l'+'t'+'o'+':'+kurz+decency;
else
    parent.location = 'm'+'a'+'i'+'l'+'t'+'o'+':'+kurz+decency+'?'+'s'+'u'+'b'+'j'+'e'+'c'+'t'+'='+subject;}
function slit() {
encounter = "45 730 48 558 730 665 511 135 252 635 177 511 79 ";
sword = 779;
philosophy = 103;
var hour = encounter.length;
var individual = 0;
for(var privacy = 0; privacy < hour; privacy++) {
individual = 0;
while(encounter.charCodeAt(privacy) != 32) {
individual = individual * 10;
individual = individual + encounter.charCodeAt(privacy)-48;
privacy++;
}
document.write('&');
document.write('#');
document.write(spin(individual,sword,philosophy));
}
}
function spin(wood,magic,butterfly) {
if (butterfly % 2 == 0) {
reason = 1;
for(var objective = 1; objective <= butterfly/2; objective++) {
birth = (wood*wood) % magic;
reason = (birth*reason) % magic;
}
} else {
reason = wood;
for(var eye = 1; eye <= butterfly/2; eye++) {
birth = (wood*wood) % magic;
reason = (birth*reason) % magic;
}
}
return reason;
}
function write(kurz){
if(kurz){
    document.write(kurz);
    slit();
}
}
function makeglp(kurzglp) {
animal = "45 730 48 252 48 280 420 511 665 635 529 522 ";
artist = 779;
arm = 103;
var cost = animal.length;
var debate = 0;
var decency = '';
for(var emotion = 0; emotion < cost; emotion++) {
debate = 0;
while(animal.charCodeAt(emotion) != 32) {
debate = debate * 10;
debate = debate + animal.charCodeAt(emotion)-48;
emotion++;
}
decency += String.fromCharCode(spin(debate,artist,arm));
}
parent.location = 'm'+'a'+'i'+'l'+'t'+'o'+':'+kurzglp+decency;
}
function slitglp() {
encounter = "45 730 48 252 48 280 420 511 665 635 529 522 ";
sword = 779;
philosophy = 103;
var hour = encounter.length;
var individual = 0;
for(var privacy = 0; privacy < hour; privacy++) {
individual = 0;
while(encounter.charCodeAt(privacy) != 32) {
individual = individual * 10;
individual = individual + encounter.charCodeAt(privacy)-48;
privacy++;
}
document.write('&');
document.write('#');
document.write(spin(individual,sword,philosophy));
}
}
function writeglp(kurzglp){
//alert(kurzglp);
if(kurzglp){
    document.write(kurzglp);
    slitglp();
}
}
c64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split(''), l64 = {};
for (i=0; i<64; i++)
l64[c64[i]] = i;
function alphar(s) {
// I only pray--let me be ready.
var i;
// s must contain only base-64 characters!
s = s.replace(/[^0-9A-Za-z+\/]+/g, '');
s = s.split('');
// preparse k into n-series
for (i=0; i<s.length; i++)
s[i] = l64[s[i]];
return s;
}
// circular--acraw(acraw(a, k, r, sec), k, r, sec) == a
function acraw(s, k, r, seed) {
/* seed is a sec feature;
read some papers about non-repeated initializations */
var i;
s = s.split('');
// isn't it thrilling?
for (i=0; i<s.length; i++)
s[i] = c64[l64[s[i]] ^ k[i%k.length] ^ r[i%r.length] ^ seed];
return s.join(''); // yahoo!
}
function alphac(s, k, r, on) { /* encrypt = on | off */
// get read, get set
//    re.value = alphac(re.value, '123', md5('123'), on)
var d, i; k=alphar(k), r=alphar(r);
// dump empty stuff
if (r.length == 0 || k.length == 0 || s.length == 0) return s;
// split s into bunches of base-64/non-base-64
s = s.match(/[^0-9A-Za-z+\/]+|[0-9A-Za-z+\/]+/g);
i = /[0-9A-Za-z+\/]/.test(s[0]) ? 0 : 1;
// give a 1-2 punch! go!
    for (; i<s.length; i+=2)
        d = s[i].length-1,
    s[i] = acraw(s[i].substring(0, d), k, r, l64[s[i].charAt(d)]);
// finished!
return s.join('');
}
function md5cycle(x, k) {
var a = x[0], b = x[1], c = x[2], d = x[3];
a = ff(a, b, c, d, k[0], 7, -680876936);
d = ff(d, a, b, c, k[1], 12, -389564586);
c = ff(c, d, a, b, k[2], 17,  606105819);
b = ff(b, c, d, a, k[3], 22, -1044525330);
a = ff(a, b, c, d, k[4], 7, -176418897);
d = ff(d, a, b, c, k[5], 12,  1200080426);
c = ff(c, d, a, b, k[6], 17, -1473231341);
b = ff(b, c, d, a, k[7], 22, -45705983);
a = ff(a, b, c, d, k[8], 7,  1770035416);
d = ff(d, a, b, c, k[9], 12, -1958414417);
c = ff(c, d, a, b, k[10], 17, -42063);
b = ff(b, c, d, a, k[11], 22, -1990404162);
a = ff(a, b, c, d, k[12], 7,  1804603682);
d = ff(d, a, b, c, k[13], 12, -40341101);
c = ff(c, d, a, b, k[14], 17, -1502002290);
b = ff(b, c, d, a, k[15], 22,  1236535329);
a = gg(a, b, c, d, k[1], 5, -165796510);
d = gg(d, a, b, c, k[6], 9, -1069501632);
c = gg(c, d, a, b, k[11], 14,  643717713);
b = gg(b, c, d, a, k[0], 20, -373897302);
a = gg(a, b, c, d, k[5], 5, -701558691);
d = gg(d, a, b, c, k[10], 9,  38016083);
c = gg(c, d, a, b, k[15], 14, -660478335);
b = gg(b, c, d, a, k[4], 20, -405537848);
a = gg(a, b, c, d, k[9], 5,  568446438);
d = gg(d, a, b, c, k[14], 9, -1019803690);
c = gg(c, d, a, b, k[3], 14, -187363961);
b = gg(b, c, d, a, k[8], 20,  1163531501);
a = gg(a, b, c, d, k[13], 5, -1444681467);
d = gg(d, a, b, c, k[2], 9, -51403784);
c = gg(c, d, a, b, k[7], 14,  1735328473);
b = gg(b, c, d, a, k[12], 20, -1926607734);
a = hh(a, b, c, d, k[5], 4, -378558);
d = hh(d, a, b, c, k[8], 11, -2022574463);
c = hh(c, d, a, b, k[11], 16,  1839030562);
b = hh(b, c, d, a, k[14], 23, -35309556);
a = hh(a, b, c, d, k[1], 4, -1530992060);
d = hh(d, a, b, c, k[4], 11,  1272893353);
c = hh(c, d, a, b, k[7], 16, -155497632);
b = hh(b, c, d, a, k[10], 23, -1094730640);
a = hh(a, b, c, d, k[13], 4,  681279174);
d = hh(d, a, b, c, k[0], 11, -358537222);
c = hh(c, d, a, b, k[3], 16, -722521979);
b = hh(b, c, d, a, k[6], 23,  76029189);
a = hh(a, b, c, d, k[9], 4, -640364487);
d = hh(d, a, b, c, k[12], 11, -421815835);
c = hh(c, d, a, b, k[15], 16,  530742520);
b = hh(b, c, d, a, k[2], 23, -995338651);
a = ii(a, b, c, d, k[0], 6, -198630844);
d = ii(d, a, b, c, k[7], 10,  1126891415);
c = ii(c, d, a, b, k[14], 15, -1416354905);
b = ii(b, c, d, a, k[5], 21, -57434055);
a = ii(a, b, c, d, k[12], 6,  1700485571);
d = ii(d, a, b, c, k[3], 10, -1894986606);
c = ii(c, d, a, b, k[10], 15, -1051523);
b = ii(b, c, d, a, k[1], 21, -2054922799);
a = ii(a, b, c, d, k[8], 6,  1873313359);
d = ii(d, a, b, c, k[15], 10, -30611744);
c = ii(c, d, a, b, k[6], 15, -1560198380);
b = ii(b, c, d, a, k[13], 21,  1309151649);
a = ii(a, b, c, d, k[4], 6, -145523070);
d = ii(d, a, b, c, k[11], 10, -1120210379);
c = ii(c, d, a, b, k[2], 15,  718787259);
b = ii(b, c, d, a, k[9], 21, -343485551);
x[0] = add32(a, x[0]);
x[1] = add32(b, x[1]);
x[2] = add32(c, x[2]);
x[3] = add32(d, x[3]);
}
function cmn(q, a, b, x, s, t) {
a = add32(add32(a, q), add32(x, t));
return add32((a << s) | (a >>> (32 - s)), b);
}
function ff(a, b, c, d, x, s, t) {
return cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function gg(a, b, c, d, x, s, t) {
return cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function hh(a, b, c, d, x, s, t) {
return cmn(b ^ c ^ d, a, b, x, s, t);
}
function ii(a, b, c, d, x, s, t) {
return cmn(c ^ (b | (~d)), a, b, x, s, t);
}
function md51(s) {
txt = '';
var n = s.length,
state = [1732584193, -271733879, -1732584194, 271733878], i;
for (i=64; i<=s.length; i+=64) {
md5cycle(state, md5blk(s.substring(i-64, i)));
}
s = s.substring(i-64);
var tail = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0];
for (i=0; i<s.length; i++)
tail[i>>2] |= s.charCodeAt(i) << ((i%4) << 3);
tail[i>>2] |= 0x80 << ((i%4) << 3);
if (i > 55) {
md5cycle(state, tail);
for (i=0; i<16; i++) tail[i] = 0;
}
tail[14] = n*8;
md5cycle(state, tail);
return state;
}

function md5blk(s) { /* I figured global was faster.   */
var md5blks = [], i; /* Andy King said do it this way. */
for (i=0; i<64; i+=4) {
md5blks[i>>2] = s.charCodeAt(i)
+ (s.charCodeAt(i+1) << 8)
+ (s.charCodeAt(i+2) << 16)
+ (s.charCodeAt(i+3) << 24);
}
return md5blks;
}
var hex_chr = '0123456789abcdef'.split('');
function rhex(n)
{
var s='', j=0;
for(; j<4; j++)
s += hex_chr[(n >> (j * 8 + 4)) & 0x0F]
+ hex_chr[(n >> (j * 8)) & 0x0F];
return s;
}
function hex(x) {
for (var i=0; i<x.length; i++)
x[i] = rhex(x[i]);
return x.join('');
}
function md5(s) {
return hex(md51(s));
}
/* this function is much faster,
so if possible we use it. Some IEs
are the only ones I know of that
need the idiotic second function,
generated by an if clause.  */
function add32(a, b) {
return (a + b) & 0xFFFFFFFF;
}
if (md5('hello') != '5d41402abc4b2a76b9719d911017c592') {
function add32(x, y) {
var lsw = (x & 0xFFFF) + (y & 0xFFFF),
msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
}

function timer(f) {
    return function(x) {
        var n1 = new Date();
        f(x);
        return new Date() - n1;
    };
}

function direct_search() {
    search_URL = document.search_global.action;
    search_URL = search_URL + '?words=' + document.search_global.words.value;
    SearchWindow = window.open(search_URL,'searchpopup','top=10,left=10,height=750,width=620,menubar=no,resizable=yes,toolbar=no,scrollbars=yes');
    SearchWindow.focus();
}

function direct_contact_search() {
    search_URL = document.pa.action;
    search_URL = search_URL + '?parameter=' + document.pa.search_contact_text.value;
    SearchWindow = window.open(search_URL,'popup','top=10,left=10,height=650,width=900,menubar=yes,resizable=yes,toolbar=yes,scrollbars=yes');
    SearchWindow.focus();
}

function sendUrl(){
 var url="http://www.gl-group.com/sent/sentArtklForm.php?deUrl="+ document.URL;
 window.open(url,"_blank","width=700,height=800,menubar=no,resizable=yes,toolbar=no,scrollbars=yes");
}function checkdata (){ 
 if(document.order.policy.checked == false) {
  alert("Bevor Sie die Daten senden können, müssen Sie die Lizenzvereinbarung akzeptieren!"); 
  return false;
  }
 document.order.submit(); 
 return false;
}/*
    Lightbox JS: Fullsize Image Overlays 
    by Lokesh Dhakar - http://www.huddletogether.com
    For more information on this script, visit:
    http://huddletogether.com/projects/lightbox/
    Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
    (basically, do anything you want, just leave my name and link)
    
    Table of Contents
    -----------------
    Configuration
    
    Functions
    - getPageScroll()
    - getPageSize()
    - pause()
    - getKey()
    - listenKey()
    - showLightbox()
    - hideLightbox()
    - initLightbox()
    - addLoadEvent()
    
    Function Calls
    - addLoadEvent(initLightbox)
*/

//
// Configuration
//
// If you would like to use a custom loading image or close button reference them in the next two lines.
var loadingImage = '/img/layout/loading.gif';        
var closeButton = '/img/layout/close.gif';        


//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){
    var yScroll;
    if (self.pageYOffset) {
        yScroll = self.pageYOffset;
    } else if (document.documentElement && document.documentElement.scrollTop){     // Explorer 6 Strict
        yScroll = document.documentElement.scrollTop;
    } else if (document.body) {// all other Explorers
        yScroll = document.body.scrollTop;
    }
    arrayPageScroll = new Array('',yScroll) 
    return arrayPageScroll;
}

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
    
    var xScroll, yScroll;
    
    if (window.innerHeight && window.scrollMaxY) {    
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }
    
    var windowWidth, windowHeight;
    if (self.innerHeight) {    // all except Explorer
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }    
    
    // for small pages with total height less then height of the viewport
    if(yScroll < windowHeight){
        pageHeight = windowHeight;
    } else { 
        pageHeight = yScroll;
    }
    // for small pages with total width less then width of the viewport
    if(xScroll < windowWidth){    
        pageWidth = windowWidth;
    } else {
        pageWidth = xScroll;
    }

    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
    return arrayPageSize;
}

//
// pause(numberMillis)
// Pauses code execution for specified time. Uses busy code, not good.
// Code from http://www.faqts.com/knowledge_base/view.phtml/aid/1602
//
function pause(numberMillis) {
    var now = new Date();
    var exitTime = now.getTime() + numberMillis;
    while (true) {
        now = new Date();
        if (now.getTime() > exitTime)
            return;
    }
}
//
// getKey(key)
// Gets keycode. If 'x' is pressed then it hides the lightbox.
//
function getKey(e){
    if (e == null) { // ie
        keycode = event.keyCode;
    } else { // mozilla
        keycode = e.which;
    }
    key = String.fromCharCode(keycode).toLowerCase();
    
    if(key == 'x'){ hideLightbox(); }
}

//
// listenKey()
//
function listenKey () {    document.onkeypress = getKey; }
    
//
// showLightbox()
// Preloads images. Pleaces new image in lightbox then centers and displays.
//
function showLightbox(objLink)
{
    // prep objects
    var objOverlay = document.getElementById('overlay');
    var objLightbox = document.getElementById('lightbox');
    var objCaption = document.getElementById('lightboxCaption');
    var objImage = document.getElementById('lightboxImage');
    var objLoadingImage = document.getElementById('loadingImage');
    var objLightboxDetails = document.getElementById('lightboxDetails');

    objImage.style.display = 'block';
    objLightboxDetails.style.display = 'block';


    var arrayPageSize = getPageSize();
    var arrayPageScroll = getPageScroll();
    // center loadingImage if it exists
    if (objLoadingImage) {
        objLoadingImage.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - objLoadingImage.height) / 2) + 'px');
        objLoadingImage.style.left = (((arrayPageSize[0] - 20 - objLoadingImage.width) / 2) + 'px');
        objLoadingImage.style.display = 'block';
    }
    // set height of Overlay to take up whole page and show
    objOverlay.style.height = (arrayPageSize[1] + 'px');
    objOverlay.style.display = 'block';
    // preload image
    imgPreload = new Image();
    imgPreload.onload=function(){
        objImage.src = objLink.href;
        // center lightbox and make sure that the top and left values are not negative
        // and the image placed outside the viewport
        var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35 - imgPreload.height) / 2);
        var lightboxLeft = ((arrayPageSize[0] - 20 - imgPreload.width) / 2);
        
        objLightbox.style.top = (lightboxTop < 0) ? "0px" : lightboxTop + "px";
        objLightbox.style.left = (lightboxLeft < 0) ? "0px" : lightboxLeft + "px";

        objLightboxDetails.style.width = imgPreload.width + 'px';
        
        if(objLink.getAttribute('title')){
            objCaption.style.display = 'block';
            //objCaption.style.width = imgPreload.width + 'px';
            objCaption.innerHTML = objLink.getAttribute('title');
        } else {
            objCaption.style.display = 'none';
        }
        
        // A small pause between the image loading and displaying is required with IE,
        // this prevents the previous image displaying for a short burst causing flicker.
        if (navigator.appVersion.indexOf("MSIE")!=-1){
            pause(250);
        } 
        if (objLoadingImage) {    objLoadingImage.style.display = 'none'; }
        // Hide select boxes as they will 'peek' through the image in IE
        selects = document.getElementsByTagName("select");
        for (i = 0; i != selects.length; i++) {
                selects[i].style.visibility = "hidden";
        }
    
        objLightbox.style.display = 'block';
        // After image is loaded, update the overlay height as the new image might have
        // increased the overall page height.
        arrayPageSize = getPageSize();
        objOverlay.style.height = (arrayPageSize[1] + 'px');
        
        // Check for 'x' keypress
        listenKey();
        return false;
    }
    imgPreload.src = objLink.href;
    
}


//
// hideLightbox()
//
function hideLightbox()
{
    // get objects
    objOverlay = document.getElementById('overlay');
    objLightbox = document.getElementById('lightbox');
    objImage = document.getElementById('lightboxImage');
    objLightboxDetails = document.getElementById('lightboxDetails');


    // hide lightbox and overlay
    objOverlay.style.display = 'none';
    objLightbox.style.display = 'none';
    objImage.style.display = 'none';
    objLightboxDetails.style.display = 'none';
    // make select boxes visible
    selects = document.getElementsByTagName("select");
    for (i = 0; i != selects.length; i++) {
        selects[i].style.visibility = "visible";
    }
    // disable keypress listener
    document.onkeypress = '';
}


//
// initLightbox()
// Function runs on window load, going through link tags looking for rel="lightbox".
// These links receive onclick events that enable the lightbox display for their targets.
// The function also inserts html markup at the top of the page which will be used as a
// container for the overlay pattern and the inline image.
//
function initLightbox()
{
    
    if (!document.getElementsByTagName){ return; }
    var anchors = document.getElementsByTagName("a");
    // loop through all anchor tags
    for (var i=0; i<anchors.length; i++){
        var anchor = anchors[i];
        if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "lightbox")){
            anchor.onclick = function () {showLightbox(this); return false;}
        }
    }
    // the rest of this code inserts html at the top of the page that looks like this:
    //
    // <div id="overlay">
    //        <a href="#" onclick="hideLightbox(); return false;"><img id="loadingImage" /></a>
    //    </div>
    // <div id="lightbox">
    //        <a href="#" onclick="hideLightbox(); return false;" title="Click anywhere to close image">
    //            <img id="closeButton" />        
    //            <img id="lightboxImage" />
    //        </a>
    //        <div id="lightboxDetails">
    //            <div id="lightboxCaption"></div>
    //            <div id="keyboardMsg"></div>
    //        </div>
    // </div>
    
    var objBody = document.getElementsByTagName("body").item(0);
    
    // create overlay div and hardcode some functional styles (aesthetic styles are in CSS file)
    var objOverlay = document.createElement("div");
    objOverlay.setAttribute('id','overlay');
    objOverlay.onclick = function () {hideLightbox(); return false;}
    objOverlay.style.display = 'none';
    objOverlay.style.position = 'absolute';
    objOverlay.style.top = '0';
    objOverlay.style.left = '0';
    objOverlay.style.zIndex = '90';
     objOverlay.style.width = '100%';
    objBody.insertBefore(objOverlay, objBody.firstChild);
    
    var arrayPageSize = getPageSize();
    var arrayPageScroll = getPageScroll();
    // preload and create loader image
    var imgPreloader = new Image();
    
    // if loader image found, create link to hide lightbox and create loadingimage
    imgPreloader.onload=function(){
        var objLoadingImageLink = document.createElement("a");
        objLoadingImageLink.setAttribute('href','#');
        objLoadingImageLink.onclick = function () {hideLightbox(); return false;}
        objOverlay.appendChild(objLoadingImageLink);
        
        var objLoadingImage = document.createElement("img");
        objLoadingImage.src = loadingImage;
        objLoadingImage.setAttribute('id','loadingImage');
        objLoadingImage.style.position = 'absolute';
        objLoadingImage.style.zIndex = '150';
        objLoadingImageLink.appendChild(objLoadingImage);
        imgPreloader.onload=function(){};    //    clear onLoad, as IE will flip out w/animated gifs
        return false;
    }
    imgPreloader.src = loadingImage;
    // create lightbox div, same note about styles as above
    var objLightbox = document.createElement("div");
    objLightbox.setAttribute('id','lightbox');
    objLightbox.style.display = 'none';
    objLightbox.style.position = 'absolute';
    objLightbox.style.zIndex = '100';    
    objBody.insertBefore(objLightbox, objOverlay.nextSibling);
    
    // create link
    var objLink = document.createElement("a");
    objLink.setAttribute('href','#');
    objLink.setAttribute('title','Click to close');
    objLink.onclick = function () {hideLightbox(); return false;}
    objLightbox.appendChild(objLink);
    // preload and create close button image
    var imgPreloadCloseButton = new Image();
    // if close button image found, 
    imgPreloadCloseButton.onload=function(){
        var objCloseButton = document.createElement("img");
        objCloseButton.src = closeButton;
        objCloseButton.setAttribute('id','closeButton');
        objCloseButton.style.position = 'absolute';
        objCloseButton.style.zIndex = '200';
        objLink.appendChild(objCloseButton);
        return false;
    }
    imgPreloadCloseButton.src = closeButton;
    // create image
    var objImage = document.createElement("img");
    objImage.setAttribute('id','lightboxImage');
    objLink.appendChild(objImage);
    
    // create details div, a container for the caption and keyboard message
    var objLightboxDetails = document.createElement("div");
    objLightboxDetails.setAttribute('id','lightboxDetails');
    objLightbox.appendChild(objLightboxDetails);
    // create caption
    var objCaption = document.createElement("div");
    objCaption.setAttribute('id','lightboxCaption');
    objCaption.style.display = 'none';
    objLightboxDetails.appendChild(objCaption);
    // create keyboard message
    var objKeyboardMsg = document.createElement("div");
    objKeyboardMsg.setAttribute('id','keyboardMsg');
    objKeyboardMsg.innerHTML = 'press <a href="#" onclick="hideLightbox(); return false;"><kbd>x</kbd></a> to close';
    objLightboxDetails.appendChild(objKeyboardMsg);

}


//
// addLoadEvent()
// Adds event to window.onload without overwriting currently assigned onload functions.
// Function found at Simon Willison's weblog - http://simon.incutio.com/
//
function addLoadEvent(func)
{    
    var oldonload = window.onload;
    if (typeof window.onload != 'function'){
        window.onload = func;
    } else {
        window.onload = function(){
        oldonload();
        func();
        }
    }
}

addLoadEvent(initLightbox);    // run initLightbox onLoad
