/*
 * openWin
 *
 * opens a popup with spec'd u (url), n (name), h (height), and w (width) options
 * used in \games\screenshotsContent.jsp
 *
 */
function openWin(u,n,w,h){
	options = 'height=' + h + ',width=' + w + ',directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no'
	discon = window.open (u,n,options)
}
function openWinSpot(u,n,options){
//	options = 'height=' + h + ',width=' + w + ',directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no'
	discon = window.open (u,n,options)
}

function isEmailValid(FormName,ElemName) {
var Temp	 = document.forms[FormName].elements[ElemName]
var AtSym	= Temp.value.indexOf('@')
var Period   = Temp.value.lastIndexOf('.')
var Space	= Temp.value.indexOf(' ')
var Length   = Temp.value.length - 1   // Array is from 0 to length-1

	// '@' cannot be in first position
	// Must be at least 1 valid char btwn '@' and '.'
	// Must be atleast one valid char after '.'
	// No empty spaces permitted
	if ((AtSym < 1) || 
			(Period <= AtSym+1) ||
			(Period == Length ) || 
			(Space != -1)) {		  
		alert('Please enter a valid e-mail address!');
		return false;
	}
return true;
}

function validateUserForm() {
	if (!document.userForm.firstname.value) {
		alert("You must type a first name.");
		return false;
	}
	if (!document.userForm.lastname.value) {
		alert("You must type a last name.");
		return false;
	}
	if (!document.userForm.company.value) {
		alert("You must type a company name.");
		return false;
	}
	if (!document.userForm.addy1.value) {
		alert("You must type an address.");
		return false;
	}
	if (!document.userForm.zip.value) {
		alert("You must type a postal code.");
		return false;
	}
	if (!document.userForm.email.value) {
		alert("You must type an email address.");
		return false;
	}
	if (!document.userForm.password1.value) {
		alert("You must type a password.");
		return false;
	}
	if (!document.userForm.password2.value) {
		alert("You must type a confirm password.");
		return false;
	}
	if (document.userForm.password1.value != userForm.password2.value) {
		alert("Password and confirm password do not match.");
		return false;
	}
}



// the following functions add a "refresh favorites" link to the favorites page


// addEvent cross-browser event handling for IE5+, NS6 and Mozilla
// By Scott Andrew
function addEvent(elm, evType, fn, useCapture) {	
	if (elm.addEventListener) {
	  elm.addEventListener(evType, fn, useCapture); 
	  return true;
	} else if (elm.attachEvent) {
	  var r = elm.attachEvent('on' + evType, fn);
	  return r;
	} else {
	  elm['on' + evType] = fn;
	}
}


function refreshLink() {
	if(document.getElementById('refreshpage')) {
		var ref = document.getElementById('refreshpage');
		
		var link = document.createElement('a');
		link.href="#";
		link.innerHTML = "Refresh Favorites";
		
		addEvent(link, "click", refreshPage, false);
		
		ref.appendChild(link);
	}
}

var sURL = unescape(window.location.pathname);

function refreshPage() {
	window.location.replace( sURL );
}

addEvent(window, "load", refreshLink, false);