$(document).ready(function(){
  
  //menu-timeout-object
  /*var timeoutObject;
  
  
  //open menu when mouse enters
  $("#menu > li > a").mouseenter(function(){
    
    //kill all other slidedown-events when a new one is started
    clearTimeout(timeoutObject);
    
    var cur = $(this).parent();    
    timeoutObject = setTimeout( function() {

      
      $("#menu li").each(function(){
        
        if($(this).get(0) != cur.get(0)) {
          $(this).find("ul").slideUp("fast");
        }
      });      
  		
  		cur.find("ul").slideDown("fast");


    }, 500);
		
  });*/
  
  
  //messages akkordion
  $("#messages ul li:first-child p").slideDown("slow");
  
  $("#messages ul li h4 a").each(function(){
    $(this).attr("href", 'javascript:;');
  });
  
  $("#messages ul li h4 a").click(function(){
    
    $("#messages ul li p").each(function(){
      $(this).slideUp("fast");
    });
    
    $(this).parent().parent().find("p").slideDown("fast");
  });
  
  
  
  
  //get youtube-videos
  $("#media .videos a.readmore").before('<span class="loading">Laden...</span>');
  
  //check if it is the small or the big media-box
  var width = 72;
  if($("#media").hasClass("small"))
    width = 59;

  $.ajax({
    type: "GET",
  	url: "http://gdata.youtube.com/feeds/api/videos?max-results=6&alt=json&orderby=published&author=SPOEEU",
  	dataType: "jsonp",
  	success: function(json) {
      
      if(json.feed.entry != null) {
        for(i=0; i < json.feed.entry.length; i++) {
          curOb = json.feed.entry[i]
          $("#media .videos ul").append('<li><a href="'+curOb.link[0].href+'"><img width="'+width+'px" height="41px" src="'+curOb.media$group.media$thumbnail[3].url+'" alt="'+curOb.title.$t+'" /></a></li>');               
        }
      } 
      
      $("#media .videos .loading").hide();
  	}
  });  
  
  
  //wrapper around hr-tags 4 IE < 8
  if ($.browser.msie && $.browser.version.substr(0,1)<8) {
    $("hr").wrap('<div class="hr" />');
  }
  
  

});
