/* The following functions are for launching the various types of resources from the resource listings. 
   or from the annotation/feature listing. (The features will need to be made to handle these.)
   Tyler DeWall, 7-15-02
*/

var myWindow; 
var filename;  
var fileTitle;

function loadDocument(titleRef, fileNameRef){
	// This function loads a text-only document(html)
	// titleRef is the text of the link clicked on, for use in title tag of popup
	// fileNameRef is the filename of the document to load
	
	myWindow = window.open(fileNameRef, 'openwin','width=640,height=480,scrollbars=yes');
        myWindow.focus;
}


function loadImage(titleRef, fileNameRef){
	//This function displays an image
	// titleRef is the text of the link clicked on, for use in title tag of popup
	// fileNameRef is the filename of the image to load

	var title;	
	title = unescape(titleRef);
	filename = fileNameRef.substr(14, (fileNameRef.length - 14));
	//change size from width=590,height=440 TD-8-15-02
        myWindow = window.open('../../content/imageloader.html','','width=740,height=540');
}

function loadMap(titleRef, fileNameRef){
	// This function displays a map
	// titleRef is the text of the link clicked on, for use in title tag of popup
	// Note that maps can be static (.jpg) or animated(.swf)
	// fileNameRef is the filename of the map to load


        var title;
	myRegEx = new RegExp("\w*\.jpg$") 
	title = unescape(titleRef);
	filename = fileNameRef.substr(14, (fileNameRef.length - 14));

	if(myRegEx.test(fileNameRef)) {
		//change size from width=590,height=440 TD-8-15-02
	        myWindow = window.open('../../content/imageloader.html','','width=740,height=540');
	}
	else {	
		myWindow = window.open('','','toolbar=no,width=580,height=680');
		myWindow.document.writeln('<html><head><title>');
		myWindow.document.write(title);
		myWindow.document.write('</title></head><body>');
		myWindow.document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="560" height="660">');
		myWindow.document.write('<param name=movie value=');
		myWindow.document.write(fileNameRef);
		myWindow.document.write('>');
		myWindow.document.write('<param name=quality value=high>');
		myWindow.document.write('<embed src=');
		myWindow.document.write(fileNameRef);
		myWindow.document.write(' quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="560" height="660">');
		myWindow.document.write('</embed></object>');
		myWindow.document.write('</body></html>');
		myWindow.document.close();
	       	myWindow.focus;
	}
}

function loadAudio (titleRef, fileNameRef, narrationFileRef){
	// This function plays an audio resource
	// titleRef is the title of the audio file, it'll be displayed if no narration
	// fileNameRef is the file to be played
	// narrationFileRef is the text of the audio, display it if available.

        var title;
	fileTitle = titleRef;
	title = unescape(titleRef);
	filename = fileNameRef.substr(14, (fileNameRef.length - 14));

  	if(narrationFileRef != "") {
            textWindow = window.open(narrationFileRef, 'openwin','width=640,height=480');
  	}

        myWindow = window.open('../../content/audioPlayer.html','','width=140,height=15');
        myWindow.focus;
}

function loadVideo (titleRef, fileNameRef){
	// This function displays a video resource
	// titleRef is the text of the link clicked on, for use in title tag of popup
	// fileNameRef is the filename of the video to load

        var title;
	fileTitle = titleRef;
	title = unescape(titleRef);
	filename = fileNameRef.substr(14, (fileNameRef.length - 14));
        myWindow = window.open('../../content/vidPlayer.html','','width=250,height=210');
	myWindow.focus;
}

function goSearch () {
	// I don't know what this function does yet, but eventually there will
	// be some useful information in here

	//alert("Hey, this function works");
	/* old popup method
	myWindow = window.open('/inventing/content/search.html','','width=658,height=498,scrollbars=yes');
	myWindow.focus;*/
	document.location.href="/inventing/content/search.html";


}

/* functions have not been defined yet for the overview, annotation, feature, and quiz buttons
   as they should just load within the page set. If a function needs to be defined, use the same
   naming convention as above
*/