window.onload = function() {
	//Create Menu Settings: (Menu ID, Is Vertical, Show Timer, Hide Timer, On Click ('all', 'main' or 'lev2'), Right to Left, Horizontal Subs, Flush Left, Flush Top)
	qm_create(0,false,0,0,false,false,false,false,false);
	initSpotLight();
}

function getQueryVariable(variable) { 
  var query = window.location.search.substring(1); 
  var vars = query.split("&"); 
  for (var i=0;i<vars.length;i++) { 
    var pair = vars[i].split("="); 
    if (pair[0] == variable) { 
      return pair[1]; 
    } 
  } 
}

function getPageScroll() {
    var xScroll, yScroll;
    if (self.pageYOffset) {
        yScroll = self.pageYOffset;
        xScroll = self.pageXOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {
        yScroll = document.documentElement.scrollTop;
        xScroll = document.documentElement.scrollLeft;
    } else if (document.body) {
        yScroll = document.body.scrollTop;
        xScroll = document.body.scrollLeft;
    }
    arrayPageScroll = new Array(xScroll, yScroll);
    return arrayPageScroll;
}

function initDoctorSwap() {
	var target = getQueryVariable("doctor");
	
	$("#doctor_list a").attr("id", function() {
		var href = $(this).attr("href");
		href = href.replace(/#/,"");
		href = href.replace(/_bio/,"");
		return href;
		});
	
	$("#doctor_list a").bind("click", function() {
		doctorSwap(this.id);
		return false;
		});
	
	doctorSwap(target);
}

function doctorSwap(target) {
	$("#doctor_wrapper div").addClass("hide");
	$("#doctor_list a").removeClass("selected");
	
	if (target == null || target == "") {
		$("#doctor_list a:first").addClass("selected");
		$("#doctor_wrapper div:first").removeClass("hide");
	}
	
	else {
		$("#doctor_list a[href='#"+target+"_bio']").addClass("selected");
		$("#"+target+"_bio").removeClass("hide");
	}
}


function initSpotLight() {
	$("a.spotlight").bind("click", function() {
		spotLight(this);
		return false;
		});	
}

function spotLight(ele) {
	var target = $(ele).attr("href");
	var targetId = ele.id;
	var targetFlash = $(target).attr("id")+"_flash";
	var overlay = $("#overlay");
	var documentHeight = $(document).height();
	var documentWidth = $(document).width();	
	var arrayPageScroll = getPageScroll();
	var topPosition = arrayPageScroll[1] + 50;
	swfobject.embedSWF("http://eyemaginations.com/3deyeonline/3deonlinev20.swf", targetFlash, "402", "400", "8.0.0", "../js/expressInstall.swf", {aID:targetId}, {wmode:"transparent"}, "false");
	
	$(target).css({"display":"block","position":"absolute","top":topPosition,"left":"268px"});
	
	$(overlay).css({height:documentHeight, width:documentWidth, "display":"block"});
	$("div.spotlight a, #overlay").bind("click", function() {
		$(overlay).css("display","none");
		$("#"+targetFlash).replaceWith("<div id="+targetFlash+"></div>");
		$(target).css("display","none");
		return false;
		});
}