var which_mode = "simple";


function show_expert() {
	which_mode = "complex";
	expert_mode.style.display = '';
	simple_mode.style.display = 'none';
	document.addContent.expert_content.value = bpitEditor.document.body.innerHTML;
}

function show_simple() {
	which_mode = "simple";
	expert_mode.style.display = 'none';
	simple_mode.style.display = '';
	bpitEditor.document.body.innerHTML = document.addContent.expert_content.value;
}

function send_page() {
	if (document.addContent.name.value == "") {
	alert("You must enter a name for the page before submitting.");
	} else {
	//set_x();
	document.addContent.submit();
	}
}

function send_question() {
	if (document.addContent.name.value == "") {
	alert("You must enter a name for the page before submitting.");
	} else {
		//if (document.addContent.answer1.value=="") {
		//alert("You must enter at least one answer for the question.");
		//} else {
			document.addContent.submit();
		//}
	}
}

function send_page_OO() {
document.addContent.submit();
}

function set_x() {
	var x = bpitEditor.document.body.innerHTML;
	var y = document.addContent.expert_content.value;
	if (which_mode == "simple") {
	document.addContent.content.value = x;
	} else {
	document.addContent.content.value = y;
	}
}

function button_over(doitButton)
        {
        doitButton.style.backgroundColor = "#CCCCCC";
        doitButton.style.borderColor = "#FFFFFF #666666 #666666 #FFFFFF";
        }
function button_out(doitButton)
        {
        doitButton.style.backgroundColor = "CCCCCC";
        doitButton.style.borderColor = "#CCCCCC";
        }
function button_down(doitButton)
        {
        doitButton.style.backgroundColor = "#CCCCCC";
        doitButton.style.borderColor = "#666666 #FFFFFF #FFFFFF #666666";
        }
function button_up(doitButton)
    {
    doitButton.style.backgroundColor = "#CCCCCC";
        doitButton.style.borderColor = "#CCCCCC";
    }

function doit(it) {
	  var tr = frames.bpitEditor.document.selection.createRange()
	  tr.execCommand(it)
	  tr.select()
	  frames.bpitEditor.focus()
           }
		   
function del_mod(which) {
	if (confirm("Are you sure you want to delete this Module? If you have lessons and pages attached to this module, they will be lost.")) {
		location="st_structure.asp?code=delete&theID=" + which;
	}
}

function del_lesson(which) {
	if (confirm("Are you sure you want to delete this Lesson? If you have pages attached to this lesson, they will be lost.")) {
		location="st_structure.asp?code=delete&theID=" + which;
	}
}

function del_page(which) {
	if (confirm("Are you sure you want to delete this Page?")) {
		location="st_content.asp?code=delete&theID=" + which;
	}
}

function open_menu_window(myLoc) {
		myWin= open(myLoc, "Menu" ,"width=500,height=500,location=no,status=no,toolbar=no,menubar=no,scrollbars=yes");
		myWin.focus();	
}

function openContent(myLoc) {
		cwWin= open(myLoc, "courseware" ,"width=775,height=525,location=no,status=no,toolbar=no,menubar=no,scrollbars=no");
		cwWin.focus();	
}

function openContent_full(myLoc) {
		cwWin= open(myLoc, "courseware" ,"width=775,height=525,location=no,status=no,toolbar=no,menubar=no,scrollbars=no,fullscreen=yes");
		cwWin.focus();	
}

function popStats (name, start, end) {
	//myWin= open("", "Stats" ,"width=400,height=200,status=no,toolbar=no,menubar=no,scrollbars=no");
	//myWin.document.writeln('<html><head></head><body><table align=center width=90% border=0 class="text"><tr><td><strong>' + name + '</strong></td></tr><tr><td>Started: ' + start + '</td></tr><tr><td>Completed: ' + end + '</td></tr></body></html>');
	//myWin.focus();
	//alert (name + "\nStarted: " + start + "\nCompleted: " + end);

}

function launch_ilt_pres(loc) {
		myWin= open(loc, "Presentation" ,"width=775,height=525,location=no,status=yes,toolbar=no,menubar=no,scrollbars=no");
		myWin.focus();	
}

function launch_pda(loc) {
		myWin= open(loc, "Presentation" ,"width=240,height=320,location=no,status=no,toolbar=no,menubar=no,scrollbars=yes");
		myWin.focus();	
}

function previewPage(which) {
		myWin= open("st_preview_page.asp?theID=" + which, "Preview" ,"width=775,height=575,location=no,status=yes,toolbar=no,menubar=no,scrollbars=no");
		myWin.focus();
}

function showImage(where) {
		myWin= open(where, "Preview" ,"width=500,height=500,location=no,status=no,toolbar=no,menubar=no,scrollbars=auto");
		myWin.focus();	
}

function deleteUser(which) {
	if (confirm("Are you sure you want to delete this user account?")) {
		location = "st_edit_user_admin.asp?code=go&theUser=" + which;
	}
}

function deleteDev(which) {
	if (confirm("Are you sure you want to delete this developer account?")) {
		location = "st_edit_dev_admin.asp?code=go&theUser=" + which;
	}
}

function popTypes() {
		myWin= open("popTypes.html", "Types" ,"width=500,height=350,location=no,status=no,toolbar=no,menubar=no,scrollbars=auto");
		myWin.focus();
}

function deleteCourse(which) {
	if (confirm("Are you SURE you wish to delete this course. The entire contents of this course\nwill be LOST including all pages, lessons and images!")) {
		if (confirm("Are you really sure?")) {
			location="st_main.asp?code=delete&deleteID=" + which;
		}
	}
}

function confirmDeleteImage(where) {
	if (confirm("Are you sure you want to remove this image?")) {
	location = where;
	}

}

function viewComment(theID) {
		myWin= open("st_viewComment.asp?page_id=" + theID, "comments" ,"width=600,height=500,location=no,status=yes,toolbar=no,menubar=no,scrollbars=auto");
		myWin.focus();
}

function closeComment(which, pageID) {
	if (confirm("Are you sure you want to remove this comment?")) {
	location = "st_viewComment.asp?code=delete&deleteID=" + which + "&page_id=" + pageID;
	}
}

function popCrit() {
		myWin= open("popCrit.html", "Types" ,"width=500,height=350,location=no,status=no,toolbar=no,menubar=no,scrollbars=auto");
		myWin.focus();
}

function deleteCrit(which) {
	if (confirm("Are you sure you want to delete this Criteria? You will\nlose the criteria option and all data associated with it.")) {
	location = "st_deliver.asp?code=delete&deleteID=" + which;
	}
}

function popContent(what) {
		myWin= open("st_showContent.asp?theID=" + what, "Content_Preview" ,"width=600,height=500,location=no,status=yes,toolbar=no,menubar=no,scrollbars=auto");
		myWin.focus();
}

function pickType() {
//check for converting from existing free
var qs = new Querystring();
var convertID = qs.get("convertID")
//convertID = 17;

	document.signupform.convertID.value=convertID;
	document.signupform.submit();
}

function Querystring(qs) { // optionally pass a querystring to parse
	this.params = new Object()
	this.get=Querystring_get
	
	if (qs == null)
		qs=location.search.substring(1,location.search.length)

	if (qs.length == 0) return

// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ')
	var args = qs.split('&') // parse out name/value pairs separated via &
	
// split out each name=value pair
	for (var i=0;i<args.length;i++) {
		var value;
		var pair = args[i].split('=')
		var name = unescape(pair[0])

		if (pair.length == 2)
			value = unescape(pair[1])
		else
			value = name
		
		this.params[name] = value
	}
}

function Querystring_get(key, default_) {
	// This silly looking line changes UNDEFINED to NULL
	if (default_ == null) default_ = null;
	
	var value=this.params[key]
	if (value==null) value=default_;
	
	return value
}

function pasteContent(what) {
addContent.narrText.value=what;
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
   
function clearNameField() {
//alert("doing it");
if (document.addContent.name.value == "New Page Name") {
document.addContent.name.value = "";
}
}

