/* Document Ready Functions */
jQuery(document).ready(function(){
	jQuery("ul.top li").each(function(){
		var idName = jQuery(this).text();
		if(jQuery("#"+idName).length>0){
			jQuery(this).hover(function(){
				jQuery(".dropdownItems").hide();
				jQuery(".dropdownImage").css("background-image",'url('+jQuery("#"+$(this).text()+" .dropdownPlaceholderImage").text()+')');
				var dropMenuLeftPos = Math.ceil(jQuery(this).position().left)-145+"px";
				jQuery(".dropdown").show();
				jQuery("#"+$(this).text()).css("margin-left",dropMenuLeftPos).show();
				if(jQuery("video").length>0){
					jQuery("video").hide();
				}
			},
			function(){
				jQuery(".dropdown").delay(200).hide();
			});
		}
	});
	
	jQuery(".dropdown").hover(function(){
		jQuery(".dropdown").show();
	},
	function(){
		jQuery(".dropdown").delay(200).hide();
	})

	/********************/
	/** IE z-index fix **/
	/********************/

	if(jQuery.browser.msie == true && parseInt(jQuery.browser.version) < 8)
	{
		var zIndexNumber = 1000;
		jQuery('div').each(function() {
			var $this = jQuery(this);
			if($this.attr('class')==='backgroundMedia' || $this.attr('class')==='backgroundContent'){
				$this.css('zIndex', 10);
			} else {
				$this.css('zIndex', zIndexNumber);
				zIndexNumber += 10;
			}
		});
	}
	
	jQuery("#musicControl a").toggle(
		function(){
			sendToActionScript('mute');
			jQuery(this).text("Music Off");
		},
		function(){
			sendToActionScript('unmute');
			jQuery(this).text("Music On");
		}
	);
});

//Function call to flash media player
function sendToActionScript(value) {
	document.getElementById("movie").sendToActionScript(value);
}

/* Cufon styling */
Cufon.replace(".content h1");
Cufon.replace(".content.text2 h2");
