/**********************************************************/
/*  digiDock: Dock like cone effect						  */ 
/*	Copyright DIGIPETS 2009								  */
/*	Version 0.5										  */
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

//$(document).ready(function() {
	
function loadDigiDog(){
	
	
	
	$.fn.digiDock = function(o){
		o = $.extend({
			hoveredHeight: 66, //Height of the hovered element
			hoveredWidth: 20, //Width of the hovered element
			normalHeight: 40, //Height of the unhovered elements
			normalWidth: 16, //Width of the unhovered elements
			normalGFX: 'fileadmin/img/zeitstrahl_punkte.png', //Graphicpath for the normal Object graphic
			hoveredGFX: 'fileadmin/img/zeitstrahl_punkte_hover.png', //Graphicpath for the hovered Object graphic
			normalGFX_ie6: 'fileadmin/img/zeitstrahl_punkte.gif', //Graphicpath for the normal Object graphic
			hoveredGFX_ie6: 'fileadmin/img/zeitstrahl_punkte_hover.gif', //Graphicpath for the hovered Object graphic
			selectClass: 'Select', //The name of the select Class	 
			speed: 200
		}, o ||
		{});	
		
		var midWidth = Math.round((o.hoveredWidth + o.normalWidth) / 2), midHeight = Math.round((o.hoveredHeight + o.normalHeight) / 2), object = $(this), objectChild = $(this).children('li'), linkElement = objectChild.children("a"), fadeOutMultiplyer = 0;
		
		//Do IE6 Stuff
		jQuery.each(jQuery.browser, function(i, val) {
			if(i=="msie" && jQuery.browser.version.substr(0,1)=="6") {
				o.normalGFX = o.normalGFX_ie6;
				o.hoveredGFX = o.hoveredGFX_ie6;
				
				object.parent().parent().find('li a img').attr('src', o.normalGFX);
				object.parent().parent().find('li a.Select img').attr('src', o.hoveredGFX);
			}
		});
		
		$(this).find('li span').fadeOut(0);
		$(this).find('li a.' + o.selectClass).parent().find('span').fadeIn(0);
		$(this).find('li span:first').css('left', -10);
		$(this).find('li span:last').css('left', -80);
		
		linkElement.mouseover(function(){
			thisElement = $(this);
			$(this).parent().parent().find('li span').fadeOut(o.speed * fadeOutMultiplyer);
			$(this).parent().parent().find('li a img').attr('src', o.normalGFX);
			$(this).find('img').attr('src', o.hoveredGFX);
			$(this).parent().parent().find('li a img').stop().animate({
				width: o.normalWidth,
				height: o.normalHeight
			}, o.speed);
			$(this).find('img').stop().animate({
				width: o.hoveredWidth,
				height: o.hoveredHeight
			}, o.speed, function(){
				thisElement.parent().find('span').fadeIn(o.speed * fadeOutMultiplyer);
			});
			$(this).parent().next().find('a img').stop().animate({
				width: midWidth,
				height: midHeight
			}, o.speed);
			$(this).parent().prev().find('a img').stop().animate({
				width: midWidth,
				height: midHeight
			}, o.speed);
			
		});
		
		$(this).mouseleave(function(){
			$(this).find('li a img').stop().animate({
				width: o.normalWidth,
				height: o.normalHeight
			}, o.speed);
			$(this).find('li a.' + o.selectClass + ' img').stop().animate({
				width: o.hoveredWidth,
				height: o.hoveredHeight
			}, o.speed);
			$(this).find('li a').not('a.' + o.selectClass + '').find('img').attr('src', o.normalGFX);
			$(this).find('li a.' + o.selectClass + ' img').attr('src', o.hoveredGFX);
			$(this).find('li span').not('a.' + o.selectClass + '').fadeOut(o.speed * fadeOutMultiplyer);
			$(this).find('li a.Select').parent().find('span').fadeIn(o.speed * fadeOutMultiplyer);
		});
		/*
		linkElement.click(function(){
			object.find('li a').removeClass('Select');
			$(this).addClass('Select');
			return false;
		});
		*/
		
		
	}
	
	
	$('.STYLE_zeitstrahl div ul').digiDock({
		togglerHeight: 18,
		speed: 100
	});
}
//});
