jQuery.noConflict();

jQuery(document).ready(function() {
	jQuery("#leftMenu li").toggle();
	jQuery("#leftMenu li").slideDown(1000);

	/*
	jQuery("#claim").toggle();
	jQuery("#claim").fadeIn(1800);
	*/
	
	jQuery("#topMenu").css("marginLeft","0");
	jQuery("#topMenu").animate({marginLeft: "100px"},1000);
	
	jQuery("#body1 #imgBenniHead").css("width","0").css("height","0").css("marginTop","67px");
	jQuery("#body1 #imgBenniHead").animate({ width: "100px", height: "135px", marginTop: "0" }, 1000);
	
	/*
	jQuery("#imgBenniHead").mouseover( function(e) {
		jQuery("#imgBenniHead").css("width","0").css("height","0").css("marginTop","67px");
		jQuery("#imgBenniHead").animate({ width: "100px", height: "135px", marginTop: "0px" }, 500);
	});
	*/
	
	jQuery(".tx-bekomedia-pi1").toggle();
	jQuery(".tx-bekomedia-pi1").slideDown(1000);

	jQuery("#footerContent a").toggle();
	jQuery("#footerContent a").fadeIn(1800);

	/* old ver: */
	jQuery("div#topMenu ul li").mouseover( function() {
		jQuery(this).children("ul.topmenuSub").css("display","block");
	}).mouseleave( function() {
		jQuery(this).children("ul.topmenuSub").css("display","none");
	});
	/*
	jQuery("div#topMenu ul li").mouseover( function(e) {
		if ( e.pageY < 138 ) { // anti-flackern
			jQuery(this).children("ul.topmenuSub").slideDown(300);
			jQuery("select").addClass("ie6HiddenSelect");
			jQuery(".fadeP").addClass("ie67Hidden");
		}
	}).mouseleave( function() {
		jQuery(this).children("ul.topmenuSub").slideUp(300);
		jQuery("select").removeClass("ie6HiddenSelect");
		jQuery(".fadeP").removeClass("ie67Hidden");
	});
	*/
	
	jQuery(".boxLeftTopExpand").click(function() {
		var boxLeft = jQuery(this).parents(".boxLeft");
		boxLeft.children(".boxLeftContent").removeClass("hide");
		boxLeft.children(".boxLeftBottom").removeClass("hide");
		boxLeft.children(".boxLeftTopExpand").addClass("boxLeftTop").removeClass("boxLeftTopExpand");
	});
	// Menu Left:
	slide("#leftMenu ul", 12, 0, 100, .75);
	
	// Witze:
	jQuery(".bekojokes-listrow").mouseover(function() {
		jQuery(this).css("border","1px solid #cccccc");
	}).mouseleave(function() {
		jQuery(this).css("border","1px solid transparent");
	});
	
	// Witze - Paging:
	jQuery(".tx-bekojokes-pi1-browsebox a").mouseover(function() {
		jQuery(this).css("fontSize",22);
	}).mouseleave(function() {
		jQuery(this).css("fontSize",12);
	});
	
	// fade p
	jQuery(".fadeP").innerfade({ animationtype: 'fade', speed: 1500, timeout: 6000, type: 'sequence', containerheight: '2.2em' });
	
	// blogs + co:
	if ( !(typeof jQueryOnReadyActions === "undefined") ) {
		while ( readyAction = jQueryOnReadyActions.pop() ) {
			eval(readyAction);
		}
	}
	
	// Skills:
	jQuery(".skillCloud span").each(function(e) {
		jQuery(this).wrap('<a href="http://de.wikipedia.org/wiki/'+jQuery(this).text()+'" target="_blank" />');
	});
}); // end: func ready


// based on http://net.tutsplus.com/tutorials/javascript-ajax/how-to-create-a-mootools-homepage-inspired-navigation-effect-using-jquery/
function slide(navigation_id, pad_out, pad_in, time, multiplier) {
	// creates the target paths
	var list_elements = navigation_id + " li";
	var link_elements = list_elements + " a";
	
	// initiates the timer used for the sliding animation
	var timer = 0;
	
	// creates the slide animation for all list elements 
	if( jQuery.browser.msie!=true ) // not ie!
	jQuery(list_elements).each(function(i)
	{
		// margin left = - ([width of element] + [total vertical padding of element])
		jQuery(this).css("margin-left","-180px");
		// updates timer
		timer = (timer*multiplier + time);
		jQuery(this).animate({ marginLeft: "0" }, timer);
		jQuery(this).animate({ marginLeft: "15px" }, timer);
		jQuery(this).animate({ marginLeft: "0" }, timer);
	});

	// creates the hover-slide effect for all link elements 		
	jQuery(link_elements).each(function(i)
	{
		jQuery(this).hover(
		function()
		{
			jQuery(this).animate({ paddingLeft: pad_out }, 150);
		},		
		function()
		{
			jQuery(this).animate({ paddingLeft: pad_in }, 150);
		});
	});
}

function changeElementText(element, text) {
	document.getElementById(element).firstChild.data = text;
}

function chooseAim (link) {
	location.href = link; 
}

function expandGroup(group, prefix) {
	if (document.getElementById(group).style.display != "none") {
	  document.getElementById(prefix).firstChild.data = "+";
	  document.getElementById(group).style.display = "none"; 
	}
	else {
	  document.getElementById(prefix).firstChild.data = "-";
	  document.getElementById(group).style.display = "block"; 
	} 
}

function ShowDate() {
	var now = new Date();
	var day = now.getDate();
	var month = now.getMonth()+1;
	var year = now.getYear();
	if (day < 10) {day = '0' + day};
	if (month < 10) {month = '0' + month};
	if (year > 2000) {year = year - 2000};
	if (year > 100) {year = year - 100};
	if (year < 10) {year = '0' + year};
	document.write(day+'.'+month+'.'+year);
}

/* blogs: */
function handleHttpResponse(status, response) {
	function addLeadingZero( number ) {
		var result = number;
		if ( number < 10 )
			result = "0"+result;
		return result;
	}

	var ajax_entry = eval("(" + response + ")");
	if ( document.getElementById("tx_bekomedia_blogs_title"+ajax_entry.blogid) && document.getElementById("tx_bekomedia_blogs_date"+ajax_entry.blogid) ) {
		document.getElementById("tx_bekomedia_blogs_title"+ajax_entry.blogid).innerHTML = ajax_entry.lastentry_title;
		document.getElementById("tx_bekomedia_blogs_date"+ajax_entry.blogid).innerHTML = ajax_entry.lastentry_time;
	}
	if ( document.getElementById("tx_bekomedia_blogs_lastupdatetime") ) {
		var currentDate = new Date();
		var currentDay = addLeadingZero(currentDate.getDate());
		var currentMonth = addLeadingZero(currentDate.getMonth()+1);
		var currentYear = addLeadingZero(currentDate.getFullYear()-2000);
		var currentHours = addLeadingZero(currentDate.getHours());
		var currentMinutes = addLeadingZero(currentDate.getMinutes());
		document.getElementById("tx_bekomedia_blogs_lastupdatetime").innerHTML = currentDay+"."+currentMonth+"."+currentYear+" um "+currentHours+":"+currentMinutes+"h";
	}
}