
 //clears temp score table at right

//function emptySlctBx(e){
//
//alert('in')
////					for (var i=0;i<e.length;i++){
////						e.remove(i);
////					}
//}





var directionsDisplayed=false;

function showDirections (){

if (directionsDisplayed==false){
document.getElementById("directions").style.display="block"
directionsDisplayed=true;
//alert('ye')
}else{
//alert('no')
document.getElementById("directions").style.display="none"
directionsDisplayed=false;
}
}


function getPostDash(full) {
var parts= 	full.split('-')
return parts[1]
 }
 
 
function loadSlctBoxWithNameAndId(xmlDoc, list, names, ids){
		
	while (list.options.length){
		list.options.remove(0)
	}

	
	var    objectsNode= xmlDoc.documentElement;
	
	for(var index=0; index<objectsNode.childNodes.length; index++) {
	
		var newOpt=document.createElement('option')
		newOpt.text=names[index].firstChild.nodeValue
		newOpt.value=ids[index].firstChild.nodeValue
			list.add(newOpt)
	}
}
 
 
 
 //clears temp score table at right
function clearTable(tblElm){
					for (var i=tblElm.rows.length-1;i>0;i--){
						tblElm.deleteRow(i);
					}
}





 function reloadAfterJSONResp(originalRequest)
	{
//	alert(originalRequest.responseText)

	var resp =eval('(' + originalRequest.responseText + ')');

	pp.log (resp.message)
	
	if (resp.result==true){
		window.location.reload();
	}
		
}
		
		


 function loadURLAfterJSONResp(originalRequest)
	{
//	alert(originalRequest.responseText)
	var resp =eval('(' + originalRequest.responseText + ')');
	pp.log (resp.message)
	if (resp.result){
			window.open(resp.url);
	}
}




 function showURL_LinkAfterJSONResp(originalRequest)
	{

//alert(originalRequest.responseText)
	var resp =eval('(' + originalRequest.responseText + ')');

	pp.log (resp.message)
	
	if (resp.result==true){

//alert('show')	
$(rptLink).style.display='block'	;
$(rptLink).href=resp.url;
$(rptTitle).innerHTML=resp.urlTitle;
//$(rptLink).highlight();		

loadURLAfterJSONResp(originalRequest)

	}
		
}



//
// function openNewWindow(url)
//	{
//	window.open(url)
//	}
//		



var univNumClicked=false;

function checkAndClearTextField(id){

if (!univNumClicked){
		univNumClicked=true;
		clearTextField(id);
	}
}
		




function ajaxIndicate() {
 	
// 	alert('in')
 	
 	Ajax.Responders.register({
onCreate:
function(){

//	document.getElementById('waitIndicator').style.display='block';
//document.getElementById('waitIndicator').style.display='inline';
//	alert('don')
	$('waitIndicator').show();

	
	
//$(rptLink).style.display='none'	;
//	fh.indicateWait('waitIndicator');
},

onComplete:
function(){
//	fh.indicateNoWait('waitIndicator');
	$('waitIndicator').hide();
//	alert('don')
$('pgBody').pulsate({'pulses':2, 'duration': 0.05})

	
}

});
 }
 
 
 
function ajWait(){
	$('waitIndicator').show();
} 
 
 
 
// 
// function(){
//
////	document.getElementById('waitIndicator').style.display='block';
////document.getElementById('waitIndicator').style.display='inline';
//	alert('don')
//	
//	$('waitIndicator').show();
//
//	
////$(rptLink).style.display='none'	;
////	fh.indicateWait('waitIndicator');
//}
// 
 
 
 
 
 
 
 
 
 
 function ArrayUtil(arr) {

this.arr=arr;

}


ArrayUtil.prototype.getCSV_Values= function() {
	var csv='';
	for(var index=0; index<this.arr.length; index++) {
		csv+=this.arr[index]+',';
	}
	return stripLastChar(csv);
}



function urlParam(name, val){
	
	this.name=name;
	this.val=val;
}

function url() {
	
}



//generic class for form field handling and validation


function postnukeURL( mod, type ,func ,opt, params) {

this.baseURL="index.php?";

this.parameterString='';


for(var index=0; index<params.length; index++) {
	this.parameterString=this.parameterString+'&'+params[index].name+'='+params[index].val;

//alert(params[index].name)
//alert(params[index].val)
} 

this.url = this.baseURL
	+"module="+ mod
	+"&type="+ 	type
	+"&func="+ 	func 
	+"&option="+ opt 
;



}


function Math2() {

}

Math2.prototype.getRand1B= function() {
    return Math.floor((Math.random()*1000000000)+1);
}

//FORM FIELD HANDLING

//clear text field
function clearTextField(id) {

document.getElementById(id).value="";

}


//STRING HANDLING

//remove last character
function stripLastChar(inString) {

	var stripped = new String(inString);
	
	var slen = stripped.length;
//	alert("stripLastChar: "+stripped.substring(0,slen-1));
	
   return stripped.substring(0,slen-1) ;
}


//forms & validation

//GENERAL

// general purpose function to see if an input value has been
// entered at all
function isEmpty(inputStr) {
   if (inputStr == null || inputStr == "") {
      return true;
   }
   return false;
}


function highlightRow(id){
document.getElementById(id).style.backgroundColor = '#CCFFFF'
}

//NUMBERS

// general purpose function to see if a suspected numeric input
// is a positive or negative number
function isNumber(inputVal) {
   oneDecimal = false;
   inputStr = inputVal.toString();
   for (var i = 0; i < inputStr.length; i++) {
      var oneChar = inputStr.charAt(i);
      if (i == 0 && oneChar == "-") {
         continue;
      }
      if (oneChar == "." && !oneDecimal) {
         oneDecimal = true;
         continue;
      }
      if (oneChar < "0" || oneChar > "9") {
         return false;
      }
   }
   return true;
}


// general purpose function to see if a suspected numeric input
// is a positive integer
function isPosInteger(inputVal) {
   inputStr = inputVal.toString();
   for (var i = 0; i < inputStr.length; i++) {
      var oneChar = inputStr.charAt(i);
      if (oneChar < "0" || oneChar > "9") {
         return false;
      }
   }
   return true;
}


// function to determine if value is in acceptable range
// for this application
function inRange(inputStr, min, max) {
   num = parseInt(inputStr);
   if ((num <= max)&&(num >= min )){
      return true;
   }
   else {
   return false;
   }
}

function resetAndSelect(id){
document.getElementById(id).value="";
document.getElementById(id).select();
//alert (id);
}

//AJAX


function getRequestObject (){
	 
  var xmlHttp;
  
  try
    {    
    	
    // Firefox, Opera 8.0+, Safari   
    xmlHttp=new XMLHttpRequest();    
    
    }
  catch (e)
    	{    // Internet Explorer    
    		try
      		{      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      }
    		catch (e)
      			{      
		      	try
		        {        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        }
		      	catch (e)
		        {        alert("Your browser does not support AJAX!");        
		        			return false;        
		        			}      
		        			}    
		        			}  
		        			
	return xmlHttp;
}

//admin functions

//function validateGrade(id){
//
//	if (checkForValidTotalPointsPossible(id) == false) {
//	exit;	
//	}
//	
//	var enteredScore = document.getElementById("orig_"+id).value;
//	
//	var totalPointsPossible = document.getElementById("total_points_possible").value;
//	
//	var componentValue = <!--[$componentValue]-->;
//	
//	var min = 0;
//	
//	var max = totalPointsPossible ;
//	
//	var validInput = true;
//	
//	//**validate entry
//	
//	//check for non-null
//	if (isEmpty(enteredScore)==true) { 
//	alert ("The form field is empty."); 
//	document.getElementById("orig_"+id).select();
//	validInput = false;
//	}
//	
//	//check that it's a valid number
//	if ((validInput ==true)&&(isNumber(enteredScore)==false)) { 
//	alert ("The data entered is not a number."); 
//	document.getElementById("orig_"+id).select();
//	validInput = false;
//	}
//	
//	//check for proper range
//	if ((validInput ==true)&&(inRange(enteredScore, min, max )==false)) { 
//	alert ("The data entered is not in the proper range. It is too high or too low."); 
//	document.getElementById("orig_"+id).select();
//	validInput = false;
//	}
//	
//	
//	//calculate new grade
//	document.getElementById("post_conversion_"+id).value = Math.round((enteredScore/totalPointsPossible*componentValue)*100)/100;
//	
//	//indicate that grade has been updated
//	document.getElementById("was_updated_"+id).value=true;
//	
//highlightRow("row_"+id)
//
//}
//
//function unConvertGrade(id){
//	document.getElementById("converted"+id).value= document.getElementById("orig_"+id).value/
//	document.getElementById("total_points_possible").value*<!--[$componentValue]-->;
//}
//
//function  clearField(fieldId){
//	document.getElementById("orig_"+fieldId).value= "";
//}
//



//NUMBERS


function resetAndSelect(id){
document.getElementById(id).value="";
document.getElementById(id).select();
}

//validation


// general purpose function to see if a suspected numeric input
// is a positive or negative number
function isNumber(inputVal) {
   oneDecimal = false;
   inputStr = inputVal.toString();
   for (var i = 0; i < inputStr.length; i++) {
      var oneChar = inputStr.charAt(i);
      if (i == 0 && oneChar == "-") {
         continue;
      }
      if (oneChar == "." && !oneDecimal) {
         oneDecimal = true;
         continue;
      }
      if (oneChar < "0" || oneChar > "9") {
         return false;
      }
   }
   return true;
}


// general purpose function to see if a suspected numeric input
// is a positive integer
function isPosInteger(inputVal) {
   inputStr = inputVal.toString();
   for (var i = 0; i < inputStr.length; i++) {
      var oneChar = inputStr.charAt(i);
      if (oneChar < "0" || oneChar > "9") {
         return false;
      }
   }
   return true;
}


// function to determine if value is in acceptable range
// for this application
function inRange(inputStr, min, max) {
   num = parseInt(inputStr);
   if ((num <= max)&&(num >= min )){
      return true;
   }
   else {
   return false;
   }
}

//GENERAL

// general purpose function to see if an input value has been
// entered at all
function isEmpty(inputStr) {
   if (inputStr == null || inputStr == "") {
      return true;
   }
   return false;
}


String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

//// example of using trim, ltrim, and rtrim
//var myString = " hello my name is ";
//alert("*"+myString.trim()+"*");
//alert("*"+myString.ltrim()+"*");
//alert("*"+myString.rtrim()+"*");
//Javascript Trim Stand-Alone Functions
//If you prefer not to modify the string prototype, then you can use the stand-alone functions below. 


function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

//// example of using trim, ltrim, and rtrim
//var myString = " hello my name is ";
//alert("*"+trim(myString)+"*");
//alert("*"+ltrim(myString)+"*");
//alert("*"+rtrim(myString)+"*");
