var xmlHttp

function sendme() 
{ 
    window.open("","myNewWin","width=550,height=300,toolbar=0"); 
    var a = window.setTimeout("document.form1.submit();",500); 
} 

function onSubmitForm() {
    var formDOMObj = document.frmSend;
    if (formDOMObj.attach1.value == "" || formDOMObj.caption1.value == "" || formDOMObj.description1.value == "")
		{
        alert("Please fill in all the fields so that the information about the picture you wish to upload is complete.  Thank you.");
		returnval = false;
		}
    else
		{
	    window.open("../includes/wait.asp","Upload","width=500,height=400,toolbar=0,resize=1"); 
        returnval = true;
		}
    return returnval;
	}

function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function

function IsEmpty(aTextField) {
	aTextField.value = trim(aTextField.value)
   if ((aTextField.value.length==0) ||
   (aTextField.value==null)) {
      return true;
   }
   else { return false; }
}

function ValidateForm(form){
   if(IsEmpty(form.location_id)) 
   { 
      alert('You have to select the village this GO was working at') 
      form.location_id.focus(); 
      return false; 
   } 
 
   if(IsEmpty(form.fun)) 
   { 
      alert('Please tell us what the GO was doing') 
      form.fun_code.focus(); 
      return false; 
   } 
   if(IsEmpty(form.addday))
   { 
      alert('Please choose a day.') 
      form.addday.focus(); 
      return false; 
   } 
   if(IsEmpty(form.addmonth))
   { 
      alert('Please choose a month.') 
      form.addmonth.focus(); 
      return false; 
   } 
   if(IsEmpty(form.addyear))
   { 
      alert('Please choose a year.') 
      form.addyear.focus(); 
      return false; 
   } 
return true;
} 

function delconf(pers_id,act_id){
	if (confirm('Are you sure you want to delete this function ?'))
		{
		people_activity('people_activity_list','act=DELACT&act_id='+act_id+'&pers_id='+pers_id);
		}
	}

function addFavorite(PageName) {
	var url = document.location.href;
	if (navigator.appName != 'Microsoft Internet Explorer' ) {
		window.sidebar.addPanel(PageName,url,"");
	}
	else {
		window.external.AddFavorite(url,PageName);
	}
}


function people_activity(tag,parms)
	{
	if (tag.length==0)
		{ 
		document.getElementById(tag).innerHTML="";
		return;
		}
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
		{
		alert ("Your browser does not support AJAX!");
		return;
		} 
	var url="../includes/ajax_hello_world.asp";
	url=url+"?"+parms+"&tag="+tag;
	xmlHttp.onreadystatechange = function(){ stateChanged(tag); };

	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	} 


function ImgTogglePrivate(tag,img_id)
	{
	if (tag.length==0)
		{ 
		document.getElementById(tag).innerHTML="";
		return;
		}
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
		{
		alert ("Your browser does not support AJAX!");
		return;
		} 
	var url="../includes/img_toggle_private.asp";
	url=url+"?img_id="+img_id+"&tag="+tag;
	xmlHttp.onreadystatechange = function(){ stateChanged(tag); };

	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	} 


function stateChanged(str) 
	{ 
	if (xmlHttp.readyState==4)
	{document.getElementById(str).innerHTML=xmlHttp.responseText;}
	}

function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	  // Firefox, Opera 8.0+, Safari
	  {xmlHttp=new XMLHttpRequest();}
	catch (e)
	  // Internet Explorer
	  {
	  try
		{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
	  catch (e)
		{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
	  }
	return xmlHttp;
	}	
