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 HideContent(d) {
	document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
	document.getElementById(d).style.display = "block";
}
function ReverseDisplay(d) {
	if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
	else { document.getElementById(d).style.display = "none"; }
}
function checkEM(form) {
pw1 = form.Email.value;
pw2 = form.Email2.value;

if (pw1 != pw2) 
	{
		alert ("\nYou did not enter the same new email twice. Please re-enter your email.")
		successCheck = false;
	} 
	//global variable identifying that all fields were filled...
	return successCheck;
}
function MM_validateForm() 
{ //v3.0 
	var i,p,q,nm,test,num,min,max,errors='', args=MM_validateForm.arguments;
	var P1Selected = false;
	var isSelected = false; //check or radio chosen?
	var objLen = '';
	var otherFld ='';
	var newArgs = '';
	var newObj = '';
	for (i=0; i<(args.length-2); i+=3) 
	{ 	//loop through fields to validate
		test=args[i+2]; val=MM_findObj(args[i]);

		if(test=="C")
		{//check or radio field objects

			if(val.length==null)
			{
				isSelected = ((val.checked) ? true : false)
			}else{
				objLen = val.length
				for(var x=0;x!=objLen;x++)
				{//loop through choices in check or radio field

					if(val[x].checked)
					{//has a selection been made, loop through all
					//choices assuring that even if one selection is made that
					//"other" isn't selected, if so check if "Other" field
					//is filled out
						isSelected = true;
						if(val[x].value.indexOf("^")!=-1){
						//Checks "Other" fields that must be filled once they
						//are chosen from main question's selections
							args = args;
							args.length = args.length + 3
							newObj = MM_findObj(val[0].name+'Other')
							args[args.length-3] = val[0].name+'Other';
							args[args.length-2] = '';
							args[args.length-1] = ((newObj.type.indexOf("select")!=-1)?'P1':'R');
							MM_validateForm(args)
						}else if(val[x].value.indexOf("~")!=-1){
							var valObj = MM3_findObj("DayOpt"+val[x].value)
							if(valObj!=null)
							{
								if(valObj.options.selectedIndex == 0)
								{
									isSelected = false;								
								}
							}
						}
					}
				}
			}
			if(!isSelected)
			{	//check or radio not validated, append warning to "error" variable
				errors+= '- '+ ((args[i].toLowerCase().indexOf("other")==-1)?args[i] + ' option must be selected.\n':args[i].substring(0, args[i].indexOf("Other")) + 'please specify.\n');
			}
			isSelected = false 
		}else if(test=="P1"){
			//dropdown field found (single value)
			nm = val.name
			if(val.length==null)
			{
				isSelected = ((val.checked) ? true : false)
			}else if(val.options.selectedIndex == 0 | val.options[val.options.selectedIndex].value==""){
				//field not selected, append warning to "error" variable
				errors+= '- '+ ((args[i].toLowerCase().indexOf("other")==-1)?args[i] + '  is required.\n':args[i].substring(0, args[i].indexOf("Other")) + ' please specify.\n');

			}else if(val.options[val.options.selectedIndex].value.indexOf("0.")!=-1){
				errors+= '- '+ args[i] + ' does not contain a valid choice, reselect.\n';
			}else{
				if(val.options[val.options.selectedIndex].value.indexOf("^")!=-1)
				{ //if dropdown selection is "Other" validate Other field

						args = args;
						args.length = args.length + 3
						args[args.length-3] = val.name+'Other';
						args[args.length-2] = '';
						args[args.length-1] = 'R';

						//errors='';
						MM_validateForm(args)
				}
			}
		}else if(test=="P2"){
			//multiple choice select box
			for(var g=0;g!=val.options.length;g++)
			{
				if(val.options[g].selected & val.options[g].value!="")
				{//selection made stop field validation
					P1Selected = true;
					break;
				}
			}
			//field not validated it, append warning to "error" variable
			if(!P1Selected) {errors+='- '+val.name+ ' is required.\n'}
			P1Selected = false
		}else{ //replaces original if(test == "R")
			if(val) //checkboxes will always return undefined, hence this call will be bypassed.
			{ //There really isn't a need to check if the object exists since its value is passed
				//from the form as a parameter to MM_validateform(), hence declaring its existance
				nm=val.name;
				if ((val=val.value)!="")
		  		{ 			
					if (test.indexOf('isEmail')!=-1) 
  					{
						var checkEmail = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
						var result = val.match(checkEmail)
						if(result==null) errors+='- '+nm+' must contain a valid e-mail address.\n';
						//p=val.indexOf('@');
		    			    	//if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
			   		}else if (test!='R') {
						//although test isn't R with dropdown, checkboxes, and radio buttons this call
						//determins if it is anything else as well as a text field.  not suer if this is
						//ever called as I've yet to see a place where it is being used in the few forms
						//I've seen. (March 30th 2005)
				 		num = parseFloat(val);
	    		    	if (val!=''+num) errors+='- '+nm+' must contain a number.\n';
		    		    if (test.indexOf('inRange') != -1) 
						{ 
							p=test.indexOf(':');
		        			min=test.substring(8,p); max=test.substring(p+1);
				          	if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
						}
					}
				}else if (test.charAt(0) == 'R') errors += ((nm.indexOf("Other")==-1)?'- '+nm+' is required.\n': '- '+nm.substring(0,nm.indexOf("Other")) +  ' please specify.\n')
			}
		}
	}
	successCheck = ((errors)?false:true)
	if (errors) alert('Please fill in these required fields to proceed:\n'+errors);

  	document.MM_returnValue = (errors == '');
}

