var LiferayJedi = function () {
	var $ = jQuery;
	return {
		init: function() {
			var instance = this;
			$('#clip').css({ overflow:"hidden", height:"190px" });
			$('#clap').css({overflow:"hidden",width:"550px"});
			var n = $('#p_p_id_15_,#p_p_id_86_,#p_p_id_88_,#p_p_id_2_,#p_p_id_art_,#p_p_id_bp_articles_WAR_articlesportlet_,#p_p_id_2,#_8_description').length;
			if (n > 0) { 
				$('#wrapper_right').toggle();
				$('#wrapper_left').css({width:"100%"});
			}
			if($("a[class*='active'],[id^=['nav']").length > 0){
				var colorArr = new Array("","","lila","rot","blau","gruen","dunkelgruen","dunkellila") 
				var inst = $("a[class*='active'],[id^=['nav']").attr("id").substr(3);
				var subm = $('#nav_sub'+ inst);
				var parentElem = $('#wrapper_left');
				parentElem.addClass(colorArr[parseInt(inst)]);
				subm.toggle(200);
			}
			
			
			$("#goto_btn").click(function(){									
					$(this).addClass("init");
					$('#goto').toggle();
					$('#goto').css($(this).position());
				}
			);
			
			
			$(".cat_btn").hoverIntent({									
					interval: 25,
					timeout: 0,
					over: function () {
						var instance = $(this);
						var inst_id = instance.attr("id");
						//alert (inst_id);
						var child = $('#child_' + inst_id);
						instance.addClass("init");
						child.toggle(300);
						child.css(instance.position());
					},
					out: function () {
												
					}
				}
			);
			$(".article_nav, #goto").hoverIntent({
					interval: 25,
					timeout: 0,
					over: function () {
						
					},
					out: function () {
						$(this).removeClass("init");
						$(this).hide();
					}
				}
			);
			instance.dropDownMenu();
			
		},
		
		dropDownMenu: function() {
			
			$(".parent-nav-item").hoverIntent(
				{
									
					interval: 25,
					timeout: 0,
					over: function () {
						var instance = $(this);
						var child = $('.child-menu', this);
						instance.addClass("init");
						child.show();
						child.slideDown(100);
					},
					out: function () {
						var instance = $(this);
						var child = $('.child-menu', this);
						child.slideUp(50);
						instance.removeClass("init");
						child.hide();
					}
				}
				
			);
		}
	};
}();
jQuery.easing['BounceEaseOut'] = function(p, t, b, c, d) {
	if ((t/=d) < (1/2.75)) {
		return c*(7.5625*t*t) + b;
	} else if (t < (2/2.75)) {
		return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
	} else if (t < (2.5/2.75)) {
		return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
	} else {
		return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
	}
};
//Image Gallery						  
jQuery(function( $ ){
	var $prev = $('#ctrl a.s_prev'),//prev button
	$next = $('#ctrl a.s_next');//next button
	$('#clip').serialScroll({
		step:3,
		start:0,
		items:'li',
		axis:'y',
		jump: true,
		cycle:true,
		navigation:'#right li a',
		lock: true,
		constant:true,
		prev:'#ctrl a.s_prev',
		next:'#ctrl a.s_next',
		easing:'linear',
		onBefore:function( e, elem, $pane, $items, pos ){
		//if( pos == 0 )
		//$prev.hide();
		//else if( pos == $items.length-1 )
		//$next.hide();
	}
});
$(document).keyup(function(e){
  switch( e.keyCode ){
      	case 40://up (->)
       		$('#clip').trigger('next');
       	break;
       	case 38://down (<-)
       		$('#clip').trigger('prev');
       	break;
          }
     });
});
//Special
jQuery(function( $ ){
		  		  var $prev = $('#ctrl a.s_prev'),//prev button
		  		  $next = $('#ctrl a.s_next');//next button
		  		  $('#clap').serialScroll({
		  		  		step:2,
		  		  		start:0,
		  		  		items:'li',
		  		  		axis:'x',
		  		  		jump: true,
		  		  		cycle:true,
		  		  		navigation:'#rightx li a',
		  		  		lock: true,
		  		  		constant:true,
		  		  		prev:'#ctrl a.s_prev',
		  		  		next:'#ctrl a.s_next',
		  		  		easing:'linear',
		  		  		onBefore:function( e, elem, $pane, $items, pos ){
		  		  			//if( pos == 0 )
		  		  				//$prev.hide();
		  		  			//else if( pos == $items.length-1 )
		  		  				//$next.hide();
		  		  			}
		  		  	});



		  		  	$(document).keyup(function(e){
		  		          switch( e.keyCode ){
		  		          	case 39://right (->)
		  		          		$('#clap').trigger('next');
		  		          	break;
		  		          	case 37://left (<-)
		  		          		$('#clap').trigger('prev');
		  		          	break;
		  		          }
		  		      });
			});	
jQuery(document).ready(
	function() {
		var $ = jQuery;
		function checklogin1(){
			if($("#login").length > 0){
			if($("#login").val().length > 0)
				$("#login").css("background-image","none");
			else
				$("#login").css("background","#fff url('mav-theme/images/bg_login_email.gif') no-repeat -3px 0");
			if($("#password").val().length > 0)
				$("#password").css("background-image","none");
			else
				$("#password").css("background","#fff url('mav-theme/images/bg_login_password.gif') no-repeat -3px 0");
			}
		}
		function checklogin2(ele){ele.css("background-image","none");}
		checklogin1();
		$("#login,#password").focus(function(){checklogin2($(this))}).blur(function(){checklogin1()}).change(function(){checklogin1()})
		
		if(($.browser.msie) && ($.browser.version.number == 6)){
			$('input[type="submit"]').each(function(){$(this).addClass("submit")});
			$('input[type="checkbox"]').each(function(){$(this).addClass("checkbox")});
			$('input[type="radio"]').each(function(){$(this).addClass("radio")});
			$('input[type="submit"],input[type="button"],input[type="reset"],button').each(function(){$(this).addClass("button")});
			$('input[type="text"],input[type="password"]').each(function(){$(this).addClass("textfield")});
			$('img[align="left"]').each(function(){$(this).addClass("left")});
			$('img[align="right"]').each(function(){$(this).addClass("right")});
			$('img[alt="captcha"]').each(function(){$(this).addClass("captchaimg")});
			$("#nav_main li:not('.active')").hover(function(){$(this).addClass("hover")},function(){$(this).removeClass("hover")})
			$(".teaserlink").hover(function(){$(this).addClass('teaserlinkon');},function(){$(this).removeClass('teaserlinkon');});
			$(".tabs a").each(function(){$(this).addClass("test")});
			$("#site").pngFix();
		}	
		$("#content-wrapper label>input[type='checkbox']").parent().css("width","auto");
		$("#content-wrapper label>input[type='radio']").parent().css("width","auto");
		
		
		$("#site dl").each(function(){
			if($(this).parent().hasClass("logolist") == false){
				var maxwidth = $(this).children().find("img").width();
				$(this).children().find("img").each(function(){
					if($(this).width() > maxwidth){
						maxwidth = $(this).width();
					}
				});
				$(this).css("width",maxwidth);
			}
		});
		$(function() {
			$("a.zoom").lightBox();
		});
		LiferayJedi.init();
	}
);