     var swant;
     var cwant;
     var intwant;
     var varwant;
     var sitename;

   function childValue(xmlnode,tagname){

      if (xmlnode == null) return " ";

      var elementlist = xmlnode.getElementsByTagName(tagname);
      if (elementlist == null) return " ";

      if (elementlist.length == 0) return " ";

      var childNode = elementlist[0].childNodes[0];
      if (childNode == null) return " ";

      return childNode.nodeValue;

}

  function showcrs(obj){

     var o = ShowCrsInfo.windowObj.document;

     tmpmsg = obj.xmlDoc.responseText;

     if (tmpmsg.substring(2,8) == "ERROR|") {
         o.writeln("<center><br>&nbsp;<br><font size=+1 color=red>"+tmpmsg.substring(8,tmpmsg.length)+"</font></center>");
	 o.writeln("</body></html>");
         o.close();
         return};

     if (tmpmsg.substring(2,11) == "NOTFOUND|") {
         o.writeln("<center><br>&nbsp;<br><font size=+1 color=red>Course " + swant + " " + cwant +
			" " + intwant + " not Found in Course Inventory.</font></center>");
	 o.writeln("</body></html>");
         o.close();
         return};

     docRoot = obj.xmlDoc.responseXML;

     o.writeln('<div class="clustertt">');
     variant = childValue(docRoot,"variant");
     if ( variant != '*') {
	     crsid = childValue(docRoot,"crsid");
	     o.write("<h3>" + crsid);
     
	     credit = childValue(docRoot,"credit");
	     oper1 = childValue(docRoot,"oper1");
	     if ((credit != 0) && (oper1 != 'G')){o.write("&nbsp;("+credit+")&nbsp;")};
	     o.write(childValue(docRoot,"title") + "&nbsp;");

	     if (oper1 != 'G'){
	     o.write("("+ childValue(docRoot,"lechr") + ":"+ childValue(docRoot,"semhr") +
		":"+ childValue(docRoot,"labhr") + ")");

	          fieldhrs = childValue(docRoot,"fieldhrs");
	          if (fieldhrs != 0 ){
	             o.write('&nbsp;-&nbsp;'+fieldhrs+ " field hours over " +
	      	         childValue(docRoot,"duration") + " weeks.")};

	     o.writeln("</h3>\n<br>&nbsp;<br>\n"+
			unescape(childValue(docRoot,"description")));

	     var prereq = childValue(docRoot,"prereq");
	     if (prereq != ' '){
	              o.writeln("<br>&nbsp;<br><i>Prerequisites: " + prereq + "</i>")};

	     var coreq = childValue(docRoot,"coreq");
	     if (coreq != ' '){
	              o.writeln("<br>&nbsp;<br><i>Co-requisites: " + coreq + "</i>")};


	     };

	     intakeid = childValue(docRoot,"intake");
	     if (intakeid != ' ') {
	           o.writeln("<br>&nbsp;<br><h4>Section: " + intakeid + "</h4>");
		   outlinedoc = childValue(docRoot,"outlinedoc");
		   if (outlinedoc != ' ') {
		    o.writeln('<a href="retrieve_course_outline?crsid='+crsid+"&intakeid="+intakeid+
			 '" title="Course Outline"><img src=/www/reg/outline40.gif></a>');
		  };
		};

	     var instructors = docRoot.getElementsByTagName("instructor");

	     if (instructors.length != 0) {
		o.writeln('<br>&nbsp;<br>\n<table style="width:auto; float:none;">' +
			"<tr><td align=center><b>Instructor</b></td>" +
			"<td align=center><b>Email</b></td>" +
			"<td align=center><b>Phone</b></td>" +
			"<td align=center colspan=2><b>Office Location</b></td></tr>" )
		};

	     for (var instindx = 0 ; instindx < instructors.length; instindx++){
		var instructor = instructors[instindx];

	          o.write("<tr><td>" + childValue(instructor,"name") + "</td>");

		  var email = childValue(instructor,"email");
		  o.write("<td>");
		  if (email != ' ') {
	                o.write('<a href="mailto:' + email + '">'+ email +"</a>")
		      };
	          o.write("</td>");

	          o.write("<td>" + childValue(instructor,"phone") + "</td>");
	          o.write("<td>" + childValue(instructor,"officeCampus") + "</td>");

		  var officeBldg = childValue(instructor,"officeBldg");
		  var officeRoom = childValue(instructor,"officeRoom");
		  o.write("<td>");
		  if ( (officeBldg != ' ') && (officeRoom != ' ') ){
		          o.write(officeBldg + "/" + officeRoom + "</td>")
			 };
		  o.write("</td>");

	          o.writeln("</tr>");

		}

             if (instructors.length != 0) { o.writeln('</table>\n<div style="clear:both;"></div>')};

	     o.writeln('<br><hr width=80%>');

	} else { oper1 = '*' };

     if (oper1 == 'G'){
	    o.writeln("</body></html>");
	    o.close()} else
	{
	if (oper1 != 'A'){

	    o.writeln('<center><font size=+1>Course Transfer Information</font>'+
	    	'<br>&nbsp;<br>\n<table style="width:auto; float:none">\n<tr><td width="450px"><font size=-1>Please Note: This information is' +
	    	'provided by the BC Council on Admissions &amp; Transfer ' +
	    	'<a target=bccat_window href=http://www.bctransferguide.ca>Transfer Guide Database</a>. It is believed' +
	    	'to be correct; however for definitive information on course transferabililty please'+
	    	'contact the Admissions Office at the institution you are attending or plan to attend.' +
	    	'</font></td></tr>\n</table>\n</center>\n<div style="clear:both;"></div>');

	     var sends = docRoot.getElementsByTagName("sends");
	     if ( (sends != null) && (sends.length != 0) ) sends = sends[0].getElementsByTagName("agreement");

	    if ((sends == null) || (sends.length == 0)) {
		o.writeln("<br>&nbsp;<br><font color=red>This course is not currently articulated for transfer to any other B.C. institutions.</font>")
		   } else {

	       o.writeln("<br>&nbsp;<br>Credits earned at " +
		      sitename + " for <font color=blue>"+
	              swant+" "+cwant+'</font> may be transferred to:\n<br>&nbsp;<br>\n<table style="width:auto; float:none">\n'+
	       		'<tr class="color1"><td align=center><b>Receiving Institution</b></td>' +
	       		"<td align=center><b>Transfer Credit</b></td>" +
	       		"<td align=center><b>Effective Dates</b></td></tr>");

	       colorindex = 1;

	     for (var sendindx = 0 ; sendindx < sends.length; sendindx++){
		var send = sends[sendindx];

		    var endt = childValue(send,"endt");
		    if (endt == ' ') endt = "Present";
		   if (colorindex == 1) { bgclass = "color2"; colorindex = 0} else { bgclass = "color1"; colorindex = 1};
		   o.writeln('<tr valign=top class="' + bgclass+'"><td>'+
	                childValue(send,"recn")+"</td>" +
		   	'<td style="width:400px; white-space:normal;">'+childValue(send,"agmt")+"</td>" +
		   	"<td>"+ childValue(send,"stdt") + " to "+endt+"</td></tr>");
	       };

	       o.writeln('</table>\n<div style="clear:both;"></div>');
	     };

	     var receives = docRoot.getElementsByTagName("receives");
	     if ( (receives != null)  && (receives.length != 0) ) receives = receives[0].getElementsByTagName("agreement");

	    if ((receives == null) || (receives.length == 0)) {
		o.writeln("<br>&nbsp;<br><font color=red>We are not aware of any equivalent courses at other B.C. institutions.</font>")
	   } else {
	      o.writeln("<br>&nbsp;<br>Credits earned at other institutions that may be used in lieu of <font color=blue>"+
			swant+" "+cwant+"</font> at " + sitename + ':\n<br>&nbsp;<br>\n<table style="width:auto; float:none">\n' +
	      		'<tr class="color1"><td align=center><b>Sending Institution</b></td>' +
	      		"<td align=center><b>Equivalent Course</b></td>" +
	      		"<td align=center><b>Effective Dates</b></td></tr>");
	      colorindex = 1;

	     for (var recvindx = 0 ; recvindx < receives.length; recvindx++){
		var recv = receives[recvindx];

		    var endt = childValue(recv,"endt");
		    if (endt == ' ') endt = "Present";
		   if (colorindex == 1) { bgclass = "color2"; colorindex = 0} else { bgclass = "color1"; colorindex = 1};
		   o.writeln('<tr valign=top class="' + bgclass+'"><td>'+
	                childValue(recv,"sndn")+"</td>" +
		   	'<td style="width:400px; white-space:normal;">'+childValue(recv,"agmt")+"</td>" +
		   	"<td>"+ childValue(recv,"stdt") + " to "+endt+"</td></tr>");
	       };

	     o.writeln('</table>\n<div style="clear:both;"></div>');
	   };

	     o.writeln("</body>\n</html>");

	     o.close();
	    }
	   else
		{
		    o.writeln('<center><font size=4>Course Transfer Information</font>'+
		    	'<br>&nbsp;<br><table width=50%><tr><td><font size=-1>'+
		    	'For transfer information on ABE courses please see the  ' +
		    	'<a target=bccat_window href=http://bctransferguide.ca/program/abe/abeguide.cfm>' +
		    	'ABE Articulation Guide</a>.'+
		    	'For definitive information on course transferabililty please' +
		    	'contact the Admissions Office at the institution you are attending or plan to attend.' +
		    	'</font></td></tr></table></body></html>');
		    o.close();

		};
	};

    };

   function ShowCrsInfo(subj,crse,intake,variant,site){

    sitename = site;
    swant = subj;
    cwant = crse;

    if (intake == undefined) {
		intwant = "";
		varwant = "*";
		title="Transfer Guide";
	} else {
		intwant = intake;
		varwant = variant;
		title="Course Information";
	} 

   //
   //  Set up onunload handler if not already done
   //

    if (ShowCrsInfo.prevUnloadHandler == undefined){
	   ShowCrsInfo.prevUnloadHandler = window.onunload;
	   if (ShowCrsInfo.prevUnloadHandler == undefined){
			ShowCrsInfo.prevUnloadHandler = function(){return true};
		}
	   window.onunload = function(){
		    if (typeof ShowCrsInfo.windowObj  == "object"){ 
			if (!ShowCrsInfo.windowObj.closed){
					ShowCrsInfo.windowObj.close()
				}
			};
		    if (ShowCrsInfo.prevUnloadHandler != undefined){
				ShowCrsInfo.prevUnloadHandler();
			}
		};
	}

    if (typeof ShowCrsInfo.windowObj  != "object")  { ShowCrsInfo.windowObj = window.open("","tguide_window",
	        "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,width=900,height=750,resizable=yes")}
      else { if ( ShowCrsInfo.windowObj.closed ) ShowCrsInfo.windowObj = window.open("/www/reg/nulltguide.htm","tguide_window",
	        "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,width=900,height=750,resizable=yes")};

    ShowCrsInfo.windowObj.focus();

    ShowCrsInfo.windowObj.document.open();
    ShowCrsInfo.windowObj.document.writeln("<html>\n<head>\n" +
        '<link rel="stylesheet" type="text/css" href="/www/css/uni_global.css">\n' +
        '<link rel="stylesheet" type="text/css" href="/www/css/uni_print.css">\n' +
        '<link rel="stylesheet" type="text/css" href="/www/reg/css/clustertt.css">\n' +
        '<title>' + title + ' for ' + swant + ' ' + cwant + '</title>\n</head>\n<body>');

     var reqstring = "/reg/htbin/getcrsinfo?subject="+swant+"&course="+cwant+"&intake="+intwant+"&variant="+varwant;

     dhtmlxAjax.get(reqstring,showcrs);

}



