//jkmegamenu.definemenu("anchorid", "menuid", "mouseover|click")
jkmegamenu.definemenu("megaanchor", "megamenu1", "mouseover")
var oCurrentTrigger;

function fToggleFlash(){
	var $objFlash = $("#cubeidle object");
	$objFlash.each(function(){
		this.sendToActionScript('toggleactive');
	});
	/*
	var $cube = $("#cubeidle");
	if ($cube.css("visibility") == "visible"){
		$cube.css("visibility","hidden");
	} else {
		$cube.css("visibility","visible");
	}
	*/						
}
var objFlashVersion = [8, 0];						   	
function fFlashFail(){
}

$(document).ready(function() {
	$("#overlay, #overlay2").overlay({

		expose: { 
			color: '#333', 
			loadSpeed: 200, 
			opacity: 0.6 
		}, 
		api: true,
		top: 20,
		oneInstance: false,  
		onBeforeLoad: function() {
			// grab wrapper element inside content
			var wrap = this.getContent().find("div.wrap");
			// load the page specified in the trigger
			wrap.load(oCurrentTrigger.href);
			var sPageName = "/WhatsYourMix_form.asp";
			if (oCurrentTrigger.href.indexOf("WhatsYourMix_orderform.asp") >= 0){
				sPageName = "/WhatsYourMix_orderform.asp";
			}
			pageTracker._trackPageview(sPageName); 
			fToggleFlash();
		},
		onBeforeClose: function(){
			fToggleFlash();
		},
		onClose: function(){
			var wrap = this.getContent().find("div.wrap");
			$(wrap).html('');
		},
		onLoad: function(){
		}
	});
	$("#headerallstar").flashembed({
		src:"includes/swf/VIP_header_allStar.swf",
		version: objFlashVersion,
		wmode:"transparent",
		onFail: fFlashFail
	});
	$("#headergrownup").flashembed({
		src:"includes/swf/VIP_header_grownUpBoys_01.swf",
		version: objFlashVersion,
		wmode:"transparent",
		onFail: fFlashFail
	});
	$("#headerinternational").flashembed({
		src:"includes/swf/VIP_header_InternationallyMinded.swf",
		version: objFlashVersion,
		wmode:"transparent",
		onFail: fFlashFail
	});
	$("#headerkidslab").flashembed({
		src:"includes/swf/VIP_header_kidsLab.swf",
		version: objFlashVersion,
		wmode:"transparent",
		onFail: fFlashFail
	});
	$("#headerathome").flashembed({
		src:"includes/swf/VIP_header_lifeAtHome.swf",
		version: objFlashVersion,
		wmode:"transparent"
	});
	$("#headermoviemogul").flashembed({
		src:"includes/swf/VIP_header_movie-mogul.swf",
		version: objFlashVersion,
		wmode:"transparent",
		onFail: fFlashFail
	});
	$("#headermusicplayer").flashembed({
		src:"includes/swf/VIP_header_music-player.swf",
		version: objFlashVersion,
		wmode:"transparent",
		onFail: fFlashFail
	});
	$("#headerondemand").flashembed({
		src:"includes/swf/VIP_header_onDemand.swf",
		version: objFlashVersion,
		wmode:"transparent",
		onFail: fFlashFail
	});
	$("#headerordinary").flashembed({
		src:"includes/swf/VIP_header_critically-aclaimed.swf",
		version: objFlashVersion,
		wmode:"transparent",
		onFail: fFlashFail
	});
	$("#headerviphd").flashembed({
		src:"includes/swf/VIP_header_HD.swf",
		version: objFlashVersion,
		wmode:"transparent",
		onFail: fFlashFail
	});
	$("#cubeidle").flashembed({
		src:"includes/swf/WunderCubeIdle.swf",
		version: objFlashVersion,
		wmode:"transparent",
		onFail: fFlashFail
	});
	$("#leftColumn blockquote ul li ul li:last-child").css({"border-bottom":"none"});   
	$("#leftColumn blockquote > ul > li:last-child").css({"border-bottom":"none"});
	$(".jqOverlay").live("click",function(){
		oCurrentTrigger = this;								  
		var sSelector = this.rel;
		var oAPI = $(sSelector).overlay(); 
		oAPI.load();
		return false;
	});
	$("img").ifixpng();
	
});

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
