/* ****************** Slideshow on frontpage ******************  */
$(document).ready(function() {
	var stack = [];

	// preload images into an array; we will preload slide03.jpg - slide13.jpg
	for (var i = 3; i < 14; i++) {
		var img = new Image(347,331);
		img.src = 'img/slideshow/slide' + i + '.jpg';
		$(img).bind('load', function() {
			stack.push(this);
		});
	}
	
	// start slideshow
	$('#slideshow01').cycle({
		timeout: 4000,
		before: onBefore
	});
	
	// add images to slideshow
	function onBefore(curr, next, opts) {
		if (opts.addSlide) // <-- important!
			while(stack.length)
				opts.addSlide(stack.pop());
	};
}); 	// END slideshow


/* ****************** Round corners ******************  */

$(function() {
	$('.rounded').wrap(
		'<div class="rounder">'+
		'</div>');
	$('.rounder').prepend(
		'<i class="corner1"></i>'+
		'<i class="corner2"></i>'+
		'<i class="corner3"></i>'+
		'<i class="corner4"></i>'
	);
});

$(function() {
	$('.rounded1').wrap(
		'<div class="rounder1" id="tabs-1">'+
		'</div>');
	$('.rounder1').prepend(
		'<i class="corner2"></i>'+
		'<i class="corner3"></i>'+
		'<i class="corner4"></i>'
	);
});

$(function() {
	$('.rounded2').wrap(
		'<div class="rounder2" id="tabs-2">'+
		'</div>');
	$('.rounder2').prepend(
		'<i class="corner2"></i>'+
		'<i class="corner3"></i>'+
		'<i class="corner4"></i>'
	);
});

$(function() {
	$('.rounded3').wrap(
		'<div class="rounder3" id="tabs-3">'+
		'</div>');
	$('.rounder3').prepend(
		'<i class="corner2"></i>'+
		'<i class="corner3"></i>'+
		'<i class="corner4"></i>'
	);
});


/* ****************** Gallery fade ******************  */

$(function(){
	$(".gallery li img").fadeTo(0, 0.3); // This sets the opacity of the thumbs to fade down to 30% when the page loads
	$(".gallery").css('color', '#888888')

	$(".gallery li").hover(function(){
		$(this).children("img").stop().fadeTo(300, 1.0); // This should set the opacity to 100% on hover
		$(this).stop().animate({ color: "#111111" }, 300);
	},function(){
   		$(this).children("img").stop().fadeTo(500, 0.3); // This should set the opacity back to 30% on mouseout
   		$(this).stop().animate({ color: "#888888" }, 500);
	});
});


/* ********* Change large image on thumbnail click in gallery  ********  */
$(document).ready(function(){
	$(".thumbnails li img").each(function(){
		$(this).click(function(){
			var src = $(this).attr("src").replace("thumbs", "big"); // change source path
			$(this).closest("div").find(".big-img").attr({src: $(this).attr("swap")});
			
		});
	});
});


/* ****************** Swap tabs ******************  */
$(function() {
    $('body.tabs #tabs-wrapper').tabs();
    $('body.tabs .rounded2').tabs();
    $('body.tabs .rounded1').tabs();
   
});



/* ********* Show labels over input fields ********  */

$(document).ready(function() {
	 $("label.overlabel").overlabel();
});

/* ********* Swap tabs and use links for radio buttons  ********  */

$(function() {
	$(".weddings.design a[href='#tabs-1']").click( function(){
		if($(".weddings.design a[href='#tabs-2']").hasClass('selected')) {
		  $(".weddings.design a[href='#tabs-2']").removeClass('selected');
		}		
		$(this).addClass('selected');		
		$('input#rbText').click();
		return false;
	});
	$(".weddings.design a[href='#tabs-2']").click( function(){
		if($(".weddings.design a[href='#tabs-1']").hasClass('selected')) {
		  $(".weddings.design a[href='#tabs-1']").removeClass('selected');
		}
		$(this).addClass('selected');
		$('input#rbHearts').click();
		return false;
	});
});






