function goLast()
{
  var l=ajfuncs.getCookie("last");
  if (l)
  {
    var b=l.split("|");
    if (b.length==2) window.location.href=b[0];
  }
}
function selectcharity()
{
  ajfuncs.killCookie("charity");
  ajfuncs.killCookie("busidx");
  window.location.href="g_main.php";
}
function doLogout()
{
  var xml="<e cmd='LO' />";
  var rt=ajax.send("cmd.php?"+xml,null,false,null,null,null,null,loDone);
  if (!rt)
  {
    alert("Error communicating with page:\n"+ajax.cErr);
  }
}
function loDone(success,pid)
{
  if (success)
  {
    window.location.href="index.php";
  }
  else
  {
    alert("Could not log out");
  }
}
var pwind=null;
var pwind_w=0;
function showPop(d,x,y)
{
  if (!pwind)
  {
    var p=addDiv("popup","","");
    p.appendChild(addSpan("info","",""));
    document.body.appendChild(p);
    pwind=ajfuncs.geID("popup")
    pwind_w=ajfuncs.GetWidth(pwind);
  }
  pwind.style.left=x+"px";
  pwind.style.top=y+"px";
  var cw;
  try
  {
    cw=pwind.children[0];
  }
  catch(e)
  {
    cw=pwind.children(0);
  }
  pwind.style.width=pwind_w+"px";
  cw.style.width=pwind_w+"px";
  cw.innerHTML=d;
  pwind.style.height=ajfuncs.GetHeight(cw)+5;
  pwind.style.width=ajfuncs.GetWidth(cw)+5;
  pwind.style.display=d==""?"none":"block";
}
function displayInfo(obj,d)
{
  d=d=="null" || d==null?"":d;
  var h=ajfuncs.GetHeight(obj);
  var w=ajfuncs.GetWidth(obj);
  var x=ajfuncs.GetLeft(obj);
  var y=ajfuncs.GetTop(obj);
  var yl=y+h+10;
  showPop(d,x,yl);
}

function doLoadFunc()
{
}
    function intitype(s)
    {
      var r="";
      switch (Number(s))
      {
        case 1:
          r="gif";
          break;
        case 2:
          r="jpg";
          break;
        case 3:
          r="png";
          break;
      }
      return r;
    }
		 function addPic(fn,w,h,t,mw,mh)
		 {
		    var ar,arW,arH;
		    mw=mw==undefined?0:mw;
		    mh=mh==undefined?0:mh;
		    if ((w>mw && mw!=0) || (h>mh && mh!=0))
		    {
		      arW=mw/w;
          arH=mh/h;
          ar=arW<arH?arW:arH;
          w=w*ar;
          h=h*ar;
		    }
        var td=document.createElement("img");
        td.src=fn;
        td.style.width=w+"px";
        td.style.height=h+"px";
        return td;
     }
		 function addSpan(id,clss,txt)
		 {
        var td=document.createElement("span");
        if (id) td.id=id;
        if (clss) td.className=clss;
        td.innerHTML=txt;
        return td;
     }
		 function addDiv(id,clss,txt)
		 {
        var td=document.createElement("div");
        if (id) td.id=id;
        if (clss) td.className=clss;
        td.innerHTML=txt;
        return td;
     }
		 function addHidden(id,txt)
		 {
        var td=document.createElement("div");
        td.id=id;
        td.style.display="none";
        td.innerHTML=txt;
        return td;
     }
		  function gv(e)
		  {
		    var l=ajfuncs.geID(e);
		    return l?l.value:null;
		  }
		  function addCharity()
		  {
		    var cn=prompt("Enter the name of the charity you would like to submit","");
		    if (cn=="" || cn==null) return;
		    //<e cmd='L' n='' p='' />
		    var xml="<e cmd='AC' ><![CDATA["+cn+"]]></e>";
		    var rt=ajax.send("cmd.php?"+xml,null,false,null,null,null,null,addCharityDone);
		    if (!rt)
		    {
		      alert("Error communicating with page:\n"+ajax.cErr);
		    }
		  }
		  function addCharityDone(success,pid)
		  {
		    if (success)
		    {
		      var r=ajax.GNT("/ret");
		      if (r=="1")
		      {
              alert("The charity has been added.  You will now see an Administration button at the top menu after you press the OK button and this page refreshes.");
              window.location.href="g_main.php";
          }
          else
          {
              alert("That charity already exists in our system");
		      }
  	    }
		    else
		    {
	        alert("Could not submit charity, error");
		    }
		  }
		  function addBus()
		  {
		    var cn=prompt("Enter the name of the business you would like to submit","");
		    if (cn=="" || cn==null) return;
		    //<e cmd='L' n='' p='' />
		    var xml="<e cmd='AB' ><![CDATA["+cn+"]]></e>";
		    var rt=ajax.send("cmd.php?"+xml,null,false,null,null,null,null,addBusDone);
		    if (!rt)
		    {
		      alert("Error communicating with page:\n"+ajax.cErr);
		    }
		  }
		  function addBusDone(success,pid)
		  {
		    if (success)
		    {
		      var r=ajax.GNT("/ret");
		      if (r=="1")
		      {
              alert("The business has been added.  You will now see an Administration button at the top menu after you press the OK button and this page refreshes.");
              window.location.href="g_main.php";
          }
          else
          {
              alert("That business already exists in our system");
		      }
  	    }
		    else
		    {
	        alert("Could not submit charity, error");
		    }
		  }

