var browser = navigator.appName;
if(browser == "Netscape"){
	show_string = "table-row";
} 
else {
	show_string = "block";
}
	
function header(title){

	document.write('<link rel="tsh" type="text/css" href="alamedastyleauction.css" />');

	document.write('<style>');
	
	document.write('@import "alamedastyleauction.css";');

	document.write('</style>');
	
	document.write('<title>'+title+'</title>');
	document.write('<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />');	
	
	document.write('</head>');

	return;	

}


function navbuttons(room_num){

	document.write('<body id="pagestyle">');

	document.write('<table id="maintablestyle" cellspacing="0"  align="center" width=93%>');

	document.write('<tr>');
	document.write('<td colspan="2">');
	document.write('<p align="center"><a class="nav" href="http://www.alamedaschool.org/auction/index.php"><img src="images/carnaval banner.png" border="0"></a></p>');
	document.write('</td></tr>');
	document.write('<tr>');
	document.write('<td colspan="2">');
	document.write('<p id=address align="center">An Alameda Auction <br>BENEFITING STAFF FUNDING</p>');
	document.write('</td></tr>');
	document.write('<tr>');
	document.write('<td colspan="2">');
/*	if ((location.href).indexOf("http://www.alamedaschool.org/auction/index.php")>-1)
		document.write('<p align=center><img src="images/carnaval postcard.png" border=0></a></p>');
	else*/
		document.write('<br/>');
	document.write('</td></tr>');
	
/* starting new buttons on left */
	document.write('<br/>');
	document.write('</td></tr>');
	if ((location.href).indexOf("http://www.alamedaschool.org/auction/sponsors.php?tier")>-1)
		document.write('<tr>');
	else{
	document.write('<tr><td valign="top" cellpadding="5";>');
	document.write('<table class="navbar" cellspacing="1">');
	document.write('<tr><td class="navb">');
	document.write('<a class="nav" href="http://www.alamedaschool.org/auction/index.php">Home</a>');
	document.write('</td></tr>');
/*	document.write('<tr><td class="navb">');
	document.write('<a class="nav" href=sponsors.php>Sponsors</a>');
	document.write('</td></tr>');
	document.write('<tr><td class="navb">');
	document.write('<a class="nav" href=donors.php>Donors</a>');
	document.write('</td></tr>');
	document.write('<tr><td class="navb">');
	document.write('<a class="nav" href=class_projects.php>Class Projects</a>');
	document.write('</td></tr>');
	document.write('<tr><td class="navb">');
	document.write('<a class="nav" href=board_items.html>Board Items</a>');
	document.write('</td></tr>');
	document.write('<tr><td class="navb">');
	document.write('<a class="nav" href=advertise.html>Advertise!</a>');
	document.write('</td></tr>');
	document.write('<tr><td class="navb">');
	document.write('<a class="nav" href=donate.html>Donate!</a>');
	document.write('</td></tr>');
	document.write('<tr><td class="navb">');
	document.write('<a class="nav" href=volunteer.php>Volunteer!</a>');
	document.write('</td></tr>');
	document.write('<tr><td class="navb">');
	document.write('<a class="nav" href=forms.html>Forms</a>');
	document.write('</td></tr>');
*/	document.write('<tr><td class="navb">');
	document.write('<a class="nav" href=contact.html>Contact Us</a>');
	document.write('</td></tr>');
	document.write('<tr><td class="navb">');
	document.write('<a class="nav" href="http://www.alamedaschool.org">Alameda Parent Site</a>');
	document.write('</td></tr>');
	document.write('</table>');
	document.write('</td>');
}
	document.write('<td id="maincell">');

}
function footer(){

	document.write('<p class="topref"><a class="topref" href="#top"><br/>Return to the Top</a></p>');

	if ((location.href).indexOf("http://www.alamedaschool.org/auction/sponsors.php?tier")>-1){
		document.write('<div align=center><table class=bottomnavbar><tr><td class=bnavb><a href=sponsors.php?tier=1 class=nav>Wranglers</a></td><td class=bnavb><a href=sponsors.php?tier=2 class=nav>Buckaroos</a></td><td class=bnavb><a href=sponsors.php?tier=3 class=nav>Dudes</a></td><td class=bnavb><a href=sponsors.php?tier=4 class=nav>The OK Corral</a></td></tr></table></div><div align=right><img src="images/medbison08.gif" border=0 align=bottom></div>');}
	else{
		/*if ((location.href).indexOf("http://www.alamedaschool.org/auction/index.php")==-1)*/
			document.write('<p align=center><img src="images/carnaval footer.png" border=0></p>');
	}
	document.write('</td>');

	document.write('</tr>');

	document.write('<tr>');

	document.write('<td colspan="2" bgcolor="CCCCCC">');

	document.write('<div id=footer><a href=http://www.alamedaschool.org>Return to the Alameda Parent Site</a></div>');

	document.write('</td>');

	document.write('</tr>');

	document.write('<tr>');

	document.write('<td colspan="2" bgcolor="349834">');

	document.write('<p align=center><a href="mailto:auction@alamedaschool.org" class=nav>auction@alamedaschool.org</a></p>');

	document.write('</td>');

	document.write('</tr>');

	document.write('</table>');

	document.write('</body>');

	document.write('</html>');

	return;

}

function Toggle(e){
	if (!document.getElementById) return;
		if(!e) var e = window.event;
	//which link was the mouse over?
	whichlink = (e.target) ? e.target.id : e.srcElement.id;
	
	// get the description
	obj=document.getElementById(whichlink+"desc");
	visible=(obj.style.display=="block")
	key=document.getElementById(whichlink);
	keyname=key.firstChild.nodeValue.substring(3);
	if (visible){
		obj.style.display="none";
		//change button to +
		key.firstChild.nodeValue="[+]"+keyname;
	}
	else{
		obj.style.display="block";
		//change button to -
		key.firstChild.nodeValue="[-]"+keyname;
	}
}
	
function addDescription(){
	i=1;
	while(document.getElementById("activityName"+i)){
		document.getElementById("activityName"+i).onclick=Toggle;
		i++;
	}
}
function addIndex(){
	i=1;
	while(document.getElementById("index"+i)){
		document.getElementById("index"+i).onclick=Toggle;
		i++;
	}
}

f=1;
function freqst(){
	while(document.getElementById("frequency"+f+"icon")){
		document.getElementById("frequency"+f+"icon").onmouseover=ScreenTip;
		document.getElementById("frequency"+f+"icon").onmouseout=clear_ScreenTip;
		f++;
	}
}
tod=1;
function todst(){
	while(document.getElementById("timeOfDay"+tod+"icon")){
		document.getElementById("timeOfDay"+tod+"icon").onmouseover=ScreenTip;
		document.getElementById("timeOfDay"+tod+"icon").onmouseout=clear_ScreenTip;
		tod++;
	}
}
sac=1;
function sacst(){
	while(document.getElementById("schoolAgedChildren"+sac+"icon")){
		document.getElementById("schoolAgedChildren"+sac+"icon").onmouseover=ScreenTip;
		document.getElementById("schoolAgedChildren"+sac+"icon").onmouseout=clear_ScreenTip;
		sac++;
	}
}
smc=1;
function smcst(){
	while(document.getElementById("smallChildren"+smc+"icon")){
		document.getElementById("smallChildren"+smc+"icon").onmouseover=ScreenTip;
		document.getElementById("smallChildren"+smc+"icon").onmouseout=clear_ScreenTip;
		smc++;
	}
}

function ScreenTip(e){
	if (!e) var e = window.event;
	whichlink = (e.target) ? e.target.id : e.srcElement.id;
	d=document.getElementById(whichlink+"st");
	d.style.display="block";
}
function clear_ScreenTip(e){
	if (!e) var e = window.event;
	whichlink = (e.target) ? e.target.id : e.srcElement.id;
	d=document.getElementById(whichlink+"st");
	d.style.display="none";
}
function ShowStyle(){
	if (location.href == "http://www.alamedaschool.org/volunteer.html" || (location.href).indexOf("http://www.alamedaschool.org/calendar.php")>-1) 
	{
		if ((location.href).indexOf("http://www.alamedaschool.org/calendar.php?num_events=only")>-1)
		{
			if ((location.href).indexOf("#calendar")<0)
				document.form1.num_events[1].checked=true;
			if ((location.href).indexOf("cbschool")>-1)
				document.form1.cbschool.checked=true;
			if ((location.href).indexOf("cbbaschool")>-1)
				document.form1.cbbaschool.checked=true;
			if ((location.href).indexOf("cbpta")>-1)
				document.form1.cbpta.checked=true;
			if ((location.href).indexOf("cbfoundation")>-1)
				document.form1.cbfoundation.checked=true;
		}
		if (document.form1.num_events[0].checked == true)
			document.getElementById("show_only").style.display='none';
		else
			document.getElementById("show_only").style.display='block';
	}
}

function SelectAll(max,form,type){
	bool=true;
	if (eval("document."+form+".submit.value")=="Remove Selected Entries"){
		if (confirm ("Are you sure you want to remove ALL of these entries?")){
			for(i=1;i<=max;i++){
				if (eval("document."+form+"."+type+"_"+i))
					eval("document."+form+"."+type+"_"+i).checked=true;
			}
		}
		bool=false;
	}
	if (eval("document."+form+".submit.value")=="Update Status" && type=="box"){
		if (confirm ("Are you sure you revert ALL of these entries to the previous status?")){
			for(i=1;i<=max;i++){
				if (eval("document."+form+"."+type+"_"+i))
					eval("document."+form+"."+type+"_"+i).checked=true;
			}
		}
		bool=false;
	}
	if (bool==true){
		for(i=1;i<=max;i++){
			if (eval("document."+form+"."+type+"_"+i))
				eval("document."+form+"."+type+"_"+i).checked=true;
		}
	}	
}
function DeselectAll(max,form,type){
	for(i=1;i<=max;i++){
		if (eval("document."+form+"."+type+"_"+i))
			eval("document."+form+"."+type+"_"+i).checked=false;
	}
}
function ExpandAll(){
	for(i=0;i<document.form1.num_entries.value;i++)
	{
		index=i+1;
		prefix=document.getElementById("activityName"+index+"desc");
		prefix.style.display = "block";
	}
}
function CollapseAll(){
	for(i=0;i<document.form1.num_entries.value;i++)
	{
		index=i+1;
		prefix=document.getElementById("activityName"+index+"desc");
		prefix.style.display = "none";
	}
}
function validNonNegNumber(num){
	if (num=='')
		return true;
	if (isNaN(num) || num<0) /*isNan means is Not a Number*/
		return false;
	return true;
}
function VerifyResult(form,vals_in_db_str,proc_id_corr){
	vals_in_db_arr=new Array();
	vals_in_db_arr=vals_in_db_str.split(", ");
	val_len=vals_in_db_arr.length-1;
	proc_id_corr_arr=new Array();
	proc_id_corr_arr=proc_id_corr.split(", ");
	max=proc_id_corr_arr.length-1;
	bool=true;
	document.getElementById("message").innerHTML="";
	for(q=val_len;q>=0;q--){
		row_error_arr=true;
		i=proc_id_corr_arr[q];
		curr_box="document."+form+".tof_id_"+i;
		if (eval(curr_box)){
			if (validNonNegNumber(eval(curr_box).value)==false){
				bool=false;
				ChangetoError(i,"NaN","");
				eval(curr_box).focus();
				eval(curr_box).select();
				row_error_arr=false;
			}
			else{
				for(z=0;z<=max;z++){
					j=proc_id_corr_arr[z];
					foo=eval(curr_box).value;
					if (foo=='')
						foo=0;
					if (foo==vals_in_db_arr[z] && foo!=0 && i!=j){
						bool=false;
						ChangetoError(i,"in DB",j);
						eval(curr_box).focus();
						eval(curr_box).select();
						row_error_arr=false;
					}
				}
			}
			if (eval("document."+form+".complete_"+i).checked==true && eval(curr_box).value==0){
				bool=false;
				ChangetoError(i,"comp","");
				eval(curr_box).focus();
				eval(curr_box).select();
				row_error_arr=false;
			}
			if (row_error_arr==true)
				ChangetoOkay(i);
		}
	}
	curr_message=document.getElementById("message").innerHTML;
	if (curr_message!="")
		document.getElementById("message").style.display="block";
	else
		document.getElementById("message").style.display="none";
	return bool;

}
function ChangetoError(proc_id,error_type,alt_proc_id){
	cell=document.getElementById("tof_cell_"+proc_id);
	cell.className="errortableelementgreen";
	curr_message=document.getElementById("message").innerHTML;
	if (error_type=="NaN")
		new_message="The input for the Tofino ID with proc_id="+proc_id+" is not a non-negative number. Enter zero for this value (or leave it blank) if there is not Tofino ID for this item.";
	if (error_type=="in DB")
		new_message="The Tofino ID you entered for the proc_id="+proc_id+" is already logged in the database for the item with proc_id="+alt_proc_id+". Please check to make sure you entered your result correctly. If you think there has been an error, please contact <a href=mailto:webadmin@alamedaschool.org class=topref>Chris Wiegand</a>."; 
	if (error_type=="comp")
		new_message="The row with proc_id="+proc_id+" cannot be marked as complete because its Tofino ID is 0. Please enter its valid Tofino ID in order to complete it."; 
	if (curr_message=='')	
		document.getElementById("message").innerHTML=new_message;
	else
		document.getElementById("message").innerHTML=new_message+"<BR>"+curr_message;
}
function ChangetoOkay(proc_id){
	cell=document.getElementById("tof_cell_"+proc_id);
	cell.className="tableelementgreen";
	curr_message=document.getElementById("message").innerHTML;
	if (curr_message.indexOf("The input for the Tofino ID with proc_id="+proc_id)>-1){
		pre_msg=curr_message.substring(0,curr_message.indexOf("The input for the Tofino ID with proc_id="+proc_id));
		rem=curr_message.substring(curr_message.indexOf("The input for the Tofino ID with proc_id="+proc_id));
		if (rem.indexOf("<BR>")>-1)
			post_msg=rem.substring(rem.indexOf("<BR>")+4);
		else
			post_msg='';
		document.getElementById("message").innerHTML=pre_msg+post_msg;
	}
}
function Display(id_to_change,row_to_hide,row_to_show){
	document.getElementById(id_to_change).style.display='block';
	document.getElementById(row_to_hide).style.display='none';
	document.getElementById(row_to_show).style.display='block';
}
function Display_TR(){
	document.getElementById('add_new_row').innerHTML="<input type=button name=add_new value='Remove New Volunteer' onClick=Hide_TR();>";
	for (i=0; i<=6; i++){
		ri="r"+i;
		document.getElementById(ri).style.display=show_string;
	}
	document.forminfo.vol_id[document.forminfo.num_vols.value].checked=true;
	document.forminfo.new_bool.value=document.forminfo.num_vols.value;
	document.forminfo.num_vols.value++;
}
function Hide(id_to_change,row_to_hide,row_to_show){
	document.getElementById(id_to_change).style.display='none';
	document.getElementById(row_to_hide).style.display='block';
	document.getElementById(row_to_show).style.display='none';
}
function Hide_TR(){
	document.getElementById('add_new_row').innerHTML="<input type=button name=add_new value='Add a New Volunteer to this Email Address' onClick=Display_TR();>";
	for (i=0; i<=6; i++){
		ri="r"+i;
		document.getElementById(ri).style.display='none';
	}
	document.forminfo.num_vols.value--;
	document.forminfo.vol_id[0].checked=true;
	document.forminfo.new_bool.value="none";
}
function alterCheckBox(rem_or_ass,row_id){
	if (rem_or_ass=='Remove'){
		if (eval("document.form2.box_"+row_id).checked==true){
			if (confirm('Are you sure you want to remove this entry from our database?'))
				eval("document.form2.box_"+row_id).checked=true;
			else
				eval("document.form2.box_"+row_id).checked=false;
		}
	}
	if (rem_or_ass=='Revert'){
		if (eval("document.form3.box_"+row_id).checked==true){
			if (confirm('Are you sure you want to revert this row to the previous status in our database?'))
				eval("document.form3.box_"+row_id).checked=true;
			else
				eval("document.form3.box_"+row_id).checked=false;
		}
	}
}

isAlpha="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
isNumber="0123456789";
isAlphaNumeric=isAlpha+isNumber;
function isBadString(str,goodstring){
	for(i=0;i<str.length;i++){
		if (goodstring.indexOf(str.charAt(i))<0)
			return true;		
	}
	return false;
}
function validateFirstName(form_num){
if (!eval("document.forminfo.first_name"+form_num))
	return true;
else{
	if (eval("document.forminfo.first_name"+form_num).value.length < 1 || eval("document.forminfo.first_name"+form_num).value.length>20 || isBadString(eval("document.forminfo.first_name"+form_num).value,isAlpha+" -'"))
	{
		fnp1=form_num+1;
		fn=document.getElementById('first_name_label'+form_num);
		fn.innerHTML='First Name\*';
		fn.style.color='red';
		eval("document.forminfo.first_name"+form_num).focus();
		error_array[num_errors]="first name for Volunteer "+fnp1;
		num_errors++;
		return false;
	}
	fn=document.getElementById('first_name_label'+form_num);
	fn.innerHTML='First Name';
	fn.style.color='black';
	return true;
    }
}
function validateLastName(form_num){
if (!eval("document.forminfo.last_name"+form_num))
	return true;
	if (eval("document.forminfo.last_name"+form_num).value.length < 1 || eval("document.forminfo.last_name"+form_num).value.length>20 || isBadString(eval("document.forminfo.last_name"+form_num).value,isAlpha+" -'")){
		fnp1=form_num+1;
		ln=document.getElementById('last_name_label'+form_num);
		ln.innerHTML='Last Name\*';
		ln.style.color='red';
		eval("document.forminfo.last_name"+form_num).focus();
		error_array[num_errors]="last name for Volunteer "+fnp1;
		num_errors++;
		return false;
	}
	fn=document.getElementById('last_name_label'+form_num);
	fn.innerHTML='Last Name';
	fn.style.color='black';
	return true;
}
function validateUserName(){
if (!document.form1.fusername)
	return true;
	if (document.form1.fusername.value.length < 6 || document.form1.fusername.value.length>20 || isBadString(document.form1.last_name.value,isAlpha+isNumber+"_-'")){
		ln=document.getElementById('fusername_label');
		ln.innerHTML='Desired Username\*';
		ln.style.color='red';
		document.form1.fusername.focus();
		error_array[num_errors]="username between 6 and 20 characters consisting of letters, numbers, and/or \"_-'\"";
		num_errors++;
		return false;
	}
	fn=document.getElementById('fusername_label');
	fn.innerHTML='Desired Username';
	fn.style.color='black';
	return true;
}
function isValidEmail(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		 if (str.indexOf(" ")!=-1){
		    return false
		 }
 		 return true					
}
function validateEmail(){
	if (!document.formemail.email){
		return true;
	}	
	while (document.formemail.email.value.length < 1 || document.formemail.email.value.length>51 || !isValidEmail(document.formemail.email.value)){
		e=document.getElementById('email_label');
		e.innerHTML='Please enter a valid email address (fewer than 50 characters):\*<br>';
		e.style.color='red';
		return false;
	}
	return true;
}
phonesyntax="() .-"+isNumber;
function validatePhone(form_num){
if (!eval("document.forminfo.phone"+form_num) || !eval("document.forminfo.alt_phone"+form_num)){
	return true;
}
else{	
   fnp1=form_num+1;
   alt_phone=false;
   phone=false;
	if((eval("document.forminfo.alt_phone"+form_num).value.length >=1 && eval("document.forminfo.alt_phone"+form_num).value.length <10) || isBadString(eval("document.forminfo.alt_phone"+form_num).value,phonesyntax)){
		ph=document.getElementById('alt_phone_label'+form_num);
		ph.innerHTML='Alternate Phone\*';
		ph.style.color='red';
		eval("document.forminfo.alt_phone"+form_num).focus();
		error_array[num_errors]="a valid alternate phone number (or you may leave it blank) for Volunteer "+fnp1;
		num_errors++;
		alt_phone=true;
	}
	if ((eval("document.forminfo.phone"+form_num).value.length <10) && (eval("document.forminfo.alt_phone"+form_num).value.length<10)){
		ph=document.getElementById('phone_label'+form_num);
		ph.innerHTML='Phone\*';
		ph.style.color='red';
		eval("document.forminfo.phone"+form_num).focus();
		error_array[num_errors]="a valid phone number for Volunteer "+fnp1;
		num_errors++;
		if (!alt_phone){
			fn=document.getElementById('alt_phone_label'+form_num);
			fn.innerHTML='Alternate Phone';
			fn.style.color='black';
		}
		phone=true;
	}
	if(!phone && (eval("document.forminfo.phone"+form_num).value.length <10 || isBadString(eval("document.forminfo.phone"+form_num).value,phonesyntax))){
		ph=document.getElementById('phone_label'+form_num);
		ph.innerHTML='Phone\*';
		ph.style.color='red';
		eval("document.forminfo.phone"+form_num).focus();
		error_array[num_errors]="a valid phone number for Volunteer "+fnp1;
		num_errors++;
		phone=true;
	}
	if (!phone){
		fn=document.getElementById('phone_label'+form_num);
		fn.innerHTML='Phone';
		fn.style.color='black';
	}
	if (!alt_phone){
		fn=document.getElementById('alt_phone_label'+form_num);
		fn.innerHTML='Alternate Phone';
		fn.style.color='black';
	}
	if (alt_phone || phone)
		return false;
	return true;
    }
}
password_syntax=+isNumber+isAlpha+"~!@#$%^&*()_+`-=,.?/"; 
function validatePassword(){
if (!document.form1.fpassword || !document.form1.ckpassword)
	return true;
	if (document.form1.fpassword.value != document.form1.ckpassword.value)
	{
		ph=document.getElementById('ckpassword_label');
		ph.innerHTML='Retype Password\*';
		ph.style.color='red';
		document.form1.ckpassword.focus();
		error_array[num_errors]=" your passwords do not match. Please retype your password";
		num_errors++;
		return false;
	}
	if(document.form1.fpassword.value.length <6 || document.form1.fpassword.value.length >16 || isBadString(document.form1.fpassword.value,password_syntax))
	{
		ph=document.getElementById('fpassword_label');
		ph.innerHTML='Password\*';
		ph.style.color='red';
		document.form1.fpassword.focus();
		error_array[num_errors]="a password between 6 and 16 characters including letters, numbers, and characters in \"~!@#$%^&*()_+`-=,.?/\"";
		num_errors++;
		return false;
	}
	fn=document.getElementById('fpassword_label');
	fn.innerHTML='Password';
	fn.style.color='black';
	fn=document.getElementById('ckpassword_label');
	fn.innerHTML='Retype Password';
	fn.style.color='black';
	return true;
}
function validateAddress(){
if (!document.form1.address1 || !document.form1.address2){
	return true;
}
	if (document.form1.address1.value.length <1 && 
document.form1.address2.value.length <1){
		alert("Please enter your street address.");
		return false;
	}
	return true;
}	
function validateCity(){
if (!document.form1.city){
	return true;
}	if (document.form1.city.value.length < 1){
		alert("Please enter your city.");
		return false;
	}
	return true;
}	
function validateState(){
if (!document.form1.state){
	return true;
}	if (document.form1.state.value.length < 1){
		alert("Please enter your state or province.");
		return false;
	}
	return true;
}	
function validateZip(){
if (!document.form1.zip){
	return true;
}	if (document.form1.zip.value.length < 1){
		alert("Please enter your ZIP or postal code.");
		return false;
	}
	return true;
}	
function validate(){
/* if num_forms is 0, still goes through once*/
num_forms=document.forminfo.num_vols.value;
total_errors=0;
if (num_forms==0)
	max=1;
else
	max=num_forms;
   for (form_num=0; form_num<max; form_num++){
	num_errors=0;
	error_array=new Array();
	string='';
	d=document.getElementById('message'+form_num);
	d.innerHTML=string;
	d.style.display='none'
	ph=validatePhone(form_num);
	l_n=validateLastName(form_num);
	f_n=validateFirstName(form_num);
	if (num_errors>0){
		string="Please enter ";
		if (num_errors == 1)
			string=string+error_array[0];
		if (num_errors == 2)
			string=string+error_array[1]+" and "+error_array[0];
		if (num_errors >2)
		{
			for (i=num_errors-1;i>0;i--){
				string=string+error_array[i]+", ";
			}
			string=string+"and "+error_array[i];
		}	
		string=string+". ";
		d=document.getElementById('message'+form_num);
		d.innerHTML=string;
		d.style.display='block'
	}
	total_errors=total_errors+num_errors;
   }
if (total_errors>0)
	return false;
else
   return true;
}
function isSignUp()
{
	signup=false;
	num=document.form1.num_entries.value;
	for(ctr=0;ctr<num;ctr++)
	{
		index=ctr+1;
		prefix=document.getElementById('javalabel'+index);
		foo=prefix.firstChild.checked;
		if(foo == true)
			signup=true;
	}
	return signup;
}
function checkSignUp()
{
	while (!isSignUp())
	{
		ph=document.getElementById("message");
		ph.innerHTML="Please sign up for at least one event to continue.";
		ph.style.color="red";
		ph.style.display="block";
		return false;
	}
	return true;	
}

function checkEmail(){
	while (!validateEmail())
		return false;
	return true;
}
$total_num_rows=0;
function AddorChangeButton(num_rows){
	if(!num_rows) //called after having changed a "remove" button to an Add on none, where number of rows not known
		num_rows=total_num_rows; // a global variable that is set the first time this function is passed through when number of rows is known
	else
		total_num_rows=num_rows; // it's set right here when we did know what it was because it was passed
	for(i=1; i<num_rows+1; i++){	
		if(document.getElementById("filerow"+i)){
			document.getElementById("filerow"+i).onclick=ChangetoBrowse;
		}
	}
	for(i=1; i<num_rows+1; i++){	
		if(document.getElementById("filerow"+i+"rem")){
			document.getElementById("filerow"+i+"rem").onclick=ChangetoBrowse;
		}
	}
}

function ChangetoBrowse(e){
	if (!document.getElementById) return;
		if(!e) var e = window.event;
	//which link was the mouse over?
	whichlink = (e.target) ? e.target.id : e.srcElement.id;
	if (document.getElementById(whichlink).innerHTML=="Change"){
		if (!confirm("Are you sure you want to change this file?"))
			return;
	}
	if (document.getElementById(whichlink).innerHTML=="Remove"){
		if (confirm("Are you sure you want to delete this file?")){
			locofrem=whichlink.indexOf("rem");
			cellname=whichlink.substring(0,locofrem);
			cell=document.getElementById(cellname+"cell");
			cell.innerHTML="<td id='"+cellname+"cell'><table class=tiny_blue_table><tr><td class=like_input>(none)<td class=tiny_blue_cell><a id='"+cellname+"' class=tinynav href='#'>Add</a></td></tr></table></td>";
			AddorChangeButton();
			return;
		}
		else
			return;
	}
	cell=document.getElementById(whichlink+"cell");
	cell.innerHTML=	"<td><input name='row$j$filename' type=file></td>";
}
	
/*function Toggle(e){
	if (!document.getElementById) return;
		if(!e) var e = window.event;
	//which link was the mouse over?
	whichlink = (e.target) ? e.target.id : e.srcElement.id;
	
	// get the description
	obj=document.getElementById(whichlink+"desc");
	visible=(obj.style.display=="block")
	key=document.getElementById(whichlink);
	keyname=key.firstChild.nodeValue.substring(3);
	if (visible){
		obj.style.display="none";
		//change button to +
		key.firstChild.nodeValue="[+]"+keyname;
	}
	else{
		obj.style.display="block";
		//change button to -
		key.firstChild.nodeValue="[-]"+keyname;
	}
}
	
function addDescription(){
	i=1;
	while(document.getElementById("activityName"+i)){
		document.getElementById("activityName"+i).onclick=Toggle;
		i++;
	}
}
function addIndex(){
	i=1;
	while(document.getElementById("index"+i)){
		document.getElementById("index"+i).onclick=Toggle;
		i++;
	}
}
*/

function Enable(form_num){
	eval("document.forminfo.first_name"+form_num).disabled=false;
	eval("document.forminfo.last_name"+form_num).disabled=false;
	eval("document.forminfo.phone"+form_num).disabled=false;
	eval("document.forminfo.alt_phone"+form_num).disabled=false;
	document.getElementById('ed_rev'+form_num).innerHTML="<input type=button value=Revert onClick=Revert("+form_num+")>";
}
function Revert(form_num){
	eval("document.forminfo.first_name"+form_num).disabled=true;
	eval("document.forminfo.last_name"+form_num).disabled=true;
	eval("document.forminfo.phone"+form_num).disabled=true;
	eval("document.forminfo.alt_phone"+form_num).disabled=true;
	eval("document.forminfo.first_name"+form_num).value=eval("document.forminfo.curr_first_name"+form_num).value;
	eval("document.forminfo.last_name"+form_num).value=eval("document.forminfo.curr_last_name"+form_num).value;
	eval("document.forminfo.phone"+form_num).value=eval("document.forminfo.curr_phone"+form_num).value;
	eval("document.forminfo.alt_phone"+form_num).value=eval("document.forminfo.curr_alt_phone"+form_num).value;
	document.getElementById('ed_rev'+form_num).innerHTML="<input type=button value=Edit onClick=Enable("+form_num+")>";
}
