$(document).ready(function(){	
	$('#nav>ul#mainNav>li>a,#media,.giftCard').ezjax({	
		container: '#contentHolder',
		initial: anchorInt(),//'home.html',
		effect: 'fade'//,bind: 'a'
	});
	
	$(".colorbox").colorbox();
	$(".iframe90").colorbox({width:"90%", height:"90%", iframe:true});
	$(".iframeSm").colorbox({width:"500px", height:"400px", iframe:true});
	$(".iframeSmT").colorbox({width:"500px", height:"90%", iframe:true});
});

function jsInitiateBubbles(){
	try {
		var swf = swfobject.getObjectById("bubbles");
		var bubLoc;
		if (swf) {
			var theUrl = document.location.toString();
			if (theUrl.match('#') && (theUrl.split('#')[1] != ''))
				bubLoc = "#"+theUrl.split('#')[1];
			else
				bubLoc = "#home";
			swf.initiateBubbles($(bubLoc).position().left,$(bubLoc).width());
		}
	} catch(exception) {
		//alert(exception);
	}
}

// Gets the current page anchor (if it exists) and sets that page to be loaded
function anchorInt(){
	var theUrl = document.location.toString();
	if (theUrl.match('#') && (theUrl.split('#')[1] != ''))
		return(theUrl.split('#')[1]+'.html');
	else
		return("home.html")
}
function anchorFunc(newAnchor){
	var theUrl = document.location.toString();
	if (theUrl.match('#'))
		theUrl = theUrl.split('#')[0]+"#"+newAnchor;
	else
		theUrl = theUrl+"#"+newAnchor;
	window.location.href = theUrl;
}

function clickLink(theLink){
	try {
		var swf = swfobject.getObjectById("bubbles");
		if (swf) {
			swf.changeBubbles($(theLink).position().left,$(theLink).width());
		}
		var swf2 = swfobject.getObjectById("clawHingeD");
		if (swf2) {
			swf2.clickClaws();
		}
	} catch(exception) {
		//alert(exception);
	}
}

jQuery(function( $ ){
	// Move the bubbles
	$('#nav>ul#mainNav>li>a').click(function(){
		/*try {
			var swf = swfobject.getObjectById("bubbles");
			if (swf) {
				swf.changeBubbles($(this).position().left,$(this).width());
			}
			var swf2 = swfobject.getObjectById("clawHingeD");
			if (swf2) {
				swf2.clickClaws();
			}
		} catch(exception) {
			//alert(exception);
		}*/
		clickLink(this);
		anchorFunc($(this).attr("id"));
		//document.getElementById("bubbles").changeBubbles(600,200);
	});
	
	$('#media').click(function(){
		/*try {
			var swf = swfobject.getObjectById("bubbles");
			if (swf) {
				swf.changeBubbles($("#more").position().left,$("#more").width());
			}
		} catch(exception) {
			//alert(exception);
		}*/
		clickLink("#more");
		anchorFunc("media");
	});
	$('.giftCard').click(function(){
		clickLink("#more");
		anchorFunc("giftCards");
	});
	
	$("#more,#media,.giftCard.DD").click(function () {
		//$("#more>ul").hide("slide", { direction: "up" }, 700);
		$("#more>ul").slideToggle(300);
		/*$("#more").hover( 
			function() {}, 
			function() { 
				$("#more>ul").hide("slide", { direction: "up" }, 300);
			} 
		);*/
		return false;
	});
	
	//	HIDE THE NAV UNTIL THE PAGE HAS FULLY LOADED
	//$("ul.nav").show();

});