<!--
/* Copyright by Amico Alpha e.K., www.amico-alpha.de
 **************************************************
 * Kunde: FC Offers e.V., Velbert (11016)
 * Projekt: 0004
 * Domain: fcoffers.de
 * Art: Website
 * Abschnitt: 06 Umsetzung
 * Arbeitsschritt: Anwender- und Serverscripte, Datenbank programmieren
 *********************************
 Zweck: Frontend (Ausgabe)
 Art: Funktionen
 Funktion: Diverse Javascripte zur Einbindung
 Platzierung: main
 parent:
 *********************************
 * Projekt: 00004
 // AA-10.04.07, 15:14h: Neuformatierung. Aufräumen. Übernahme einiger Funktionen aus anderen Projekten.
 *********************************
 Ablage:
 *********************************************** */

/**
 *
 *  Geolocation von Besucher
 *  http://www.
 *
 **/
var count = 0;
var log = "";

// http://maps.google.com/maps?f=q&hl=en&geocode=&q=37.4179948,+-122.0882558&sll=37.417995,-122.088256&sspn=0.01106,0.031393&g=37.4179948,+-122.0882558

function aaa(a){
    // AA-15.08.09, 19:27h: wird zur Zeit nicht benötigt, da keine dauerhafte Überwachung
    //count++;
    var d = document.getElementById("localizator");

    // AA-15.08.09, 19:27h: wird zur Zeit nicht benötigt, da keine dauerhafte Überwachung
    /* if (a.address) 
        d.innerHTML = log = log + "<p> " + count + " lat = " + a.coords.latitude + " long = " + a.coords.longitude + " Genauigkeit = " + a.coords.accuracy +
        "<p>" +
        a.address.streetNumber +
        " " +
        "<p>" +
        a.address.street +
        " " +
        "<p>" +
        a.address.premises +
        " " +
        "<p>" +
        a.address.city +
        " " +
        "<p>" +
        a.address.county +
        " " +
        "<p>" +
        a.address.region +
        " " +
        "<p>" +
        a.address.country +
        " " +
        "<p>" +
        a.address.countryCode +
        " " +
        "<p>" +
        a.address.postalCode +
        " " +
        "<a href=http://maps.google.com/maps?geocode=&q=" +
        a.coords.latitude +
        "+" +
        a.coords.longitude +
        "> Meinen Standort anzeigen </a></p>";
    else
*/
        d.innerHTML = log = log + "<p><a href=\"http://maps.google.de/maps?geocode=&q=" + a.coords.latitude + "+" + a.coords.longitude + "\" title=\"Hier ist ungef&auml;hr Ihr Standort im Augenblick!\" hreflang=\"de\">Und wo sind Sie? Wir wissen es!</a><br /><span style=\"font-size:72%;\";>(" + count + ". Breitengrad: " + a.coords.latitude + " L&auml;ngengrad = " + a.coords.longitude + " Genauigkeit: +-" + a.coords.accuracy + "m)</span></p>";
}

function handleError(a){
    var d = document.getElementById("d");
    d.innerHTML = log = log + "<p>Fehler: " + a.code + "</p>";
}

if (navigator.geolocation) {
    /* geolocation is available */
    // To obtain the user's current location, you can call the getCurrentPosition() method.
    // This initiates an asynchronous request to detect the user's position, and queries the
    // positioning hardware to get up-to-date information.  When the position is determined,
    // a specified callback routine is executed.  You can optionally provide a second callback
    // to be executed if an error occurs.  A third optional parameter is an options interface
    // where you can set the maximum age of the request in milliseconds), and the time to wait for arequest.
    // We here only accept cached positions whose age is not greater than 10 minutes.
    navigator.geolocation.getCurrentPosition(aaa, handleError, {maximumAge: 600000});

    // Alternativen:

    // If you want to be kept abreast of changes in the user's location, you can set up a
    // callback that is called periodically with updated position information.
    // This is done using the watchPosition() function, which has the same input parameters
    // as getCurrentPosition(). Its callback is called repeatedly instead of just once.
    // The error callback, which is optional just as it is for getCurrentPosition(),
    // is called only once, if there will never be valid results returned.set up a callback
    // that is called periodically with updated position information
    // Request repeated updates.
    //var watchId = navigator.geolocation.watchPosition(aaa, handleError);

    // Cancel the updates when the user clicks a button.
    // Using in tandem with watchPosition to clear the uniqueID
    function buttonClickHandler() {
        navigator.geolocation.clearWatch(watchId);
    }
}

/**
 *
 *  Scrollable HTML table
 *  http://www.webtoolkit.info/
 *
 **/
function ScrollableTable(tableEl, tableHeight, tableWidth){

    this.initIEengine = function(){
    
        this.containerEl.style.overflowY = 'auto';
        if (this.tableEl.parentElement.clientHeight - this.tableEl.offsetHeight < 0) {
            this.tableEl.style.width = this.newWidth - this.scrollWidth + 'px';
        }
        else {
            //this.containerEl.style.overflowY = 'hidden';
            this.containerEl.style.overflowY = 'scroll';
            this.tableEl.style.width = this.newWidth + 'px';
        }
        
        if (this.thead) {
            var trs = this.thead.getElementsByTagName('tr');
            for (x = 0; x < trs.length; x++) {
                trs[x].style.position = 'relative';
                trs[x].style.setExpression("top", "this.parentElement.parentElement.parentElement.scrollTop + 'px'");
            }
        }
        
        if (this.tfoot) {
            var trs = this.tfoot.getElementsByTagName('tr');
            for (x = 0; x < trs.length; x++) {
                trs[x].style.position = 'relative';
                trs[x].style.setExpression("bottom", "(this.parentElement.parentElement.offsetHeight - this.parentElement.parentElement.parentElement.clientHeight - this.parentElement.parentElement.parentElement.scrollTop) + 'px'");
            }
        }
        
        eval("window.attachEvent('onresize', function () { document.getElementById('" + this.tableEl.id + "').style.visibility = 'hidden'; document.getElementById('" + this.tableEl.id + "').style.visibility = 'visible'; } )");
    };
    
    
    this.initFFengine = function(){
        this.containerEl.style.overflow = 'hidden';
        this.tableEl.style.width = this.newWidth + 'px';
        
        var headHeight = (this.thead) ? this.thead.clientHeight : 0;
        var footHeight = (this.tfoot) ? this.tfoot.clientHeight : 0;
        var bodyHeight = this.tbody.clientHeight;
        var trs = this.tbody.getElementsByTagName('tr');
        if (bodyHeight >= (this.newHeight - (headHeight + footHeight))) {
            this.tbody.style.overflow = '-moz-scrollbars-vertical';
            for (x = 0; x < trs.length; x++) {
                var tds = trs[x].getElementsByTagName('td');
                tds[tds.length - 1].style.paddingRight += this.scrollWidth + 'px';
            }
        }
        else {
            this.tbody.style.overflow = '-moz-scrollbars-none';
        }
        
        var cellSpacing = (this.tableEl.offsetHeight - (this.tbody.clientHeight + headHeight + footHeight)) / 4;
        this.tbody.style.height = (this.newHeight - (headHeight + cellSpacing * 2) - (footHeight + cellSpacing * 2)) + 'px';
        
    };
    
    this.tableEl = tableEl;
    this.scrollWidth = 16;
    
    this.originalHeight = this.tableEl.clientHeight;
    this.originalWidth = this.tableEl.clientWidth;
    
    this.newHeight = parseInt(tableHeight);
    this.newWidth = tableWidth ? parseInt(tableWidth) : this.originalWidth;
    
    this.tableEl.style.height = 'auto';
    this.tableEl.removeAttribute('height');
    
    this.containerEl = this.tableEl.parentNode.insertBefore(document.createElement('div'), this.tableEl);
    this.containerEl.appendChild(this.tableEl);
    this.containerEl.style.height = this.newHeight + 'px';
    this.containerEl.style.width = this.newWidth + 'px';
    
    var thead = this.tableEl.getElementsByTagName('thead');
    this.thead = (thead[0]) ? thead[0] : null;
    
    var tfoot = this.tableEl.getElementsByTagName('tfoot');
    this.tfoot = (tfoot[0]) ? tfoot[0] : null;
    
    var tbody = this.tableEl.getElementsByTagName('tbody');
    this.tbody = (tbody[0]) ? tbody[0] : null;
    
    if (!this.tbody) 
        return;
    
    if (document.all && document.getElementById && !window.opera) 
        this.initIEengine();
    if (!document.all && document.getElementById && !window.opera) 
        this.initFFengine();
    
    
}

/*
 Parameter für diese Skript-Sammlung
 ************************************* */
// für eine der folgenden Cookie-Funktionen
var HOST = 'www.fcoffers.de';

/*
 function change_display_status
 Zweck:      Setzt Pluszeichen (für Anzeige des Inhalts)
 oder Minuszeichen sowie Cookie mit Zustand
 Ausgabe:    Display-Status, Inner-HTML-Wechsel, Cookie-Inhalt
 Parameter:  d_text    string   ID des Anzeigers, hier Pluszeichen
 d         string   ID des Elements zum Anzeigen / Verbergen
 Aufruf in HTML:
 <a href="javascript:" onclick="change_display_status('beispiel');return false;">
 <div id="beispiel_text"> How do I use this tool? [+]</div>
 </a>
 <div id="beispiel" style="display:none;">
 Zu verbergender Inhalt
 </div>
 ************************************* */
function change_display_status(res){

    if (document.getElementById) {
        obj = document.getElementById(res);
        bar = document.getElementById(res + '_bar');
        
        if (obj.style.display == "none") {
            obj.style.display = "";
            // AA-02.07.06, 22:24h: jetzt mit Wechsel der CSS-Klasse (HG-Bild)
            // bar.innerHTML = bar.innerHTML.replace("+","-");
            bar.className = 'minus';
            setCookie('cat_' + res, "", 365);
        }
        else {
            obj.style.display = "none";
            // bar.innerHTML = bar.innerHTML.replace("-","+");
            // bar.innerHTML = bar.innerHTML.replace("-","+");
            bar.className = 'plus';
            setCookie('cat_' + res, "1", 365);
        }
    }
    
} // END function change_display_status
/* Copyright (c) 1996-1997 Athenia Associates.
 http://www.webreference.com/js/
 License is granted if and only if this entire
 copyright notice is included. By Tomer Shiran.
 // AA-02.07.06, 21:25h: tw. umgeschrieben, da veraltete Bestandteile
 ************************************* */
function setCookie(name, value, nDays, path, domain, secure){

    var today = new Date();
    var expire = new Date();
    
    expire.setTime(today.getTime() + 3600000 * 24 * nDays);
    
    if (nDays == null || nDays == 0) {
        nDays = 1;
    }
    
    var curCookie = name + "=" + escape(value) + "; expires=" + expire.toGMTString() + ((path) ? "; path=" + path : "/") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
    document.cookie = curCookie;
}

function getCookie(name){

    var prefix = name + '=';
    var c = document.cookie;
    var nullstring = '';
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1) 
        return nullstring;
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1) 
        cookieEndIndex = c.length;
    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function deleteCookie(name, path, domain){
    if (getCookie(name)) 
        document.cookie = name + "=" + ((path) ? "; path=" + path : "/") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function fixDate(date){
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0) 
        date.setTime(date.getTime() - skew);
}

function rememberMe(f){
    var now = new Date();
    fixDate(now);
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    setCookie('mtcmtauth', f.author.value, now, '', HOST, '');
    setCookie('mtcmtmail', f.email.value, now, '', HOST, '');
    setCookie('mtcmthome', f.url.value, now, '', HOST, '');
}

function forgetMe(f){
    deleteCookie('mtcmtmail', '', HOST);
    deleteCookie('mtcmthome', '', HOST);
    deleteCookie('mtcmtauth', '', HOST);
    f.email.value = '';
    f.author.value = '';
    f.url.value = '';
}

/*
 function set_jump_select
 Zweck:      Jumpmenï¿½
 Ausgabe:    DESC
 Parameter:  $    string,bool,int,float   DESC
 $    string,bool,int,float   DESC
 ************************************* */
function set_jump_select(Auswahl, restore){

    var derURL, dasFenster;
    var dasZiel = Auswahl.options[Auswahl.selectedIndex].value.split("|");
    
    if (restore) {
        Auswahl.selectedIndex = 0;
    }
    
    Auswahl.options[0].blur();
    
    if (dasZiel.length == 1) {
        derURL = dasZiel;
        if (dasZiel == "nix") {
            Auswahl.selectedIndex = 0;
        }
        else {
            eval('self.location.href = "' + derURL + '"');
        }
    }
    else 
        if (dasZiel.length == 2) {
            derURL = dasZiel[1], dasFenster = dasZiel[0];
            if (dasFenster == "popup") {
                AA_popup(derURL);
            }
            else 
                if (dasFenster == "haupt") {
                    eval("parent.location.href='" + derURL + "'");
                }
                else {
                    eval("parent.frames[\'" + dasFenster + "\'].location.href = '" + derURL + "'");
                }
        }
    
} // END function set_jump_select
// ***** POPUP-Fenster *****
// popName kann auch _blank, _self sein

function popmit(ZielUri, popName, breite, hoehe, oben, links){
    var popeins = 0;
    popeins = window.open(ZielUri, popName, 'dependent=yes,hotkeys=no,locationbar=no,menubar=no,scrollbars=yes,status=no,toolbar=no,width=' + breite + ',height=' + hoehe + ',top=' + oben + ',left=' + links);
    popeins.focus();
}

function popohne(ZielUri, popName){
    var popzwei = 0;
    popzwei = window.open(ZielUri, popName, 'scrollbars=no');
    popzwei.focus();
}

// ***** Zufallsbild *****

function randomImg(){
    var dieBilder = new Array()
    
    dieBilder[1] = "nantucket.jpg"
    dieBilder[2] = "robot.jpg"
    dieBilder[3] = "fl_beach.jpg"
    dieBilder[4] = "az_road.jpg"
    dieBilder[5] = "train_ride.jpg"
    dieBilder[6] = "wheat_field.jpg"
    dieBilder[7] = "birch.jpg"
    dieBilder[8] = "cactus.jpg"
    dieBilder[9] = "finish_line.jpg"
    dieBilder[10] = "fender.jpg"
    
    var rn = Math.floor(Math.random() * dieBilder.length)
    if (rn == 0) {
        rn = 1
    }
    document.write("<img src=\"/img/" + dieBilder[rn] + "\" border=\"0\" width=\"194\" height=\"146\" alt=\" \" />")
}

/* START Z.ZT. NICHT GEBRAUCHT
 // ----------------------------------------------
 // StyleSwitcher functions written by Paul Sowden
 // http://www.idontsmoke.co.uk/ss/
 // - - - - - - - - - - - - - - - - - - - - - - -
 // For the details, visit ALA:
 // http://www.alistapart.com/stories/alternate/
 function setActiveStyleSheet(title) {
 var i, a, main;
 for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
 if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
 a.disabled = true;
 if(a.getAttribute("title") == title) a.disabled = false;
 }
 }
 }
 function getActiveStyleSheet() {
 var i, a;
 for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
 if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
 }
 return null;
 }
 function getPreferredStyleSheet() {
 var i, a;
 for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
 if(a.getAttribute("rel").indexOf("style") != -1
 && a.getAttribute("rel").indexOf("alt") == -1
 && a.getAttribute("title")
 ) return a.getAttribute("title");
 }
 return null;
 }
 function createCookie(name,value,days) {
 if (days) {
 var date = new Date();
 date.setTime(date.getTime()+(days*24*60*60*1000));
 var expires = "; expires="+date.toGMTString();
 }
 else expires = "";
 document.cookie = name+"="+value+expires+"; path=/";
 }
 function readCookie(name) {
 var nameEQ = name + "=";
 var ca = document.cookie.split(';');
 for(var i=0;i < ca.length;i++) {
 var c = ca[i];
 while (c.charAt(0)==' ') c = c.substring(1,c.length);
 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
 }
 return null;
 }
 window.onload = function(e) {
 var cookie = readCookie("style");
 var title = cookie ? cookie : getPreferredStyleSheet();
 setActiveStyleSheet(title);
 }
 window.onunload = function(e) {
 var title = getActiveStyleSheet();
 createCookie("style", title, 365);
 }
 var cookie = readCookie("style");
 var title = cookie ? cookie : getPreferredStyleSheet();
 setActiveStyleSheet(title);
 END Z.ZT. NICHT GEBRAUCHT */
//-->

// Script aus Alt-Version Website
// *****  Zeit global *****
var Wochentagname = new Array("Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag");
var Jetzt = new Date();
var Zeit = Jetzt.getTime(); // ms seit 1970
var JahrLang = Jetzt.getFullYear();
var Monat = Jetzt.getMonth() + 1;
var Tag = Jetzt.getDate();
var WoTag = Jetzt.getDay();
var Stunde = Jetzt.getHours();
var Minute = Jetzt.getMinutes();
var Sekunde = Jetzt.getSeconds();
var MonatL = ((Monat < 10) ? "0" : "") + Monat;
var TagL = ((Tag < 10) ? "0" : "") + Tag;
var StundeL = ((Stunde < 10) ? "0" : "") + Stunde;
var MinuteL = ((Minute < 10) ? "0" : "") + Minute;
var SekundeL = ((Sekunde < 10) ? "0" : "") + Sekunde;
var Wochentag = Wochentagname[WoTag];
var DatumLang = TagL + '.' + MonatL + '.' + JahrLang;
