var log = function(str) {
	if (typeof console != 'undefined' && console != null) console.log(str);
}

jQuery(document).ready(function(){

	// slider flex content
	$('.slide-content > iframe').each(function(i) {
			$(this).parent().attr("lang", $(this).attr("src"));
			$(this).attr("src", "about:blank");
		});
	
	$('a.slide-more').click(function(){
			$(this).parent('.item').children('.slide-content').slideToggle('normal', function() {
					var src = $(this).attr("lang");
					
					if (src != "") {
						$(this).children('iframe').attr("src", src);
						$(this).attr("lang", "");
					}
					else {
						$(this).attr("lang", $(this).children('iframe').attr("src"));
						$(this).children('iframe').attr("src", "about:blank");
					}
				});
			$(this).toggleClass('active');
		});
	
	// pic positioning
	var pic = $('.banner-pic img');
	var calc = - ((pic.width() - 960) / 2 );
	
	pic.css('left', calc + 'px');
	$('.banner-pic').css('height', pic.height() + 'px');
	
	
	var picWide = $('.content-wide img');
	var calcWide = - ((picWide.width() - 960) / 2 );
	
	picWide.css('left', calcWide + 'px');
	$('.content-wide').css('height', picWide.height() + 'px');

	// language
	$('#lang-select').click(function(){
		$('ul.language').toggle();
	});

	jQuery('#photo').galleryView({
			panel_width: 960,
			panel_height: 400,
			transition_speed: 3000,
			transition_interval: 7000,
			border: '0px',
			pause_on_hover: false,
			background_color: 'transparent'
		});	
	

	// rotation
	/*jQuery('div.jq_gallery').each(function(i) {
		new Teaser(jQuery(this));
	});*/

});

	

function Teaser(container) {
	var instance = this;
	this.debug = false;
	this.container = container;

	this.interval = null;
	this.current = null;

	this.t_pause = 1000 * 7; 
	this.t_animation = 3000;

	this.next = function() {
		this.current = jQuery("> div:last", this.container);
		jQuery('img', this.current).fadeOut(
			this.t_animation, 
			function() {
				instance.sort();
			}
		);
	}

	this.sort = function() {
		this.container.prepend(this.current);
		jQuery('img', this.current).show();
		this.start();
	}

	this.start = function() {
		clearInterval(this.interval);
		this.interval = setInterval(function() {instance.next()}, this.t_pause);
		
	}

	this.start();
}
