$(function() {
/* 	if (document.all) { */
		$("ul#menu li").hoverFix();
/* 	} */
	$('img#watermark').positionWatermark();	
	
	$(window).resize(function() {
		$('img#watermark').positionWatermark();	
	});
	
	$('a#arrow-slides').click(function() {
		fadeSlides();
		return false;
	});
	
	$('a#arrow-text-1').click(function() {
		$('#text-content-1').fadeOut();
		$('#text-content-2').fadeIn();
		$('#arrow-text-1').fadeOut();
		$('#arrow-text-2').fadeIn();		
		return false;
	})
	
	$('a#arrow-text-2').click(function() {
		$('#text-content-1').fadeIn();
		$('#text-content-2').fadeOut();
		$('#arrow-text-1').fadeIn();
		$('#arrow-text-2').fadeOut();		
		return false;
	})

	$('#text-backdrop').css('display', 'block').fadeTo(0,0); 
 	$('#text-content').css('display', 'block').fadeTo(0,0);
	
	setTimeout(function() {	
		fadeSlides();
	}, 6000);	
	
	setTimeout(function() { 
		$('#text-backdrop').animate({opacity: 0.7}, 500); 
		$('#text-content').animate({opacity: 1}, 500); 
		$('#arrow-text-1').fadeIn();
		$('#text-content p#text-content-1').css('display', 'block').fadeTo(0,0).animate({opacity: 1}, 500);
	}, 2000);
	
});

/* IE6 hover workaround */
$.fn.hoverFix = function() {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass('hover-fix'); $('#debug').html('hover'); },
			function() { $(this).removeClass('hover-fix'); $('#debug').html(''); }
		);
	});
};	

/* fade instead of slides */

var currentSlide = 1;
var currentTimeout = 0;

function fadeSlides() {
	clearTimeout(currentTimeout);
	
	$('#slide'+currentSlide).fadeOut(2000);
	currentSlide++;
	if (currentSlide == 11)
		currentSlide = 1;
	$('#slide'+currentSlide).fadeIn(2000);
	
	currentTimeout = setTimeout(fadeSlides, 6000);
}


/* watermark Positioning for small screens */
$.fn.positionWatermark = function() {
	return this.each(function() {
		var h = $(window).height();
		if (h<676) {
			$(this).css('top', (h-272)+'px').css('bottom','');
		}
	})
}
