
 function addLoadEvent(func) {
  var oldonload = window.onload;
   if (typeof window.onload != 'function') {
    window.onload = func;
   } else {
    window.onload = function() {
    oldonload();
    func();
   }
  }
 }

 var xmlreqs = new Array();
 var theDiv = '';

 function CXMLReq(type,xmlhttp,theDiv) {
  this.type = type;
  this.xmlhttp = xmlhttp;
  this.theDiv = theDiv;
 }

 function xmlreqGET(url,theDiv) {
  var xmlhttp = false;
  var theDiv = theDiv;
  if (window.XMLHttpRequest) {
   xmlhttp=new XMLHttpRequest();
   xmlhttp.onreadystatechange = xmlhttpChange;
   xmlhttp.open("GET",url,true);
   xmlhttp.send(null);
  } else if (window.ActiveXObject) {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   if (xmlhttp) {
    xmlhttp.onreadystatechange = xmlhttpChange;
    xmlhttp.open("GET",url,true);
    xmlhttp.send();
   }
  }
  var xmlreq = new CXMLReq('', xmlhttp, theDiv);
  xmlreqs.push(xmlreq);
 }

 function xmlhttpChange() {
  if (typeof(window['xmlreqs']) == "undefined") return;
   for (var i=0; i < xmlreqs.length; i++) {
    if (xmlreqs[i].xmlhttp.readyState == 4) {
     if (xmlreqs[i].xmlhttp.status == 200 || xmlreqs[i].xmlhttp.status == 304) {
      handle_response(xmlreqs[i].theDiv, xmlreqs[i].xmlhttp);
      xmlreqs.splice(i,1); i--;
     } else {
      xmlreqs.splice(i,1); i--;
     }
    }
   }
 }

 function handle_response(theDiv,xmlhttp) {
  var thisResponse = xmlhttp.responseText;
  if (theDiv != '') {
   document.getElementById(theDiv).innerHTML = thisResponse;
  }
 }

 function clearElement(element) {
  document.getElementById(element).value = '';
 }

 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 bookmark(url,title){
  if (document.all)
  window.external.AddFavorite(url, title);
  else if (window.sidebar)
  window.sidebar.addPanel(title, url, "");
 }

 /* Calling Functions */

 function focusKeywords() {
  var keys = document.getElementById('keywordsPublications');
  if (keys.value == 'Enter keywords') {
   keys.value = '';
  }
 }

 function unFocusKeywords() {
  var keys = document.getElementById('keywordsPublications');
  if (keys.value == '') {
   keys.value = 'Enter keywords';
  }
 }

 function cartoonPic(pid) {
  xmlreqGET('_ajax/cartoon-pic.php?pid='+pid,'cartoonMainPic'); 
 }
 
 function mapJump(aid,tid,lat,lng,map_zoom) {
  map.setCenter(new GLatLng(lat,lng),map_zoom);
  document.getElementById('projectAreas').style.display='none';
  xmlreqGET('_ajax/project-list.php?aid='+aid+'&tid='+tid,'projectList'); 
 }

 function projectBack() {
  document.getElementById('projectAreas').style.display='inline';
  document.getElementById('projectList').innerHTML='';
 }