var WH_boxes = new Array("off_WH_top", "off_WH_top1", "off_WH_left", "off_WH_right", "off_WH_bottom");
var WTLF_boxes = new Array("off_WTLF_top", "off_WTLF_left", "off_WTLF_right", "off_WTLF_bottom");
var TTK_boxes = new Array("off_TTK_top", "off_TTK_top2", "off_TTK_left", "off_TTK_right", "off_TTK_bottom");

function findPosX(obj) {
var curleft = 0;
if(obj.offsetParent)
	while(1)
	{
	  curleft += obj.offsetLeft;
	  if(!obj.offsetParent)
		break;
	  obj = obj.offsetParent;
	}
else if(obj.x)
	curleft += obj.x;
return curleft;
}

function findPosY(obj) {
var curtop = 0;
if(obj.offsetParent)
	while(1)
	{
	  curtop += obj.offsetTop;
	  if(!obj.offsetParent)
		break;
	  obj = obj.offsetParent;
	}
else if(obj.x)
	curtop += obj.x;
return curtop;
}


window.onDomReady(function(){
	
		//checks to see if the spotlight link is on and turn it off
		if(document.getElementById('whatshot') != null && document.getElementById('whatshot').src.match("btn-spotnav-spotlight-nodrop.gif") != null){
			$('whatshot').onmouseout = function() { $('whatshot').src = $('whatshot').src.replace("nodrop-over.gif", "nodrop.gif");};
		}
		if(document.getElementById('thingstoknow') != null && document.getElementById('thingstoknow').src.match("btn-spotnav-thingstoknow-nodrop.gif") != null){
			$('thingstoknow').onmouseout = function() { $('thingstoknow').src = $('thingstoknow').src.replace("nodrop-over.gif", "nodrop.gif");};
		}
		if(document.getElementById('lookfor') != null && document.getElementById('lookfor').src.match("btn-spotnav-lookfor-nodrop.gif") != null){
			$('lookfor').onmouseout = function(){ $('lookfor').src= $('lookfor').src.replace("nodrop-over.gif", "nodrop.gif");};
		}
});


function show_msm_boxes(which_boxes){

	if(which_boxes==0){
		for (var x = 0; x < WH_boxes.length; x++)	
			$(WH_boxes[x]).setStyle('display','block');
			
		for (var x = 0; x < WTLF_boxes.length; x++)	
			$(WTLF_boxes[x]).setStyle('display','none');

		for (var x = 0; x < TTK_boxes.length; x++)	
			$(TTK_boxes[x]).setStyle('display','none');
	}
	if(which_boxes==1){
		for (var x = 0; x < WTLF_boxes.length; x++)	
			$(WTLF_boxes[x]).setStyle('display','block');
			
		for (var x = 0; x < WH_boxes.length; x++)	
			$(WH_boxes[x]).setStyle('display','none');

		for (var x = 0; x < TTK_boxes.length; x++)	
			$(TTK_boxes[x]).setStyle('display','none');
	}
	if(which_boxes==2){
		for (var x = 0; x < TTK_boxes.length; x++)	
			$(TTK_boxes[x]).setStyle('display','block');
			
		for (var x = 0; x < WH_boxes.length; x++)	
			$(WH_boxes[x]).setStyle('display','none');

		for (var x = 0; x < WTLF_boxes.length; x++)	
			$(WTLF_boxes[x]).setStyle('display','none');
	}

}

function hide_msm_boxes(which_boxes){

		for (var x = 0; x < WH_boxes.length; x++)	
			$(WH_boxes[x]).setStyle('display','none');

		for (var x = 0; x < WTLF_boxes.length; x++)	
			$(WTLF_boxes[x]).setStyle('display','none');

		for (var x = 0; x < TTK_boxes.length; x++)	
			$(TTK_boxes[x]).setStyle('display','none');

}

var modulesSubMenuDrop = new Class({



 msm_slide: function (sId) {

	if(document.getElementById('WH_drop') != null)
	{
		document.getElementById('WH_drop').style.top = findPosY(document.getElementById('whatshot')) + 22 + 'px';
		document.getElementById('WH_drop').style.left = findPosX(document.getElementById('whatshot')) + 'px';
		document.getElementById('off_WH_left').style.top = findPosY(document.getElementById('WH_drop')) + 'px';
		document.getElementById('off_WH_left').style.left = findPosX(document.getElementById('WH_drop')) - 50 + 'px';
		document.getElementById('off_WH_right').style.top = findPosY(document.getElementById('WH_drop')) + 'px';
		document.getElementById('off_WH_right').style.left = findPosX(document.getElementById('WH_drop')) + document.getElementById('WH_drop').offsetWidth.toInt() + 'px';

	}
	else
	{
		if(document.getElementById('whatshot') != null)
		{
		document.getElementById('off_WH_bottom').style.top = findPosY(document.getElementById('whatshot')) + 22 + 'px';
		document.getElementById('off_WH_bottom').style.left = findPosX(document.getElementById('whatshot')) + 'px';
		}
	}
	if(document.getElementById('WTLF_drop') != null)
	{
		document.getElementById('WTLF_drop').style.top = findPosY(document.getElementById('lookfor')) + 22 + 'px';
		document.getElementById('WTLF_drop').style.left = findPosX(document.getElementById('lookfor')) + 3 + 'px';
		document.getElementById('off_WTLF_left').style.top = findPosY(document.getElementById('WTLF_drop')) + 'px';
		document.getElementById('off_WTLF_left').style.left = findPosX(document.getElementById('WTLF_drop')) - 50 + 'px';
		document.getElementById('off_WTLF_right').style.top = findPosY(document.getElementById('WTLF_drop')) + 'px';
		document.getElementById('off_WTLF_right').style.left = findPosX(document.getElementById('WTLF_drop')) + document.getElementById('WTLF_drop').offsetWidth.toInt() + 'px';

	}
	else
	{
		if(document.getElementById('lookfor') != null)
		{
		document.getElementById('off_WTLF_bottom').style.top = findPosY(document.getElementById('lookfor')) + 22 + 'px';
		document.getElementById('off_WTLF_bottom').style.left = findPosX(document.getElementById('lookfor')) + 'px';
		}
	}
	if(document.getElementById('TTK_drop') != null)
	{
		document.getElementById('TTK_drop').style.top = findPosY(document.getElementById('thingstoknow')) + 22 + 'px';
		document.getElementById('TTK_drop').style.left = findPosX(document.getElementById('thingstoknow')) + 'px';
		document.getElementById('off_TTK_left').style.top = findPosY(document.getElementById('TTK_drop')) + 'px';
		document.getElementById('off_TTK_left').style.left = findPosX(document.getElementById('TTK_drop')) - 50 + 'px';
		document.getElementById('off_TTK_right').style.top = findPosY(document.getElementById('TTK_drop')) + 'px';
		document.getElementById('off_TTK_right').style.left = findPosX(document.getElementById('TTK_drop')) + document.getElementById('TTK_drop').offsetWidth.toInt() + 'px';

	}
	else
	{
		if(document.getElementById('thingstoknow') != null)
		{
		document.getElementById('off_TTK_bottom').style.top = findPosY(document.getElementById('thingstoknow')) + 22 + 'px';
		document.getElementById('off_TTK_bottom').style.left = findPosX(document.getElementById('thingstoknow')) + 'px';
		}
	
	}
		if(document.getElementById('whatshot') != null)
		{		
		document.getElementById('off_WH_top').style.top = findPosY(document.getElementById('whatshot')) - 25 + 'px';
		document.getElementById('off_WH_top').style.left = findPosX(document.getElementById('whatshot')) - 23 + 'px';
		document.getElementById('off_WH_top1').style.top = findPosY(document.getElementById('whatshot')) + 'px';
		document.getElementById('off_WH_top1').style.left = findPosX(document.getElementById('whatshot')) - 23 + 'px';
		}
		else if(document.getElementById('lookfor') != null)
		{
		document.getElementById('off_WH_top1').style.top = findPosY(document.getElementById('lookfor')) + 'px';
		document.getElementById('off_WH_top1').style.left = findPosX(document.getElementById('lookfor')) - 23 + 'px';
		}
		else
		{
		document.getElementById('off_WH_top1').style.top = findPosY(document.getElementById('thingstoknow')) + 'px';
		document.getElementById('off_WH_top1').style.left = findPosX(document.getElementById('thingstoknow')) - 23 + 'px';
		}
		if(document.getElementById('lookfor') != null)
		{
		document.getElementById('off_WTLF_top').style.top = findPosY(document.getElementById('lookfor')) - 25 + 'px';
		document.getElementById('off_WTLF_top').style.left = findPosX(document.getElementById('lookfor')) - 23 + 'px';
		}
		if(document.getElementById('thingstoknow') != null)
		{
		document.getElementById('off_TTK_top').style.top = findPosY(document.getElementById('thingstoknow')) - 25 + 'px';
		document.getElementById('off_TTK_top').style.left = findPosX(document.getElementById('thingstoknow')) - 23 + 'px';
		document.getElementById('off_TTK_top2').style.top = findPosY(document.getElementById('thingstoknow')) + 'px';
		document.getElementById('off_TTK_top2').style.left = findPosX(document.getElementById('thingstoknow')) + 123 + 'px';
		}
		else if(document.getElementById('lookfor') != null)
		{
		document.getElementById('off_TTK_top2').style.top = findPosY(document.getElementById('lookfor')) + 'px';
		document.getElementById('off_TTK_top2').style.left = findPosX(document.getElementById('lookfor')) + 123 + 'px';
		}
		else {
		document.getElementById('off_TTK_top2').style.top = findPosY(document.getElementById('whatshot')) + 'px';
		document.getElementById('off_TTK_top2').style.left = findPosX(document.getElementById('whatshot')) + 123 + 'px';
		}
		
		if(document.getElementById(sId) != null)
		{	
			//sets element to visible
			if($(sId).getStyle('visibility') == 'hidden')
			{
				$(sId).setStyle('visibility','visible');
				
				//initializes mootools Fx.Height object
				var open = new Fx.Height($(sId), {duration: 350, transition: Fx.Transitions.cubicOut, onComplete: function() {
				if(sId == "WH_drop")
				{
           		document.getElementById('off_WH_bottom').style.top = findPosY(document.getElementById(sId)) + document.getElementById(sId).offsetHeight.toInt() + 'px';
				document.getElementById('off_WH_bottom').style.left = findPosX(document.getElementById(sId)) + 'px';
				}
				else if(sId == "WTLF_drop")
				{
				document.getElementById('off_WTLF_bottom').style.top = findPosY(document.getElementById(sId)) + document.getElementById(sId).offsetHeight.toInt() + 'px';
				document.getElementById('off_WTLF_bottom').style.left = findPosX(document.getElementById(sId)) + 'px';
				}
				else
				{
				document.getElementById('off_TTK_bottom').style.top = findPosY(document.getElementById(sId)) + document.getElementById(sId).offsetHeight.toInt() + 'px';
				document.getElementById('off_TTK_bottom').style.left = findPosX(document.getElementById(sId)) + 'px';
				}
				}
				
        });
					
				//drops down the menu
				open.toggle(); 
			
			
			}
		}

	},


//slides up dropdown
 msm_slide_out: function(sId){
 
		if(document.getElementById(sId) != null)
		{	
			$(sId).setStyle('visibility','hidden');
			var close = new Fx.Height($(sId), {wait:false});
			
			//closes the menu
			close.hide(); 
			
			//checks to see if the spotlight link is on and turn it off
			if(document.getElementById('whatshot') != null && document.getElementById('whatshot').src.match("btn-spotnav-spotlight-drop-over.gif") != null && sId == 'WH_drop'){
				$('whatshot').src=$('whatshot').src.replace("btn-spotnav-spotlight-drop-over.gif", "btn-spotnav-spotlight-drop.gif");
			}
			if(document.getElementById('thingstoknow') != null && document.getElementById('thingstoknow').src.match("btn-spotnav-thingstoknow-drop-over.gif") != null && sId == 'TTK_drop'){
				$('thingstoknow').src=$('thingstoknow').src.replace("btn-spotnav-thingstoknow-drop-over.gif", "btn-spotnav-thingstoknow-drop.gif");
			}
			if(document.getElementById('lookfor') != null && document.getElementById('lookfor').src.match("btn-spotnav-lookfor-drop-over.gif") != null && sId == 'WTLF_drop'){
				$('lookfor').src=$('lookfor').src.replace("btn-spotnav-lookfor-drop-over.gif", "btn-spotnav-lookfor-drop.gif");
			}
		}
	}
});

var msmDrop = new modulesSubMenuDrop();