// Macromedia code
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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

// custom code


function layerToFront(objName) {
  var IE=document.all,NS4=document.layers,NS6=(!IE&&document.getElementById),NS=(NS4||NS6);
  if (!IE && !NS) return false;
  curLayer = MM_findObj(objName); if (!curLayer) return false;
  if (!document.allLayers) { document.allLayers = new Array();
    with (document) if (NS4) { for (i=0; i<layers.length; i++) allLayers[i]=layers[i];
      for (i=0; i<allLayers.length; i++) if (allLayers[i].document && allLayers[i].document.layers)
        with (allLayers[i].document) for (j=0; j<layers.length; j++) allLayers[allLayers.length]=layers[j];
    } else {
      if (NS6) { var spns = getElementsByTagName("span"); var all = getElementsByTagName("div");
        for (i=0;i<spns.length;i++) if (spns[i].style&&spns[i].style.position) allLayers[allLayers.length]=spns[i];}
      for (i=0;i<all.length;i++) if (all[i].style&&all[i].style.position) allLayers[allLayers.length]=all[i];
  } }
  document.MM_maxZ = 0;
    for (i=0; i<document.allLayers.length; i++) { aLayer = document.allLayers[i];
      var aLayerZ = (NS4)?aLayer.zIndex:parseInt(aLayer.style.zIndex);
      if ((aLayerZ > document.MM_maxZ) && (aLayerZ<1000)) {document.MM_maxZ = aLayerZ;}
    }
	
  eval('curLayer.'+((NS4)?'':'style.')+'zIndex=document.MM_maxZ+1');
    document.MM_maxZ++;
      retVal = false; if(!NS4&&!NS6) event.returnValue = false;
  return retVal;
}


function showLayerToFront (objName) {
  layerToFront(objName);
}

function initDrags() {
	// get all DIVS into an array / list
	if (document.getElementsByTagName){
			all = document.getElementsByTagName("DIV");
	} else if (document.all){
			all = document.all.tags("DIV");
	}
	for (var i=0;i<all.length;i++){
		if (all[i].id.indexOf("MAINHOLDER")>0) {
		attachEventsToDrag(all[i].id);
		}
	}
}

// inits our layers and assigns drag object to them
function attachEventsToDrag(tmp) {
	ref=document.getElementById(tmp);
	// tmp is the MAINHOLDER div for the window, find the TITLEHANDLE one
	var p=tmp.substring(0,tmp.indexOf("MAINHOLDER"))+"TITLEHANDLE";
	Drag.init(document.getElementById(p), ref ,6,719-ref.offsetWidth,89,526-ref.offsetHeight);			
	ref.onDrag = function(x, y) {
		layerToFront(this.id);
	}
}

// assigns drag behaviour to MINIMISED windows
function attachEventsToDragHidden(tmp) {
	ref=document.getElementById(tmp);
	// tmp is the MAINHOLDER div for the window, find the TITLEHANDLE one
	var p=tmp.substring(0,tmp.indexOf("MAINHOLDER"))+"TITLEHANDLE";
	Drag.init(document.getElementById(p), ref ,6,719-ref.offsetWidth,89,502);			
	ref.onDrag = function(x, y) {
		layerToFront(this.id);
	}
}

/* Expand / collapse window */
function showHide(id) {
	// id is CONTENTHOLDER
	ref=document.getElementById(id);
	// find out what the MAINHOLDER is
	var p=id.substring(0,id.indexOf("CONTENTHOLDER"))+"MAINHOLDER";
	
	if (ref.style.display=="none") {
		ref.style.display="block";
			ref2=document.getElementById(p);
			var ptr = ref2.style.top;
		    var top = new Number(ptr.substring(0,ptr.indexOf("px",0)));
			if (top+ref2.offsetHeight>556) { 
				ref2.style.top=(526-ref2.offsetHeight).toString()+"px";
			}

		// check if its gone off the bottom
		attachEventsToDrag(p);
		layerToFront(id);
	} else {
		ref.style.display="none";	
		attachEventsToDragHidden(p);
		layerToFront(id);
	}
}

function showlayer(tmp) {
	// called from clicking on a subpage.  Hides all layers except the menu, and then switches on the selected page.
	if (document.getElementsByTagName){
			all = document.getElementsByTagName("DIV");
	} else if (document.all){
			all = document.all.tags("DIV");
	}
	

	for (var i=0;i<all.length;i++){
		if ((all[i].id.indexOf("MAINHOLDER")>0) && (all[i].id!="menu_MAINHOLDER") && (all[i].id!="menu_mod_1_MAINHOLDER") && (all[i].id!="menu_mod_2_MAINHOLDER") ) {
		all[i].style.visibility="hidden";
		}
	}

	
	ref=document.getElementById(tmp);
	ref.style.visibility="visible";
	layerToFront(tmp);
}

function showpage(tmp) {
	// called from clicking on next>> or back<< in a window. 
	ref=document.getElementById(tmp);
	ref.style.visibility="visible";
	layerToFront(tmp);
}

function showlayerforcefront(tmp,force) {
	// shows layer by id tmp, then forces 'force' to front.
	ref=document.getElementById(tmp);
	ref.style.visibility="visible";
	layerToFront(tmp);
	layerToFront(force);
}
function hidelayer(arr) {
	// array of ids to hide
	for (var i=0;i<arr.length;i++){
		ref=document.getElementById(arr[i]);
		ref.style.visibility="hidden";
	}
}
function OpenImage(width, height,pic,caption) {
  var x = Math.round((screen.availWidth - width) / 2);
  var y = Math.round((screen.availHeight - height) / 2);
  var featureString = 'left=' + x + ',top=' + y + ',width=' + width + ',height=' + height;
  popref=window.open("popup.php" + "?filepath="+pic+"&caption="+caption, "mms", featureString+",scrollbars=no,toolbars=no");
  popref.focus();
}
function OpenVideo(width, height,vid,caption) {
  var x = Math.round((screen.availWidth - width) / 2);
  var y = Math.round((screen.availHeight - height) / 2);
  height=Number(height)+60;
  width=Number(width)+60;
  var featureString = 'left=' + x + ',top=' + y + ',width=' + width + ',height=' + height;
  popref=window.open("video.php" + "?filename="+vid+"&caption="+caption, "mms", featureString+",scrollbars=no,toolbars=no");
  popref.focus();
}
function launchSuccess() {

  width=798;
  height=652;
  var x = Math.round((screen.availWidth - width) / 2);
  var y = Math.round((screen.availHeight - height) / 2);
  var featureString = 'left=' + x + ',top=' + y + ',width=' + width + ',height=' + height;
  popref=window.open("flash/success.php","mms", featureString+",scrollbars=no,toolbars=no");
  popref.focus();	
}
function addFlash(iSlideShow) {
   // add slideshow 
   var fo = new FlashObject("flash/flash.swf", "mymovie", "282", "288", "8", "#ffffff");
   fo.addParam("wmode", "transparent");
   fo.write("largepic");
   
   // add banner
   var fo = new FlashObject("flash/3dtourbanner.swf", "tourban", "282", "142", "7", "#000000");
   fo.addParam("wmode", "transparent");
   fo.write("smallpic");
  
   // add footer
   var fo = new FlashObject("flash/footer.swf", "foot", "690", "27", "8", "#ffffff");
   
   fo.write("footerflash"); 
   
   // INDEX PAGE - add why
   if (document.getElementById('flash_why')) {
  	 var fo = new FlashObject("flash/why.swf", "why", "125", "92", "8", "#dad5b8");
	 fo.addParam("wmode", "transparent");
  	 fo.write("flash_why")	   
   }
   
   // INDEX PAGE - add news
   if (document.getElementById('news')) {
  	 var fo = new FlashObject("flash/news_small.swf", "news", "282", "68", "8", "#FFFFFF");
	 fo.addParam("wmode", "transparent");
  	 fo.write("news")	   
   }   
   
   // INDEX PAGE - add schol offer
   if (document.getElementById('sch_offer')) {
  	//  var fo = new FlashObject("flash/sch_offer.swf", "sch", "282", "68", "8", "#FFFFFF");
	 fo.addParam("wmode", "transparent");
	 var fo = new FlashObject("flash/youtube.swf", "sch", "282", "68", "8", "#FFFFFF");
  		 fo.write("sch_offer")	   
   }      
   
   // INDEX PAGE - add artist roster
	if (document.getElementById('artist')) {
  	 var fo = new FlashObject("flash/rightartists.swf", "rightartists", "139", "143", "8", "#FFFFFF");
	 fo.addParam("wmode", "transparent");
  	 fo.write("artist")	   
   }   
   
   // INDEX PAGE - flash thumbnail of promo vid
	if (document.getElementById('flash_vid')) {
  	 var fo = new FlashObject("flash/promo_clip.swf", "flash_vid", "123", "70", "7", "#FFFFFF");
	 fo.addParam("wmode", "transparent");
  	 fo.write("flash_vid");
   }   
   
}
