<!--
function eventDel(id)
{
	var anc = getElementFromID("eDA"+id);	
  newNoteValue = "type=eventdel&action=del&id="+id;
	if (http == false)
	{
	  document.location = "/events.php?"+newNoteValue;
	}
	else if (!ajaxIsBusy) 
		{
	      http.open("GET", "/processAJAX.php?" + newNoteValue, true);
	      ajaxIsBusy = anc;
	      http.onreadystatechange = handleEventDelToggleResponse;
	      ajaxIsBusy.style.color="red";
	      http.send(null);
	}	
}

function editEventInline(id)
{
	var anc = getElementFromID("er"+id);	
	var ancLink = getElementFromID("erL"+id);	
	if (!ajaxIsBusy) 
		{
			if (ancLink.innerHTML == "edit")
			{
	      http.open("GET", "/processAJAX.php?type=editEvent&eventValue=" + id, true);
	      ajaxIsBusy = anc;
	      http.onreadystatechange = handleEditEvent;
	      ancLink.innerHTML = "close";
	    }
	    else
    	{
	      http.open("GET", "/processAJAX.php?type=getEvent&eventValue=" + id, true);
	      ajaxIsBusy = anc;
	      http.onreadystatechange = handleGetEvent;	    		
	      ancLink.innerHTML = "edit";
    	}
      ajaxIsBusy.style.color="red";
      ancLink.style.color=="red";
      http.send(null);
	}	
}

function handleEditEvent()
{
	 if (http.readyState == 4) {
    if (http.status == 200) {
      ajaxIsBusy.style.color="white";
    } else {
      alert("Unable to update note: " + http.status);
    }		
    eventArray = http.responseText.split('\n');
    var cellone = "";
    var celltwo = "";
    ajaxIsBusy.cells[2].innerHTML = celltwo;
    cellone = "<form name='thisform' id='thisform' action='events.php' method=get>";
    cellone += "id: "+eventArray[0]+"<input type=hidden name='id'  id='id' size=5 value='"+eventArray[0]+"'><br>";
    cellone += "Date: <input name='date' id='date' value=\""+eventArray[1]+"\"><br>";
    cellone += "Bands:<br><textarea cols=55 rows=7 name='band' >"+eventArray[2]+"</textarea><br>";
    cellone += "Canceled? <select name=canceled id=canceled><option "+((eventArray[4]=='0')?" selected":"")+">NO</option><option"+((eventArray[4]=='1')?" selected":"")+">YES</option></select><br>";
   // ajaxIsBusy.cells[1].innerHTML += "Filter? <input name='filter' value='"+eventArray[5]+"'><br>";
    cellone += "Location:<br><input name='location' id='location' value=\""+eventArray[3]+"\">";
    cellone += "<select><option>"+eventArray[3]+"</option></select>";
    cellone += "<input type=submit value='Edit' name='submitEdit' onClick='submitEventsEdit(); return false;'></form>";
     ajaxIsBusy.cells[1].innerHTML = cellone;
		
    ajaxIsBusy = 0;
 }
}

function submitEventsEdit()
{
  var form = document.getElementById('thisform' );
  //var arr = new Array('id','canceled','date','band','location');
   var arr = form.childNodes;
  var id = "";
  var args="";
  for (var i=0; i< arr.length;i++)
  { 
    var elem = arr[i];
    if(elem.type!=undefined && elem.name!=undefined&& elem.name!='')
    {
      args += "&"+elem.name+"="+elem.value;
      if (elem.name == 'id')
      {
       id=elem.value;
      }
    }
  }
  var ancLink = getElementFromID("erL"+id); 
  alert ("/processAJAX.php?type=submitevent"+args);
      http.open("GET", "/processAJAX.php?type=submitevent"+args, true);
        http.onreadystatechange = handleSubmitEvent;
        ancLink.innerHTML = "submitting";
        ajaxIsBusy = ancLink;
}
function handleSubmitEvent()
{
   if (http.readyState == 4) {
    if (http.status == 200) {
      ajaxIsBusy.style.color="white";
    } else {
      alert("Unable to update note: " + http.status);
    }   
    alert("hello");
    id = http.responseText;
    ajaxIsBusy.innerHTML = "close";
    ajaxIsBusy =0;
    editEventInline(id);
  }
}


function handleGetEvent()
{
	 if (http.readyState == 4) {
    if (http.status == 200) {
      ajaxIsBusy.style.color="white";
    } else {
      alert("Unable to update note: " + http.status);
    }		
    eventArray = http.responseText.split('\n');
    ajaxIsBusy.cells[1].innerHTML = eventArray[2];
    ajaxIsBusy.cells[2].innerHTML = eventArray[3];
    ajaxIsBusy = 0;
 }
}

function toggleEvent(id)
{
	var anc = getElementFromID("ePMA"+id);	
	var newNoteValue = anc.innerHTML;
  if (newNoteValue == '+')
  	newNoteValue = "type=event&action=add&id="+id;
  else
  	newNoteValue = "type=event&action=del&id="+id;
	if (http == false)
	{
	  document.location = "/events.php?"+newNoteValue;
	}
	else if (!ajaxIsBusy) 
		{
	      http.open("GET", "/processAJAX.php?" + newNoteValue, true);
	      ajaxIsBusy = anc;
	      http.onreadystatechange = handleEventToggleResponse;
	      ajaxIsBusy.style.color="red";
	      http.send(null);
	}	
}
function handleEventDelToggleResponse()
{	
 if (http.readyState == 4) {
    if (http.status == 200) {
      ajaxIsBusy.style.color="white";
    } else {
      alert("Unable to update note: " + http.status);
    }		
		ajaxIsBusy.innerHTML= '';
    ajaxIsBusy = 0;
 }
}

function handleEventToggleResponse()
{	
 if (http.readyState == 4) {
    if (http.status == 200) {
      ajaxIsBusy.style.color="white";
    } else {
      alert("Unable to update note: " + http.status);
    }
		if (ajaxIsBusy.innerHTML == '+')
		{	
			ajaxIsBusy.innerHTML = '-';
		}
		else
		{
			ajaxIsBusy.innerHTML= '+';
		}
    ajaxIsBusy = 0;
 }
}

function sendChangeSiteRequest(who, id)
{
	var anc  = document.getElementById(who);
	anc.DISABLED  = true;
	alert(anc);
  	newNoteValue = "type=changeSite&id="+id+"&value="+anc.options[anc.selectedIndex].value;
	if (!ajaxIsBusy) 
		{
	      http.open("GET", "/processAJAX.php?" + newNoteValue, true);
	      ajaxIsBusy = anc;
	      http.onreadystatechange = handleChangeSiteResponse();
	    //  ajaxIsBusy.style.color="red";
	      http.send(null);
	}	
}
function handleChangeSiteResponse()
{	
    ajaxIsBusy.DISABLED  = false;
	  ajaxIsBusy.style.color="black";
    ajaxIsBusy = 0;
}

//-->
