Array.prototype.in_array = function ( obj ) {
	var len = this.length;
	for ( var x = 0 ; x <= len ; x++ ) {
		if ( this[x] == obj ) return true;
	}
	return false;
}

function getById(id)
{
	var it;
	if(document.getElementById)
		it=document.getElementById(id);
	else if (document.all)
		it=document.all[id];
	else if (document.layers)
		it=document.layers[id];
	else
		it=null;
	return it;	
}

function openTab(whichTab,numberTabs)
{
	for(var i=1; i<=numberTabs; i++)
	{
		if(i==whichTab)
		{
			getById('contentTab'+i).style.backgroundColor="#FFF";
			getById('contentTab'+i).style.color="black";
			getById('content'+i).style.display="block";
		}
		else
		{
			getById('contentTab'+i).style.backgroundColor="#DDD";
			getById('contentTab'+i).style.color="blue";
			getById('content'+i).style.display="none";
		}
	}
	getById('chosenTab').value=whichTab;
	if(getById('tabArrow1'))
		getById('tabArrow1').value=whichTab;
	if(getById('tabArrow2'))
		getById('tabArrow2').value=whichTab;
	if(getById('tabArrow3'))
		getById('tabArrow3').value=whichTab;
	if(getById('tabArrow4'))
		getById('tabArrow4').value=whichTab;
}

function updateResults(updateAffiliated)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				if (window.ActiveXObject)
				{
					xmlobject = xmlHttp.responseXML;
				}
				else if (window.XMLHttpRequest)
				{
					var parser = new DOMParser();
					xmlobject = parser.parseFromString(xmlHttp.responseText, "text/xml");
				}
				var resultset = xmlobject.getElementsByTagName('Results')[0];
				var result = resultset.getElementsByTagName("Result");
				
				var thisresult;
				var thisOrg;
				var thisName;
				var thisType;
				var i=0;
				var contents="";
				var currArray=getById('orgList').value.split(",");
				for(i=0; i<result.length;i++)
				{
					thisresult = result[i];
					thisOrg=thisresult.getElementsByTagName("OrgEntity")[0].firstChild.nodeValue;
					thisName=thisresult.getElementsByTagName("OrgName")[0].firstChild.nodeValue;
					thisType=thisresult.getElementsByTagName("OrgType")[0].firstChild.nodeValue;
					if(!currArray.in_array(thisOrg))
					{
						contents+="<img src='../images/adminmenu/singleleft.jpg' width='14px' height='14px' style='cursor: pointer;' onclick='addAffiliation("+thisOrg+",\""+thisName+"\",\""+thisType+"\")' />&nbsp;"+thisName+"<br />";
					}
				}
				getById('searchResults').innerHTML=contents;
				if(updateAffiliated=='y')
				{
					//separate ajax call to refill Affiliated Organizations
					resetAffiliated();
					
				}
				getById('workingDiv').style.display='none';
			}//end if status==200
			else 
			{ 
				getById('workingDiv').style.display='none';
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	getById('workingDiv').style.display='block';
	var searchField=getById('searchOrg').value;
	
	xmlHttp.open('GET', "../ajax/searchOrg.php?searchField="+searchField, true); 
	xmlHttp.send(null);
}
function resetAffiliated()
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				getById('currentlyAffiliated').innerHTML=xmlHttp.responseText;
				
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	
	var orgList=getById('orgList').value;
	
	xmlHttp.open('GET', "../ajax/resetAffiliated.php?orgList="+orgList, true); 
	xmlHttp.send(null);
}
function addAffiliation(entityId, entityName, entityType)
{
	getById('searchResults').innerHTML="";
	var addString="";

	currSize=parseInt(getById('numOrgs').value);
	if(currSize>0)
		addString=",";
	addString+=entityId;
	getById('orgList').value=getById('orgList').value+addString;
	getById('numOrgs').value=currSize+1;
	updateResults('y');
}
function removeAffiliation(entityId, entityName, entityType)
{
	var currArray=getById('orgList').value.split(",");
	var currSize=parseInt(getById('numOrgs').value);
	var newString="";
	var counter=0;
	for(var i=0; i<currSize;i++)
	{
		if(currArray[i]!=entityId)
		{
			counter++;
			if(counter>1)
				newString+=",";
			newString+=currArray[i];
		}
	}
	getById('orgList').value=newString;
	getById('numOrgs').value=currSize-1;
	updateResults('y');
}

function disableEnterKey(e)
{
     var key;

     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox

     if(key == 13)
          return false;
     else
          return true;
}

function orgupdateResults(updateAffiliated)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				if (window.ActiveXObject)
				{
					xmlobject = xmlHttp.responseXML;
				}
				else if (window.XMLHttpRequest)
				{
					var parser = new DOMParser();
					xmlobject = parser.parseFromString(xmlHttp.responseText, "text/xml");
				}
				var resultset = xmlobject.getElementsByTagName('Results')[0];
				var result = resultset.getElementsByTagName("Result");
				
				var thisresult;
				var thisPerson;
				var thisFirst;
				var thisLast;
				var i=0;
				var contents="";
				var currArray=getById('personList').value.split(",");
				for(i=0; i<result.length;i++)
				{
					thisresult = result[i];
					thisPerson=thisresult.getElementsByTagName("PersonEntity")[0].firstChild.nodeValue;
					thisFirst=thisresult.getElementsByTagName("PersonFirstName")[0].firstChild.nodeValue;
					thisLast=thisresult.getElementsByTagName("PersonLastName")[0].firstChild.nodeValue;
					if(!currArray.in_array(thisPerson))
					{
						contents+="<img src='../images/adminmenu/singleleft.jpg' width='14px' height='14px' style='cursor: pointer;' onclick='orgaddAffiliation("+thisPerson+",\""+thisFirst+" "+thisLast+"\")' />&nbsp;"+thisFirst+" "+thisLast+"<br />";
					}
				}
				
				getById('orgsearchResults').innerHTML=contents;
				if(updateAffiliated=='y')
				{
					//separate ajax call to refill Affiliated Organizations
					orgresetAffiliated();
				}
				getById('workingDiv').style.display='none';
			}//end if status==200
			else 
			{ 
				getById('workingDiv').style.display='none';
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	getById('workingDiv').style.display='block';
	var searchField=getById('searchPerson').value;
	if(searchField!='')
	{
		xmlHttp.open('GET', "../ajax/searchPerson.php?searchField="+searchField, true); 
		xmlHttp.send(null);
	}
	else
	{
		getById('workingDiv').style.display='none';
		if(updateAffiliated=='y')
		{
			//separate ajax call to refill Affiliated Organizations
			orgresetAffiliated();
		}
	}
}
function orgresetAffiliated()
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getById('orgcurrentlyAffiliated').innerHTML=xmlHttp.responseText;
				
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	
	var personList=getById('personList').value;
	xmlHttp.open('GET', "../ajax/orgresetAffiliated.php?personList="+personList, true); 
	xmlHttp.send(null);
}
function orgaddAffiliation(entityId, entityName)
{
	getById('orgsearchResults').innerHTML="";
	var addString="";

	currSize=parseInt(getById('numPersons').value);
	if(currSize>0)
		addString=",";
	addString+=entityId;
	getById('personList').value=getById('personList').value+addString;
	getById('numPersons').value=currSize+1;
	orgupdateResults('y');
}
function orgremoveAffiliation(entityId, entityName)
{
	var currArray=getById('personList').value.split(",");
	var currSize=parseInt(getById('numPersons').value);
	var newString="";
	var counter=0;
	for(var i=0; i<currSize;i++)
	{
		if(currArray[i]!=entityId)
		{
			counter++;
			if(counter>1)
				newString+=",";
			newString+=currArray[i];
		}
	}
	getById('personList').value=newString;
	getById('numPersons').value=currSize-1;
	orgupdateResults('y');
}

function groupupdateResults(updateAffiliated)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				if (window.ActiveXObject)
				{
					xmlobject = xmlHttp.responseXML;
				}
				else if (window.XMLHttpRequest)
				{
					var parser = new DOMParser();
					xmlobject = parser.parseFromString(xmlHttp.responseText, "text/xml");
				}
				var resultset = xmlobject.getElementsByTagName('Results')[0];
				var result = resultset.getElementsByTagName("Result");
				
				var thisresult;
				var thisPerson;
				var thisFirst;
				var thisLast;
				var i=0;
				var contents="";
				var currArray=getById('personList').value.split(",");
				for(i=0; i<result.length;i++)
				{
					thisresult = result[i];
					thisPerson=thisresult.getElementsByTagName("PersonEntity")[0].firstChild.nodeValue;
					thisFirst=thisresult.getElementsByTagName("PersonFirstName")[0].firstChild.nodeValue;
					thisLast=thisresult.getElementsByTagName("PersonLastName")[0].firstChild.nodeValue;
					if(!currArray.in_array(thisPerson))
					{
						contents+="<img src='../images/adminmenu/singleleft.jpg' width='14px' height='14px' style='cursor: pointer;' onclick='groupaddAffiliation("+thisPerson+",\""+thisFirst+" "+thisLast+"\")' />&nbsp;"+thisFirst+" "+thisLast+"<br />";
					}
				}
				
				getById('groupsearchResults').innerHTML=contents;
				if(updateAffiliated=='y')
				{
					//separate ajax call to refill Affiliated Organizations
					groupresetAffiliated();
				}
				getById('workingDiv').style.display='none';
			}//end if status==200
			else 
			{ 
				getById('workingDiv').style.display='none';
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	getById('workingDiv').style.display='block';
	var searchField=getById('searchPerson').value;
	if(searchField!='')
	{
		xmlHttp.open('GET', "../ajax/searchPerson.php?searchField="+searchField, true); 
		xmlHttp.send(null);
	}
	else
	{
		getById('workingDiv').style.display='none';
		if(updateAffiliated=='y')
		{
			//separate ajax call to refill Affiliated Organizations
			groupresetAffiliated();
		}
	}
}
function groupresetAffiliated()
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getById('groupcurrentlyAffiliated').innerHTML=xmlHttp.responseText;
				
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	
	var personList=getById('personList').value;
	xmlHttp.open('GET', "../ajax/groupresetAffiliated.php?personList="+personList, true); 
	xmlHttp.send(null);
}
function groupaddAffiliation(entityId, entityName)
{
	getById('groupsearchResults').innerHTML="";
	var addString="";

	currSize=parseInt(getById('numPersons').value);
	if(currSize>0)
		addString=",";
	addString+=entityId;
	getById('personList').value=getById('personList').value+addString;
	getById('numPersons').value=currSize+1;
	groupupdateResults('y');
}
function groupremoveAffiliation(entityId, entityName)
{
	var currArray=getById('personList').value.split(",");
	var currSize=parseInt(getById('numPersons').value);
	var newString="";
	var counter=0;
	for(var i=0; i<currSize;i++)
	{
		if(currArray[i]!=entityId)
		{
			counter++;
			if(counter>1)
				newString+=",";
			newString+=currArray[i];
		}
	}
	getById('personList').value=newString;
	getById('numPersons').value=currSize-1;
	groupupdateResults('y');
}

function getGoals(entity,chosen)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				var returnText=xmlHttp.responseText;
				
				if(returnText=="0")
				{
					getById('currentGoalsList').innerHTML="There are no goals/strategies to display<br /><a href=\"javascript: selectGoal("+entity+",0,0);\">Add Goal/Strategy</a>";
				}
				else
				{
					getById('currentGoalsList').innerHTML=returnText+"<br /><a href=\"javascript: selectGoal("+entity+",0,0);\">Add Goal/Strategy</a>";
					if(chosen==0)
						setTimeout("selectGoal("+entity+","+getById('counterGoal1').value+",1)",500);
					else
					{
						var number=getById('entityGoal'+chosen).value;
						setTimeout("selectGoal("+entity+","+chosen+","+number+")",500);
					}
				}
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	
	xmlHttp.open('GET', "../ajax/getGoals.php?entity="+entity, true); 
	xmlHttp.send(null);
}
function selectGoal(entity,goal,counter)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				getById('goalForm').innerHTML=xmlHttp.responseText;
		
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	var i=1;
	while(getById('arrowDiv'+i))
	{
		if(counter!=i)
			getById('arrowDiv'+i).style.display='none';
		else
			getById('arrowDiv'+i).style.display='block';
		i++;
	}
	xmlHttp.open('GET', "../ajax/selectGoal.php?entity="+entity+"&goal="+goal, true); 
	xmlHttp.send(null);
}
function submitGoal(entity,goal)
{
	var goalTarget=getById('Goal_Target').value.replace(",","");
	goalTarget=parseFloat(goalTarget).toFixed(2);
	
	var goalBudget=getById('Goal_Budget').value.replace(",","");
	goalBudget=parseFloat(goalBudget).toFixed(2);
	
	var goalFiscal=getById('Goal_Fiscal').options[getById('Goal_Fiscal').selectedIndex].value;
	var goalPriority=getById('Goal_Priority').options[getById('Goal_Priority').selectedIndex].value;
	var goalProgram=getById('Goal_Event').options[getById('Goal_Event').selectedIndex].value;
	var goalStrategy=getById('Goal_Strategy').value;
	
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getGoals(entity,parseInt(xmlHttp.responseText));
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function

	xmlHttp.open('GET', "../ajax/createGoal.php?entity="+entity+"&goal="+goal+"&goalTarget="+goalTarget+"&goalBudget="+goalBudget+"&goalFiscal="+goalFiscal+"&goalPriority="+goalPriority+"&goalProgram="+goalProgram+"&goalStrategy="+goalStrategy, true); 
	xmlHttp.send(null);
}
function deleteGoal(entity,goal)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getGoals(entity,0);
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function

	xmlHttp.open('GET', "../ajax/deleteGoal.php?goal="+goal, true); 
	xmlHttp.send(null);
}

function updateRoleResults(updateRoles)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				if (window.ActiveXObject)
				{
					xmlobject = xmlHttp.responseXML;
				}
				else if (window.XMLHttpRequest)
				{
					var parser = new DOMParser();
					xmlobject = parser.parseFromString(xmlHttp.responseText, "text/xml");
				}
				var resultset = xmlobject.getElementsByTagName('Results')[0];
				var result = resultset.getElementsByTagName("Result");
				
				var thisresult;
				var thisOrg;
				var thisName;
				var thisType;
				var i=0;
				var contents="";
				var currArray=getById('roleList').value.split(",");
				for(i=0; i<result.length;i++)
				{
					thisresult = result[i];
					thisRole=thisresult.getElementsByTagName("RoleTypeId")[0].firstChild.nodeValue;
					thisName=thisresult.getElementsByTagName("RoleName")[0].firstChild.nodeValue;
					if(!currArray.in_array(thisRole))
					{
						contents+="<img src='../images/adminmenu/singleleft.jpg' width='14px' height='14px' style='cursor: pointer;' onclick='addRole("+thisRole+",\""+thisName+"\")' />&nbsp;"+thisName+"<br />";
					}
				}
				
				getById('searchRoleResults').innerHTML=contents;
				if(updateRoles=='y')
				{
					//separate ajax call to refill roles
					resetRoles();
					
				}
				getById('workingRoleDiv').style.display='none';
			}//end if status==200
			else 
			{ 
				getById('workingRoleDiv').style.display='none';
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	getById('workingRoleDiv').style.display='block';
	var searchField=getById('searchRole').value;
	
	xmlHttp.open('GET', "../ajax/searchRole.php?searchField="+searchField, true); 
	xmlHttp.send(null);
}
function resetRoles()
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				getById('currentRoles').innerHTML=xmlHttp.responseText;
				
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	
	var roleList=getById('roleList').value;
	xmlHttp.open('GET', "../ajax/resetRoles.php?roleList="+roleList, true); 
	xmlHttp.send(null);
}
function addRole(roleTypeId, roleName)
{
	getById('searchRoleResults').innerHTML="";
	var addString="";
	currSize=parseInt(getById('numRoles').value);

	if(currSize>0)
		addString=",";
	addString+=roleTypeId;
	getById('roleList').value=getById('roleList').value+addString;
	getById('numRoles').value=currSize+1;
	updateRoleResults('y');
}
function removeRole(roleTypeId, roleName)
{
	var currArray=getById('roleList').value.split(",");
	var currSize=parseInt(getById('numRoles').value);
	var newString="";
	var counter=0;
	for(var i=0; i<currSize;i++)
	{
		if(currArray[i]!=roleTypeId)
		{
			counter++;
			if(counter>1)
				newString+=",";
			newString+=currArray[i];
		}
	}
	getById('roleList').value=newString;
	getById('numRoles').value=currSize-1;
	updateRoleResults('y');
}

function updateSkillResults(updateSkills)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				if (window.ActiveXObject)
				{
					xmlobject = xmlHttp.responseXML;
				}
				else if (window.XMLHttpRequest)
				{
					var parser = new DOMParser();
					xmlobject = parser.parseFromString(xmlHttp.responseText, "text/xml");
				}
				var resultset = xmlobject.getElementsByTagName('Results')[0];
				var result = resultset.getElementsByTagName("Result");
				
				var thisresult;
				var thisOrg;
				var thisName;
				var thisType;
				var i=0;
				var contents="";
				var currArray=getById('skillList').value.split(",");
				for(i=0; i<result.length;i++)
				{
					thisresult = result[i];
					thisSkill=thisresult.getElementsByTagName("SkillId")[0].firstChild.nodeValue;
					thisName=thisresult.getElementsByTagName("SkillName")[0].firstChild.nodeValue;
					if(!currArray.in_array(thisSkill))
					{
						contents+="<img src='../images/adminmenu/singleleft.jpg' width='14px' height='14px' style='cursor: pointer;' onclick='addSkill("+thisSkill+",\""+thisName+"\")' />&nbsp;"+thisName+"<br />";
					}
				}
				
				getById('searchSkillResults').innerHTML=contents;
				if(updateSkills=='y')
				{
					//separate ajax call to refill skills
					resetSkills();
					
				}
				getById('workingSkillDiv').style.display='none';
			}//end if status==200
			else 
			{ 
				getById('workingSkillDiv').style.display='none';
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	getById('workingSkillDiv').style.display='block';
	var searchField=getById('searchSkill').value;
	
	xmlHttp.open('GET', "../ajax/searchSkill.php?searchField="+searchField, true); 
	xmlHttp.send(null);
}
function resetSkills()
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				getById('currentSkills').innerHTML=xmlHttp.responseText;
				
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	
	var skillList=getById('skillList').value;
	xmlHttp.open('GET', "../ajax/resetSkills.php?skillList="+skillList, true); 
	xmlHttp.send(null);
}
function addSkill(skillId, skillName)
{
	getById('searchSkillResults').innerHTML="";
	var addString="";
	currSize=parseInt(getById('numSkills').value);

	if(currSize>0)
		addString=",";
	addString+=skillId;
	getById('skillList').value=getById('skillList').value+addString;
	getById('numSkills').value=currSize+1;
	updateSkillResults('y');
}
function removeSkill(skillId, skillName)
{
	var currArray=getById('skillList').value.split(",");
	var currSize=parseInt(getById('numSkills').value);
	var newString="";
	var counter=0;
	for(var i=0; i<currSize;i++)
	{
		if(currArray[i]!=skillId)
		{
			counter++;
			if(counter>1)
				newString+=",";
			newString+=currArray[i];
		}
	}
	getById('skillList').value=newString;
	getById('numSkills').value=currSize-1;
	updateSkillResults('y');
}
function getActions(entity,chosen)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				var returnText=xmlHttp.responseText;
				
				if(returnText=="0")
				{
					getById('currentActionsList').innerHTML="There are no actions to display<br /><a href=\"javascript: selectAction("+entity+",0,0);\">Add Action</a>";
				}
				else
				{
					getById('currentActionsList').innerHTML=returnText+"<br /><a href=\"javascript: selectAction("+entity+",0,0);\">Add Action</a>";
					if(chosen==0)
						setTimeout("selectAction("+entity+","+getById('counterAction1').value+",1)",500);
					else
					{
						var number=getById('entityAction'+chosen).value;
						setTimeout("selectAction("+entity+","+chosen+","+number+")",500);
					}
				}
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	
	xmlHttp.open('GET', "../ajax/getActions.php?entity="+entity, true); 
	xmlHttp.send(null);
}
function selectAction(entity,theaction,counter)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getById('actionForm').innerHTML=xmlHttp.responseText;
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	var i=1;
	while(getById('arrowDiv'+i))
	{
		if(counter!=i)
			getById('arrowDiv'+i).style.display='none';
		else
			getById('arrowDiv'+i).style.display='block';
		i++;
	}
	xmlHttp.open('GET', "../ajax/selectAction.php?entity="+entity+"&theaction="+theaction, true); 
	xmlHttp.send(null);
}
function submitAction(entity,theaction)
{

	var actionFiscal=getById('Action_Fiscal').options[getById('Action_Fiscal').selectedIndex].value;
	var actionPriority=getById('Action_Priority').options[getById('Action_Priority').selectedIndex].value;
	var actionStatus=getById('Action_Status').options[getById('Action_Status').selectedIndex].value;
	var actionProgram=getById('Action_Event').options[getById('Action_Event').selectedIndex].value;
	var actionVolunteer=getById('Action_Volunteer').options[getById('Action_Volunteer').selectedIndex].value;
	var actionStaff=getById('Action_Staff').options[getById('Action_Staff').selectedIndex].value;
	var actionType=getById('Action_Type').options[getById('Action_Type').selectedIndex].value;
	var actionDate=getById('Action_Date').value;
	var actionComments=getById('Action_Comments').value;
	var actionOutcome=getById('Action_Outcome').value;

	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getActions(entity,parseInt(xmlHttp.responseText));
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	if(actionDate=='')
	{
		//alert("Please enter a date. If you are unsure of the date, you can change it later.");
	}
	else
	{
		xmlHttp.open('GET', "../ajax/createAction.php?entity="+entity+"&theaction="+theaction+"&actionFiscal="+actionFiscal+"&actionPriority="+actionPriority+"&actionStatus="+actionStatus+"&actionProgram="+actionProgram+"&actionDate="+actionDate+"&actionComments="+actionComments+"&actionOutcome="+actionOutcome+"&actionVolunteer="+actionVolunteer+"&actionStaff="+actionStaff+"&actionType="+actionType, true); 
		xmlHttp.send(null);
	}
}
function deleteAction(entity,theaction)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getActions(entity,0);
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function

	xmlHttp.open('GET', "../ajax/deleteAction.php?theaction="+theaction, true); 
	xmlHttp.send(null);
}
function getRelations(entity,chosen)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				var returnText=xmlHttp.responseText;
				
				if(returnText=="0")
				{
					getById('currentRelationsList').innerHTML="There are no relationships to display<br /><a href=\"javascript: selectRelation("+entity+",0,0);\">Add Relationship</a>";
				}
				else
				{
					getById('currentRelationsList').innerHTML=returnText+"<br /><a href=\"javascript: selectRelation("+entity+",0,0);\">Add Relationship</a>";
					if(chosen==0 && getById('counterRelation1'))
						setTimeout("selectRelation("+entity+","+getById('counterRelation1').value+",1)",500);
					else
					{
						var number=getById('entityRelation'+chosen).value;
						setTimeout("selectRelation("+entity+","+chosen+","+number+")",500);
					}
				}
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	
	xmlHttp.open('GET', "../ajax/getRelations.php?entity="+entity, true); 
	xmlHttp.send(null);
}
function selectRelation(entity,relation,counter)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getById('relationForm').innerHTML=xmlHttp.responseText;
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	var i=1;
	while(getById('relationArrowDiv'+i))
	{
		if(counter!=i)
			getById('relationArrowDiv'+i).style.display='none';
		else
			getById('relationArrowDiv'+i).style.display='block';
		i++;
	}
	xmlHttp.open('GET', "../ajax/selectRelation.php?entity="+entity+"&relation="+relation, true); 
	xmlHttp.send(null);
}
function submitRelation(entity,relation)
{
	var relType=getById('Relationship_Type').options[getById('Relationship_Type').selectedIndex].value;
	var isOf=getById('isOf').options[getById('isOf').selectedIndex].value;
	var other=getById('Relationship_Other').options[getById('Relationship_Other').selectedIndex].value;

	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	}
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getRelations(entity,parseInt(xmlHttp.responseText));
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function

	xmlHttp.open('GET', "../ajax/createRelation.php?entity="+entity+"&relation="+relation+"&relType="+relType+"&isOf="+isOf+"&other="+other, true); 
	xmlHttp.send(null);
	
}
function deleteRelation(entity,relation)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getRelations(entity,0);
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function

	xmlHttp.open('GET', "../ajax/deleteRelation.php?relation="+relation, true); 
	xmlHttp.send(null);
}
function getNotes(entity,chosen)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				var returnText=xmlHttp.responseText;
				
				if(returnText=="0")
				{
					getById('currentNotesList').innerHTML="There are no notes to display<br /><a href=\"javascript: selectNote("+entity+",0,0);\">Add Note</a>";
				}
				else
				{
					getById('currentNotesList').innerHTML=returnText+"<br /><a href=\"javascript: selectNote("+entity+",0,0);\">Add Note</a>";
					if(chosen==0 && getById('counterNote1'))
						setTimeout("selectNote("+entity+","+getById('counterNote1').value+",1)",500);
					else
					{
						var number=getById('entityNote'+chosen).value;
						setTimeout("selectNote("+entity+","+chosen+","+number+")",500);
					}
				}
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	
	xmlHttp.open('GET', "../ajax/getNotes.php?entity="+entity, true); 
	xmlHttp.send(null);
}
function selectNote(entity,note,counter)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getById('noteForm').innerHTML=xmlHttp.responseText;
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	var i=1;
	while(getById('noteArrowDiv'+i))
	{
		if(counter!=i)
			getById('noteArrowDiv'+i).style.display='none';
		else
			getById('noteArrowDiv'+i).style.display='block';
		i++;
	}
	xmlHttp.open('GET', "../ajax/selectNote.php?entity="+entity+"&note="+note, true); 
	xmlHttp.send(null);
}
function submitNote(entity,note)
{
	var noteSubject=getById('Note_Subject').value;
	var noteEvent=getById('Note_Event').options[getById('Note_Event').selectedIndex].value;
	var noteAuthor=getById('Note_Author').options[getById('Note_Author').selectedIndex].value;
	var noteNote=getById('Note_Note').value;
	if(getById('Note_Follow_y').checked)
		var noteFollow='y';
	else
		var noteFollow='n';
	var noteEmail=getById('Note_Email').value;
	var noteFollowDate=getById('Note_Follow_Date').value;
	
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	}
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getNotes(entity,parseInt(xmlHttp.responseText));
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function

	xmlHttp.open('GET', "../ajax/createNote.php?entity="+entity+"&note="+note+"&noteSubject="+noteSubject+"&noteEvent="+noteEvent+"&noteNote="+noteNote+"&noteAuthor="+noteAuthor+"&noteFollow="+noteFollow+"&noteEmail="+noteEmail+"&noteFollowDate="+noteFollowDate, true); 
	xmlHttp.send(null);
	
}
function deleteNote(entity,note)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getNotes(entity,0);
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function

	xmlHttp.open('GET', "../ajax/deleteNote.php?note="+note, true); 
	xmlHttp.send(null);
}
function getEventActions(theevent,chosen)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				var returnText=xmlHttp.responseText;
				
				if(returnText=="0")
				{
					getById('currentActionsList').innerHTML="There are no actions to display";
				}
				else
				{
					getById('currentActionsList').innerHTML=returnText
					if(chosen==0)
						setTimeout("selectEventAction("+theevent+","+getById('counterAction1').value+",1)",500);
					else
					{
						var number=getById('eventAction'+chosen).value;
						setTimeout("selectEventAction("+theevent+","+chosen+","+number+")",500);
					}
				}
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	
	xmlHttp.open('GET', "../ajax/getEventActions.php?event="+theevent, true); 
	xmlHttp.send(null);
}
function selectEventAction(theevent,theaction,counter)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getById('actionForm').innerHTML=xmlHttp.responseText;
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	var i=1;
	while(getById('arrowDiv'+i))
	{
		if(counter!=i)
			getById('arrowDiv'+i).style.display='none';
		else
			getById('arrowDiv'+i).style.display='block';
		i++;
	}
	xmlHttp.open('GET', "../ajax/selectEventAction.php?event="+theevent+"&theaction="+theaction, true); 
	xmlHttp.send(null);
}

function getEventGoals(theevent,chosen)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				var returnText=xmlHttp.responseText;
				
				if(returnText=="0")
				{
					getById('currentGoalsList').innerHTML="There are no goals/strategies to display";
				}
				else
				{
					getById('currentGoalsList').innerHTML=returnText;
					if(chosen==0)
						setTimeout("selectEventGoal("+theevent+","+getById('counterGoal1').value+",1)",500);
					else
					{
						var number=getById('entityGoal'+chosen).value;
						setTimeout("selectEventGoal("+theevent+","+chosen+","+number+")",500);
					}
				}
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	
	xmlHttp.open('GET', "../ajax/getEventGoals.php?event="+theevent, true); 
	xmlHttp.send(null);
}
function selectEventGoal(theevent,goal,counter)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				getById('goalForm').innerHTML=xmlHttp.responseText;
		
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	var i=1;
	while(getById('arrowDiv'+i))
	{
		if(counter!=i)
			getById('arrowDiv'+i).style.display='none';
		else
			getById('arrowDiv'+i).style.display='block';
		i++;
	}
	xmlHttp.open('GET', "../ajax/selectEventGoal.php?event="+theevent+"&goal="+goal, true); 
	xmlHttp.send(null);
}

function getEventNotes(theevent,chosen)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				var returnText=xmlHttp.responseText;
				
				if(returnText=="0")
				{
					getById('currentNotesList').innerHTML="There are no notes to display<br /><a href=\"javascript: selectEventNote("+theevent+",0,0);\">Add Note</a>";
				}
				else
				{
					getById('currentNotesList').innerHTML=returnText+"<br /><a href=\"javascript: selectEventNote("+theevent+",0,0);\">Add Note</a>";
					if(chosen==0 && getById('counterNote1'))
						setTimeout("selectEventNote("+theevent+","+getById('counterNote1').value+",1)",500);
					else
					{
						var number=getById('eventNote'+chosen).value;
						setTimeout("selectEventNote("+theevent+","+chosen+","+number+")",500);
					}
				}
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	
	xmlHttp.open('GET', "../ajax/getEventNotes.php?event="+theevent, true); 
	xmlHttp.send(null);
}
function selectEventNote(theevent,note,counter)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getById('noteForm').innerHTML=xmlHttp.responseText;
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	var i=1;
	while(getById('noteArrowDiv'+i))
	{
		if(counter!=i)
			getById('noteArrowDiv'+i).style.display='none';
		else
			getById('noteArrowDiv'+i).style.display='block';
		i++;
	}
	xmlHttp.open('GET', "../ajax/selectEventNote.php?event="+theevent+"&note="+note, true); 
	xmlHttp.send(null);
}
function submitEventNote(theevent,note)
{
	var noteSubject=getById('Note_Subject').value;
	var noteAuthor=getById('Note_Author').options[getById('Note_Author').selectedIndex].value;
	var noteNote=getById('Note_Note').value;
	if(getById('Note_Follow_y').checked)
		var noteFollow='y';
	else
		var noteFollow='n';
	var noteEmail=getById('Note_Email').value;
	var noteFollowDate=getById('Note_Follow_Date').value;
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	}
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getEventNotes(theevent,parseInt(xmlHttp.responseText));
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function

	xmlHttp.open('GET', "../ajax/createEventNote.php?event="+theevent+"&note="+note+"&noteSubject="+noteSubject+"&noteNote="+noteNote+"&noteAuthor="+noteAuthor+"&noteFollow="+noteFollow+"&noteEmail="+noteEmail+"&noteFollowDate="+noteFollowDate, true); 
	xmlHttp.send(null);
	
}
function deleteEventNote(theevent,note)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getEventNotes(theevent,0);
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function

	xmlHttp.open('GET', "../ajax/deleteEventNote.php?note="+note, true); 
	xmlHttp.send(null);
}
function getRegs(theevent,chosen)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				var returnText=xmlHttp.responseText;
				var newReg="<a href=\"javascript: selectReg("+theevent+",0,0);\">Add Involvement</a>";
				if(returnText=="0")
				{
					getById('currentRegsList').innerHTML="There is no involvement to display<br />"+newReg;
				}
				else
				{
					getById('currentRegsList').innerHTML=newReg+returnText;
					if(chosen==0)
					{
						getById('idGrabber').value=getById('grabber1').value;
						setTimeout("selectReg("+theevent+","+getById('counterReg1').value+",1)",500);
					}
					else
					{
						var number=getById('eventReg'+chosen).value;
						getById('idGrabber').value=getById('grabber'+number).value;
						setTimeout("selectReg("+theevent+","+chosen+","+number+")",500);
					}
					//getReceipts(theevent,1);
				}
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	getById('regForm').innerHTML="";
	var regType=getById('reg_type').options[getById('reg_type').selectedIndex].value;
	var regFiscal=getById('reg_fiscal').options[getById('reg_fiscal').selectedIndex].value;
	xmlHttp.open('GET', "../ajax/getRegs.php?event="+theevent+"&regType="+regType+"&regFiscal="+regFiscal, true); 
	xmlHttp.send(null);
}
function selectReg(theevent,reg,counter)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getById('regForm').innerHTML=xmlHttp.responseText;
				updateRegFor();
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	var i=1;
	while(getById('regArrowDiv'+i))
	{
		if(counter!=i)
			getById('regArrowDiv'+i).style.display='none';
		else
			getById('regArrowDiv'+i).style.display='block';
		i++;
	}
	
	xmlHttp.open('GET', "../ajax/selectReg.php?event="+theevent+"&reg="+reg, true); 
	xmlHttp.send(null);
}
function submitReg(theevent,reg)
{
	var regFor=getById('Reg_For').options[getById('Reg_For').selectedIndex].value;
	var regEntity=getById('Reg_Entity').options[getById('Reg_Entity').selectedIndex].value;
	var regType=getById('Reg_Type').options[getById('Reg_Type').selectedIndex].value;
	var regRestrict=getById('Reg_Restrict').options[getById('Reg_Restrict').selectedIndex].value;
	var regSolicitor=getById('Reg_Solicitor').options[getById('Reg_Solicitor').selectedIndex].value;
	var regDate=getById('Reg_Date').value;
	var regFiscal=getById('Reg_Fiscal').options[getById('Reg_Fiscal').selectedIndex].value;
	var regAckDate=getById('Reg_Ack_Date').value;
	var regStimulus=getById('Reg_Stimulus').options[getById('Reg_Stimulus').selectedIndex].value;
	var regValue=getById('Reg_Value').value;
	var regNotes=getById('Reg_Notes').value;
	//function takes search field and updates div accordingly
	var xmlHttp;
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				var myArray=xmlHttp.responseText.split(".");
				getById('reg_type').value=myArray[1];
				getById('reg_fiscal').value=myArray[2];
				getRegs(theevent,parseInt(myArray[0]));
				getReceipts(theevent,0);
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function

	var addText="&regFor="+regFor;
	addText+="&regEntity="+regEntity;
	addText+="&regType="+regType;
	addText+="&regRestrict="+regRestrict;
	addText+="&regSolicitor="+regSolicitor;
	addText+="&regDate="+regDate;
	addText+="&regFiscal="+regFiscal;
	addText+="&regAckDate="+regAckDate;
	addText+="&regStimulus="+regStimulus;
	addText+="&regValue="+regValue;
	addText+="&regNotes="+regNotes.replace(/[\r\n]+/g,"<br />");
	
	if(getById('hasReceipt_y').checked)
	{
		addText+="&regReceipt=y";
		addText+="&receiptAmount="+getById('receiptAmount').value;
		addText+="&receiptLogo="+getById('Receipt_Logo').options[getById('Receipt_Logo').selectedIndex].value;
		addText+="&receiptText="+getById('Receipt_Text').value.replace(/[\r\n]+/g,"<br />");
	}
	else
	{
		addText+="&regReceipt=n";
	}

	xmlHttp.open('GET', "../ajax/createReg.php?event="+theevent+"&reg="+reg+addText, true); 
	xmlHttp.send(null);
}
function deleteReg(entity,reg)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getRegs(entity,0);
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function

	xmlHttp.open('GET', "../ajax/deleteReg.php?reg="+reg, true); 
	xmlHttp.send(null);
}
function updateRegFor()
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getById('regChooserDiv').innerHTML=xmlHttp.responseText;
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	var regType=getById('Reg_For').options[getById('Reg_For').selectedIndex].value;
	var idGrabber=getById('idGrabber').value;
	xmlHttp.open('GET', "../ajax/updateRegFor.php?type="+regType+"&idGrabber="+idGrabber, true); 
	xmlHttp.send(null);
}
function updateRecFor()
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getById('recChooserDiv').innerHTML=xmlHttp.responseText;
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	var regType=getById('Rec_For').options[getById('Rec_For').selectedIndex].value;
	xmlHttp.open('GET', "../ajax/updateRecFor.php?type="+regType, true); 
	xmlHttp.send(null);
}
function updateEventFor()
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				var arr=xmlHttp.responseText.split(",");
				getById('regTypeDiv').innerHTML=arr[0];
				getById('Event_Attend_Fee').value=arr[1];
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	var eventFor=getById('Reg_Event').options[getById('Reg_Event').selectedIndex].value;
	var selectedReg=getById('selectedRegType').value;
	xmlHttp.open('GET', "../ajax/updateEventFor.php?eventFor="+eventFor+"&selectedReg="+selectedReg, true); 
	xmlHttp.send(null);
}
function updateValueDiv()
{
	var regType=getById('Reg_Type').value;
	if(regType==1)
		getById('Value_Div').innerHTML="Hours: ";
	else if(regType==2)
		getById('Value_Div').innerHTML="Cost: $";
	else
		getById('Value_Div').innerHTML="Amount: $";
}
function updateHasReceipt(show)
{
	if(show=='y')
	{
		getById('receiptData').style.display='block';
		if(getById('receiptAmount').value=='' && getById('Reg_Type').options[getById('Reg_Type').selectedIndex].value!=1)
		{
			getById('receiptAmount').value=getById('Reg_Value').value;
		}
	}
	else
		getById('receiptData').style.display='none';
}
function updateLogoDiv()
{
	getById('logoPreviewDiv').innerHTML="&nbsp;<a href='../files/graphics/"+getById('Receipt_Logo').options[getById('Receipt_Logo').selectedIndex].value+"' target='_blank'>Preview</a>";
}
function updaterecLogoDiv()
{
	getById('reclogoPreviewDiv').innerHTML="&nbsp;<a href='../files/graphics/"+getById('Rec_Logo').options[getById('Rec_Logo').selectedIndex].value+"' target='_blank'>Preview</a>";
}
function getReceipts(theevent,chosen)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				var returnText=xmlHttp.responseText;
				
				if(returnText=="0")
				{
					getById('currentReceiptsList').innerHTML="There are no receipts to display";
				}
				else
				{
					getById('currentReceiptsList').innerHTML=returnText+"<br />";
					if(chosen==0)
						setTimeout("selectReceipt("+theevent+","+getById('counterReceipt1').value+",1)",500);
					else
					{
						var number=getById('eventReceipt'+chosen).value;
						setTimeout("selectReceipt("+theevent+","+chosen+","+number+")",500);
					}
				}
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	
	xmlHttp.open('GET', "../ajax/getReceipts.php?event="+theevent, true); 
	xmlHttp.send(null);
}
function selectReceipt(theevent,receipt,counter)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				getById('receiptForm').innerHTML=xmlHttp.responseText;
				if(receipt==0)
					updateRecFor();
		
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	var i=1;
	while(getById('recArrowDiv'+i))
	{
		if(counter!=i)
			getById('recArrowDiv'+i).style.display='none';
		else
			getById('recArrowDiv'+i).style.display='block';
		i++;
	}
	xmlHttp.open('GET', "../ajax/selectReceipt.php?event="+theevent+"&receipt="+receipt, true); 
	xmlHttp.send(null);
}
function submitReceipt(theevent,receipt)
{
	var receiptAmount=getById('Rec_Amount').value.replace(",","");
	receiptAmount=parseFloat(receiptAmount).toFixed(2);
	var receiptText=getById('Rec_Text').value.replace("\n","--");
	var receiptLogo=getById('Rec_Logo').options[getById('Rec_Logo').selectedIndex].value;
	
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getReceipts(theevent,parseInt(xmlHttp.responseText));
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	
	xmlHttp.open('GET', "../ajax/createReceipt.php?receipt="+receipt+"&receiptAmount="+receiptAmount+"&receiptText="+receiptText+"&receiptLogo="+receiptLogo, true); 
	xmlHttp.send(null);
}
function deleteReceipt(theevent,receipt)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getReceipts(theevent,0);
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function

	xmlHttp.open('GET', "../ajax/deleteReceipt.php?receipt="+receipt, true); 
	xmlHttp.send(null);
}

function checkAttend()
{
	if(getById('Reg_Type').options[getById('Reg_Type').selectedIndex].value==2)
	{
		if(parseFloat(getById('Reg_Value').value)<parseFloat(getById('Event_Attend_Fee').value))
		{
			alert("Caution: The cost you have entered is less than the registration fee.");
		}
	}
}
function getPersonRegs(entity,chosen)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				var returnText=xmlHttp.responseText;
				var newReg="<a href=\"javascript: selectPersonReg("+entity+",0,0);\">Add Involvement</a>";
				if(returnText=="0")
				{
					getById('currentRegsList').innerHTML="There is no involvement to display<br />"+newReg;
				}
				else
				{
					getById('currentRegsList').innerHTML=newReg+returnText;
					if(chosen==0)
					{
						getById('idGrabber').value=getById('grabber1').value;
						setTimeout("selectPersonReg("+entity+","+getById('counterReg1').value+",1)",500);
					}
					else
					{
						var number=getById('eventReg'+chosen).value;
						getById('idGrabber').value=getById('grabber'+number).value;
						setTimeout("selectPersonReg("+entity+","+chosen+","+number+")",500);
					}
				}
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	getById('regForm').innerHTML="";
	var regType=getById('reg_type').options[getById('reg_type').selectedIndex].value;
	var regFiscal=getById('reg_fiscal').options[getById('reg_fiscal').selectedIndex].value;
	xmlHttp.open('GET', "../ajax/getPersonRegs.php?entity="+entity+"&regType="+regType+"&regFiscal="+regFiscal, true); 
	xmlHttp.send(null);
}
function selectPersonReg(entity,reg,counter)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getById('regForm').innerHTML=xmlHttp.responseText;
				updateEventFor(getById('selectedRegType').value);
				updateLogoDiv();
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	var i=1;
	while(getById('regArrowDiv'+i))
	{
		if(counter!=i)
			getById('regArrowDiv'+i).style.display='none';
		else
			getById('regArrowDiv'+i).style.display='block';
		i++;
	}
	
	xmlHttp.open('GET', "../ajax/selectPersonReg.php?entity="+entity+"&reg="+reg, true); 
	xmlHttp.send(null);
}
function submitPersonReg(entity,reg)
{
	var regEvent=getById('Reg_Event').options[getById('Reg_Event').selectedIndex].value;
	var regType=getById('Reg_Type').options[getById('Reg_Type').selectedIndex].value;
	var regRestrict=getById('Reg_Restrict').options[getById('Reg_Restrict').selectedIndex].value;
	var regSolicitor=getById('Reg_Solicitor').options[getById('Reg_Solicitor').selectedIndex].value;
	var regDate=getById('Reg_Date').value;
	var regFiscal=getById('Reg_Fiscal').options[getById('Reg_Fiscal').selectedIndex].value;
	var regAckDate=getById('Reg_Ack_Date').value;
	var regStimulus=getById('Reg_Stimulus').options[getById('Reg_Stimulus').selectedIndex].value;
	var regValue=getById('Reg_Value').value;
	var regNotes=getById('Reg_Notes').value;
	var addText="";
	//function takes search field and updates div accordingly
	var xmlHttp;
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				var myArray=xmlHttp.responseText.split(".");
				getById('reg_type').value=myArray[1];
				getById('reg_fiscal').value=myArray[2];
				getPersonRegs(entity,parseInt(myArray[0]));
				getPersonReceipts(entity,0)
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function

	addText+="&regEvent="+regEvent;
	addText+="&regType="+regType;
	addText+="&regRestrict="+regRestrict;
	addText+="&regSolicitor="+regSolicitor;
	addText+="&regDate="+regDate;
	addText+="&regFiscal="+regFiscal;
	addText+="&regAckDate="+regAckDate;
	addText+="&regStimulus="+regStimulus;
	addText+="&regValue="+regValue;
	addText+="&regNotes="+regNotes.replace(/[\r\n]+/g,"<br />");
	
	if(getById('hasReceipt_y').checked)
	{
		addText+="&regReceipt=y";
		addText+="&receiptAmount="+getById('receiptAmount').value;
		addText+="&receiptLogo="+getById('Receipt_Logo').options[getById('Receipt_Logo').selectedIndex].value;
		addText+="&receiptText="+getById('Receipt_Text').value.replace(/[\r\n]+/g,"<br />");
	}
	else
	{
		addText+="&regReceipt=n";
	}

	xmlHttp.open('GET', "../ajax/createPersonReg.php?entity="+entity+"&reg="+reg+addText, true); 
	xmlHttp.send(null);
}
function deletePersonReg(entity,reg)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getPersonRegs(entity,0);
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function

	xmlHttp.open('GET', "../ajax/deleteReg.php?reg="+reg, true); 
	xmlHttp.send(null);
}

function getPersonReceipts(entity,chosen)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				var returnText=xmlHttp.responseText;
				var newRec="<a href=\"javascript: selectPersonReceipt("+entity+",0,0);\">Add Receipt</a>";
				if(returnText=="0")
				{
					getById('currentReceiptsList').innerHTML="There are no receipts to display<br />"+newRec;
				}
				else
				{
					getById('currentReceiptsList').innerHTML=newRec+"<br />"+returnText;
					if(chosen==0)
						setTimeout("selectPersonReceipt("+entity+","+getById('counterReceipt1').value+",1)",500);
					else
					{
						var number=getById('entityReceipt'+chosen).value;
						setTimeout("selectPersonReceipt("+entity+","+chosen+","+number+")",500);
					}
				}
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	
	xmlHttp.open('GET', "../ajax/getPersonReceipts.php?entity="+entity, true); 
	xmlHttp.send(null);
}
function selectPersonReceipt(entity,receipt,counter)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				getById('receiptForm').innerHTML=xmlHttp.responseText;
		
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	var i=1;
	while(getById('recArrowDiv'+i))
	{
		if(counter!=i)
			getById('recArrowDiv'+i).style.display='none';
		else
			getById('recArrowDiv'+i).style.display='block';
		i++;
	}
	xmlHttp.open('GET', "../ajax/selectPersonReceipt.php?entity="+entity+"&receipt="+receipt, true); 
	xmlHttp.send(null);
}
function submitPersonReceipt(entity,receipt)
{
	var receiptAmount=getById('Rec_Amount').value.replace(",","");
	receiptAmount=parseFloat(receiptAmount).toFixed(2);
	var receiptText=getById('Rec_Text').value.replace(new RegExp( "\\n", "g" ), "--");
	var receiptLogo=getById('Rec_Logo').options[getById('Rec_Logo').selectedIndex].value;
	var receiptPerson=getById('Receipt_Entity').options[getById('Receipt_Entity').selectedIndex].value;
	
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getPersonReceipts(entity,parseInt(xmlHttp.responseText));
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	
	xmlHttp.open('GET', "../ajax/createPersonReceipt.php?entity="+entity+"&receipt="+receipt+"&receiptAmount="+receiptAmount+"&receiptText="+receiptText+"&receiptLogo="+receiptLogo+"&receiptPerson="+receiptPerson, true); 
	xmlHttp.send(null);
}
function deletePersonReceipt(entity,receipt)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getPersonReceipts(entity,0);
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function

	xmlHttp.open('GET', "../ajax/deletePersonReceipt.php?receipt="+receipt, true); 
	xmlHttp.send(null);
}

function getOrgRegs(entity,chosen)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				var returnText=xmlHttp.responseText;
				var newReg="<a href=\"javascript: selectOrgReg("+entity+",0,0);\">Add Involvement</a>";
				if(returnText=="0")
				{
					getById('currentRegsList').innerHTML="There is no involvement to display<br />"+newReg;
				}
				else
				{
					getById('currentRegsList').innerHTML=newReg+returnText;
					if(chosen==0)
					{
						getById('idGrabber').value=getById('grabber1').value;
						setTimeout("selectOrgReg("+entity+","+getById('counterReg1').value+",1)",500);
					}
					else
					{
						var number=getById('eventReg'+chosen).value;
						getById('idGrabber').value=getById('grabber'+number).value;
						setTimeout("selectOrgReg("+entity+","+chosen+","+number+")",500);
					}
				}
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	getById('regForm').innerHTML="";
	var regType=getById('reg_type').options[getById('reg_type').selectedIndex].value;
	var regFiscal=getById('reg_fiscal').options[getById('reg_fiscal').selectedIndex].value;
	xmlHttp.open('GET', "../ajax/getOrgRegs.php?entity="+entity+"&regType="+regType+"&regFiscal="+regFiscal, true); 
	xmlHttp.send(null);
}
function selectOrgReg(entity,reg,counter)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getById('regForm').innerHTML=xmlHttp.responseText;
				updateEventFor(getById('selectedRegType').value);
				updateLogoDiv();
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	var i=1;
	while(getById('regArrowDiv'+i))
	{
		if(counter!=i)
			getById('regArrowDiv'+i).style.display='none';
		else
			getById('regArrowDiv'+i).style.display='block';
		i++;
	}
	
	xmlHttp.open('GET', "../ajax/selectOrgReg.php?entity="+entity+"&reg="+reg, true); 
	xmlHttp.send(null);
}
function submitOrgReg(entity,reg)
{
	var regEvent=getById('Reg_Event').options[getById('Reg_Event').selectedIndex].value;
	var regType=getById('Reg_Type').options[getById('Reg_Type').selectedIndex].value;
	var regRestrict=getById('Reg_Restrict').options[getById('Reg_Restrict').selectedIndex].value;
	var regSolicitor=getById('Reg_Solicitor').options[getById('Reg_Solicitor').selectedIndex].value;
	var regDate=getById('Reg_Date').value;
	var regFiscal=getById('Reg_Fiscal').options[getById('Reg_Fiscal').selectedIndex].value;
	var regAckDate=getById('Reg_Ack_Date').value;
	var regStimulus=getById('Reg_Stimulus').options[getById('Reg_Stimulus').selectedIndex].value;
	var regValue=getById('Reg_Value').value;
	var regNotes=getById('Reg_Notes').value;
	var addText="";
	//function takes search field and updates div accordingly
	var xmlHttp;
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				var myArray=xmlHttp.responseText.split(".");
				getById('reg_type').value=myArray[1];
				getById('reg_fiscal').value=myArray[2];
				getOrgRegs(entity,parseInt(myArray[0]));
				getOrgReceipts(entity,0);
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function

	addText+="&regEvent="+regEvent;
	addText+="&regType="+regType;
	addText+="&regRestrict="+regRestrict;
	addText+="&regSolicitor="+regSolicitor;
	addText+="&regDate="+regDate;
	addText+="&regFiscal="+regFiscal;
	addText+="&regAckDate="+regAckDate;
	addText+="&regStimulus="+regStimulus;
	addText+="&regValue="+regValue;
	addText+="&regNotes="+regNotes.replace(/[\r\n]+/g,"<br />");
	
	if(getById('hasReceipt_y').checked)
	{
		addText+="&regReceipt=y";
		addText+="&receiptAmount="+getById('receiptAmount').value;
		addText+="&receiptLogo="+getById('Receipt_Logo').options[getById('Receipt_Logo').selectedIndex].value;
		addText+="&receiptText="+getById('Receipt_Text').value.replace(/[\r\n]+/g,"<br />");
	}
	else
	{
		addText+="&regReceipt=n";
	}

	xmlHttp.open('GET', "../ajax/createOrgReg.php?entity="+entity+"&reg="+reg+addText, true); 
	xmlHttp.send(null);
}
function deleteOrgReg(entity,reg)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getOrgRegs(entity,0);
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function

	xmlHttp.open('GET', "../ajax/deleteReg.php?reg="+reg, true); 
	xmlHttp.send(null);
}
function getOrgReceipts(entity,chosen)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				var returnText=xmlHttp.responseText;
				var newRec="<a href=\"javascript: selectOrgReceipt("+entity+",0,0);\">Add Receipt</a>";
				if(returnText=="0")
				{
					getById('currentReceiptsList').innerHTML="There are no receipts to display<br />"+newRec;
				}
				else
				{
					getById('currentReceiptsList').innerHTML=newRec+"<br />"+returnText;
					if(chosen==0)
						setTimeout("selectOrgReceipt("+entity+","+getById('counterReceipt1').value+",1)",500);
					else
					{
						var number=getById('entityReceipt'+chosen).value;
						setTimeout("selectOrgReceipt("+entity+","+chosen+","+number+")",500);
					}
				}
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	
	xmlHttp.open('GET', "../ajax/getOrgReceipts.php?entity="+entity, true); 
	xmlHttp.send(null);
}
function selectOrgReceipt(entity,receipt,counter)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				getById('receiptForm').innerHTML=xmlHttp.responseText;
		
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	var i=1;
	while(getById('recArrowDiv'+i))
	{
		if(counter!=i)
			getById('recArrowDiv'+i).style.display='none';
		else
			getById('recArrowDiv'+i).style.display='block';
		i++;
	}
	xmlHttp.open('GET', "../ajax/selectOrgReceipt.php?entity="+entity+"&receipt="+receipt, true); 
	xmlHttp.send(null);
}
function submitOrgReceipt(entity,receipt)
{
	var receiptAmount=getById('Rec_Amount').value.replace(",","");
	receiptAmount=parseFloat(receiptAmount).toFixed(2);
	var receiptText=getById('Rec_Text').value.replace("\n","--");
	var receiptLogo=getById('Rec_Logo').options[getById('Rec_Logo').selectedIndex].value;
	var receiptOrg=getById('Receipt_Entity').options[getById('Receipt_Entity').selectedIndex].value;
	
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getOrgReceipts(entity,parseInt(xmlHttp.responseText));
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	
	xmlHttp.open('GET', "../ajax/createOrgReceipt.php?entity="+entity+"&receipt="+receipt+"&receiptAmount="+receiptAmount+"&receiptOrg="+receiptOrg+"&receiptText="+receiptText+"&receiptLogo="+receiptLogo, true); 
	xmlHttp.send(null);
}
function deleteOrgReceipt(entity,receipt)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getOrgReceipts(entity,0);
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function

	xmlHttp.open('GET', "../ajax/deleteOrgReceipt.php?receipt="+receipt, true); 
	xmlHttp.send(null);
}

function getGroupRegs(group,chosen)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				var returnText=xmlHttp.responseText;
				var newReg="<a href=\"javascript: selectGroupReg("+group+",0,0);\">Add Involvement</a>";
				if(returnText=="0")
				{
					getById('currentRegsList').innerHTML="There is no involvement to display<br />"+newReg;
				}
				else
				{
					getById('currentRegsList').innerHTML=newReg+returnText;
					if(chosen==0)
					{
						getById('idGrabber').value=getById('grabber1').value;
						setTimeout("selectGroupReg("+group+","+getById('counterReg1').value+",1)",500);
					}
					else
					{
						var number=getById('eventReg'+chosen).value;
						getById('idGrabber').value=getById('grabber'+number).value;
						setTimeout("selectGroupReg("+group+","+chosen+","+number+")",500);
					}
				}
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	getById('regForm').innerHTML="";
	var regType=getById('reg_type').options[getById('reg_type').selectedIndex].value;
	var regFiscal=getById('reg_fiscal').options[getById('reg_fiscal').selectedIndex].value;
	xmlHttp.open('GET', "../ajax/getGroupRegs.php?group="+group+"&regType="+regType+"&regFiscal="+regFiscal, true); 
	xmlHttp.send(null);
}
function selectGroupReg(group,reg,counter)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getById('regForm').innerHTML=xmlHttp.responseText;
				updateEventFor(getById('selectedRegType').value);
				updateLogoDiv();
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	var i=1;
	while(getById('regArrowDiv'+i))
	{
		if(counter!=i)
			getById('regArrowDiv'+i).style.display='none';
		else
			getById('regArrowDiv'+i).style.display='block';
		i++;
	}
	
	xmlHttp.open('GET', "../ajax/selectGroupReg.php?group="+group+"&reg="+reg, true); 
	xmlHttp.send(null);
}
function submitGroupReg(group,reg)
{
	var regEvent=getById('Reg_Event').options[getById('Reg_Event').selectedIndex].value;
	var regType=getById('Reg_Type').options[getById('Reg_Type').selectedIndex].value;
	var regRestrict=getById('Reg_Restrict').options[getById('Reg_Restrict').selectedIndex].value;
	var regSolicitor=getById('Reg_Solicitor').options[getById('Reg_Solicitor').selectedIndex].value;
	var regDate=getById('Reg_Date').value;
	var regFiscal=getById('Reg_Fiscal').options[getById('Reg_Fiscal').selectedIndex].value;
	var regAckDate=getById('Reg_Ack_Date').value;
	var regStimulus=getById('Reg_Stimulus').options[getById('Reg_Stimulus').selectedIndex].value;
	var regValue=getById('Reg_Value').value;
	var regNotes=getById('Reg_Notes').value;
	var addText="";
	//function takes search field and updates div accordingly
	var xmlHttp;
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				var myArray=xmlHttp.responseText.split(".");
				getById('reg_type').value=myArray[1];
				getById('reg_fiscal').value=myArray[2];
				getGroupRegs(group,parseInt(myArray[0]));
				getGroupReceipts(group,0);
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function

	addText+="&regEvent="+regEvent;
	addText+="&regType="+regType;
	addText+="&regRestrict="+regRestrict;
	addText+="&regSolicitor="+regSolicitor;
	addText+="&regDate="+regDate;
	addText+="&regFiscal="+regFiscal;
	addText+="&regAckDate="+regAckDate;
	addText+="&regStimulus="+regStimulus;
	addText+="&regValue="+regValue;
	addText+="&regNotes="+regNotes.replace(/[\r\n]+/g,"<br />");
	
	if(getById('hasReceipt_y').checked)
	{
		addText+="&regReceipt=y";
		addText+="&receiptAmount="+getById('receiptAmount').value;
		addText+="&receiptLogo="+getById('Receipt_Logo').options[getById('Receipt_Logo').selectedIndex].value;
		addText+="&receiptText="+getById('Receipt_Text').value.replace(/[\r\n]+/g,"<br />");
	}
	else
	{
		addText+="&regReceipt=n";
	}

	xmlHttp.open('GET', "../ajax/createGroupReg.php?group="+group+"&reg="+reg+addText, true); 
	xmlHttp.send(null);
}
function deleteGroupReg(group,reg)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getGroupRegs(group,0);
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function

	xmlHttp.open('GET', "../ajax/deleteReg.php?reg="+reg, true); 
	xmlHttp.send(null);
}
function getGroupReceipts(group,chosen)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				var returnText=xmlHttp.responseText;
				var newRec="<a href=\"javascript: selectGroupReceipt("+group+",0,0);\">Add Receipt</a>";
				if(returnText=="0")
				{
					getById('currentReceiptsList').innerHTML="There are no receipts to display<br />"+newRec;
				}
				else
				{
					getById('currentReceiptsList').innerHTML=newRec+"<br />"+returnText;
					if(chosen==0)
						setTimeout("selectGroupReceipt("+group+","+getById('counterReceipt1').value+",1)",500);
					else
					{
						var number=getById('groupReceipt'+chosen).value;
						setTimeout("selectGroupReceipt("+group+","+chosen+","+number+")",500);
					}
				}
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function 
	
	xmlHttp.open('GET', "../ajax/getGroupReceipts.php?group="+group, true); 
	xmlHttp.send(null);
}
function selectGroupReceipt(group,receipt,counter)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				getById('receiptForm').innerHTML=xmlHttp.responseText;
		
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	var i=1;
	while(getById('recArrowDiv'+i))
	{
		if(counter!=i)
			getById('recArrowDiv'+i).style.display='none';
		else
			getById('recArrowDiv'+i).style.display='block';
		i++;
	}
	xmlHttp.open('GET', "../ajax/selectGroupReceipt.php?group="+group+"&receipt="+receipt, true); 
	xmlHttp.send(null);
}
function submitGroupReceipt(group,receipt)
{
	var receiptAmount=getById('Rec_Amount').value.replace(",","");
	receiptAmount=parseFloat(receiptAmount).toFixed(2);
	var receiptText=getById('Rec_Text').value.replace("\n","--");
	var receiptLogo=getById('Rec_Logo').options[getById('Rec_Logo').selectedIndex].value;
	var receiptGroup=getById('Receipt_Group').options[getById('Receipt_Group').selectedIndex].value;
	
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getGroupReceipts(group,parseInt(xmlHttp.responseText));
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	
	xmlHttp.open('GET', "../ajax/createGroupReceipt.php?group="+group+"&receipt="+receipt+"&receiptAmount="+receiptAmount+"&receiptText="+receiptText+"&receiptLogo="+receiptLogo+"&receiptGroup="+receiptGroup, true); 
	xmlHttp.send(null);
}
function deleteGroupReceipt(group,receipt)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getGroupReceipts(group,0);
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function

	xmlHttp.open('GET', "../ajax/deleteGroupReceipt.php?receipt="+receipt, true); 
	xmlHttp.send(null);
}
function selectTable(whichSelect)
{
	//function takes search field and updates div accordingly
	var xmlHttp;
	//alert(inputVal);
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				selectConnect(whichSelect,xmlHttp.responseText);
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
		}//end if readystate==4
	}; //end state change function
	
	getById('searchContainer'+whichSelect).style.display='block';
	var whichTable=getById('table'+whichSelect).options[getById('table'+whichSelect).selectedIndex].value;
	if(whichTable!="0")
	{
		xmlHttp.open('GET', "../ajax/selectTable.php?table="+whichTable+"&currSelect="+whichSelect, true); 
		xmlHttp.send(null);
	}
	else
	{
		if(getById('searchFields'+whichSelect))
		{
			getById('searchFields'+whichSelect).innerHTML="";
			getById('fields'+whichSelect).innerHTML="";
			do
			{
				whichSelect++;
				if(getById('searchContainer'+whichSelect))
				{
					getById('searchContainer'+whichSelect).style.display='none';
				}
			}
			while(whichSelect<10);
		}
	}
}

function selectConnect(whichSelect, fieldsText)
{
	getById('reportResults').innerHTML="";
	if(whichSelect<10)
	{
		var oldSelect=whichSelect;
		var whichTable=getById('table'+whichSelect).options[getById('table'+whichSelect).selectedIndex].value;
		whichSelect=whichSelect+1;
		//function takes search field and updates div accordingly
		
		var xmlHttp;
		//alert(inputVal);
		if (window.XMLHttpRequest)     // Object of the current windows
		{ 
			xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
		} 
		else if (window.ActiveXObject)   // ActiveX version
		{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
		} 
		xmlHttp.onreadystatechange  = function()
		{ 
			if(xmlHttp.readyState  == 4)
			{
				if(xmlHttp.status  == 200) 
				{
					if(getById('searchContainer'+whichSelect))
					{
						getById('searchContainer'+whichSelect).style.display='block';
						getById('searchBox'+whichSelect).innerHTML=xmlHttp.responseText;
						var i=whichSelect;
						while(i<10)
						{
							i++;
							getById('searchFields'+i).innerHTML="";
							getById('searchContainer'+i).style.display='none';
						}
						var resultText=fieldsText;
						if(fieldsText.length>0)
						{
							var array=resultText.split("~");
							var searchFields=array[0];
							var returnFields=array[1];
							getById('searchFields'+oldSelect).innerHTML=searchFields;
							getById('fields'+oldSelect).innerHTML=returnFields;
						}
					}
				}//end if status==200
				else 
				{ 
					//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
				}
			}//end if readystate==4
		}; //end state change function
		
		xmlHttp.open('GET', "../ajax/selectConnect.php?table="+whichTable+"&currSelect="+whichSelect, true); 
		xmlHttp.send(null);
	}
}

function runReport(runType)
{
	var params="";
	getById('reportResults').innerHTML="Scanning records. Depending on the report size, this could take a minute...";
	for(i=0; i<document.reportForm.elements.length; i++)
	{
		if(document.reportForm.elements[i].type!="checkbox" || (document.reportForm.elements[i].type=="checkbox" && document.reportForm.elements[i].checked==true))
		{
			if(i>0)
				params+="&";
			else
				params+="?";
			params+=document.reportForm.elements[i].name+"="+document.reportForm.elements[i].value;
		}
	}
	var xmlHttp;
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				if(getById('reportResults'))
				{
					if(xmlHttp.responseText==0)
					{
						alert("A report already exists by this name");
						getById('reportResults').innerHTML="";
					}
					else
					{
						getById('reportResults').innerHTML=xmlHttp.responseText;
						if(runType==2)
						{
							runReport(0);	
						}
						else if(runType==1)
						{
							window.location.href="http://www.calgarylearningcentre.com/main/page.php?type=report&action=saved";	
						}
					}
				}
			}//end if status==200
			else 
			{ 
				//alert('Error: '+xmlHttp.status+'. Please contact technical support if this problem persists');
			}
			return false;
		}//end if readystate==4
	}; //end state change function
	if(runType==0)
	{
		xmlHttp.open('GET', "../ajax/submitReport.php"+params, true); 
		xmlHttp.send(null);
	}
	else if(runType==1 || runType==2)
	{
		if(getById('Report_Name').value.length==0 || getById('Report_Description').value.length==0)
		{
			alert('Please enter both a name and a description to save a report.');
		}
		else
		{
			xmlHttp.open('GET', "../ajax/saveReport.php"+params, true); 
			xmlHttp.send(null);
		}
	}
}

function addFileOption(theFileName)
{
	getById('Rec_Logo').options[getById('Rec_Logo').options.length]=new Option(theFileName,theFileName,true,true);
	updaterecLogoDiv();
}


/*
 * EventManager.js
 * by Keith Gaughan
 *
 * This allows event handlers to be registered unobtrusively, and cleans
 * them up on unload to prevent memory leaks.
 *
 * Copyright (c) Keith Gaughan, 2005.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Common Public License v1.0
 * (CPL) which accompanies this distribution, and is available at
 * http://www.opensource.org/licenses/cpl.php
 *
 * This software is covered by a modified version of the Common Public License
 * (CPL), where Keith Gaughan is the Agreement Steward, and the licensing
 * agreement is covered by the laws of the Republic of Ireland.
 */

// For implementations that don't include the push() methods for arrays.
if (!Array.prototype.push) {
    Array.prototype.push = function(elem) {
        this[this.length] = elem;
    }
}

var EventManager = {
    _registry: null,

    Initialise: function() {
        if (this._registry == null) {
            this._registry = [];

            // Register the cleanup handler on page unload.
            EventManager.Add(window, "unload", this.CleanUp);
        }
    },

    /**
     * Registers an event and handler with the manager.
     *
     * @param  obj         Object handler will be attached to.
     * @param  type        Name of event handler responds to.
     * @param  fn          Handler function.
     * @param  useCapture  Use event capture. False by default.
     *                     If you don't understand this, ignore it.
     *
     * @return True if handler registered, else false.
     */
    Add: function(obj, type, fn, useCapture) {
        this.Initialise();

        // If a string was passed in, it's an id.
        if (typeof obj == "string") {
            obj = document.getElementById(obj);
        }
        if (obj == null || fn == null) {
            return false;
        }

        // Mozilla/W3C listeners?
        if (obj.addEventListener) {
            obj.addEventListener(type, fn, useCapture);
            this._registry.push({obj: obj, type: type, fn: fn, useCapture: useCapture});
            return true;
        }

        // IE-style listeners?
        if (obj.attachEvent && obj.attachEvent("on" + type, fn)) {
            this._registry.push({obj: obj, type: type, fn: fn, useCapture: false});
            return true;
        }

        return false;
    },

    /**
     * Cleans up all the registered event handlers.
     */
    CleanUp: function() {
        for (var i = 0; i < EventManager._registry.length; i++) {
            with (EventManager._registry[i]) {
                // Mozilla/W3C listeners?
                if (obj.removeEventListener) {
                    obj.removeEventListener(type, fn, useCapture);
                }
                // IE-style listeners?
                else if (obj.detachEvent) {
                    obj.detachEvent("on" + type, fn);
                }
            }
        }

        // Kill off the registry itself to get rid of the last remaining
        // references.
        EventManager._registry = null;
    }
};


