// --------------------
// Funktion zur Erkennung des Browsers
// die informationen sind im objekt cD verfuegbar
//
// function clientDetection
//

function clientDetection(){
var agt = navigator.userAgent.toLowerCase();

this.platform = navigator.platform.toLowerCase();
this.name = agt;

this.major = parseInt(navigator.appVersion);
this.minor = parseFloat(navigator.appVersion);

this.nav  = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1)));
this.nav2 = (this.nav && (this.major == 2));
this.nav3 = (this.nav && (this.major == 3));
this.nav4 = (this.nav && (this.major == 4));
this.nav6 = (this.nav && (this.major == 5));

this.ie   = (agt.indexOf("msie") != -1);
this.ie3  = (this.ie && (this.major == 2));
this.ie4  = (this.ie && (this.major == 4));

this.opera = (agt.indexOf("opera") != -1);

this.nav6up = this.nav && (this.major >= 5);
this.ie4up  = this.ie  && (this.major >= 4);
}

var cD = new clientDetection();


function changeNavIcon(img, mode)
{
    var curImage = eval('document.' + img);
    var curkey = navImagesB[curImage.name + "_" + mode];
    if (navImagesA[curkey])
    {
        curImage.src=navImagesA[curkey].src;
    }
}  

function emptyInput(formname, name, event)
{
    var defaultvals = new Array();
    defaultvals["vorname"] = "Vorname *";
    defaultvals["nachname"] = "Nachname *";
    defaultvals["strasse"] = "Strasse *";
    defaultvals["plz"] = "PLZ *";
    defaultvals["hausnr"] = "Haus-Nr. *";
    defaultvals["wohnort"] = "Wohnort *";
    defaultvals["telefon"] = "Telefon";
    defaultvals["email"] = "E-Mail *";
    defaultvals["kunden_id"] = "Kunden-Nr. (falls vorhanden)";
    defaultvals["nachricht"] = "Ihre Nachricht";
    
    for (var field in defaultvals)
    {
        if (field != name)
        {
            var aktInput = eval("document." + formname + "." + field);
            if (aktInput)
            {
                if (aktInput.value == "")
                {
                    aktInput.value = defaultvals[field];
                }
            }
        }
    }
    
    var aktInput = eval("document." + formname + "." + name); 
    if(aktInput)
    {
        if(event == "blur")
        {
            if (aktInput.value == "")
            {
                aktInput.value = defaultvals[name];
            }
        }
        else
        {
            if (aktInput.value == defaultvals[name])
            {
                aktInput.value = "";
            }
        }
    }
}

function openpopup(path,popName,width,height,left,top,scrolling,resize)
{
    if (scrolling == "")
    {
        scrolling = "no";
    }
    if (top == "")
    {
        top = 10;
    }
    if (left == "")
    {
        left = 10;
    }
    if (resize == "")
    {
        resize = "yes";
    }
    resizable = ",resizeable=" + resize + "";
    settings = 'height=' + height + ', width=' + width + ', top=' + top + ',left=' + left + ',scrollbars=' + scrolling + ',resizable=' + resize;
    var newWin = window.open(path, popName, settings); 
    newWin.focus();
    return false;
}

function ebob_openinpopup(path,popName,width,height,left,top,scrolling,resize)
{
    openpopup(path,popName,width,height,left,top,scrolling,resize);
    return false;
}

var currentGroupImages = new Array();

function changeImagegroup(flexmodulid, action, total)
{
    if (!currentGroupImages[flexmodulid]) currentGroupImages[flexmodulid] = 1;
    if (parseInt(action))
    {
        currentGroupImages[flexmodulid] = parseInt(action);
        var MyImage = eval('document.images.imggroup_' + flexmodulid);
        Imagearray = eval("ebobImageGroup_" + flexmodulid);
        MyImage.src = Imagearray[action].src; 
    }
    else
    {
        if (action == "next")
        {
//            alert("c" + currentGroupImages[flexmodulid] + " - " + total);
            if (currentGroupImages[flexmodulid] >= total)
            {
                changeImagegroup(flexmodulid, '1', total);
            }
            else
            {
                changeImagegroup(flexmodulid, currentGroupImages[flexmodulid] + 1, total);
            }
        }
        else
        {
            if (currentGroupImages[flexmodulid] <= 1) 
            {
                changeImagegroup(flexmodulid, total, total);
            }
            else
            {
                changeImagegroup(flexmodulid, currentGroupImages[flexmodulid] - 1, total);
            }
        }
    }
    for (var i=1; i<=total; i++)
    {
        var linkid = "imgchangelink_" + flexmodulid + "_" + i;
        var linkTag = document.getElementById(linkid);
        if (i == currentGroupImages[flexmodulid])
        {
            if (cD.ie)
            {
                linkTag.style.color = "#ffffff";
            }
            else
            {
                linkTag.setAttribute("class", "lnNavi2active");
            }
        }
        else
        {
            if (cD.ie)
            {
                linkTag.style.color = "#000000";
            }
            else
            {
                linkTag.setAttribute("class", "lnNavi2");
            }
        }
    }
    
}
function resizearbeitsprobe(width,height)
{
    if(cD.nav6up)
    {
        var diff;
        if(cD.platform == "win32")
        {
            diff = 11;
        }
        else
        {
            diff = 15;
        }
        window.resizeTo((width-diff),height);
    }
    if (cD.platform.indexOf('mac')!=-1)
    {
        window.resizeTo((width-17),height);
    }
}
function checkkid(targetReqId)
{
    var Form = document.anmeldeform;
    Form.id.value = targetReqId;
    Form.cmd.value = "checkkid";
    Form.submit();
}
function jump(targetReqId)
{
    var Form = document.anmeldeform;
    Form.id.value = targetReqId;
    Form.submit();
}
function initInfoDivs()
{
    alert("InfoDivDingens");
}
function showObjTree(obj, objName){
    var count = 0;
    var result = ""
    for(var i in obj){
        result += objName + "." + i + " = " + obj[i] + "\n";
        count++;
    }
//    document.writeln( result );
    alert(result);
    return result
}
