$(window).bind("unload", function() {});

function newsSwitch(carousel, item, idx, state){
	var numUp=idx%$.newsTotal;
	if(numUp==0){ numUp=$.newsTotal; }
	$('#nc_ctext').html("NEWS "+numUp+"/"+$.newsTotal);
}

function kampSwitch(carousel, item, idx, state){
	var numUp=idx%$.kampTotal;
	if(numUp==0){ numUp=$.kampTotal; }
	$('#nc_ctext').html("BILD "+numUp+"/"+$.kampTotal);
}



$(document).ready(function() {			   
	
	$.newsTotal=$('#news_carousel li').length;
	$.kampTotal=$('#right_carousel.kamp_car li').length;
	
	$('#news_carousel').jcarousel({
		scroll : 1 ,
		wrap : 'circular' ,
		itemVisibleInCallback: { onBeforeAnimation: newsSwitch }
	});
	
	$('#right_carousel.rn_car').jcarousel({
		scroll:1 , 
		wrap : 'circular' 
	});
	
	$('#right_carousel.kamp_car').jcarousel({
		scroll:1 , 
		itemVisibleInCallback: { onBeforeAnimation: kampSwitch }
	});
	
	$('#submenu').hide();
	
	$('a.mm_ob').each(function(){
		var id=$(this).attr('id');
		if($.loc.indexOf(id)==0){
			$(this).addClass('chosen');
			if($.loc.indexOf("0X6")==0){ 
				$('#submenu').show();
			}
		}else{
			$(this).hover(function(){ $(this).toggleClass('chosen'); });
		}
	}).hide();
	
	$('div.landing_link').hover(function(){ $(this).toggleClass('chosen') });
	
	
	$('#nc_next').click(function(){ 
	if($('.jcarousel-next').hasClass('jcarousel-next-disabled')){
			window.location.href=$('#nextpageref').html().replace("&amp;","&");
		}else{
			$('.jcarousel-next').click();
		}
	})
	$('#nc_prev').click(function(){ 
		if($('.jcarousel-prev').hasClass('jcarousel-prev-disabled')){
			window.location.href=$('#prevpageref').html().replace("&amp;","&");
		}else{
			$('.jcarousel-prev').click();
		}
	})
	
	$('div.hk_text').hide().parent().hover(function(){
		$(this).children('.hk_text').slideToggle();
													});
	$('.hover').hover(function(){$(this).imH();}).each(function(){ $(this).preLoad(); });
	whenload();
	
	$('#anmelde_img').hover(function(){
		$(this).animate({width : '370px' , height : '297px'}, 100);
									 },function(){
		$(this).animate({width : '115px' , height : '92px'}, 100);
									 });
	$('.hk_uholder').hover(function(){
		$(this).fadeTo(200,1);
		},function(){
		$(this).fadeTo(200,0.3);
	}).fadeTo(1,0.3);
	
	$('.hp').hide();
	$('.send').click(function(){
		$.send=true;
		
		$('.form_in').each(function(index){
		if($(this).attr('name').indexOf('*')>0){
		  if($(this).val().length<2){
			$.send=false;
			$(this).css("background","#a40a0a");
		}else{
			$(this).css("background","#cccbb7");
		}
			}
		  });
	if($('.hp').val().length>0){
		$.send=false;
	}
	if($.send){
		$('.form_in[name*="*"]').each(function(){
			$(this).attr('name',$(this).attr('name').replace('*',''));
		});
		$('form').submit();
	}
	 });
	
	$('div.rc_con img:first').hide();
	
});

function whenload(){
	if($('.col_left').height() < $('.col_right').height()){
		$('.col_left').height($('.col_right').height());
	}else if($('.col_left').height() > $('.col_right').height()){
		$('.col_right').height($('.col_left').height());
	}
	$('a.mm_ob').delay(1000).show();
	var facesrc="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2FHELDISCH%2F113977751979372%3Fref%3Dts&layout=button_count&show_faces=false&width=115&action=like&font&colorscheme=light&height=21";
	
	$('#facebook').attr('src',facesrc);
	$('div.rc_con').each(function(i){
		var th=$(this).innerHeight();
		var ih=$(this).children('img:first').height();
		$(this).children('img:first').css('margin-top',Math.floor((th-ih)/2)+"px").show();
	});
}
												

$(window).load(function () {
	whenload();
	setTimeout('whenload()',500);
});
