function class_mapbuilder(){

    this.get_maps=function(my_value,obj_target){

        var obj=eval("(" + my_value + ")");

        //alert(window.zoomstufe);

        for (var Eigenschaft in obj)  {
            for (var Eigenschaft1 in obj[Eigenschaft]) {
                if(obj.zoomstufe[Eigenschaft1].Stufe==window.zoomstufe){
                    var current_obj=obj.zoomstufe[Eigenschaft1];
                }
            }
        }


        this.init_build(current_obj,obj_target);
        
    }


    this.init_build=function(my_value,obj_target){

        //var obj=eval("(" + my_value + ")");

        var obj=my_value;

        window.map_width=obj.Dimension.Breite;
        window.map_height=obj.Dimension.Hoehe;

        window.my_map_controller.update_dimension();

        for (var Eigenschaft in obj.Kartenteile){
            var my_div=create_my_div(obj.Kartenteile[Eigenschaft]);
            obj_target.appendChild(my_div);
        }
        
    }
    
    this.init_points=function(obj_target){
        /*
        p1 oben link
        p2 oben rechts
        p3 unten link
        p4 unten rechts
        */
        for(var i=0;i<obj_target.childNodes.length;i++){
            var p1x = document.createAttribute("p1x");
            var p2x = document.createAttribute("p2x");
            var p3x = document.createAttribute("p3x");
            var p4x = document.createAttribute("p4x");
            
            var p1y = document.createAttribute("p1y");
            var p2y = document.createAttribute("p2y");
            var p3y = document.createAttribute("p3y");
            var p4y = document.createAttribute("p4y");


            p1x.nodeValue=obj_target.childNodes[i].offsetLeft;
            p2x.nodeValue=obj_target.childNodes[i].offsetLeft+obj_target.childNodes[i].offsetWidth;
            p3x.nodeValue=obj_target.childNodes[i].offsetLeft;
            p4x.nodeValue=obj_target.childNodes[i].offsetLeft+obj_target.childNodes[i].offsetWidth;
            
            p1y.nodeValue=obj_target.childNodes[i].offsetTop;
            p2y.nodeValue=obj_target.childNodes[i].offsetTop;
            p3y.nodeValue=obj_target.childNodes[i].offsetTop+obj_target.childNodes[i].offsetHeight;
            p4y.nodeValue=obj_target.childNodes[i].offsetTop+obj_target.childNodes[i].offsetHeight;

            obj_target.childNodes[i].setAttributeNode(p1x);
            obj_target.childNodes[i].setAttributeNode(p2x);
            obj_target.childNodes[i].setAttributeNode(p3x);
            obj_target.childNodes[i].setAttributeNode(p4x);
            
            obj_target.childNodes[i].setAttributeNode(p1y);
            obj_target.childNodes[i].setAttributeNode(p2y);
            obj_target.childNodes[i].setAttributeNode(p3y);
            obj_target.childNodes[i].setAttributeNode(p4y);
        }
       return;
    }
    
    this.validate_scope=function(obj_target){
        for(var i=0;i<obj_target.childNodes.length;i++){

            if(obj_target.childNodes[i].style.backgroundImage!="url("+obj_target.childNodes[i].getAttribute("alt")+")"){
                var p1x=obj_target.childNodes[i].getAttribute("p1x");
                var p1y=obj_target.childNodes[i].getAttribute("p1y");
                
                var p2x=obj_target.childNodes[i].getAttribute("p2x");
                var p2y=obj_target.childNodes[i].getAttribute("p2y");
                
                var p3x=obj_target.childNodes[i].getAttribute("p3x");
                var p3y=obj_target.childNodes[i].getAttribute("p3y");
                
                var p4x=obj_target.childNodes[i].getAttribute("p4x");
                var p4y=obj_target.childNodes[i].getAttribute("p4y");

                var lo=(p1x>=window.my_scope.scope_p1x && p1x<=window.my_scope.scope_p2x && p1y>=window.my_scope.scope_p1y && p1y<=window.my_scope.scope_p3y);
                var ro=(p2x>=window.my_scope.scope_p1x && p2x<=window.my_scope.scope_p2x && p2y>=window.my_scope.scope_p1y && p2y<=window.my_scope.scope_p3y);
                var lu=(p3x>=window.my_scope.scope_p1x && p3x<=window.my_scope.scope_p2x && p3y>=window.my_scope.scope_p1y && p3y<=window.my_scope.scope_p3y);
                var ru=(p4x>=window.my_scope.scope_p1x && p4x<=window.my_scope.scope_p2x && p4y>=window.my_scope.scope_p1y && p4y<=window.my_scope.scope_p3y);

                if(ro || lo || lu || ru){
                    obj_target.childNodes[i].style.backgroundImage="url("+obj_target.childNodes[i].getAttribute("alt")+")";
                }
            }
        }
    }
    
    
    function create_my_div(obj){
            //div erstellen
            var my_div=document.createElement('div');

            //id setzen
            my_div.id=obj.ID;

            //alt attribute setzen
            var alt = document.createAttribute("alt");
            alt.nodeValue=obj.backgroundImage;
            my_div.setAttributeNode(alt);

            //style attribut setzen
            my_div.style.backgroundImage="url(maps/leerkarte.gif)";
            my_div.style.width=obj.Width+"px";
            my_div.style.height=obj.Height+"px";
            my_div.style.display=obj.Display;

            window.weiche(my_div,"obj.style.styleFloat='"+obj.CSSFloat+"'","obj.style.cssFloat='"+obj.CSSFloat+"'");

            my_div.style.clear=obj.Clear;
            return my_div;
    }
    
    this.clear_all=function(){
        for(var i=0; i<window.all_maps.length;i++){
            obj=window.all_maps[i];
            obj.innerHTML="";
        }
    }
    
}

function weiche(my_obj,ie,moz,opera,other){

        obj=my_obj;

        if (navigator.appName.indexOf("Opera") != -1)
        {
            //opera
            eval(moz);
        }
        else if (navigator.appName.indexOf("Explorer") != -1)
        {
            //ie

            eval(ie);

        }
        else if (navigator.appName.indexOf("Netscape") != -1)
        {
            //netscape
            eval(moz);

        }
        else
        {
            //other
            eval(other);
        }
}