$(document).ready(function(){
	$("#nav1-2").hover(function(){
		$("#navSecondary1:hidden").slideDown(500, function(){
			$("#navSecondary1:visible").fadeTo(500, 0.95); 
		return false;}); 
	return false;});
$("#page #page-top").hover(function(){ //menu closer
		$("#navSecondary1:visible").slideUp(500);
	return false;});
$("#page-main-home").hover(function(){ //menu closer
		$("#navSecondary1:visible").slideUp(500);
	return false;});
	$("#page-main-interior").hover(function(){ //menu closer
		$("#navSecondary1:visible").slideUp(500);
	return false;});
	$("#page-top").hover(function(){ //menu closer
		$("#navSecondary1:visible").slideUp(500);
	return false;});
	$("#page-bottom-interior").hover(function(){ //menu closer
		$("#navSecondary1:visible").slideUp(500);
	return false;});
	$("#nav1-3").hover(function(){ //menu closer
		$("#navSecondary1:visible").slideUp(500);
	return false;});
	$("#nav1-1").hover(function(){ //menu closer
		$("#navSecondary1:visible").slideUp(500);
	return false;});

	$("#nav1-3").hover(function(){
		$("#navSecondary2").slideToggle(500, function(){
			$("#navSecondary2").fadeTo(500, 0.95); 
		return false;}); 
	return false;});
$("#page-top").hover(function(){ //menu closer
		$("#navSecondary2:visible").slideUp(500);
	return false;});
$("#page-main-home").hover(function(){ //menu closer
		$("#navSecondary2:visible").slideUp(500);
	return false;});
$("#page-main-interior").hover(function(){ //menu closer
		$("#navSecondary2:visible").slideUp(500);
	return false;});
	$("#page-top").hover(function(){ //menu closer
		$("#navSecondary2:visible").slideUp(500);
	return false;});
	$("#page-bottom-interior").hover(function(){ //menu closer
		$("#navSecondary2:visible").slideUp(500);
	return false;});
	$("#nav1-2").hover(function(){ //menu closer
		$("#navSecondary2:visible").slideUp(500);
	return false;});
	$("#nav1-4").hover(function(){ //menu closer
		$("#navSecondary2:visible").slideUp(500);
	return false;});

});


/*****************************************************
 * phIsBlank
 * if the string is blank return true 
 *****************************************************/
function phIsBlank(thetext) {
	if (thetext == "") { return true; } else { return false; }
}

/*****************************************************
 * phValidEmail
 * check if text appears to be an email address 
 * return true or false 
 *****************************************************/
function phValidEmail(email) {
	// characters not allowed in an email address
	invalidChars = " /:,;";

	// blank emails are invalid
	if (email == "") { return false }
	
	// emails with illegal characters are invalid
	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i);
		if (email.indexOf(badChar,0) > -1) { return false }
	}

	// emails without an @ are invalid
	atPos = email.indexOf("@",1)
	if (atPos == -1) { return false }
	
	// emails with more than one @ are invalid
	if (email.indexOf("@",atPos +1) > -1) { return false }

	// emails without a . are invalid
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) { return false }

	// emails with less than three chars after the 
	// first . following the @ are invalid
	if (periodPos + 3 > email.length) { return false }
	
	return true;
}
/*****************************************************
 * setSection
 * uses the Section info to turn on the main nav buttons 
 * note: editing folder names will break this function. If folder names are changed, update header.inc in offline>includes
 * return true or false 
 *****************************************************/
function setSection(sectionId) {
	if (document.getElementById(sectionId)) {
		document.getElementById(sectionId).style.backgroundPosition='0 0';
	}
	return true;
}

/*****************************************************
 * popitup from quirksmode.org
 * use it with an onclick in an anchor tag
 * return false 
 *****************************************************/
function popItUp(url) {
	newwindow=window.open(url,'Specials','width=780,height=520');
	if (window.focus) {newwindow.focus()}
	return false;
}

/*****************************************************
http://www.mollerus.net/
includes a centering function
 *****************************************************/

function newWindow(windowName, URL, width, height, scrolling) {
	width = width || 400;
	height = height || 360;
	scrolling = scrolling || 0;
	
	var topX = (window.screen.width / 2) - ( width / 2);
	var topY = (window.screen.height / 2) - ( height / 2);
	
	window.open(URL, windowName, 'width=' + width + ',height=' + height +
 ',location=no,resizable=yes,scrollbars=' + scrolling + 
',screenX=' + topX + ',screenY=' + topY);
}

/*****************************************************
my hybrid: popItUpCenter
quirks mode's good code + centering + mods

*****************************************************/
function popItUpCenter(url) {
	var width = 780;
	var height =520;
	var browserName=navigator.appName; 
	
if (browserName=="Microsoft Internet Explorer") {

	var topX = (document.body.offsetWidth / 2) - ( width / 2) + window.screenLeft;
	var topY = (document.body.offsetHeight / 4) - ( height / 2) + window.screenTop;
 
 } else {

	var topX = (window.innerWidth / 2) - ( width / 2) + window.screenX;
	var topY = (window.innerHeight / 2) - ( height / 2) + window.screenY;
}

newwindow=window.open(url,'Specials','width='+width+',height='+height+',location=no,left='+topX+',top='+topY);
	if (window.focus) {newwindow.focus()}
	return false;
}

