//**************************************************
//* (c) 2006 by M.E. Koch, http://www.AdOptimize.de
//**************************************************



    var w3c      = 0;
    var ie       = 0;
    var ns       = 0;
    var obj_show = 1;
    var os       = 'win';
    var iec      = -1;
    var nsc = (navigator.appName.indexOf('Netscape') != -1) ? 1 : 0;  // border substractor
	platform     = navigator.platform;
	if(platform.indexOf('Mac')!= -1)
	    os = 'mac';
    iec = (navigator.appName.indexOf('Explorer') != -1) ? 0 : 2;  // border substractor

    if(document.getElementById) w3c = 1;
    else if (document.all) ie = 1;
    else { 
        browserVersion = parseInt(navigator.appVersion); 
        if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) ns = 1; 
    }
    
    function getlayer(lname,lstyle) {
        if(lstyle == 1) {
            if (w3c) if(dc = document.getElementById(lname)) return(dc.style);
            else if (ie) if(dc = document.all[lname]) return (dc.style); 
            else if (ns) if(dc = document.layers[lname]) return (dc);
        } else {
            if (w3c) if(dc = document.getElementById(lname)) return (dc); 
            else if (ie) if((dc = document.all[lname])) return (dc); 
            else if (ns) if(dc = document.layers[lname]) return (dc);
        }
    } // ENDE getlayer

    function replaceIt(string,se,re) {
        out = "" + string;
        while (out.indexOf(se)>-1) {
            pos= out.indexOf(se);
            out= "" + (out.substring(0, pos) + re + out.substring((pos + se.length), out.length));
        }
        return(out);
    }


/***********************************
* CONTENT HIGHT 
************************************/
// Puropose : return the height of the given element
// Sun Jun  3 01:15:52 CEST 2007 Mathias E. Koch  <info@adoptimize.de>

    function return_objHeight(id) {
        if(obj = getlayer(id,2))
        {
            return(obj.offsetHeight);
        }
        return false;
    } // ENDE return objHeight

    var hint;

    function get_leftbox_height(which, length, hint) {
        // berechnet die Zellenhoehe der linken boxen im Vergleich zum Content 

        substract = 0;
        if(iec == 0)
            substract = 15;
        switch(which) {
            case('a') :
				id_select       = (nsc == 1) ? 'topbanner' : ((iec>0) ? 'toprow' : 'topbanner');  // netscape height workaround
                top_rowHeight   = return_objHeight(id_select,2) - iec;         // substract 2px for the border in Moz
                box_height      = Math.round(top_rowHeight) + 'px';
                if(obj_BoxA = getlayer('left_box_a', 1))
                    obj_BoxA.height = box_height;
                if(obj_BoxB = getlayer('left_box_aa', 1))
                    obj_BoxB.height = box_height;
                if(obj_BoxC = getlayer('topbanner', 1))
                    obj_BoxC.height = box_height;
							
								// Wed Mar  2 11:33:31 CET 2011 Mathias E. Koch  <info@na8ur.com>
								// update bei zu langen menus
				
								if(typeof jQuery != 'undefined') {
									if($("#left_box_b").html().match(/### begin --><\!--###/) && $("#left_box_aa").html() == null) {
											var leftboxAHeight = 0;
											$("#left_box_b").hide();
											$("#left_box_a li a img").each(function() {
												//document.write( ($(this).attr('height')+  " " ));
												leftboxAHeight += Math.round($(this).height()) +4;
											});

											if(leftboxAHeight>Math.round(top_rowHeight)) {
												//document.write(leftboxAHeight + ' ' + top_rowHeight);
												// we need to modify the layout .. we do a snapshot of the positions
												// and place the boxes manually
												var ie7broserHeight = 0;
												var ie7broserHeight = ((navigator.appName.indexOf('Explorer')>0 && navigator.appVersion.indexOf('MSIE 7')>0) ? -4 : 0);
												var positionLeftBoxA = $("#left_box_a").position();
												var positionContainer = $("#container").position();
												$("#left_box_a").height(leftboxAHeight) ;
												$("#left_box_a").css('position', 'absolute');
												$("#left_box_a").css('top', (140 + ie7broserHeight)+'px');
												$("#left_box_a").css('left', positionLeftBoxA.left+'px');
												$("#container").css('position', 'absolute');
												//$("#container").css('right', positionLeftBoxA.left+ 10 +'px');
												$("#container").css('left', positionContainer.left+'px');
												$("#container").css('margin-top', '10px');
												//$("#container").css('margin-left', '-20px');
												$(".footer").css('margin-top', '7px');
											}
									}
								}

                break;

            case('a_news') :

                right_rowHeight   = return_objHeight('container',2)- iec;
                left1_rowHeight   = return_objHeight('contentAll',2) - iec - (2*13);
                if(hint == 'double')
                    left1_rowHeight = left1_rowHeight + 212 + 13;
                //alert('right: ' + right_rowHeight + ' left:' + left1_rowHeight);
                if(right_rowHeight < left1_rowHeight)
                {
                    if(obj_BoxA = getlayer('container', 1))
                        obj_BoxA.height = left1_rowHeight +  'px';
                } else
                    if(obj_contentAll = getlayer('contentAll', 1))
                        obj_contentAll.height = right_rowHeight +  28 + 'px';

                break;
             case('b') :
                right_rowHeight   = return_objHeight('container',2)- iec;
                left1_rowHeight   = return_objHeight('left_box_b',2) - iec;
                if(hint == 'double')
                    left1_rowHeight = left1_rowHeight + 212 + 13;
                //alert('right: ' + right_rowHeight + ' left:' + left1_rowHeight);
                if(right_rowHeight < left1_rowHeight)
                {
                    if(obj_BoxA = getlayer('container', 1))
                        obj_BoxA.height = left1_rowHeight +  'px';
                } else 
                    if(obj_contentAll = getlayer('contentAll', 1))
                        obj_contentAll.height = right_rowHeight +  15 + 'px';
                break;
              case('box_content') :
                left1_rowHeight   = return_objHeight(which,2) - iec;
                height            = 212 - iec;
                //alert(height + ' left:' + left1_rowHeight);
                //alert(left1_rowHeight);
                if(height > left1_rowHeight)
                {
                    if(obj_BoxA = getlayer(which, 1))
                        obj_BoxA.height =  height +  'px';
                }
                break;
            
            
             case('bb') :
                right_rowHeight   = return_objHeight('container',2) - iec;
                left1_rowHeight   = return_objHeight('left_doublebox',2) - iec;
                //alert(right_rowHeight + ' left:' + left1_rowHeight);
                if(right_rowHeight < left1_rowHeight)
                {
                    if(obj_BoxA = getlayer('mainContent', 1))
                        obj_BoxA.height = left1_rowHeight + 'px';
                }
                if(right_rowHeight > left1_rowHeight)
                {
                    differ    = right_rowHeight - left1_rowHeight;
                    //if(ie == 0)
                        //differ = differ -30;                            // margin beruecksichtigen fuer IE
                    left_top = return_objHeight('left_box_bb',2) - iec;
                    left_topStyle = getlayer('left_box_b', 1);
                    left_topStyle.height = left_top + differ + 'px';
                }
                break;
            case('bbb') :
                l_bHeight       = return_objHeight('left_box_b') - iec;
                l_bbHeight      = return_objHeight('left_box_bb') - iec;
                l_bbbHeight     = return_objHeight('left_box_bbb') - iec;
                switch(true)
                {
                    case(l_bHeight >= l_bbHeight):
                        if(l_bHeight >= l_bbbHeight)
                            max = l_bHeight + 'px';
                        else
                            max = l_bbbHeight + 'px';
                        break;
                    case(l_bbHeight >= l_bbbHeight):
                            max = l_bbHeight + 'px';
                        break;
                    case(l_bbbHeight > l_bHeight):
                            max = l_bbbHeight + 'px';
                        break;
                    default:
                        break;
                } // switch
                //alert(max + ' l_b: ' + l_bHeight + ' l_bb:' + l_bbHeight + ' l_bbb:' + l_bbbHeight) ;
                if(obj_BoxA = getlayer('left_box_b', 1))
                    obj_BoxA.height = max;
                if(obj_BoxB = getlayer('left_box_bb', 1))
                    obj_BoxB.height = max;
                if(obj_BoxC = getlayer('left_box_bbb', 1))
                    obj_BoxC.height = max;
                
                break;
        
            default:
                break;
        } // switch

        return false;
    } // ENDE get_leftbox_height

    function get_leftboxb_height() {
        if(lba = getlayer('left_box_b_img', 2)) ltop= lba.offsetTop;
	    else ltop= 0;
        //if(ltop>620) 
        //{
        //   leftboxa = getlayer('left_box_b', 2);
        //    leftboxas = getlayer('left_box_b', 1);
        //    leftboxas.height= '920pix';
        // }
    }


    function show_obj(id,state)
    {
        obj = getlayer(id,1);
        if(state==1)
        {
            obj.visibility='visible';
            obj.display   ='block';
            obj2 = getlayer(id, 2);
            if(obj2.offsetHeight< 210)
                obj.height = '203px';
        }
        else
        {
            obj.visibility='hidden';
            obj.display   ='none';
        }
    } // ENDE show_obj



/***********************************
* MENUE JS
************************************/


	/* Das aktive Menue Element identifizieren */
    var zdex = 1; /* Zindex damit die layer nicht uebereinander gelegt werden */
  	var strID;
    rExp     = /(.*)((\?|&)id=)([^&]+)(.*)/i;
  	ltoS     = window.document.location.toString();
    strID    = ltoS.replace(rExp,"$4");
        
    
		// IE SelectBox-Hack! the problem that layers can't be placed above SelectBoxes
		// Purpose : hiding the selectboxes if IE the used browser
		var formular_selectboxlength = -1;
		var formular_selectbox;
		function do_selectbox(showhide)
		{
			if(showhide!= '')
			{
				for(i=0; i<formular_selectboxlength; i++)
					formular_selectbox[i].style.visibility = showhide;
			}
		} // ENDE do_selectbox

		function hide_selectbox() {
			if(formular_selectboxlength == -1)
				if(navigator.appName.indexOf('Explorer')!= -1)
				{
					formular_selectbox       = document.getElementsByTagName('SELECT');
					formular_selectboxlength = formular_selectbox.length;
				}
				if(formular_selectboxlength != -1)
					do_selectbox('hidden');
		} // ENDE hide_selectbox

		function show_selectbox() {
			if(formular_selectboxlength != -1)
				do_selectbox('visible');
		} // ENDE show_selectbox;





		function get_parent(obj) {
			if(!getlayer(obj,2)) {
				if(objul = getlayer('submenu' + strID,2)) {
					if(objul.parentNode.nodeName == 'UL') {
						obj = objul.parentNode.id;
					}
				}
			}
			return(obj);
		} // ENDE get_parent


		function process_subshow(objc,obj) {
			cln = objc.className;
			if(cln == 'everhide') {
				obj = get_parent('menu' + strID);
			} else if (cln == 'submenwi') {
				objc.parentNode.nodeName == 'UL'
				obj = objc.parentNode.id;
			}
			return(obj);
		} // ENDE process_subshow 


		function check_show(obj) {
			if(objc = getlayer(obj,2)) {
				obj = process_subshow(objc,obj);
			} else if(objc = getlayer('sub' + obj,2)) {
				obj = process_subshow(objc,'sub' + obj);
			}
			return(obj);
		} // END check_show 


        var objhilight;

		// PURPOSE discards all Menue - Elements and shows the background - image
		var menu_links;
		var menu_linkslength = -1;
		function color_sub(obj) {
            return false;
		} // color_sub


    var active_object, active_object_parent='';

    function show(obj) {
	    zdex++;
		se = 'menu'; re = '';
		number = replaceIt(obj,se,re);
		if(objf = getlayer('menwi' + number,2)) {
		    position_left = objf.offsetLeft;
            objfs = getlayer('menwi' + number,1);
            objfs.backgroundColor = 'rgb(56, 82, 69)';
            active_object_parent= objfs;
		}
		if(objf = getlayer('menwi_hi' + number,2)) {
	        position_left = objf.offsetLeft;
		}
        if(objp = getlayer('buttonmenu' + number,1)) {
            objp.backgroundColor = 'rgb(56, 82, 69)';
        }
        if(objn = getlayer(obj, 1)) {
		    if(objn.visibility != 'visible') {
      	    	objn.visibility = 'visible';
      	    	objn.display    = 'inline';
				objn.zIndex     = zdex;
				active_object   = objn;
            	//  objn.marginTop= '2px';
	        }
	    }
    } // END show


    function hide(obj,out) {
        // hintergrundfarbe zuruecksetzten
		se = 'menu'; re = '';
		number = replaceIt(obj,se,re);
        if(objp = getlayer('buttonmenu' + number,1)) {
            objp.backgroundColor = 'rgb(21, 52, 37)';
        }
        if(out) {
      	  	active_object.visibility= 'hidden';
      	    active_object.display   = 'none';
            if(active_object_parent != '') active_object_parent.backgroundColor = 'rgb(21, 52, 37)';
	        obj = check_show(obj);
        }
    } // ENDE hide


	function change_col(obj,bg,co) {
        stya = getlayer(obj + 'ADO',1);
        styp = getlayer('ADO' + obj,1);
	    if(co) styp.color= co;
	    if(bg) stya.backgroundColor= bg;
	} // ENDE change_col


    var bg_color_org = '';
    function bg_color(obj) {
        objlay = getlayer(obj.id,2);
        if(bg_color_org!='') {
            objlay.className = bg_color_org;
            bg_color_org = '';
        } else {
            bg_color_org = objlay.className;
            objlay.className = objlay.className + ' bg_dark_green';
        }
    } // ENDE bg_color

// Purpose: checks the total height of the page and decides how many teaser should be displayed
// Wed May 23 23:57:14 CEST 2007 Mathias E. Koch  <info@adoptimize.de>

    var printthis;

    function check_content_height() {
        atop = 0;
        aobj = 0;
        bobj = 0;
        if(aobj = getlayer('mainContent', 2))
            atop= aobj.offsetTop;
        if(bobj = getlayer('left_box_b', 2)) {
            btop= bobj.offsetHeight;
					  if(btop<210) {
							
							bobj.style.height = '210';
						}
			}
			
        if(atop > (btop + 400))
        {
            //alert('insert teaser');
        }
        else if((atop + 400) < btop) 
        {
            //alert('remove teaser');
        }
        if(printthis == 1)
            print_page();
    }
    


// redirects a dropdown selectobx to the selected URL (Adress-finder)
// obj is the object of the selectbox
// Sat May 19 13:24:04 CEST 2007 Mathias E. Koch  <info@adoptimize.de>

    function show_selected(obj) {

        if((obj.value !='')) 
        {
                location.href = obj.value;
                return true;
        }
        len = obj.childNodes.length;  // workaround for IE
        for(i=1; i<=len; i++)
        {
            if((obj.childNodes[i].nodeName== 'OPTION') && (obj.childNodes[i].selected == true) && (obj.childNodes[i].value.indexOf('---')== -1))
            {
                location.href = obj.value;
                return true;
            }
        }
    } // ENDE show_selected


    function hide_mailform(swi) {
        objsty             = getlayer('mail_formular',1);
        objsty.visibility  = 'hidden';
        objsty.display     = 'none'; 
        objsty             = getlayer('mail_danke',1);
        objsty.visibility  = 'hidden';
        objsty.display     = 'none'; 

        if(hobj = getlayer('trenner', 1))
        {
            hobj.visibility = 'hidden';
            hobj.display    = 'none';
        }
        
        if(!swi) {
            objsty            = getlayer('mail_danke',1);
            objsty.visibility = 'visible';
            objsty.display    = 'block'; 
        }

        return(true);
    } // ENDE hide_mailform

    function open_popup(file,target) {
        window.open(file,target);
    } // ENDE open_popup


// nachsehen ob left_box_b empty ist wenn ja, verschwinden lassen


