	// JavaScript functions for Timber Toolbox version 13_05
	// Author: Jim Vaughan
	// Last modification: 10 June 2010

	//function to toggle document element to hide or show
	function toggle_visibility(id) {			
	   var e = document.getElementById(id);
		 if(e.style.display == 'block')
			 e.style.display = 'none';
		 else
			 e.style.display = 'block';
	}
	
	//function to open separate windows
	function MM_openBrWindow(theURL,winName,features) { //v2.0
	  window.open(theURL,winName,features);
	}
	
	//function to validate the answer in learning activity situation1
	function checkAnswer1(obj){ //this function is to show or hide the portion of text trigged by the user
		var answer = getRadioValue(obj);
		if(answer == "eva"){
			document.getElementById('correct').style.visibility = 'visible'; 
			document.getElementById('incorrect').style.visibility = 'hidden'; 
		}
		else {
			document.getElementById('incorrect').style.visibility = 'visible'; 
			document.getElementById('correct').style.visibility = 'hidden'; 
		}
	}

	//function to validate the answer in learning activity situation2
	function checkAnswer2(obj){ //this function is to show or hide the portion of text trigged by the user
		var answer = getRadioValue(obj);
		if(answer == "end"){
			document.getElementById('correct').style.visibility = 'visible'; 
			document.getElementById('incorrect').style.visibility = 'hidden'; 
		}
		else {
			document.getElementById('incorrect').style.visibility = 'visible'; 
			document.getElementById('correct').style.visibility = 'hidden'; 
		}
	}
	
	//function to validate the answer in learning activity situation3
	function checkAnswer3(obj){ //this function is to show or hide the portion of text trigged by the user
		var answer = getRadioValue(obj);
		if(answer == "pre"){
			document.getElementById('correct').style.visibility = 'visible'; 
			document.getElementById('incorrect').style.visibility = 'hidden'; 
		}
		else {
			document.getElementById('incorrect').style.visibility = 'visible'; 
			document.getElementById('correct').style.visibility = 'hidden'; 
		}
	}
	
	//function to validate the answer in learning activity situation4
	function checkAnswer4(obj){ //this function is to show or hide the portion of text trigged by the user
		var answer = getRadioValue(obj);
		if(answer == "int"){
			document.getElementById('correct').style.visibility = 'visible'; 
			document.getElementById('incorrect').style.visibility = 'hidden'; 
		}
		else {
			document.getElementById('incorrect').style.visibility = 'visible'; 
			document.getElementById('correct').style.visibility = 'hidden'; 
		}
	}
		
	function getRadioValue(idOrName) {
		var value = null;
		var element = document.getElementById(idOrName);
		var radioGroupName = null; // if null, then the id must be the radio group name
		if (element == null) {
			radioGroupName = idOrName;
		}
		else {
			radioGroupName = element.name;
		}
		if (radioGroupName == null) {
		   return null;
		}  
		var radios = document.getElementsByTagName('input');
		for (var i=0; i<radios.length; i++) {
			var input = radios[ i ]; 		
			if (input.type == 'radio' && input.name == radioGroupName && input.checked) {
			   value = input.value;
			   break;
			 }
		 }
		return value;
	}
	
	
	function doSaveAs(){
			
		if (document.execCommand){
			if (getBrowser2()){document.execCommand("SaveAs");}
		}else{
			alert('Feature available only in Internet Exlorer');
		}
		
	}
	
    function getBrowser2() {
	  
	   if (navigator.userAgent.lastIndexOf("MSIE") > 0) {
		   return true;
	   } else {
		   return false;
	   }
   }
   
   
// - - - - - - - task email answer sheet functions  - - - - - - - 

	function mailPopUp(emailAddress) {
		document.location.href = "mailto:" + emailAddress;
	}
	
	function doEmail(){
		document.location.href = "mailto:?subject=" + subjectstr + "&body=" + bodystr;
		return;
	}

// - - - - - - - Popup Window function  - - - - - - -

	function myPopUp(mName, mUrl) {
		var mWidth = 900;
		var mHeight = 700;
		var mFeatures = "location=no,toolbar=no,menubar=no,directories=no,status=no,resizable=yes,scrollbars=yes,height=" + mHeight + ",width=" + mWidth;
		var w = window.open(mUrl, mName, mFeatures);
		
	}
	
	function mobilePopUp(mName, mUrl) {
		var mWidth = 300;
		var mHeight = 700;
		var mFeatures = "location=no,toolbar=no,menubar=no,directories=no,status=no,resizable=yes,scrollbars=yes,height=" + mHeight + ",width=" + mWidth;
		var w = window.open(mUrl, mName, mFeatures);
		
	}
	

// - - - - - - - Popup Window function with content - - - - - - -
	function myPopUpContent(mName, mContent) {
		var mWidth = 400;
		var mHeight = 200;
		var mFeatures = "location=no,toolbar=no,menubar=no,directories=no,status=no,resizable=yes,scrollbars=yes,height=" + mHeight + ",width=" + mWidth;
		var w = window.open("", mName, mFeatures);
		var newContent = "<div style='font-family:Arial, Helvetica, sans-serif;'>" + mContent + "</div>";
		w.document.body.innerHTML = newContent;
		w.document.title = "Answer";
		//w.moveTo(100, 100);
	}
	

	function myPopUpT(mName, mUrl) {
		var mWidth = 900;
		var mHeight = 700;
		var mFeatures = "location=yes,toolbar=yes,menubar=yes,directories=no,status=no,resizable=yes,scrollbars=yes,height=" + mHeight + ",width=" + mWidth;
		var w = window.open(mUrl, mName);
		
	}
	
		
	
