function swapIn()
{
		document.volunteerhover.src="images/volunteerOVER.gif";
}
function swapOut()
{
		document.volunteerhover.src="images/volunteerUP.gif";
}

function showClip(clip)
{
	$("homeowner_div").style.display="none";
	var flashMovie=getFlashMovieObject("hplayer");
    flashMovie.SetVariable("chapterNum.chapter",clip);
}

function openWin(spot)
{
	var url="mediaPlayer.php?video=" + spot ;
 	newWindow = window.open(url,"newone","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=880, height=496,screenX=10,screenY=10,left=10,top=10")
	
}

function showMenu()
{
	document.getElementById("cats").style.display = "block";
}
function swapIn()
{
		document.volunteerhover.src="images/volunteerOVER.gif";
}
function swapOut()
{
		document.volunteerhover.src="images/volunteerUP.gif";
}


function submitLogin()
{
	$("loginForm").submit();
}

function submitReg()
{
	var rx = /^[\w\.-]+@[\w\.-]+\.\w+$/i;
	var tester = rx.test($("email").value);
	if(!$("first").value || !$("last").value || !$("email").value || !$("pass1").value || !$("pass2").value ||  !$("state").value ||  !$("zip").value)
		alert("One or more required fields are empty.");
	else if($("pass1").value != $("pass2").value)
	{
		alert("Passwords don't match.");
		$("pass1").select();
		$("pass2").value = "";
	}
	else if(!tester)
	{
		alert("Email address is invalid");
		$("email").select();
	}
	else if($("pass1").value.length < 5 || $("pass2").value.length < 5)
	{
		alert("Passwords not long enough, 5 character minimum.");
		$("pass1").select();
	}
	else
		$("regForm").submit();
}
/*
function closeAndGo(id)
{
	window.opener.advanceClip(id);
	self.close();
}*/

//////////////////////////


function getResults(workshop,section)
{
	var url = "action.php";
	var id = "quiz_div";
	myHash = "cmd=check&workshop=" + workshop +"&section=" + section + "&";
	myHash += $("resultsform").serialize();
	new Ajax.Updater(id, url, { method: 'post', parameters: myHash }); 
}
function fetchQuiz(workshop,section,pageTitle)
{
	document.title=pageTitle;
	var url = "action.php";
	var id = "quiz_div";
	myHash = "cmd=fetch&workshop=" + workshop + "&section=" + section;
	new Ajax.Updater(id, url, { method: 'post', parameters: myHash }); 
}
function advanceClip(clip)
{
	var flashMovie=getFlashMovieObject("player");
    flashMovie.SetVariable("chapterNum.chapter",clip);
}
// Safe at home funct
function advanceClipSAH(clip)
{
	var flashMovie=getFlashMovieObject("playersah");
    flashMovie.SetVariable("chapterNum.chapter",clip);
}

function getFlashMovieObject(movieName)
{
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
  return (isIE) ? window[movieName] : document[movieName];

}
function updateSection(id)
{
	window.location = "quiz.php?section=" + id;
}

function closeAndGo(workshop,section,clip,pageTitle)
{
	$("quiz_div").style.display="none";
	fetchQuiz(workshop,section,pageTitle);
	advanceClip(clip);
	
}

function closeAndGoSAH(workshop,section,clip,pageTitle)
{
	$("quiz_div").style.display="none";
	fetchQuiz(workshop,section,pageTitle);
	advanceClipSAH(clip);
	
}

// Energy Efficiency rollovers

function mouseOnImage(divID)
{
	document.getElementById(divID).src = "images/tocRollovers/rollOvers/" + divID + "_over.gif";
}
function mouseOutImage(divID)
{
	document.getElementById(divID).src = "images/tocRollovers/" + divID + ".gif";
}

// Safe At Home rollovers

function mouseOnImage2(divID)
{
	document.getElementById(divID).src = "images/tocRollovers2/rollOvers/" + divID + "_over.gif";
}
function mouseOutImage2(divID)
{
	document.getElementById(divID).src = "images/tocRollovers2/" + divID + ".gif";
}
