//@todo try / catch
jQuery(document).ready(function(){

	var i = 0;
	$('.ui-accordion div.i').each(function(a) {
			//$(this).slideUp();
			$(this).parent().children('h3').attr('stus', "active");

		i++;
	});

	i = 0;


	$('.ui-accordion h3').click(function(){
		cur_stus = $(this).attr('stus');
		if(cur_stus != "active")
		{
			//reset everthing - content and attribute
			//$('#accordion dd').slideUp();
			$('.ui-accordion h3').attr('stus', '');

			//then open the clicked data
			$(this).next().slideDown();
			$(this).attr('stus', 'active');
		}
		else {
			$(this).next().slideUp();
			$(this).attr('stus', '');
		}
		return false;
	});

	//Galerie
	$('.thumb-list a').click(function() {
    	var loadingDiv = $('#gallerywrapper .loadingIMG');
    	loadingDiv.fadeIn();
		$('.thumb-list a').each(function(index, elem) {
			$(this).removeClass('active');
		});
		var img = new Image();
		$(img).load(function () {
	    	$(this).hide();
	    	$('#gallerywrapper a.single_image').html(this);
	    	$(this).fadeIn();
	    	loadingDiv.fadeOut();
	    }).error(function () {
	        // error handler
	    }).attr('src', $(this).attr('href').split("|")[0] + "|185|148");
		$('#gallerywrapper a.single_image').attr('href', $(this).attr('href'));
		$(this).addClass('active');

		return false;
	});

	/*
	$('.thumb-list a').click(function() {

		$('.thumb-list a').each(function(index, elem) {
			$(this).removeClass('active');
		});

		$(this).addClass('active');

		$('#gallerywrapper a.single_image img').attr('src', $(this).attr('href').split("|")[0] + "|185|148");
		$('#gallerywrapper a.single_image').attr('href', $(this).attr('href'));

		return false;
	});
	*/

	$("a.single_image").fancybox({
		'type'	:	'image',
		'overlayShow' : false,
		'transitionIn' : 'elastic'
	});



	//DropDownNavi
	try {
		$('#dropdownNavi select').change(function() {
			if($(this).val() != "--- bitte wählen ---" || $(this).val() != "--- please select ---"){
				location.href = "/"+$(this).val();
			} else {
				return false;
			}
		});
	} catch (e) {};

});

function startLoader(){
	var loadingDiv = $('#gallerywrapper .loadingIMG');
	loadingDiv.css("display","block");
}
function stopLoader(){
	var loadingDiv = $('#gallerywrapper .loadingIMG');
	loadingDiv.css("display","none");
}
