// --- son of a suckerfish dropdowns
sfHover = function() {
	var sfEls = document.getElementById("dropdown").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

$(document).ready(function() {
	
	// --- function to move the copy
	var copy = $('#old-copy').html();
	$("#old-copy").remove();
	$("#copy").html(copy);

	// --- remove text in sign up window
	$("input").focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
});


// --- for live chat popup
$(function() {
	$(".popupwindow").popupwindow();
});	


// --- check email for newsletter
function checkEmail(fieldId){
	var field = document.getElementById(fieldId);
	var error = '';
	if (field.value) {
		if (field.value.match(/^[^\s@]+@[^\s@]+\.[^\s@]+[^\.]$/)){
			return true;
		}
		error = 'The email you entered is invalid';
	} else {
		error = 'Please enter an email address';
	}
	document.getElementById('signup-error').innerHTML = error;
	return false;
}

// --- check email for newsletter
function footCheckEmail(fieldId){
	var field = document.getElementById(fieldId);
	var error = '';
	if (field.value) {
		if (field.value.match(/^[^\s@]+@[^\s@]+\.[^\s@]+[^\.]$/)){
			return true;
		}
		error = 'The email you entered is invalid';
	} else {
		error = 'Please enter an email address';
	}
	document.getElementById('foot-signup-error').innerHTML = error;
	return false;
}