function showText(inputdata){ 
	window.alert(inputdata);
}


function buildPage(){
	var pagecontent = "<html><head><title>";
	pagecontent += document.pageform.pagetitle.value;
	pagecontent += "</title></head>\n"
	pagecontent += "<body bgcolor='white'>\n"
	pagecontent += document.pageform.bodytext.value;
	pagecontent += "\n</body>\n</html>";
	document.pageform.mycode.value=pagecontent;
}


/* Code to manipulate values from form objects */

function getRadioValue(formname,radioname){
	var theRadioButtons = document[formname][radioname];
	var checkButton=""

	for (i=0;i<theRadioButtons.length;i++){
		if (theRadioButtons[i].checked){
		checkButton= theRadioButtons[i].value;
		}
	}
	return checkButton
}

function showRadioValue(formname,radioname,thevalue){
	var theRadioButtons = document[formname][radioname];
	for (i=0;i<theRadioButtons.length;i++){
		var temp = theRadioButtons[i].value;
		if (temp == thevalue){
		theRadioButtons[i].checked = true;
		}
	}
}


function getSelectValue(formname,selectname){
	var theMenu = document[formname][selectname];
	var selecteditem = theMenu.selectedIndex;
	return theMenu.options[selecteditem].value;
}


function showSelectValue(formname,selectname,thevalue){
	var theMenu = document[formname][selectname];
	for (i=0;i<theMenu.options.length;i++){
		var temp = theMenu.options[i].value;
		if (temp == thevalue){
		 theMenu.selectedIndex = i;
		}
	}
}

/* End of code to manipulate values from form objects */


/* Code to check and score self grading test */
function verify() {
if (!document.testform.userid.value) {
	window.alert("You must enter your name.");
	document.testform.userid.focus();
	return false;}
else{
	if (checkAnswers()==true){
		 // Display total
		if (score<100)
			{window.alert("Your Total Score is " + score +"\n The question(s) you answered incorrectly are " + nowrong);}
		else
			{window.alert("Your Total Score is " + score +"\n Congratulations, you answered each question correctly");}
		return true;
	}
			

	else 		
	{return false;}
     }
			
}


function checkAnswers(){
	
score=0;
nowrong="";	



//Check that all questions have been answered
	//Check for answer for question 1
	if (!document.testform.question1.value) {
			window.alert("You have not answered question 1");
			return false;
			document.testform.question1.focus();
			}
	
	else{ 
		//Check for answer for question 2		
		var radioval=getRadioValue("testform", "question2")
		 if (radioval=="")
			{window.alert("Please select an answer for question 2 ");
					return false;
		       			document.testform.question1.focus();}

	
			else{
			
				//Check for answer for question 3
				var cbanswer=""		<!-- // Variable declared to hold value of check box -->
				var studentanswer=""	<!-- // Variable declared to hold student's cumulative answer -->

				for (i=0; i<6; i++){
					if (document.testform['question3' + i].checked)
						{cbanswer=document.testform['question3' + i].value;
						studentanswer=studentanswer +cbanswer;}
				}

				if (studentanswer=="")
					{window.alert("Please select an answer for question 3");
					return false;
					document.testform.question3a.focus();}
			

					else{
							//Check for answer for question 4
							if (!document.testform.question4.value)
							{window.alert("Please select an answer for question 4");
							return false;
							document.testform.question4.focus();}
					      }
			}
	

//Check answer for question 1's text box and if correct, add 25 points to the score

     		if (testform.question1.value=="check" || testform.question1.value== "Check" || testform.question1.value=="CHECK")
			{score+=25;}
		else
			{nowrong="1";}



     		//Check answer for question 2's radio buttons and if correct, add 25 points to the score
			if(getRadioValue("testform", "question2")=="radiobtn")
				{score+=25;}
			else{
				if (nowrong=="")
				{nowrong+=  "2";} 
					else {nowrong+=  " and 2";} 
			}
				
		
    
			//Check answer for question 3's check boxes and if correct, add 25 points to the score

					if (studentanswer=="imgattribute")
						{score+=25;}
					else{
						if (nowrong=="")
						{nowrong+=  "3";} 
							else {nowrong+= " and 3";}
					}



					// Check answer for question 4's select box and if correct, add 25 points to the score-->

							if (document.testform.question4.value=="216")
								{score+=25;
								return true;}
							else{
								if (nowrong=="")
								{nowrong+=  "4";}
									else {nowrong+= " and 4";
								return true;}
							}
	}
	
}

/* End of code for self grading test */




/*Arrays for pages with calendars */
var theDays = new Array();
theDays[0]="Sunday";
theDays[1]="Monday";
theDays[2]="Tuesday";
theDays[3]="Wednesday";
theDays[4]="Thursday";
theDays[5]="Friday";
theDays[6]="Saturday";

var theMonths = new Array();
theMonths[0]="January";
theMonths[1]="February";
theMonths[2]="March";
theMonths[3]="April";
theMonths[4]="May";
theMonths[5]="June";
theMonths[6]="July";
theMonths[7]="August";
theMonths[8]="September";
theMonths[9]="October";
theMonths[10]="November";
theMonths[11]="December";



/*Cookie Code Based on code by Bill Dortch of hidaho designs.*/
function SetCookie(name,value,expires,path,domain,secure){
	var temp = name + "=" + escape(value);
	if (expires){
	temp += "; expires=" + expires.toGMTString();
	}

	if (path){
	temp += "; path=" + path;
	}

	if (domain){
	temp += "; domain=" + domain;
	}

	if (secure){
	temp += "; secure";
	}

	document.cookie = temp;
}



function GetCookie(name){
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	
	while (i < clen) {
		var j = i + alen;
			if (document.cookie.substring(i,j) == arg){
			return getCookieVal(j);
			}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}

	return null;
}


function getCookieVal(offset){
	var endstr = document.cookie.indexOf(";", offset);
	if (endstr == -1){
		endstr = document.cookie.length;
	}

	return unescape(document.cookie.substring(offset,endstr));
}




function DeleteCookie (name,path,domain) {
	if (GetCookie(name)) {
		var temp = name + "=";
		temp += ((path) ? "; path=" + path : "");
		temp += ((domain) ? "; domain=" + domain : "");
		temp += "; expires=Thu, 01-Jan-70 00:00:01 GMT";
		document.cookie = temp;
	}
}

/* End of Cookie Code */


/* converts days to milliseconds */
function daysToMS(days){
return days * 24 * 60 * 60 * 1000;
}


/* converts weeks to milliseconds */
function weeksToMS(weeks){
return weeks * 7 * 24 * 60 * 60 * 1000;
}


/* converts years to milliseconds */
function yearsToMS(years){
return years * 365.25 * 24 * 60 * 60 * 1000;
}



/*var myWindow = null;*/
function openWin(url,targetname,W,H,L,T,thefeatures) {
    var params = "";
    var nofeatures = "toolbar=0,location=0,directories=0,status=0,";
    nofeatures += "menubar=0,scrollbars=0,resizable=0,copyhistory=0";
    var basicfeatures = "scrollbars=1,resizable=1,menubar=1 ";
    var morefeatures = "toolbar=1,location=1,directories=1,";
	morefeatures += "status=1,copyhistory=1";
    var dimensions = "width=" + W + ",height=" + H;
    var placement = "left="  + L + ",top=" + T;
    placement += ",screenX="  + L + ",screenY=" + T;
    
    /* Callout: The switch control structure makes decisions that depend on the value of a variable. In this case the value of the parameter variable thefeatures determines the value of the variable params. */

    switch (thefeatures){
        case "none":
            params += nofeatures;
            break;
        case "basic":
            params += basicfeatures;
            break;
        case "full":
            params += basicfeatures + "," + morefeatures;
            break;
        default:
            params += thefeatures;
    }

    /* Adds the dimensions and placement info to the params variable. */
    params += "," + dimensions + "," + placement;
    /* The window.open()method  creates myWindow. */
    myWindow = window.open(url,targetname,params);
}



function closeWin(){
    if (myWindow != null){
        myWindow.close();
        myWindow = null;    
    }
}






/* Browser detection code */
/* Contains the browser name */
var theApp = navigator.appName.toLowerCase();

/* UA for user agent will contain more detailed browser info. For example, UA for Internet Explorer on Mac would be 'mozilla/4.0 (compatible; msie 5.0; mac_powerpc)' */
var UA = navigator.userAgent.toLowerCase();

/* variables for the two major browsers in existence today. */
var isIE = (UA.indexOf('msie') >= 0) ? true : false;
var isNS = (UA.indexOf('mozilla') >= 0) ? true : false;

// 'compatible' text string exists only in non-Netscape browsers
if (UA.indexOf('compatible')>0){
	isNS = false;
}

// platform
var thePlatform = navigator.platform.toLowerCase();
var isMAC = (UA.indexOf('mac') >= 0) ? true : false;
var isWIN = (UA.indexOf('win') >= 0) ? true : false;

/* Most UNIX users use X-Windows so this detects UNIX most of the time.*/
var isUNIX = (UA.indexOf('x11') >= 0) ? true : false;

// browser version
var version = navigator.appVersion;
var isMajor = parseInt( version );
// Internet Explorer version 5 on the Mac reports itself as version 4
if(isIE && isMAC) {
	if(UA.indexOf("msie 5")) {
		isMajor = 5;
		var stringLoc = UA.indexOf("msie 5");
		version = UA.substring(stringLoc + 5, stringLoc + 8);
	}
}

// Netscape 6 reports itself as version 5
if(isNS && isMajor>4) {
	if(UA.indexOf("netscape6")) {
		isMajor = 6;
		var stringLoc = UA.indexOf("netscape6");
		version = UA.substring(stringLoc + 10, stringLoc + 14);
	}
}
var isMinor = parseFloat( version );

var obsolete = (document.getElementById) ? false : true;
/* End of browser detection code */






