var optionSlider = null;

function hideLayer(id){

	if(document.getElementById(id)){
		document.getElementById(id).style.display = 'none';
	}
}

function showLayer(id, obj, top, left){
	if($(id)){
	
		if(obj && top){
			$(id).style.top = obj.top  - 13  - top + 'px';
		}
		else if(obj && left){
			$(id).style.left = left  -21 + 'px';
		}
		
		else if(obj){
			$(id).style.top = obj.top  - 13 + 'px';
		}
		$(id).style.display = 'block';
	}
    
    
    if(id=='sidebar-popup-tour'){
        // Create the new slider instance
        optionSlider = new Slider('optionSlider', 'optionKnob');
        optionSlider.set($("elevFac").value)
        optionSlider.detach();
    
    }
    
}

 function showInfoLayer(id, evt){
		
	var bubbles = getElementsByClassName('infoBubble')
	
	for(var i =0; i < bubbles.length; i++){
		bubbles[i].style.display='none';
	} 

	if($(id)){
		$(id).style.display = 'block';
	}
	
	$(id).style.top = evt.clientY - $(id).getSize().y -30 + 'px';
	$(id).style.left = evt.clientX  - 30 + 'px';
} 

function getElementsByClassName(className) {
  var a =new Array();
  var els = document.getElementsByTagName("div");
  for ( var i = 0, j = els.length ; i < j ; i++ ) {
    if (els.item(i).className.indexOf(className) != -1)
      a.push(els.item(i));
  }
  return a;
}

function hideOverlay(id){
	if($(id)){
		$(id).setStyle("display","none");
		$("overlayBg").setStyle("display","none");
		$("overlayBg").removeEvent("click", function(){hideOverlay(id)});
		$(id).removeEvent("click", function(){hideOverlay(id)});
	}
	else{

		for(var i=0;i < $(document.body).getElements('div[class=overlay-content]').length; i++){
			$(document.body).getElements('div[class=overlay-content]')[i].style.display = 'none';	
		}
		
		$('overlay').style.display= 'none';
	}
}

function showOverlay(id){


	if($(id)){
		$("overlayBg").addEvent("click", function(){hideOverlay(id)});
		$("overlayBg").setStyle("display","block");
        
        
      
       /*  if(id!='overlayRoute' && id!='overlayAnmelden' && id!='overlayRegistrieren' && id!='overlayMeineRouten'){
            $(id).addEvent("click", function(){hideOverlay(id)});
        } */
        
		$(id).setStyle("display","block");
        
        if(id=='overlayRoute'){
        	// Create the new slider instance
        	optionSlider = new Slider('optionSlider', 'optionKnob', {
        		steps: 100,	// There are 100 steps
        		range: [0],	// Minimum value is 0
        		onChange: function(value){
                    $('elevFac').value = value;
        		}
        	});
            
            optionSlider.set($("elevFac").value)
        
        }
       
	}
	else{
	
		$('overlay-content').style.display = '';	
		$('overlay').style.display = '';	
	}
}

function showTab(id){

	if(id!=activeTab)
	{
		$(id).className = "active";
		$(activeTab).className = "inactive";
		showLayer(id+"Content");
		hideLayer(activeTab+"Content");
		activeTab = id;
	}
}
activeTab = "tabRoute";

function uncheck(idstring){

	var ids = idstring.split(";");
	for(i = 0; i < ids.length; i++){
		$(ids[i]).checked = false;
	}
}

function check(idstring){
	var ids = idstring.split(";");
	for(i = 0; i < ids.length; i++){
		$(ids[i]).checked = true;
	}
}

// select one row and deselect rows
function selectRow(id){
	var i, tr;  

	for(i=0; (tr = document.getElementsByTagName('tr')[i]); i++){  
	 
        if(tr.getAttribute("id") && tr.getAttribute("id").indexOf(id.substring(0, id.lastIndexOf('-'))) != -1)
		{
			deselectRow(tr.getAttribute("id"));
		}
	}

	//hightlight the selected row
	if($(id)){
		$(id).className="selected-row";
	}
}

function deselectRow(id){
	if($(id)){
		$(id).className="";
	}
}

function showRoute(id, fullTrip, type){
	selectRow("tabRoute-Row-"+id);
	showLayer("tabRoute-leg-"+id);
	
	showLayer("overviewTrip_"+id);
	
	if(lastRoute != id){ 
		hideLayer("tabRoute-leg-"+lastRoute);
		hideLayer("overviewTrip_"+lastRoute);
	}
	lastRoute = id;
	
	var sessionID = document.getElementById('sessionID').value;
	var requestID = document.getElementById('requestID').value;	
	
	 setTripSelector(id +1);
	
	if(type=='display'){
		if(mdvJpMaps['aerial']){
			mdvJpMaps['aerial'].displayJourney(sessionID, requestID, $('itdLPxx_tripSelector').value, fullTrip);
		}
		else if(mdvJpMaps['city']){
			mdvJpMaps['city'].displayJourney(sessionID, requestID, $('itdLPxx_tripSelector').value, fullTrip);
		}
		else if(mdvJpMaps['navteq']){
			mdvJpMaps['navteq'].displayJourney(sessionID, requestID, $('itdLPxx_tripSelector').value, fullTrip);
		}  
	}
	
}
lastRoute = "0";

function showElevation(id){
	selectRow("tabElevation-Row-"+id);
	showLayer("tabElevationChart-"+id);
	if(lastElevation != id)
	{
		deselectRow("tabElevation-Row-"+lastElevation);
		hideLayer("tabElevationChart-"+lastElevation);
	}
	lastElevation = id;
}
lastElevation = "1";

function showRouteLeg(id, imgid){
	var myC = toggle($(id));
	if($(imgid))
	{
		if(myC == "tabRouteLED") $(imgid).src = "./images/icon_plus.gif";
		else $(imgid).src = "./images/icon_minus.gif";
	}
}


function showPOISubCat(id, imgid, hierarchy){
	var myC = toggle($(id));
    
    // create sub categories 
    if(!$(id + '-0')){
        var host = 'XML_STOPFINDER_REQUEST'
        
    	var _params = { 
    		language: mapLanguage, 
    		nameHierarchy_sf: 'poiHierarchy:' + hierarchy, 
            nameInfo_sf: 'poiHierarchy:' + hierarchy, 
    		type_sf: 'poi', 
    		placeInfo_sf: '-1:-1' 
    	};
        
    	var _ajax = mdvLib.ajax({ host: host, parameters: _params, onComplete: MDVEFAPOISub_onAjaxComplete});
    }
    
	if($(imgid))
	{
		if(myC == "tabRouteLED"){ 
            $(imgid).src = "./images/icon_plus.gif";
            selCat.replace(hierarchy + ':', '');
        }
		else{ 
            $(imgid).src = "./images/icon_minus.gif";
             selCat += hierarchy + ':';
        }
	}
}

function MDVEFAPOISub_onAjaxComplete(request){

    var poiNodes = this.response.xml.getElementsByTagName('itdPoiNode')
    var html = '';
    var poiContainerId = 'tabZieleLED-0-' + poiNodes[0].getAttribute('hierarchy').substring(0,1);
    
    for(var i =0; i < poiNodes.length; i++){
    
        var catName = poiNodes[i].textContent || poiNodes[i].text;
        var catId = poiContainerId + '-' + i;
        var catHier = poiNodes[i].getAttribute('hierarchy') 
        
		html+='<div id="' + catId +'" class="tabRouteLEDE'
        if($('itdLPxx_poiSubCat').value.indexOf(catHier +':')!='-1'){
            html += 'Active';
        }
        html += '">';

		html+='<p class="tabZieleCB">';

        if($('itdLPxx_poiSubCat').value.indexOf(catHier +':')!='-1'){
        
            $('itdLPxx_poiSubCat').value = $('itdLPxx_poiSubCat').value.replace(catHier +':', '');
        
            html += '<input type="checkbox" class="radio" value="1" id="' + catHier +'" name="type" checked="checked"/>'
            showPOIsInCat(catHier, true)
        }
        else{
            html += '<input type="checkbox" class="radio" value="1" id="' + catHier +'" name="type"/>'
        }
        
        html += '<label for="' + catHier + '">' + catName +'</label></p>'
		html +=	'<br/></div>' 
    } 

    
   $(poiContainerId).innerHTML = html;
   
   
    $$("#tabZieleLegScroller .tabRouteLEDE").each(function(el) {
        el.addEvent("click", function() {
            iTargets.toggle(this);
        });
        
    });
    
    $$("#tabZieleLegScroller .tabRouteLEDEActive").each(function(el) {
        el.addEvent("click", function() {
            iTargets.toggle(this);
        });
        
    });
}


function showPOIsInCat(cat, state){


    if(selSubCat.indexOf(cat+':') !='-1' && state==true){
        return false;
    }

    selSubCat = '';
    $$(".tabZieleCB input[type='checkbox']").each(function(el){
        if(el.checked==true){
            selSubCat +=  el.id + ':'
        }
    
    });
    
    if($$('input[name=radius_1]:checked')[0]){
        
        var radiusValue = $$('input[name=radius_1]:checked')[0].value;
        
        if(radiusValue==0){
            $('umkreis100').checked = true;
        }
        
        mdvJpMaps[currentMap].getProxPOIs(radiusValue);
    }
    

    if(state==true){
    
        // create sub categories 
        var host = 'XML_STOPFINDER_REQUEST'
        
        var _params = { 
            language: mapLanguage, 
            nameHierarchy_sf: 'poiHierarchy:' + cat, 
            nameInfo_sf: 'poiHierarchy:' + cat, 
            type_sf: 'poi', 
            placeInfo_sf: '-1:-1' 
        };
        
        var _ajax = mdvLib.ajax({ host: host, parameters: _params, onComplete: MDVEFAPOIsInCat_onAjaxComplete});
    }
    else{
        MDVEFAPOIsInCat_onAjaxComplete(state, cat);
    }
   
}

var checkedPOIs = new Array;

function MDVEFAPOIsInCat_onAjaxComplete(request, cat){

    mdvJpMaps[currentMap].mdvMap.update()

    var html = '';

    if(request == false){
        var tmpPOIs = new Array;
    
        for(var a =0; a < checkedPOIs.length; a++){

            if(checkedPOIs[a][1].indexOf(cat)=='-1'){
                tmpPOIs.push([checkedPOIs[a][0], checkedPOIs[a][1], checkedPOIs[a][2], checkedPOIs[a][3]])
            }
        }   

        checkedPOIs =   tmpPOIs;     
        
    }
    else{

        var poiNodes = this.response.xml.getElementsByTagName('odvNameElem');
        var input = this.response.xml.getElementsByTagName('odvNameInput')[0]
        var catHier = input.textContent || input.text;
        
        
        for(var i =0; i < poiNodes.length; i++){
            var poiName = poiNodes[i].textContent || poiNodes[i].text;
            checkedPOIs.push([poiName, catHier, poiNodes[i].getAttribute('x'), poiNodes[i].getAttribute('y')])
        } 
    
    }

    checkedPOIs.sortAsc(0);
    
    for(var s =0; s < checkedPOIs.length; s++){
    
        var poiName = checkedPOIs[s][0];
        var x = checkedPOIs[s][2];
        var y = checkedPOIs[s][3];
        html+='<li class="" id="'+ s + ':' +x +':' + y +'">';
        html+='<span title="' + poiName+'">' + poiName+'</span>';
        html+='</li>';
        
    } 
    
    if(html ==''){
        iTargets.hide();
        $('umkreis0').checked = true;
    }
    
    $('flyoutList').innerHTML = html;

    $$("#flyoutContent li").each(function(el){
        el.addEvent("click", function(){

              var coord = el.id.split(':')
              var x = coord[1]
              var y = coord[2]
              mdvJpMaps[currentMap].zoomCoord(x,y);
            
              $$("#flyoutContent li.Active").each(function(li){
                  li.removeClass("Active");
              });
              el.toggleClass("Active");
        });
    });
 
    
}

function clickPOI(x, y){


 mdvJpMaps[currentMap].zoomCoord(x,y);

}


function toggleLeg (obj){
	if(obj.id == lastToggleLeg.id){
		return false;
	}
	 
	toggle(obj);
	if(lastToggleLeg != "" && obj.id != lastToggleLeg.id) {
		toggle(lastToggleLeg);
	}
	
	lastToggleLeg = obj;
}
lastToggleLeg = "";

function toggle(obj){

	if(obj.className && obj.className.lastIndexOf("Active") != -1) obj.className = obj.className.substring(0,obj.className.lastIndexOf("Active"))
	else obj.className = obj.className + "Active";
	return obj.className;
}

function selectRoute(id){
	selectRow("tabRoute-Row-"+id);
}

function dateUpDown(upOrDown,suffix){

	var tag = parseFloat($("itdDateDay").value);
	var monat = parseFloat($("itdDateMonth").value);
	var jahr = parseFloat($("itdDateYear").value);
	jahr = (jahr >= 0 && jahr <= 75) ? jahr = 2000 + jahr : 1900 + jahr;
	heute = (upOrDown == 'up') ? new Date(jahr, monat-1, tag+1):new Date(jahr, monat-1, tag-1);
	tag = LZ(heute.getDate());
	monat = LZ(heute.getMonth()+1);
	jahr = ((heute.getFullYear()).toString()).substr(2,2);
	$("itdDateDay").value = tag;
	$("itdDateMonth").value = monat;
	$("itdDateYear").value = jahr;
	$("itdDateDayPopUp").value = tag;
	$("itdDateMonthPopUp").value = monat;
	$("itdDateYearPopUp").value = jahr;
}


var mh = 0;
var mw = 0;

/* this function is to initate the page */
function initiate(){

	var sbh = $("searchbar")?$("searchbar").offsetHeight:$("addressbar").offsetHeight;
	if( $("searchbar") && $("searchbar").style.display=='none' && $("addressbar")){
		sbh = $("addressbar").offsetHeight;
	}
	var fh=$("header")?$("header").offsetHeight+sbh:sbh;
	var sh=$("sidebarmenu")?$("sidebarmenu").offsetHeight:34;
	var sw=$("sidebarmenu")?$("sidebarmenu").offsetWidth:34;
	var ch=document.documentElement.clientHeight;
	var cw=document.documentElement.clientWidth;
	mh=ch-fh;
	mw=cw-sw;
    
	if($("sidebar"))$("sidebar").style.height=(ch>=sh+fh)?(ch-sh-fh)+"px":"0";
	
	if($("startseite"))$("startseite").style.height=(ch>=sh+fh)?(ch-sh-fh)+"px":"0";
	
	if($("searchbar")){
		$("searchbar").style.width=cw;
	}
	
	if($("addressbar")){
		$("addressbar").style.width=cw;
	}
    
    if($('tabRoute') && $("sidebar-info")){
		var ah = $("sidebartabs").offsetHeight + $("sidebar-info").offsetHeight +sh+sbh+fh;

		var trscrl = getElementsByClassName("tabRouteLegScroll", "div");
        
		for(var i=0;i<trscrl.length;i++)
		{
			if((ch-ah) > 0){
                $(trscrl[i]).style.height = (ch-ah) + 3 +"px";
			}
			else{
				$(trscrl[i]).style.height = "100px";
			}
		}
    }

	 if($("tabRouteLines")){
		var ah = $("sidebartour").offsetHeight+$("sidebartabs").offsetHeight+$("tabRouteLines").offsetHeight+sh+sbh+fh+1;
        
		var ahPOI = $("sidebartour").offsetHeight+$("sidebartabs").offsetHeight+sh+sbh+fh+1;
		var trscrl = getElementsByClassName("tabRouteLegScroll", "div");
        
		for(var i=0;i<trscrl.length;i++)
		{
			if((ch-ah) > 0){
                
                if($(trscrl[i]).id=='tabZieleLegScroller'){
                 $(trscrl[i]).style.height = (ch-ahPOI - 25)+"px";
                }
                else if($(trscrl[i]).id=='tabRouteLegScroller-0'){
                 $(trscrl[i]).style.height = (ch-ah - 19)+"px";
                }
                
                else{
                    $(trscrl[i]).style.height = (ch-ah)+"px";
                }
			}
			else{
				$(trscrl[i]).style.height = "100px";
			}
		}
		
		if($('itdLPxx_tripSelector')){
			showRoute($('itdLPxx_tripSelector').value -1, true);
		}
	}

	 if($("tabElevationLines")){
     
		if($("tabElevationLines").getElements("tr").length > 1) {
			if(ch>550){
				$("tabElevationLines").setStyles({height:"auto",minHeight:"50px",maxHeight:"150px"});
			}else{
				$("tabElevationLines").setStyle("height", "50px");
			}
		} 
        else {
			$("tabElevationLines").setStyles({display:"none",height:0});
		}

		var eh = $("sidebartour").getSize().y+$("sidebartabs").getSize().y+sh+fh+$("tabElevationLines").getSize().y;
		var trscrl = getElementsByClassName("tabElevationChart", "div");
		
		for(var i=0;i<trscrl.length;i++)
		{
			$(trscrl[i]).style.height = (ch-eh)+"px";
		}
		showElevation(0);
	}  
	
	
	 if($("tabTrackWrapper")){
	
        var eh = $("sidebartour").getSize().y+$("sidebartabs").getSize().y+sh+fh+$("tabElevationLines").getSize().y;

	
		if(ch-eh>405){
			$("tabTrackWrapper").setStyles({height:"auto"});
		}
        else{
			$("tabTrackWrapper").setStyle("height", ch-eh - 11 + 'px');
		}
	}   
	
	if($("mdvMap")){
		$("mdvMap").style.height=(ch>=mh && mh > 300)?mh+"px":"300px";
		$("map").style.height=(ch>=mh && mh > 295)?mh+"px":"295px";
		$("mdvMap").style.width=(cw>=mw && mw > 425)?mw+"px":"425px";
		$("map").style.width=(cw>=mw && mw > 420)?mw+"px":"420px";
		$("maplegend").style.width = (cw>=mw)?Math.round(mw*0.9)+"px":"0"; 

		if (mdvJpMaps['navteq'] && mdvJpMaps['navteq'].mdvMap) {
			mdvJpMaps['navteq'].setViewport();
		} 

		if(document.getElementById('sessionID').value=='0'){
			document.forms[0].useSignedRoute.checked=false;
			document.forms[0].usePseudoRouting.checked='checked';
			document.forms[0].preferAsphaltTracks.checked=false;
			document.forms[0].preferGreenTracks.checked='checked';
			document.forms[0].cycleSpeed.value='15';
		}
	}
    

    if(iTargets) iTargets.setHeight();

}

var iTargets = iTargets?iTargets:{
	el:false,
	init:function() {
		if($("flyout")) {
			this.el = $("flyout");
			$("flyoutAOpen").addEvent('click', function(e){

				e.stop();
				iTargets.show();
			});
			$("flyoutAClose").addEvent('click', function(e){

				e.stop();
				iTargets.hide();
			});
			this.el.fade("hide");
			$$("#flyoutContent li").each(function(el){
				el.addEvent("click", function(){
                
                    // zoom to coord
					$$("#flyoutContent li.Active").each(function(li){
						li.removeClass("Active");
					});
					el.toggleClass("Active");
				});
			});
		}
	},
	toggle: function(obj) {
    
		var checked = false;
		if(obj.className.lastIndexOf("Active") != -1 && obj.getElement('input[type="checkbox"]').checked ==false) {
			obj.className = obj.className.substring(0,obj.className.lastIndexOf("Active"))
			
		} 
        else if(obj.getElement('input[type="checkbox"]').checked==true){
        
            if(obj.className.lastIndexOf("Active") == -1){
                obj.className = obj.className + "Active";
            }
			checked = true;
		}
        
        var cat =  obj.getElement('input[type="checkbox"]').id;
        showPOIsInCat(cat, checked);
        
        if(checked==true && !this.open()){  
            this.show();
        
        }
        
		obj.getElement('input[type="checkbox"]').set("checked", checked);
	},
	show:function() {
		if(this.el) {
			this.el.fade("in");
			$("flyoutAOpen").fade("out");
		}
	},
	hide:function() {
    
		if(this.el) {
			this.el.fade("out");
			$("flyoutAOpen").fade("in");
		}
	},
	open:function() {
		var open=false;
		if(this.el && this.el.get("opacity")==1) open=true;
		return open;
	},
	setHeight:function(){
		if($("flyout")&&mh>0) {
			$("flyout").setStyle("height", mh+"px");
			$("flyoutContent").setStyle("height", mh-124+"px");
		}
	}
};


var getElementsByClassName = function (className, tag, elm){
	if (document.getElementsByClassName) {
		getElementsByClassName = function (className, tag, elm) {
			elm = elm || document;
			var elements = elm.getElementsByClassName(className),
				nodeName = (tag)? new RegExp("\\b" + tag + "\\b", "i") : null,
				returnElements = [],
				current;
			for(var i=0, il=elements.length; i<il; i+=1){
				current = elements[i];
				if(!nodeName || nodeName.test(current.nodeName)) {
					returnElements.push(current);
				}
			}
			return returnElements;
		};
	}
	else if (document.evaluate) {
		getElementsByClassName = function (className, tag, elm) {
			tag = tag || "*";
			elm = elm || document;
			var classes = className.split(" "),
				classesToCheck = "",
				xhtmlNamespace = "http://www.w3.org/1999/xhtml",
				namespaceResolver = (document.documentElement.namespaceURI === xhtmlNamespace)? xhtmlNamespace : null,
				returnElements = [],
				elements,
				node;
			for(var j=0, jl=classes.length; j<jl; j+=1){
				classesToCheck += "[contains(concat(' ', @class, ' '), ' " + classes[j] + " ')]";
			}
			try	{
				elements = document.evaluate(".//" + tag + classesToCheck, elm, namespaceResolver, 0, null);
			}
			catch (e) {
				elements = document.evaluate(".//" + tag + classesToCheck, elm, null, 0, null);
			}
			while ((node = elements.iterateNext())) {
				returnElements.push(node);
			}
			return returnElements;
		};
	}
	else {
		getElementsByClassName = function (className, tag, elm) {
			tag = tag || "*";
			elm = elm || document;
			var classes = className.split(" "),
				classesToCheck = [],
				elements = (tag === "*" && elm.all)? elm.all : elm.getElementsByTagName(tag),
				current,
				returnElements = [],
				match;
			for(var k=0, kl=classes.length; k<kl; k+=1){
				classesToCheck.push(new RegExp("(^|\\s)" + classes[k] + "(\\s|$)"));
			}
			for(var l=0, ll=elements.length; l<ll; l+=1){
				current = elements[l];
				match = false;
				for(var m=0, ml=classesToCheck.length; m<ml; m+=1){
					match = classesToCheck[m].test(current.className);
					if (!match) {
						break;
					}
				}
				if (match) {
					returnElements.push(current);
				}
			}
			return returnElements;
		};
	}
	return getElementsByClassName(className, tag, elm);
};

//this function display the net path 
function showThemenRoute(routeId) {
	if(!routeId){
		routeId= selPathId;
	}
	
	mdvJpMaps[currentMap].displayWaitDiv(true);
	mdvNetPath = new MDVNetPathHelper(routeId);
	mdvNetPath.displayNetPath();
    

}


function sendForm(){

    
    $('itdLPxx_poiSubCat').value = selSubCat;
    $('itdLPxx_poiCat').value = selCat;
    
    $('searchform').submit();

}


window.addEvent('domready', function() {

    //debugger;
    //$('header').style.width= document.documentElement.clientWidth + 'px';
    //$('searchbar').style.width= document.documentElement.clientWidth + 'px';

    resizeMap();

    if($('searchform')){
    	$('searchform').addEvent('submit', function(e) {
        
            $('itdLPxx_poiSubCat').value = selSubCat;
            $('itdLPxx_poiCat').value = selCat;
    	}); 
    }

    
    
    if($('linkto')){
        $('linkto').addEvent('focus', function(e) {
            this.select();
        }); 
    }
    
      if($('itdLPxx_poiCat') && $('itdLPxx_poiCat').value!=''){
        
        var savedCat = $('itdLPxx_poiCat').value.split(':');
        
        for(var i =0; i< savedCat.length -1; i++){
          
           var txt = savedCat[i].substring(0,1);
        
           var id = 'tabZieleLED-0-' + txt;
           var imgid = 'tabZieleLEDI-0-' + txt;;
           var hierarchy = txt;
   
          showPOISubCat(id, imgid, hierarchy)

        }
        
    }

	var sortStarted=false;
	var sort = new Sortables("item-list",
	{
		onStart: function() {
			this.clone.style.borderTop = "2px solid #000";
			this.clone.style.borderBottom = "2px solid #000";
		},	
		revert:true,
		constrain: true,
		clone: true,
		onSort: function(){sortStarted=true},
		onComplete: function() {
	
			if(sortStarted==true){
				mdvEventOnNewSortComplete(this.element)
			}
		}
	});

	
	 if($("overlayBg")) $("overlayBg").fade(0.5);
	initiate();  
    
    
	if($("myRoutesButton")) {
    
    
		var abox = $("anmeldebox");
		abox.fade("hide");
		abox.setStyle("display", "block");
		$("myRoutesButton").addEvent("click", function(e) {
			e.stop();
			abox.fade("in");
		});
        
        if($("myRoutesButtonTR")){
    		$("myRoutesButtonTR").addEvent("click", function(e) {
    			e.stop();
    			abox.fade("in");
    		});
        }
        
	}
    
    
	if($("myRoutesClose")) {
		$("myRoutesClose").addEvent("click", function(e) {
			e.stop();
			abox.fade("out");
		});
	}

    iTargets.init();
	
});

function addMyEvent(obj, eventType, func, useCaption)
{
	if(obj.addEventListener)
	{
		obj.addEventListener(eventType, func, useCaption);
		return true;
	}
	else if (obj.attachEvent)
	{
		var retVal = obj.attachEvent("on"+eventType, func);
		return retVal;
	}
	else
	{
		return false;
	}
}

addMyEvent(window, "resize", initiate, false);
addMyEvent(window, "load", initiate, false);
var lastSelectedRow = "";
