﻿/* Scrollposition */
function getScroll() {
    var scrOfY = 0;

    if (typeof (window.pageYOffset) == 'number') {
        //Netscape compliant   
        scrOfY = window.pageYOffset;
    } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
        //DOM compliant   
        scrOfY = document.body.scrollTop;
    } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
        //IE6 standards compliant mode   
        scrOfY = document.documentElement.scrollTop;
    }
    return scrOfY;
}

function fixPosition() {
    $("#north").css("top", getScroll());
}


/* Scrollposition speichern */
$(window).scroll(function() {
    //fixPosition();
});


function routenplanerInit() {
    var defValue = ""
    $(".txtRoutenplaner").attr("value", defValue);
    // Click
    $(".txtRoutenplaner").click(function() {
        cValue = $(this).attr("value");
        if (cValue == defValue) { $(this).attr("value", ""); }
    });
    // Blur
    $(".txtRoutenplaner").blur(function() {
        cValue = $(this).attr("value");
        if (cValue == null) { $(this).attr("value", defValue); }
    });

    $(".lnkRoutenplaner").click(function() {
        var txtRoutenplaner = $("#" + $(this).attr("id").replace("lnk", "txt"));
        // Start
        cValue = txtRoutenplaner.attr("value");
        // Ziel
        cAdresse = txtRoutenplaner.attr("adresse");
        // Eingabe korrekt?
        if (cValue == null || cValue == defValue)
        { txtRoutenplaner.addClass(" inpError") }
        else {
            window.open('http://maps.google.de/maps?f=d&hl=de&saddr=' + escape(cValue) + '&daddr=' + escape(cAdresse));
        }
    });
}

function anfrageInit() {
    // Click
    $(".txtAnfrage").click(function() {
        var defValue = $(this).attr("Label");
        cValue = $(this).attr("value");
        if (cValue == defValue) { $(this).attr("value", ""); }
    });
    // Blur
    $(".txtAnfrage").blur(function() {
        var defValue = $(this).attr("Label");
        cValue = $(this).attr("value");
        if (cValue == null) { $(this).attr("value", defValue); }
    });
}

$(document).ready(function() {
    routenplanerInit();
    // anfrageInit();    
});
