// JavaScript Document

/* File name: forms.js					*/
/* Author: Erick Zelaya						*/
/* Maintained by: eezelaya@csupomona.edu	*/
/* Last modified: 2006-09-13				*/
/* Purpose: I&IT Learning Site Javascript for Forms	*/
/* General rollovers for form buttons and functions for the feedback form   */

// these colors should match with the ones in learning.css:button
function hover(b, over) {
	if (over) {
		b.style.borderColor = "#aedf9a #94da78 #6ab94b #94da78";
		b.style.backgroundColor = "#bfefab";
	} else {
	   b.style.borderColor = "#c4cccc #acb5b5 #6f7777 #acb5b5";
		b.style.backgroundColor = "#cccccc";
	}
}

//the following relate directly to the feedBacck form
function checkForLinks()
{
	var links = false;
	var text = document.suggestions.comments.value.toLowerCase();
	var href1 = text.indexOf("a href=");
	var href2 = text.indexOf("/a>");
	var http = text.indexOf("http://");
	var html = text.indexOf(".html");
	var htm = text.indexOf(".htm");
	var www = text.indexOf("www.");
	var url1 = text.indexOf("[URL=");
	var url2 = text.indexOf("[/URL]");
	var com = text.indexOf(".com");
	var org = text.indexOf(".org");
	var exe = text.indexOf(".exe");
	var app = text.indexOf(".app");
	
	if(href1!=-1 || href2!=-1 || http!=-1 || html!=-1 || htm!=-1 || www!=-1 || url1!=-1 || url2!=-1 || com!=-1 || org!=-1 || exe!=-1 || app!=-1)
	{
		return true;
	}
	else
	{
		return false;
	}
}
function doErrorChecking()
{
	var linksExist = checkForLinks();
	
	if(linksExist)
	{
		alert("Links are not allowed through the use of this form.");
	}
	else
	{
		if(document.suggestions.email.value == "" || document.suggestions.comments.value == "")
		{
			alert("Please provide a real email address and make sure you type your comment before submitting.");
		} else
		{
			sendFeedBackForm();
		}
	}			
}
function sendFeedBackForm()
{
	var recipient = "psalim@csupomona.edu,bsoh@csupomona.edu,eezelaya@csupomona.edu";
	var redirect = "http://www.csupomona.edu/~iit/learning/learning_feedback_confirmation.shtml";
	var subject = "Feedback and Suggestions Form";
	document.suggestions.recipient.value = recipient;
	document.suggestions.redirect.value = redirect;
	document.suggestions.subject.value = subject;
	document.suggestions.submit();
}
//only good for temporary copyright symposium
function sendRegistrationForm()
{
	var to = "eezelaya@csupomona.edu";
	var from = document.form.email.value;
	var subject = "Copyright Symposium Registration";
	var fullName = document.form.first.value + " " + document.form.last.value;
	var message = document.form.additional_comments.value;
	document.form.submit();
}