$(document).ready(function() {
	$('#load').remove();
	
	$("img.a").hover(
		function() {
		$(this).stop().animate({"opacity": "0"}, "normal");
		},
		function() {
		$(this).stop().animate({"opacity": "1"}, "normal");
	});


	var hash = window.location.hash.substr(1);
	var href = $('.menuNavi a').each(function(){
		var href = $(this).attr('href');
		if(hash==href.substr(0,href.length-5)){
			var toLoad = hash+'.html #mainContent';
			$('#mainContent').load(toLoad)
		}											
	});

	$('.menuNavi a').click(function(){
		var toLoad = $(this).attr('href')+' #mainContent';
		//alert(toLoad);
		//$('#mainContent').hide('fast',loadContent);
		$('#mainContent').fadeOut('normal',loadContent);
		$('#load').remove();
		//$('#wrapper').append('<span id="load">LOADING...</span>');
		$('#load').fadeIn('normal');
		window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);
		
		//alert(toLoad);
		function loadContent() {
			$('#mainContent').load(toLoad,'',showNewContent())
		}
		function showNewContent() {
			///$('#mainContent').show('normal',hideLoader());
			$('#mainContent').fadeIn('normal',refreshPage());
		}
		function hideLoader() {
			$('#load').fadeOut('normal');
		}
		function refreshPage(){
			hideLoader();
			if (window.location.hash=="#index"){
				initHome();
			}
		}
		
		return false;
		
	});
	
	
	
	updatePuff();
 	//initHome();


	

})


function initHome(){
	$('#homeWedding').animate({
		top: '+=20',
	  }, 1000);
							   
	$('#homeLove').animate({
		left: '+=20',
	  }, 1000);
	
	$('#homeSweet').animate({
		left: '-=20',
	  }, 1000);
}

window.setInterval(function() {
    updatePuff();
}, 1000);


function updatePuff(){
	$('.smokeSpawnPointClass').each(function(){
	$(this).css({ 'top':randomXToY(0,150),
		 'left': randomXToY(0,980),
		});
	});
}
function randomXToY(minVal,maxVal,floatVal){
  var randVal = minVal+(Math.random()*(maxVal-minVal));
  return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
}


	SmokeEffect.imgLocation = "images/love.png";
	SmokeEffect.smokeWidth = 50;
	SmokeEffect.smokeHeight = 46;
	
	SmokeEffect.makeEffect("smokeSpawnPoint1", 24, 12);
	SmokeEffect.makeEffect("smokeSpawnPoint2", 24, 12);
	SmokeEffect.makeEffect("smokeSpawnPoint3", 24, 12);
	SmokeEffect.makeEffect("smokeSpawnPoint4", 24, 12);
	SmokeEffect.makeEffect("smokeSpawnPoint5", 24, 12);
	
//var Shadowbox = window.parent.Shadowbox;
Shadowbox.init();

function openVideo(content, myWidth, myHeight){
    Shadowbox.open({
        content:    content,
		player : 'flv',
		width: myWidth,
		height: myHeight
    });
}

/*
Shadowbox.init({
    // let's skip the automatic setup because we don't have any
    // properly configured link elements on the page
    skipSetup: true
});

function viewPhoto(photoPath){
	Shadowbox.open({
        content:    photoPath,
		player:     "image"
    });

}
*/
