//======================================================
// *** Robinson Secondary Website Operations Scripts
// *** Copyright 2006 Virginia Technical Services and Support Systems Corporation
// -----------------------------------------------------
// *** Created 2006-12-11
// -----------------------------------------------------
//
// MODIFICATIONS RECORDS:
// Operator			Date		Modifications
// David Holley		12/12/06	Script Created
//======================================================

//======================================================
// *** init
// -----------------------------------------------------
// ***
//======================================================
function init(){
	
	//alert('init');
}


//======================================================
// *** openNewWindow
// -----------------------------------------------------
// *** opens new window with specified variables
//======================================================
function openNewWindow(URLtoOpen, windowName, windowFeatures) {
	newWindow=window.open(URLtoOpen, windowName, windowFeatures); 
}

//======================================================
// *** MM_jumpMenu
// -----------------------------------------------------
// *** creates jump menu
//======================================================
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}



//======================================================
// *** generateBreadcrumb
// -----------------------------------------------------
// *** generates breadcrumb links for page
//======================================================
function generateBreadcrumb(){

	var thisURL = window.location;
	var thisTitle = document.title;
	
	// *** first build main part of breadcrumb
	var strURL = thisURL.toString();
	// *** pop out the first four items in the array - 
	// *** the root of the url string (http:, /, /, [domain])
	arrURL.reverse();
	for(var i=0; i<3; i++){
		arrURL.pop(i);
	}
	// *** reorder to correct order
	arrURL.reverse();
	// *** get rid of trailing slashes
	var lastItem = arrURL.length-1;
	arrURL.pop(lastItem);

	// *** clean out unwanted characters from each word
	// *** like "_" and "/"
	
	/*
	for(var k=0; k<arrURL.length; k++){
		
		 // *** break apart each word
		 arrURL[k] = cleanString(arrURL[k]);

	}
	*/

	// *** now build end of breadcrumb - the title
	var strTitle = thisTitle.toString();
	var titleColonPosition = strTitle.lastIndexOf(":");

	if(titleColonPosition == null || titleColonPosition == -1){
		titleColonPosition = 0;
	} else {
		titleColonPosition++;
	}
	
	//alert('title = ' + titleColonPosition);
	var strNewTitle = strTitle.substr(titleColonPosition, strTitle.length);
	strNewTitle = strNewTitle.toLowerCase();
	strNewTitle = cleanString(strNewTitle);
	//alert('strNewTitle = '+ strNewTitle);

	// *** now compose breadcrumb
	var breadcrumb = "<a href=\"/\" class=\"footerLinkWhite\">home</a> / ";
	
	// *** loop through array
	for(var j=0; j<arrURL.length+1; j++){
		
		// *** if this is last item in array
		if(j==arrURL.length){
			
			var section = "<span style=\"font-weight:bold;\">"+strNewTitle+"</span>";
			
			
		} else {
			
			// *** get this section url
			var sectionURL = "";
			for(var m=0; m<=j; m++){
				//alert('arrURL['+m+'] = ' + arrURL[m]);
				sectionURL += "/"+arrURL[m]; 
				
			}
			var section = "<a href="+sectionURL+" class=\"footerLinkWhite\">"+arrURL[j]+"</a> / ";
			
		}
		
		breadcrumb += section;
		
	}
	
	//alert('final breadcrumb = ' + breadcrumb);
	//document.write(breadcrumb);
	return(breadcrumb);
}


function cleanString(str){
	
	var re = /[\/_*]/g;
	str = str.replace(re, " ");
	return(str);
	
}


function validateForm(which){

	var tf = which;
	for (i=0; i<tf.length; i++){
		var te = tf.elements[i];
		var ten = te.name;
		var tev = te.value;
		var teid = te.id;
		var tet = te.type;
		
		// *** get element name prefix
		var teprefix = ten.substr(0, 2);
		//alert('hey teprefix = ' + teprefix);
		
		if(teprefix=='RE'){
			
			
			if(tev == ''){
				alert('Please make sure the "'+teid+'" field is completed.');
				return(false);
			}
			
		}
		

	}
	
	return(true);
}

function displayFooterForm(){

	var te = document.getElementById("footerFormContainer");
	te.style.display = "inline";

}

function displayEmailPageForm(){

	var te = document.getElementById("emailPageFormContainer");
	te.style.display = "inline";

}

function printThisPage(){
	
	window.print();
	
	
}