$(document).ready(function(){

$('header').find('section').find('ul').find('li').find('a').hover(function() {
    $(this).stop().animate({ color: '#990000' }, 600);
},function() {
    $(this).stop().animate({ color: '#3e3c3c' }, 1000);
});
$('footer').find('ul').find('li').find('a').hover(function() {
    $(this).stop().animate({ color: '#3e3c3c' }, 600);
},function() {
    $(this).stop().animate({ color: '#990000' }, 1000);
});
$('#lang').find('a').hover(function() {
    $(this).stop().animate({ color: '#990000' }, 600);
},function() {
    $(this).stop().animate({ color: '#3e3c3c' }, 1000);
});
$('#request-form').find('a').hover(function() {
    $(this).stop().animate({ color: '#3e3c3c' }, 600);
},function() {
    $(this).stop().animate({ color: '#990000' }, 1000);
});

    $resize = $('img', '#bgslide').add($('#bgslide'));
	$imgs = $resize.filter('img');
	var imgWidth = 1180;
	var imgHeight = 845;
	var resize = function() {
		var width = $window.width();
		var height = $window.height();
		var newWidth = 0
		var newHeight = 0;
		newWidth = width;
		newHeight = newWidth * imgHeight / imgWidth;
		if (newHeight < height) {
			newHeight = height;
			newWidth = newHeight * imgWidth / imgHeight;
		}
		$resize.css({
			width: newWidth,
			height: newHeight
		});
		imgWidth = newWidth;
		imgHeight = newHeight;
	};
	$window = $(window);
	$window.resize(resize);
	resize();
	var next = 0;
	var prev = 0;
	var total = $imgs.length;
	$imgs.css({
		opacity: 0,
		zIndex: -total
	});
	var slideNext = function() {
		prev = next-1;
		if (prev < 0) prev = total-1;
		$prev = $imgs.eq(prev);
		$next = $imgs.eq(next);
		$prev.css({zIndex: -total-1 }).fadeTo(1000, 0);
		$next.css({zIndex: -total+1 }).fadeTo(1000, 1);
		if (++next >= total) {
			next = 0;
		} 
	};
	slideNext();
	setInterval(slideNext, 5000);

	if (window.soundManager) {
		soundManager.url = 'img_home/soundmanager/';
		soundManager.flashVersion = 9;
		soundManager.useFlashBlock = false;
		soundManager.useHTML5Audio = true;
		soundManager.onready(function() {
		    if (soundManager.supported()) {
		    	var musicFile = 'img_home/Kiss_The_Bride.mp3';
		        soundManager.createSound('music', musicFile);
		        soundManager.play('music');
		    }
		});
	}
});
