$(document).ready(function(){
	
   // Keyvisual-Rotation
   $(".headnavi").css("background-image","none");
   $("#keyvisuals img").show();
   $('#keyvisuals').cycle({ 
	    delay:  100, 
	    speed:  2000	   
	});	
	
	
	// Veranstaltungs-Modul
	
	if($("#map_welt").length > 0) {
		var mapImgPath = $("#map_welt").attr("src");
		var mapImgPrePath = mapImgPath.substr(0,mapImgPath.indexOf("-")+1)
	}
	var arrAreas = new Array("nordamerika","suedamerika","europa", "asien", "afrika", "australien");
		
	if($("#map_welt").length > 0) {
		if($("#continentCard").attr("class") != undefined) {
			$("#map_welt").attr("src",mapImgPrePath + $("#continentCard").attr("class")); 
		} else {
			$("#map_welt").attr("src",mapImgPrePath + "welt");
		}    
    }	
	$("area").mouseover(function(){		
      	showTooltip("d"+$(this).attr("id").substring(5));		
		$("#maps img").attr("src",mapImgPrePath + arrAreas[$(this).attr("id").substring(5)-1]);		
	    }).mouseout(function(){
	      hideTooltip();
	      if($("#continentCard").attr("class") != undefined) {
			$("#map_welt").attr("src",mapImgPrePath + $("#continentCard").attr("class")); 
		  } else {
			$("#map_welt").attr("src",mapImgPrePath + "welt-mouseover");
		  }
	  });
	
	//Highlighting
	$(".card").mouseover(function(){	
	  $("area").removeAttr("alt");		  
	  if ($(this).find("#maps img").attr("src") == mapImgPrePath + "welt") {
	  	$(this).find("#maps img").attr("src", mapImgPrePath + "welt-mouseover");
	  }
	  	$(".containerBox .events table").css({
	  		"background-image":"url(/bmwa/images/eee/bg_eventlist_1.gif)","background-color":"#f5f0ec"
		});
	    }).mouseout(function(){
	      if ($(this).find("#maps img").attr("src") == mapImgPrePath + "welt-mouseover") {
	      	$(this).find("#maps img").attr("src", mapImgPrePath + "welt");
	      }
		  $(".containerBox .events table").css({
			"background-image":"url(/bmwa/images/eee/bg_eventlist_0.gif)","background-color":"#fcfaf8"
		  });
	  });	  
	  
	  	
	//Highlighting
	$(".cal").mouseover(function(){		
      $(this).css("background-image","url(/bmwa/images/eee/bg_kalender_1.gif)");
	  $(".containerBox .events table").css({
	  		"background-image":"url(/bmwa/images/eee/bg_eventlist_1.gif)","background-color":"#f5f0ec"
		});
	    }).mouseout(function(){
	      $(this).css("background-image","url(/bmwa/images/eee/bg_kalender_0.gif)");
		  $(".containerBox .events table").css({
			"background-image":"url(/bmwa/images/eee/bg_eventlist_0.gif)","background-color":"#fcfaf8"
		  });
	    });	
	

	$("td.event").mouseover(function(){
     	$(this).children("input").css({
	  		"background-color":"#b94907","color":"#fff"
		});	  
		$(this).children(".tooltip").show();
    }).mouseout(function(){
     	$(this).children("input").css({
		  	"background-color": "#f2dabd","color":"#b94907"
	  });
	  $(this).children(".tooltip").hide();	  
    });	
    
    $("td.past input").attr("disabled","disabled");	
    
    var tooltip = null;				
	var map = null;
	document.onmousemove = updateTooltip;
	
	function updateTooltip(e) {
		
		try {
			if(document.all){
				x=window.event.x + document.body.scrollLeft;
				y=window.event.y + document.body.scrollTop;
				if (tooltip != null) {
					tooltip.style.left = (x - 70) + "px";
					tooltip.style.top = (y + 30) + "px";					
				}
			} else {
				x=e.pageX;
				y=e.pageY;
				if (tooltip != null) {
					tooltip.style.left = (x - 295) + "px";
					tooltip.style.top = (y - 130) + "px";					
				}
			}
		} catch (error) { error=null; }
	}
	function showTooltip(id) {
		try {			
			tooltip = document.getElementById(id);
			tooltip.style.display = "block"
		} catch (error) { error=null; }
	}
	function hideTooltip() {
		try {
			tooltip.style.display = "none";
		} catch (error) { error=null; }
	}
		
	if($.browser.msie) {
		var eventsTitle = $("h3.veranstaltungstool");
		eventsTitle.css("display","none");
		$("th.spalte-1 span").css("display","none");
		$("th.spalte-1").append("<h3 style='margin:13px 0 0 13px'>" + eventsTitle.text() + "</h3>");
	}

 });

