d=document;
d.write('<style type="text/css"> html { overflow-y: scroll; } </style>');

function MM_findObj(n, d)
{ //v4.01
 var p,i,x;
 if(!d) d=document;
 if((p=n.indexOf("?"))>0&&parent.frames.length)
 {
  d=parent.frames[n.substring(p+1)].document;
  n=n.substring(0,p);
 }
 if(!(x=d[n])&&d.all) x=d.all[n];
 for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
 for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
 if(!x && d.getElementById) x=d.getElementById(n);
 return x;
}

// Anti-spam e-mail script...

function email(name,domain,subj,mode)
{
 if(!d) d=document;
 addr=name+"@"+domain;
 addrd=(mode=='short')?('email&nbsp;'+name):addr;
 subject=(subj!='')?('?subject='+subj):'';
 d.write('<a href="mailto:'+addr+subject+'">'+addrd+'</a>');
}

// Form validation...

function filled(field)
{
 v = field.value.replace(/\n/g,"").replace(/\r/g,"").replace(/\s/g,"");
 if (v == "" || v == null) return false;
 else return true;
}

// Timer function for anti-bot contact form...

function countd()
{
 if((yobj=MM_findObj('countdown'))!=null)
 {
  w=yobj.innerHTML;
  if(parseInt(w)!=w-0) w=15;
  w--;
  if(w<=0)
  {
   w='OK';
   clearInterval(counter);
   if((xobj=MM_findObj('resubmit'))!=null) xobj.style.visibility='visible';
   if((xobj=MM_findObj('countdown'))!=null) xobj.style.display='none';
   if((xobj=MM_findObj('cwait'))!=null) xobj.innerHTML='Please resubmit...';
  }
  yobj.innerHTML=w;
 }
}

// AJAX functions...

function createRequestObject()
{
 var ro;
 var browser = navigator.appName;
 if(browser == "Microsoft Internet Explorer")
 {
  ro = new ActiveXObject("Microsoft.XMLHTTP");
 } else
 {
  ro = new XMLHttpRequest();
 }
 return ro;
}

function ajax(Method, URL, ID, p1, p2)
{
 if(!d) d=document;
 httpObject = createRequestObject();
 if (httpObject != null)
 {
  Method=Method.toUpperCase();
  params='p1='+p1+'&p2='+encodeURIComponent(p2);
  if(Method!="POST") URL+='?'+params+'&ms='+new Date().getTime();
  httpObject.open(Method, URL, true);
  if(Method=="POST")
  {
   httpObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   httpObject.setRequestHeader("Content-length", params.length);
   httpObject.setRequestHeader("Connection", "close");
  }
// notice we make a local var
  var updateID = ID;
// and we wrap up the response function right here...
  httpObject.onreadystatechange = function()
  {
   if(httpObject.readyState < 4)
   {
    d.getElementById(updateID).innerHTML = '<img style="display:block;margin:0 auto" src="/phpimg.php?img=loading.gif" alt="" />';
   } else if(httpObject.readyState == 4)
   {
    d.getElementById(updateID).innerHTML = httpObject.responseText;
   }
  }
  if(Method=="POST") httpObject.send(params);
  else httpObject.send(null);
 }
} 
