/*****************
/*****************
**
** Projekt: Felix Kirchner
**
/*****************
******************/




// Menu

function mainmenu(){
	
$(" #nav ul ul ").css({display: "none"}); // Opera Fix
$(" #nav ul li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).fadeIn(400);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
//		$(this).find('ul:first').css({visibility: "visible",display: "block"}).fadeOut(400);
		});
}

 
 
function rollOver(obj) {
	
	
	if (!obj.length && obj.find("img").length > 1) return;


	$(obj).each(function() {

	var hoverImg = $(this).find("img").eq(1);
		hoverImg.hide(0,function() {
			$(this).parent().hover(function() {
				var img = $(this).find("img");
				img.eq(0).hide();
				img.eq(1).show();
			},function() {
				var img = $(this).find("img");
				img.eq(1).hide();
				img.eq(0).show();
			});
		});
	});
} 
 
function slideShow(obj) {

	if (!obj.length) return;
	var images = obj.find("img");
	
	if (obj.find("img").length <= 1) return;
	images.hide();
	images.eq(0).fadeIn(10,function(i) {
		var imgHeight = $(this).height() ? $(this).height() : 150;
		var imgWidth = $(this).width() ? $(this).width() : 150;
		obj.animate({height:imgHeight,width:imgWidth},10);		
		var count = 0;
		obj.parent().find("p.loading").remove();
		function rotate() {
			images.eq(count).delay(3000).fadeOut(1000);
			(count < images.length -1 ) ? count++ : count = 0;
			images.eq(count).delay(3000).fadeIn(1000,function() {
				rotate();
			});
		}
		rotate();
	});
}
 
/* 
function loader(obj,callback,arg) {
	
	if (!obj.length) return;

	var loaded = $();
	obj.bind("load",function() {
		loaded = loaded.add($(this));
//		if (loaded.height() > 0) {
			if (loaded.length >= obj.length) {
				obj.parent().find("p").remove();
				if($.isFunction(callback)){
//					$("body").prepend("load: "+loaded.length);
//			 	  callback.call(this,arg);
					return;
				}
			}
//		}
	});

} 
 
 
 
 
 $("#myImg").one("load",function(){
//do something
})
.each(function(){
if(this.complete) $(this).trigger("load");
});
 ///////////////////////////////////////
 
 
 $(document).ready(function(){
    $('.image-box').each(function(){
        $(this).loadImage();
    });
   
});
   
(function($){
    $.fn.loadImage = function(){                 
        $(this).addClass('loading');
        $self = $(this);
        var img = new Image();
       
        $(img).load(function(){
            $(this).css('display', 'none');
            $self.removeClass('loading').append(this);
            $(this).fadeIn();
        }).attr({'src' : $self.find('input:hidden').val() });
    };
   
})(jQuery);

 
 
 
 */
 
 
 $(document).ready(function(){	
														
//	slideShow($(".slideshow"));
	mainmenu();
//$(".slideshow img").imagesLoaded(slideShow,$(".slideshow"))
//loader($(".slideshow img"),slideShow,$(".slideshow"));
});
 
$(window).load(function() { 
	slideShow($(".slideshow"));
//	$(".slideshow img").imagesLoaded(slideShow,$(".slideshow"))
	rollOver($("#row1_col2 a"));
});

 

