if ( !document.getElementById ) {
  if ( document.all ) {
    document.getElementbyId=function(){
      if(typeof document.all[arguments[0]]!="undefined")
        return document.all[arguments[0]];
      else
        return null;
    }
  }
  else if(document.layers) {
    document.getElementById=function(){
      if(typeof document[arguments[0]]!="undefined")
        return document[arguments[0]];
      else
        return null;
    }
  }
}

var gallery_obj;
var current_gallery;
function highlight(which,color)
{
	if ( which != current_gallery ) {
		which.style.backgroundColor = color;
	}
}
function change_gallery(which)
{
	if (!which) return;
	highlight(which, '333333');
	if ( current_gallery ) {
		last_gallery = current_gallery;
		current_gallery = which;
		highlight(last_gallery, '');
	}
	else {
		current_gallery = which;
	}
	
	gallery_obj.addVariable("xmlDataPath", "data/"+which.id+".xml");
	gallery_obj.write("flashcontent");
}

function set_first_gallery(id) {
	gallery_obj = new SWFObject("flash/viewer.swf", "viewer", "100%", "100%", "7", "#333333");	
	gallery_obj.addVariable("preloaderColor", "0xffffff");	
	gallery_obj.addVariable( "langOpenImage", "Open Image in New Window" );
	gallery_obj.addVariable("langAbout", "About");
	
	menuRoot = document.getElementById("menu");
	for (x=0; x<menuRoot.childNodes.length; x++) {
		if (id) {
			for (i=0; i<menuRoot.childNodes[x].childNodes.length; i++) {
				if(menuRoot.childNodes[x].childNodes[i].nodeName=="A" && !current_gallery) {
					var text = menuRoot.childNodes[x].childNodes[i].childNodes[0].nodeValue;
					if(text.toLowerCase().match(id)) {
						change_gallery(menuRoot.childNodes[x].childNodes[i]);
					}
				}
			}
		}
		else {
			if ( menuRoot.childNodes[x].nodeName=="LI" && menuRoot.childNodes[x].childNodes[0] && menuRoot.childNodes[x].childNodes[0].nodeName=="A" && !current_gallery ) {
				change_gallery(menuRoot.childNodes[x].childNodes[0]);
			}
		}
	}
}
