// JavaScript Document
// global variable to store xml document object
	var myVocabularyDoc;
	function initialize(xmlDoc) {
		//alert("Am I even coming here? 2 "+xmlDoc);
		myVocabularyDoc = xmlDoc;
		//var x = myVocabularyDoc.getElementsByTagName('emperor');
		//alert("Is this right 1? "+xmlDoc.getElementsByTagName('emperor')[0].firstChild.nodeValue);
		getFirstWord();
		}
		
	function getFirstWord() {
		clickVocabWord('Evaporation');
	}
		
	function clickVocabWord(word) {
		//alert("You clicked on "+ word);
		if( myVocabularyDoc.documentElement && myVocabularyDoc.documentElement.tagName && myVocabularyDoc.documentElement.tagName.toUpperCase() == 'HTML' ) {
		setTimeout('alert(\'For no apparent reason, your browser has turned the clean XML into HTML based garbage.\\nScript aborted.\');',50); return; }
		var x = myVocabularyDoc.getElementsByTagName(word);
		//alert((document.getElementById("vocabularyWord")).innerHTML);
		document.getElementById("vocabularyWord").innerHTML = x[0].nodeName;
		document.getElementById("vocabularyMeaning").innerHTML = x[0].getElementsByTagName('meaning')[0].firstChild.nodeValue;
		//alert(x[0].getElementsByTagName('meaning')[0].firstChild.nodeValue);
		var mediaSrc=x[0].getElementsByTagName('media')[0].firstChild.nodeValue;
		//alert(mediaSrc.substr(-3,3));
		var extension = mediaSrc.substr(-3,3);
		switch(extension) {
		case "jpg":
			document.getElementById("vocabularyImage").innerHTML = "<img src="+mediaSrc+" align=\"middle\" />";
			break;
		case "mov":
			//alert(mediaSrc);
			document.getElementById("vocabularyImage").innerHTML="<embed src="+mediaSrc+" width=\"140\" height=\"115\" autoplay=\"true\">";
			/*document.getElementById("vocabularyImage").src = mediaSrc;
			document.getElementById("vocabularyImage").width=190px;
			document.getElementById("vocabularyImage").height=140px;
			document.getElementById("vocabularyImage").align='middle';*/
			break;
		case "swf":
			document.getElementById("vocabularyImage").innerHTML="<embed src="+mediaSrc+" width=\"140\" height=\"115\" autoplay=\"true\">";
		    break;
		default:
			document.getElementById("vocabularyImage").innerHTML=" ";
		//
		}
			
		//document.getElementById("vocabularyImage").align="center";
		//alert("Is this right 2? "+ x.length);
		}
