courseChangeWin = "";
 function openWindow(type, width, height)
 {
	courseChangeWin = open(type, "", "top=100,left=100,toolbar=yes,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height);
	return false;
 }
 
 function openWindowNC(type, width, height)
 {
	courseChangeWin = open(type, "", "top=50,left=50,toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=" + width + ",height=" + height);
	return false;
 }
 
 function openWindowBar(type, width, height)
 {
 	courseChangeWin = open(type, "", "top=50,left=50,toolbar=yes,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height);
	return false;
 }
 
function checkRB(eName)
 {
 	var form = document.form1;
	var okV = false;
	// use this if only one radio button

	if( !form[eName].length )
		okV = form[eName].checked;
	else {
		rb = 0;
		// if it finds one option checked, it stops the loop
		while( rb < form[eName].length && !okV)
		{
			okV = form[eName][rb].checked;
			rb++;
		}
	}
	return !okV;
 }
 
 function switchHTML(relativePath, formElem, colV, rowV, tableWidthV)
 {
	
 	var form = document.form1;
	var contentV = "";

	if( form[formElem + "_html"].checked ) {
		
		form[formElem].value = form[formElem + "_ta"].value;
		contentV = "<table width='" + tableWidthV + "' cellspacing='0' class='generic'><tr><th class='alignLt'><a href='javascript:;' onClick=\"return doEditor('" + relativePath + "', '" + formElem + "', " + tableWidthV + ");\"><img src='" + relativePath + "images/formatText_button.gif' alt='Format Text' width='94' height='19' border='0'></a></th></tr><tr><td>" + form[formElem + "_ta"].value + "</td></tr></table>";
	}
	else {
		contentV = "<textarea name='" + formElem + "_ta' cols='" + colV + "' rows='" + rowV + "' wrap='VIRTUAL' id='" + formElem + "_ta'>" + (form[formElem].value) + "</textarea>";
	}
	writeLayersContent(formElem + "_layer", contentV);
 }

 function writeLayersContent(layerID, newContent)
 {
 	if( document.all && (navigator.userAgent.indexOf("Opera") == -1) )
		document.all[layerID].innerHTML=newContent;
	else if (navigator.userAgent.indexOf("Mozilla/4") != -1)
		alert("You will need to upgrade your browser to be able to use this feature.");
	else
		document.getElementById(layerID).innerHTML=newContent;
 }
 
 globalRelativePath = "";
 function doEditor(relativePath, formElem, tWidth)
 {
 	globalRelativePath = relativePath;
	openWindow(relativePath + "admin/editor/index.aspx?whichOne=" + formElem + "&tw=" + tWidth, 720, 570);
 
	 return false;
 }

 function rewritePage(formElem, theContent, tableWidthVa)
 {
 	var form = document.form1;
 	form[formElem].value = theContent;
 	contentV = "<table width='" + tableWidthVa + "' cellspacing='0' class='generic'><tr><th class='alignLt'><a href='javascript:;' onClick=\"return doEditor('" + globalRelativePath + "', '" + formElem + "', " + tableWidthVa + ");\"><img src='" + globalRelativePath + "images/formatText_button.gif' alt='Format Text' width='94' height='19' border='0'></a></th></tr><tr><td>" + theContent + "</td></tr></table>";
	writeLayersContent(formElem + "_layer", contentV);
 }
 
 function fixText(textToFix)
 {
 	fixedText = textToFix.replace(/\n/g,"<br/>");
	fixedText = fixedText.replace(/\s\s/g, "&nbsp;&nbsp;");
 	return fixedText;
 }
function setWindowSize(newX, newY){
   if(document.all){
      window.resizeTo(newX,newY)
   }
   else{     window.innerHeight = newY
	  window.innerWidth = newX
   }
}