var $j = jQuery.noConflict();
$j(document).ready(function() {

$j('.tipsy a').tipsy({gravity: $j.fn.tipsy.autoNS});

// Prettyphoto init
$j("a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'fast',theme:'dark_rounded',slideshow:10000, autoplay_slideshow: false});

$j(".prettygallery img, .image img, .main-post-image img, ul.bottom-social li a").fadeTo("slow", 1); // This sets the opacity of the thumbs to fade down to 60% when the page loads

$j(".prettygallery img, .image img, .main-post-image img, ul.bottom-social li a").hover(function(){
	$j(this).fadeTo("slow", 0.6); // This should set the opacity to 100% on hover
},function(){
	$j(this).fadeTo("slow", 1); // This should set the opacity back to 60% on mouseout
});
		
//Hide (Collapse) the toggle containers on load
$j(".toggle_container").hide();

//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
$j("h2.trigger").click(function(){	$j(this).toggleClass("active").next().toggle(); });
$j('.box-content ul > li > ul').parent().addClass('has-sub-menu');

//Go to top
$j('a.go_top').click(function(){$j('html, body').animate({scrollTop: '0px'}, 300);return false;});

//No margin - featured box
$j(".featured-area-content .featured-box:nth-child(4n), .horizontal-widgets-holder .box:nth-child(4n)").addClass("last-featured");

//No background - menu
$j(".main-menu li:last-child, .tour-holder ul.simpleTabsNavigation li:last, ol.commentlist li:last-child").addClass("last");

<!-- Div clear after boxes (added on 10.02.2011) -->
$j('div.horizontal-widgets-holder .box:nth-child(4n)').after('<div class="clear"></div>');

$j(".box-content ul li a, .tour-holder ul.simpleTabsNavigation li a,.menu_vertical_container ul li a,#leftNavi ul li a").hover(function(){
	$j(this).stop().animate({ paddingLeft: '10px'}, 300);	
}, function() {
	$j(this).stop().animate({ paddingLeft: '1px'}, 300);
});

$j(".box ul.social li a").hover(function(){
	$j(this).stop().animate({ paddingLeft: '60px'}, 300);	
}, function() {
	$j(this).stop().animate({ paddingLeft: '42px'}, 300);
});
	
	function cDebug(obj){
		if(typeof console!='undefined')
			console.log(obj)
	}

	var anfrageform=$j('#verfuegbarkeitsanfrage');
	cDebug(anfrageform)
	if(anfrageform){
		cDebug('Form gefunden')
		var sendok=true;
		function chkInputs(form){
			cDebug('checkform')
			var inputs_required=$j('#verfuegbarkeitsanfrage .required');
			cDebug(inputs_required)
			var inputs_required_once=$j('#verfuegbarkeitsanfrage .required_once');
			cDebug(inputs_required_once)
			inputs_required.each(function(input){
				if(input.value==''){
					var id=input.id;
					sendok=false
					input.setStyle('border-color','red');
					var input_label=$j('label[for='+id+']')[0];
					var label_text=input_label.html;
					input_label.html=label_text+' ?';
				}
			})
			var inputtext='';
			inputs_required_once.each(function(input){
				inputtext=inputtext+input.value;
			})		
	
			if(inputtext==''){
			sendok=false
			var inputs_required_once=form.getElements('.required_once');
				inputs_required_once.each(function(input_field){
					console.log('input zimmer')
					console.log(input_field)
					if(input_field.get('value')==''){
						var id=input_field.id;
						console.log('keine Zimmeranzahl bei '+id) 
						input_field.setStyle('border-color','red');
						var input_label=$j('label[for='+id+']')[0];
						var label_text=input_label.html;
						input_label.html=label_text+' ?';
					}
				})				
			}

		}	
		$j('#check_kontingent').click(function(ev){
			cDebug('check_kontingent clicked')
			ev.stopPropagation();
			chkInputs(anfrageform);
			//if(sendok)
			//anfrageform.submit();			
		})	
	}


});





