var ie	= document.all
var ns6	= document.getElementById&&!document.all

var CurrentMenuObject = null;
var CurrentDayObject = null;

var isMenu = false;
var isDay = false;


// ***************************************************************************************

function findPos(obj) {

	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];

}

function ShowMenu(obj,menu_obj) {
	

    
	//hides the previous menu if it apears
	if(CurrentMenuObject!=null){
		CurrentMenuObject.hide();
	}
	
	var BodyCoors=getPageCoords($$('body'));
	
	

	var ElementHeight=20;
	var HorizontalOffset=-17;
	
	if (BodyCoors.x>0) {
		offsetX=BodyCoors.x;
	} else {
		offsetX=0;
	}

    var coords = getPageCoords(obj);
	corX=coords.x-offsetX+HorizontalOffset;
	corY=coords.y+ElementHeight;

	//alert("corX="+corX);
	//alert("corY="+corY);

	menu_obj.setStyle({
		left: corX+'px',
		top: corY+'px'
	});

	
	// Show Animation
	menu_obj.show();

	CurrentMenuObject=menu_obj;
	isMenu=true;
}


function getPageCoords (el) {
  var coords = {x: 0, y: 0};
  do {
    coords.x += el.offsetLeft;
    coords.y += el.offsetTop;
  }
  while ((el = el.offsetParent));
  return coords;
}  

function HideMenu(e) {
	
		

		var	obj = ns6 ? e.target : event.srcElement;
		
		if ((obj.toString().indexOf('javascript:')!=-1)) {
			eval(obj.toString().substring(11));
		}
		
		// Dont hide on the parent menus
		if ((obj.className!="menu_about") && (obj.className!="menu_exhibitions") && (obj.className!="menu_programs") && (obj.className!="menu_support") && (obj.className!="menu_news")) {
			
			if (isMenu==true){
			CurrentMenuObject.hide();
			}
		
		}
		
		
	

}

function submenu_Button_Hide() {
	if (CurrentMenuObject!=undefined) {
		CurrentMenuObject.hide();
	}
}


function OpenLink(url) {
	document.location=url;
}

// -------------------------------------------------------------
// Gallery/Player Widget
function createPlayer(theFile,destinationDiv,width,height,thumb,autostart,logo) {
	
	// The thumb extention
	if (thumb != "") {thumb_string="&image="+thumb;} else {thumb_string="";}
	
	// The logo extention
	if (logo != "") {logo_string="&logo="+logo;} else {logo_string="";}
	
	var s1 = new SWFObject('http://www.smmoa.org/images/player.swf','player',width,height,'9');
	s1.addParam('allowfullscreen','true');
	s1.addParam('allowscriptaccess','always');
	s1.addParam('wmode','transparent');
	s1.addParam('flashvars','file='+theFile+thumb_string+autostart+"&repeat=true&shuffle=false"+logo_string+"&skin=http://www.smmoa.org/images/stylish.swf&fullscreen=true");

	s1.write(destinationDiv);
	
}

// -------------------------------------------------------------


// CALENDAR POPUP

function displayCalendarPopup(date) {
	
	CurrentContents="";
	
	for(r=0; r<DatesInfo.length; r++) {
		if (DatesInfo[r].date==date) {CurrentContents=DatesInfo[r].content;}
	}
	
	if (CurrentContents!="") {
	$('calendar_popup_contents').innerHTML=CurrentContents;
	$('calendar_popup').show();
	}
	
}

function closeCalendarPopup() {
	$('calendar_popup').hide();
}




