<!--
// ====================================================================================================
// GENERAL FORM VALIDATION
// ====================================================================================================
//Empty Check Form Validation ----------------------------------
function isEmpty(aTextField) {
	if ((aTextField.value.length==0) || (aTextField.value==null)) {
		return true;
	}
	else { return false; }
}


// Email Address Check Form Validation ------------------------
function isAnEmailAddress(aTextField) {
	// 1+@3+ [or x@x.x] is as close as we will test
	if (aTextField.value.length<5) {
		return false;
	}
	else if (aTextField.value.indexOf("@") < 1) {
		return false;
	}
	else if (aTextField.value.length - aTextField.value.indexOf("@") < 4) {
		return false;
	}
	else if (aTextField.value.indexOf(";") > 0) {
		return false;
	}
	else { return true; }
}



// ====================================================================================================
// SEARCH VALIDATOR
// ====================================================================================================
function searchValidator(theForm)
{
  if (isEmpty(theForm.q) || theForm.q.value == "keyword search" || theForm.q.value == "search invalid")
  {
    //alert("Please enter a search term.");
	theForm.q.style.color = "#E80000";
	theForm.q.value = "search invalid";
    //theForm.q.focus();
    return (false);
  }

  return (true);
}



// ====================================================================================================
// TOGGLE MENU
// ====================================================================================================
function toggleMenu (obj) {
	//alert(Object.inspect($(obj).firstChild.style.display));
	if (document.getElementById("toggle"+obj).style.display == "none") {
		Effect.BlindDown("toggle"+obj, {duration:0.2, queue: {position:'front', scope: 'togglemenuscope'}, afterFinish: 
			function() {
				document.getElementById("toggle"+obj).style.display = "block";
				document.getElementById("toggleArrow"+obj).style.backgroundPosition = "0px -15px";
			}					 
		});
	}
	else if (document.getElementById("toggle"+obj).style.display == "block") {
		Effect.BlindUp("toggle"+obj, {duration:0.2, queue: {position:'front', scope: 'togglemenuscope'}, afterFinish: 
			function() {
				document.getElementById("toggle"+obj).style.display = "none";
				document.getElementById("toggleArrow"+obj).style.backgroundPosition = "0px 0px";
			}					 
		});
	}
	else {
		Effect.BlindDown("toggle"+obj, {duration:0.2, queue: {position:'front', scope: 'togglemenuscope'}, afterFinish: 
			function() {
				document.getElementById("toggle"+obj).style.display = "block";
				document.getElementById("toggleArrow"+obj).style.backgroundPosition = "0px -15px";
			}					 
		});
	}
}



// ====================================================================================================
// MATCHING COLUMNS
// ====================================================================================================
//How it works: just apply the CSS class of 'column' to your pages' main columns.
matchColumns=function(){ 
     var divs,contDivs,maxHeight,divHeight,d; 
     // get all <div> elements in the document 
     divs=document.getElementsByTagName('div'); 
     contDivs=[]; 
     // initialize maximum height value 
     maxHeight=0; 
     // iterate over all <div> elements in the document 
     for(var i=0;i<divs.length;i++){ 
          // make collection with <div> elements with class attribute 'container' 
          if(/\bcolumn\b/.test(divs[i].className)){ 
                d=divs[i]; 
                contDivs[contDivs.length]=d; 
                // determine height for <div> element 
                if(d.offsetHeight){ 
                     divHeight=d.offsetHeight; 					
                } 
                else if(d.style.pixelHeight){ 
                     divHeight=d.style.pixelHeight;					 
                } 
                // calculate maximum height 
                maxHeight=Math.max(maxHeight,divHeight); 
          } 
     } 

     // assign maximum height value to all of container <div> elements 
     for(var i=0;i<contDivs.length;i++){ 
          contDivs[i].style.height=maxHeight + "px"; 
     } 
} 

// Runs the script when page loads 
window.onload=function(){ 
     if(document.getElementsByTagName){ 
          matchColumns();			 
     } 
}




// ====================================================================================================
// FEEDBACK FORM
// ====================================================================================================
// Show Hide Feedback ---------------------------------------------------------------------------------------------
function ShowHideFeedback(mode) {
	if (mode == "show") {
		Effect.Fade('home-feedback', {duration:0.6, queue: {position:'front', scope: 'httpResponseScope'}});
		Effect.Appear('home-feedback-form', {duration:0.6, queue: {position:'end', scope: 'httpResponseScope'}});
	}
	else if (mode == "hide") {
		Effect.Fade('home-feedback-form', {duration:0.6, queue: {position:'front', scope: 'httpResponseScope'}, afterFinish: 
			function() {
				// Clear Feedback Form -------------
				document.feedbackForm.name.value = "";
				document.feedbackForm.email.value = "";
				document.feedbackForm.comments.value = "";
				// Appear -----------------------------
				Effect.Appear('home-feedback', {duration:0.6, queue: {position:'end', scope: 'httpResponseScope'}});
			}	
		});
	}
}

// Feedback Validator -------------------------------------------------------------------------------------------------
function FeedbackValidator(theForm) {
	if (isEmpty(theForm.name) || theForm.name.value == "required") {
		theForm.name.style.color = "#E80000";
		theForm.name.value = "required";
	}
 	if (isEmpty(theForm.email) || theForm.email.value == "required" || !isAnEmailAddress(theForm.email)) {
		theForm.email.style.color = "#E80000";
		theForm.email.value = "required";
	}
	if (isEmpty(theForm.comments) || theForm.comments.value == "required") {
		theForm.comments.style.color = "#E80000";
		theForm.comments.value = "required";
 	}
	if (isEmpty(theForm.name) || theForm.name.value == "required" || isEmpty(theForm.email) || theForm.email.value == "required" || isEmpty(theForm.comments) || theForm.comments.value == "required") {
		return (false);
	}
	else {
		//return (true);
		// Target Div and Success Message ------
		targetDiv = "home-feedback-form";
		successMessage = "Thank you for taking the time to submit your feedback to the Racine Unified School District. It is appreciated.<br/><br/>Due to the volume of emails we receive, we may not be able to respond to your email personally. Please be assured, however, that we read all of the emails we receive, and we use your feedback to make improvements.";
		// Fade -------------------------------------
		Effect.Fade('home-feedback-form', {duration:0.6, queue: {position:'front', scope: 'httpResponseScope'}, afterFinish: 
			function() {
				// Submit Data -----------------------
				sendFeedback('Feedback', theForm.name.value, theForm.email.value, theForm.comments.value);
				// Clear Form ------------------------
				theForm.name.value = "";
				theForm.email.value = "";
				theForm.comments.value = "";	
			}
		});
		
	}
}

// Send AJAX Request ----------------------------------------------------------------------------------------------------
function sendFeedback(action,name,email,comments) {
	// Using Prototype ---------------------------------------------
   	new Ajax.Request('/classes/email.cfc', {
		method: 'get',
		parameters: {method: action, name: name, email: email, comments: comments},
		// Success --------------------------------
		onSuccess: function(transport){
			var response = transport.responseText || "no response text";
			//alert("Success! \n\n" + response);
			document.getElementById(targetDiv).innerHTML = successMessage;
			Effect.Appear(targetDiv, {duration:0.7, queue: {position:'end', scope: 'httpResponseScope'}});
		},
		// Failure ---------------------------------
    	onFailure: function(){ 
			//alert('Something went wrong...');
			document.getElementById(targetDiv).innerHTML = "We're sorry. There was a problem with your submission. Please try again.";
			Effect.Appear(targetDiv, {duration:0.7, queue: {position:'end', scope: 'httpResponseScope'}});
		}
    });
}


// ====================================================================================================
// SHOW MONTH FUNCTION
// ====================================================================================================
function ShowMonth(m) {
	// Hide All Months --------
	for(i=1;i<=12;i++) {
		document.getElementById(i).style.display = "none";
	}
	// Show Month ------------
	document.getElementById(m).style.display = "block";
}
function ActivateCurrentMonth() {
	var now = new Date();
	var m = now.getMonth() + 1;
	ShowMonth(m);
}
//-->
