var LiferayJedi = function () {
	var $ = jQuery;
	return {
		init: function() {			
			var instance = this;
			var n = $('#p_p_id_86_,#p_p_id_15_,#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();
				$('#featuredteaser,').toggle();
				$('#wrapper_left').css({width:"920px"});
			}
			
			$("#jobs .toggle").show().parent().contents().filter(".opener").attr("class","opener on");
			$('#clip').css({ overflow:"hidden", height:"190px" });
			$('#clap').css({overflow:"hidden",width:"550px"});
			
			/*var colorArr = new Array("","","lila","rot","blau","gruen","dunkelgruen","dunkellila") 
			var inst = $("a[class*='active'],[id^=['nav']").attr("id").substr(3);
			//alert(inst)
			var subm = $('#nav_sub'+ inst);
			var parentElem = $('#wrapper_left');
			parentElem.addClass(colorArr[parseInt(inst)]);
			subm.toggle(200);*/
			$("#jobs input").click(function(){
				$(this).val("")}).blur(function(){if($(this).val().length == 0)$(this).val("Schnellsuche")
			});
			
			$("#bar .opener").click(function(){
				$(this).next().filter(".toggle:visible").slideUp("fast").parent().contents().filter(".opener").attr("class","opener off");
				$(this).next().filter(".toggle:hidden").slideDown("fast").parent().contents().filter(".opener").attr("class","opener on");
			});
			
			$("#login_btn").click(function(){									
					var instance = $(this);
					var child = $('#login');
					instance.addClass("init");
					child.toggle(400);
					child.css(instance.position());
				}
			);
			$("#goto_btn").click(function(){									
					var instance = $(this);
					var child = $('#goto');
					instance.addClass("init");
					child.toggle(400);
					child.css(instance.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(400);
						child.css(instance.position());
					},
					out: function () {
												
					}
				}
			);
			
			$("#goto, .article_nav").hoverIntent({									
					interval: 25,
					timeout: 0,
					over: function () {
						var instance = $(this);
						var child = instance;
						//child.slideUp(50);
					},
					out: function () {
						var instance = $(this);
						var child = instance;
						//child.slideUp(50);
						instance.removeClass("init");
						child.hide(400);
					}
				}
			);
			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 < 2 ){
				$('#right li:nth-child(1) a').addClass('active');
				$('#right li:nth-child(2) a').removeClass('active');
				$('#right li:nth-child(3) a').removeClass('active');
			}else if( pos > 2 && pos < 6 ){
				$('#right li:nth-child(2) a').addClass('active');
				$('#right li:nth-child(1) a').removeClass('active');
				$('#right li:nth-child(3) a').removeClass('active');
			}else if ( pos == 6){
				$('#right li:nth-child(3) a').addClass('active');
				$('#right li:nth-child(1) a').removeClass('active');
				$('#right li:nth-child(2) a').removeClass('active');
			}
	}
});
$(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('cpp-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('cpp-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');});
			$("#site").pngFix();
		}
		$("#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();
	}
);
