function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// ----- VALIDATION FORM COMMON ----- \\
	function isValid(obj, objType)
	{
		if (objType == "text")
		{
			if (obj.value.length == 0) 
				return false;
			else 
				return true;
		}
		else if (objType == "select")
		{
			if (obj.options[0].selected)
				return false;
			else
				return true;
		}
		else if (objType == "checkbox")
		{
			if (obj.checked)
				return true;
			else
		   		return false;	
		} 
		return true;
	}

// ----- SIGNUP VALIDATION ----- \\
function  validateSignupForm(f)
{
	// validate nickname
	if (f.nickname.value.length == 0)
	{
		alert("Please enter a nickname.");
		f.nickname.focus();
		return false; 
	}
	
	if ((f.nickname.value.length < 2) || (f.nickname.value.length > 12))
	{
		alert("The nickname must be between 2 and 12 letters and/or numbers.");
		f.nickname.focus();
		return false; 
	}

	// validate email
	if (f.email.value.length == 0)
	{
		alert("Please enter your email address.");
		f.email.focus();
		return false; 
	}

	if (f.email.value != f.email1.value)
	{
	    alert("The two emails do not match. Please retype.");
	    f.email.focus();
	    return false;
	}

	var i = 1;
	var s = f.email.value;
	var l = s.length;

	while ((i < l) && (s.charAt(i) != "@"))
	{
		i++;
	}

	if ((i >= l) || (s.charAt(i) != "@"))
	{
		alert("The email address is invalid. Please enter your full email address (eg. name@server.com)");
		f.email.focus();
		return false;
	}
	else
	{
		i += 2;
	}
	
	while ((i < l) && (s.charAt(i) != "."))
	{
		i++;
	}

	if ((i >= l - 1) || (s.charAt(i) != "."))
	{
		alert("The email address is invalid. Please enter your full email address (eg. name@server.com)");
		f.email.focus();
		return false;
	}

	// validate password
	if (f.password1.value.length == 0)
	{
		alert("Please enter a password.\n-it must be 8-12 numbers AND letters long\n-it must contain BOTH numbers and letters.");
		f.password1.focus();
		return false; 
	}
	
	var numberOfDigits = 0;
	var numberOfLetters = 0;
	var numberOfGarbageChars = 0;
	s = f.password1.value;
	
	for (i = 0; i < s.length; i++)
	{   
		var c = s.charAt(i);
		if ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
		{
			numberOfLetters++;
		}
		else if ((c >= "0") && (c <= "9"))
		{
			numberOfDigits++;
		}
		else
		{
			numberOfGarbageChars++;
		}
	}

	if (numberOfGarbageChars > 0)
	{
		alert("The password may only contain letters (a-z A-Z) and numericals (0-9).");
		f.password1.focus();
		return false; 
	}

	if (((f.password1.value.length < 8) || (f.password1.value.length > 12)) && ((numberOfDigits == 0) || (numberOfLetters == 0)))
	{
		alert("The password must be between 8 and 12 numbers and letters.");
		f.password1.focus();
		return false; 
	}
	else if ((numberOfDigits == 0) || (numberOfLetters == 0))
	{
		alert("The password must contain both letters AND numbers.");
		f.password1.focus();
		return false; 
	}
	else if ((f.password1.value.length < 8) || (f.password1.value.length > 12))
	{
		alert("The password must be between 8 and 12 characters.");
		f.password1.focus();
		return false; 
	}

	if (f.password2.value.length == 0)
	{
		alert("Please retype your password in the second password box.");
		f.password2.focus();
		return false; 
	}

	if (f.password1.value != f.password2.value)
	{
		alert("The two passwords do not match. Please retype.");
		f.password1.focus();
		return false; 
	}

	if (!isValid(f.title, "select"))
	{
		alert("Please choose a title.");
		f.title.focus();
		return false; 
	}
	if (!isValid(f.firstName, "text")) 
	{
		alert("Please enter your first name.");
		f.firstName.focus();
		return false; 
	}
	if (!isValid(f.lastName, "text")) 
	{
		alert("Please enter your last name.");
		f.lastName.focus();
		return false; 
	}
	if (!isValid(f.address1, "text")) 
	{
		alert("Please enter your address.");
		f.address1.focus();
		return false; 
	}
	if (!isValid(f.city, "text")) 
	{
		alert("Please enter a city.");
		f.city.focus();
		return false; 
	}
	if (!isValid(f.country, "select"))
	{
		alert("Please enter your country!");
		f.country.focus();
		return false; 
	}
	if (!isValid(f.zip, "text")) 
	{
		alert("Please enter your zip code or your postal code.");
		f.zip.focus();
		return false; 
	}
//	if (f.timeZone.options[f.timeZone.selectedIndex].value == 'none')
//	{
//		alert("Please select a time zone.");
//		f.timeZone.focus();
//		return false; 
//	}
	if (!isValid(f.phone, "text"))
	{
		alert("Please enter your phone number.");
		f.phone.focus();
		return false; 
	}
	if (!isValid(f.year_of_birth, "select"))
	{
		alert("Please tell us what year you were born in.");
		f.year_of_birth.focus();
		return false; 
	}
	if (!isValid(f.month_of_birth, "select"))
	{
		alert("Please tell us what month you were born in.");
		f.month_of_birth.focus();
		return false; 
	}
	if (!isValid(f.day_of_birth, "select"))
	{
		alert("Please tell us what day of the month you were born on.");
		f.day_of_birth.focus();
		return false; 
	}
	if (!isValid(f.terms, "checkbox"))
		{
			alert("Please acknowledge that you agree to the terms and conditions! You have to do this before you can activate your account.");
			f.terms.focus();
			return false; 
		}
		if (!isValid(f.ru21, "checkbox"))
		{
			alert("If you are over 21, please tick the ‘I am over 21’ checkbox. We can’t let you play unless you are over 21 and you check it off.");
			f.ru21.focus();
			return false; 
		}
		if (!isValid(f.readagreement, "checkbox"))
		{
			alert("Please acknowledge that you agree to the affiliate agreement! You have to do this before you can activate your account.");
			f.ru21.focus();
			return false; 
		}	

	return true; //confirmSignupWindow(f);
}

// ----- CONFIRM SIGNUP WINDOW ----- \\
	function  confirmSignupWindow(f)
	{
		f.submit();
	}