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_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 resetSubscribeField(theForm){
	// if there is nothing in the text area, reset default text
	if (theForm.value.length < 1 ||theForm.subscribeEmail == ""){
		theForm.value = " your e-mail address";
	}			
}

// Utility Functions
function isEmpty(s) {
	return ((s == null) || (s.length == 0));
}
function isWhitespace(s) {
	var i;
	if (isEmpty(s)) return true;
	for (i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if (c != ' ') return false;
	}
	return true;
}

function clearSubscribeField(theForm){
	if (theForm.value == " your e-mail address"){
		theForm.value = "";
	}
}
	
function validateSubscribe(theForm){
	// validate friends email
	if (theForm.subscribeEmail.value == ""){
		alert("Please enter your E-Mail address.");
		theForm.subscribeEmail.focus();
		return(false);
	}

	if (isValidEmail(theForm.subscribeEmail.value)){
	}else{	
		theForm.subscribeEmail.focus();
		return(false);
	}
	return(true);
}

function isValidEmail (emailStr){
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"	
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")	
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var matchArray=emailStr.match(emailPat)

	if (matchArray==null){
		alert("Email address seems incorrect (check @ and .'s)")
		return false
	}

	var user=matchArray[1]
	var domain=matchArray[2]

	if (user.match(userPat)==null){
		alert("Your username (the part before the '@') doesn't seem to be valid.")
		return false
	}

	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null){
		for (var i=1;i<=4;i++){
			if (IPArray[i]>255){
				alert("Destination IP address is invalid!")
				return false
			}
		}
		return true
	}

	var	domainArray=domain.match(domainPat)
	if (domainArray==null){
		alert("The domain name doesn't seem to be valid.")
		return false
	}

	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3){
		alert("The address must end in a three-letter domain, or two letter country.")
		return false
	}

	if (len<2){		
		alert("This address is missing a hostname.")
		return false
	}	

	return true;
}	

function entryform_button_checker(){
		// set var radio_choice to false
		var radio_choice = false;
		// Loop from zero to the one minus the number of radio button selections
		for (counter = 0; counter < document.theform.radiobutton.length; counter++){
			// If a radio button has been selected it will return true
			// (If not it will return false)
			if (document.theform.radiobutton[counter].checked)
			radio_choice = true; 
		}
		if (!radio_choice){
			// If there were no selections made display an alert box 
			alert("Please select an answer.")
			//return (false);
		}
		if(radio_choice == true){
			document.theform.submit();
		}
	}

function poreform_button_checker(){
		// set var radio_choice to false
		var radio_choice = false;
		// Loop from zero to the one minus the number of radio button selections
		for (counter = 0; counter < document.theform.radiobutton.length; counter++){
			// If a radio button has been selected it will return true
			// (If not it will return false)
			if (document.theform.radiobutton[counter].checked)
			radio_choice = true; 
		}
		if (!radio_choice){
			// If there were no selections made display an alert box 
			alert("Please select an answer.")
			return (false);
		}
		if(radio_choice == true){
			document.theform.submit();
		}
	}