

/* 
  This code is copyright(c) by ANCOSO Development GmbH.
*/

var ts_start=new Date().getTime();
function calculateDuration() {
  var ts_end=new Date().getTime();
  var millis=ts_end-ts_start;
  var divelem=document.getElementById('hidden_duration');
  divelem.firstChild.data=(millis/1000.0)+' Sekunden';
}

function ajaxfill(elemId,url,waitId,waitText,postFunction) {
  var waitElem = null;
  if (waitId) {
    waitElem = document.getElementById(waitId);
    if (waitElem) {
      if (waitText) {
        waitElem.innerHTML = waitText;
      } else {
        waitElem.innerHTML = "&nbsp;";
      }
    }
  }

  var xmlHttp = false;
  if (typeof XMLHttpRequest != 'undefined') {
    xmlHttp = new XMLHttpRequest();
  }
  if (!xmlHttp) {
    try {
      xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
      try {
        xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
      } catch(e) {
        xmlHttp  = false;
      }
    }
  }

  if (xmlHttp) {
    xmlHttp.onreadystatechange = function () {
      if (xmlHttp.readyState == 4) {
        var content = xmlHttp.responseText;

        if (waitElem) {
          waitElem.innerHTML = "&nbsp;";
        }

        if (elemId) {
          var elem = document.getElementById(elemId);
          if (elem) {
            elem.innerHTML = content;
          }
        }

        if (postFunction) {
          postFunction(elemId,url,content);
        }
      }
    };
    xmlHttp.open('GET', url, true);
    xmlHttp.send(null);
  }
}

function loadCSSPopup() {
  var url = "http://www.businessportal24.com/en-ca/ads_jobbibel";
  ajaxfill("css_popup", url, null, null, loadCSSPopup2);
}

function loadCSSPopup2(elemId,url,content) {
  if (content) {
    window.setTimeout("closeCSSPopup('css_popup')", 21000);
  }
}

function closeCSSPopup(id) {
  var elem = document.getElementById(id);
  if (elem) {
    elem.style.display = 'none';
  }
}

function loadCSSPopupAndCalculateDuration() {
  window.setTimeout("loadCSSPopup()", 1000);
  calculateDuration();
}

