

function open_edit_window( myLocation, myName, myWidth, myHeight) {	
if (myWidth < 780) { myWidth = 780 }
		myWin= open(myLocation, myName ,"width=" + myWidth + ",height=" + myHeight + ",location=no,status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,top=0,left=0");
		myWin.focus();		
//SetCookie('cookietest',myLocation,exp);		
	
}
function moveNext(myNext) {
   document.location = myNext;
	SetCookie('cookietest',myNext,exp);    
}
function moveBack(myBack) {
   document.location = myBack;
	SetCookie('cookietest',myBack,exp);	
}
function simple_roll(name, newloc) {
	eval ('window.document.' + name + '.src = \'' + newloc + '\'');
}
function getResources(myLink) {
	openWin(myLink,'780', '420');
}
function getGlossary(myLink) {
	openWin(myLink,'780', '420');	
}

function getNavigation(myLink) {
	openWin(myLink,'780', '420');	
}

function getCoursemap(myLink) {
openWin(myLink,'780', '420');	
	
	
}



function goMainMenu() {

	/*if (parent.topEmpty.apiIsInitialized) { 
		// Course is on LMS
		x = confirm("This will close the window and bring you back to the LMS menu.\nDo you wish to continue?");
		if (x) { closeWindow(); }
	} else {
		// GO to main menu		
		x = confirm("This will close the window and bring you back to the main menu.\nDo you wish to continue?");
		if (x) { closeWindow(); }
	}*/
	x = confirm("This will close the window and bring you back to the main menu.\nDo you wish to continue?");
		if (x) { closeWindow(); }
	
}
function openWin(url,w,h) {
	win = window.open (url,"commonWin","toolbar=no,width="+w+",height="+h+",menubar=no,resizable=yes,status=no,scrollbars=yes");
	//win.moveTo(((screen.width/2)-(w/2)-5),((screen.height/2)-(h/2)-25));

	win.focus();
}
function populateReferences() {

    loadXML("../xml/references.xml");
	
	refXML = xmlObj.documentElement.getElementsByTagName("reference");

    var references = "<ul>";

    for (i = 0; i < refXML.length; i++) {
		
		if (refXML[i].getAttribute("file") == "") {
			references += "<p>" + refXML[i].getAttribute("name") + "</p>";
		} else {
      	  references += "<li><a target='_blank' href='" + refXML[i].getAttribute("file") + "'>" + refXML[i].getAttribute("name") + "</a></li>";
		}

    }

    references += "</ul>"

    if (references == "<ul></ul>") { references = "None provided"; }

    document.getElementById("coursemapDiv").innerHTML = references;
}

function populateGlossary() {

    loadXML("../xml/glossary.xml");
	
	glossXML = xmlObj.documentElement.getElementsByTagName("term");
	
    var glossaryLetters = "";
    var headers = false;

    var glossaryTerms = "<table width='90%' border='0' cellspacing='0' cellpadding='3'>";


        var alphabet = new Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");

        for (i = 0; i < alphabet.length; i++) {

            termName = alphabet[i];
            var lt = false;

            
            // Run a loop to see if header letter has any words
						
            for (x = 0; x < glossXML.length; x++) {

                if (glossXML[x].getAttribute("name").charAt(0) == termName) {
                    lt = true;
                }

            }

            // If header letter has words, link it, otherwise don't
            if (lt == true) {
				glossaryTerms += "<tr><td ><b><a id='glossHeader'  name='" + termName + "'>" + termName + "</a></b></td><td align='right'></td></tr>";
				
                glossaryLetters += "<b><a href='#" + termName + "' >" + termName + "</a></b>&nbsp;&nbsp;&nbsp;";

                for (x = 0; x < glossXML.length; x++) {

                    if (glossXML[x].getAttribute("name").charAt(0) == termName) {
                        glossaryTerms += "<tr><td valign=top><b><a name='" + glossXML[x].getAttribute("id") + "' id='" + glossXML[x].getAttribute("id") + "'></a><div></div>" + glossXML[x].getAttribute("name") + "</b></td><td valign=top>" + glossXML[x].getAttribute("desc") + "</td></tr><tr><td colspan=2 height=12>&nbsp;</td></tr>";
                    }

                }


            } else {
                glossaryLetters += "<b>" + termName + "</b>&nbsp;&nbsp;&nbsp;";
            }
        

    }
	
	glossaryTerms += "<tr><td colspan='2'><a href='#top' title='Navigate to the top of the Window'>Go To Top</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:window.parent.close();' title='Close Glossary Window'>Close Window</a></td></tr></table>"
	
    document.getElementById("definitionWords").innerHTML = glossaryTerms;
    document.getElementById("glossaryLetters").innerHTML = glossaryLetters;
    
    currentLoc = document.location.href;
    glossID = currentLoc.split("#");

    if (glossID[1]) {
        window.scrollBy(0, 0);
        window.scrollBy(0, getElementTop(glossID[1]));
    }
    
}


function loadXML(file) {
	
	var xmlhttp=false;	
	isLocal=false;
	
	var isIE = -1;
	if (navigator.appName == 'Microsoft Internet Explorer')
	{
		var ua = navigator.userAgent;
		var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null)
		isIE = parseFloat( RegExp.$1 );
	}	
	
	/* running locally on IE6, IE7 */      
	 if(location.protocol=="file:"){
	  if(!xmlhttp)try{ xmlhttp=new ActiveXObject("MSXML2.XMLHTTP"); }catch(e){xmlhttp=false;}
	  if(!xmlhttp)try{ xmlhttp=new ActiveXObject("Microsoft.XMLDOM");; }catch(e){xmlhttp=false;}
	  isLocal=true;
	 }                                                                                ; 
	/* IE7, Firefox, Safari, Opera, Chrome...  */
	 if(!xmlhttp)try{ xmlhttp=new XMLHttpRequest(); }catch(e){xmlhttp=false;}
	/* IE6 */
	 if(typeof ActiveXObject != "undefined"){
	  if(!xmlhttp)try{ xmlhttp=new ActiveXObject("MSXML2.XMLHTTP"); }catch(e){xmlhttp=false;}
	  if(!xmlhttp)try{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){xmlhttp=false;}
	 }
	
	if(isLocal==true && isIE!=-1) {
		xmlObj = new ActiveXObject("Microsoft.XMLDOM");		
		xmlObj.async = "false";
		xmlObj.load(file);
	} else {
		xmlhttp.open("GET",file,false);
		xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState!=4)return;
	
		};//onreadystatechange
		xmlhttp.send(null);
	
		xmlObj=xmlhttp.responseXML;	
	}
}

function getExit(myLocation) {
	x = confirm("Are you sure you wish to exit this course?");
	if (x) {
	//SetCookie('cookietest',myLocation,exp);		
	closeWindow();
  
	}
}

function closeWindow() {	
	window.close(); 
	finish();
}