function validateAddEvent() {
	var goodtogo="yes";
	if (document.addevent.groupName.value=="") {
		goodtogo="no";
		alert("You must specify a title for this event.");
	}
	else if (document.addevent.groupDate.value=="") {
		goodtogo="no";
		alert("You must specify a date for this event.");
	}
	else if (document.addevent.existingCity.value==0 && document.addevent.newCity.value=="") {
		goodtogo="no";
		alert("You must either specify an existing city or create a new one.");
	}
	else if (document.addevent.existingLocation.value==0 && document.addevent.newLocation.value=="") {
		goodtogo="no";
		alert("You must either specify an existing location or create a new one.");
	}
	else if (document.addevent.existingCategory.value==0 && document.addevent.newCategory.value=="") {
		goodtogo="no";
		alert("You must either specify an existing event type or create a new one.");
	}
	else if (document.addevent.existingCategoryName.selectedIndex==-1) {
		goodtogo="no";
		alert("You must either specify an existing team(s) or create a new one.");
	}
	else if (document.addevent.existingCategoryName.options(0).selected==true && document.addevent.newCategoryName.value=="") {
		goodtogo="no";
		alert("You must either specify an existing team(s) or create a new one.");
	}
	else if (document.addevent.groupPassBool.value=="yes" && document.addevent.groupPass.value=="") {
		goodtogo="no";
		alert("You must specify a password if the event is to be protected.");
	}
	if (goodtogo=="no") {
		return false;
	}
	else {
		return;
	}
}

function populateList(whichlist) {
	if (whichlist=="location") {
		var maxtimes=tblLoc_locID.length
		for (i = 0; i <= maxtimes; i++) {
			if (tblLoc_cityID[i]=existingCity.value) {
				existingLocation.insertAdjacentHTML(beforeEnd,"<option value="+tblLoc_locID[i]+">"+tblLoc_location[i]);
			}
		}
		
	}
	if (whichlist=="categoryName") {
		
	}	
}

function refresh(whichform) {
	whichform.action=document.URL
	var resubmit=whichform.submit()
}

function showCreate(firstItem,secondItem) {
	if (firstItem.value==0) { secondItem.style.display=""; }
	else { secondItem.style.display="none"; }
}

function updateAddEvent() {
	if (formtype.value=="tblGroup") {
		showCreate(existingCity,newCity);
		showCreate(existingLocation,newLocation);
		showCreate(existingCategory,newCategory);
		showCreate(existingCategoryName,newCategoryName1);
	}
}

function submitonce(theform){
if (document.all||document.getElementById){
for (i=0;i<theform.length;i++){
var tempobj=theform.elements[i]
if(tempobj.type.toLowerCase()=='submit'||tempobj.type.toLowerCase()=='reset')
tempobj.disabled=true
} } }

function extendField(ID) {
	if (ID.style.display=="none") {
		if (ID.id=="showbutton") {
			ID.style.display="inline";
		}
		else {
			ID.style.display="block";
		}
	}
	else if (ID.style.display=="block") {
		ID.style.display="none";
	}
	else if (ID.style.display=="inline") {
		ID.style.display="none";
	}
}

function toggleArrow(ID) {
	if (ID.name=="up") {
		ID.innerHTML="&nbsp;+&nbsp;";
		ID.name="down";
		dummy.href="processor.php?setbar="+ID.id+"&state=down";
		dummy.click();
	}
	else if (ID.name=="down") {
		ID.innerHTML="&nbsp;-&nbsp;";
		ID.name="up";
		dummy.href="processor.php?setbar="+ID.id+"&state=up";
		dummy.click();
	}
}

function toggleLeftBar() {
	if (leftbartable.name=="up") {
		leftbartable.name="down";
		dummy.href="processor.php?setbar=leftbar&state=down";
		dummy.click();
	}
	else if (leftbartable.name=="down") {
		leftbartable.name="up";
		dummy.href="processor.php?setbar=leftbar&state=up";
		dummy.click();
	}
}

function popUp(URL,height) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1,width=400,height="+height+",left = 100,top = 100');");
}

function popUpPic(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1,width=600,height=550,left = 100,top = 100');");
}

function resizePopup() {
	picheight = document.getElementById('mainpic').height + 100;
	picwidth = document.getElementById('mainpic').width + 12;
	window.resizeTo(picwidth,picheight);
	document.getElementById('mainpic').style.display ='none';
	document.getElementById('picdiv').style.display ='block';
	document.getElementById('picdiv').style.width = document.getElementById('mainpic').width; 
	document.getElementById('picdiv').style.height = document.getElementById('mainpic').height; 
}

function askUser(message) {
  if (confirm(message)) {
    return;
  }
  else {
    return false;
  }   
}

function Check_All(theForm)
{
  for(var i=0; i<theForm.length; i++)
  {
    var el= theForm.elements[i];
    if(el.type == "checkbox")
    {
      el.checked = true;
    }
  }
}

function UnCheck_All(theForm)
{
  for(var i=0; i<theForm.length; i++)
  {
    var el= theForm.elements[i];
    if(el.type == "checkbox")
    {
      el.checked = false;
    }
  }
}
