var ie45,ns6,ns4,dom, tid;
var req;
var cnt=0;
if (navigator.appName=="Microsoft Internet Explorer")
ie45=parseInt(navigator.appVersion)>=4;
else if (navigator.appName=="Netscape"){
ns6=parseInt(navigator.appVersion)>=5;
ns4=parseInt(navigator.appVersion)<5;}
dom=ie45 || ns6;


function setApplet()
{
	oPhone = document.getElementById("phone");
	if (oPhone != null)
	{
		eval(base64_decode(sCode));
		oPhone.innerHTML = appletHTML;
	}
}


function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    // if cookie exists
    if (offset != -1) {
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1) end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

function refreshSession()
{
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        refreshReq = new XMLHttpRequest();
        refreshReq.open("GET", window.location.href, true);
        refreshReq.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        refreshReq = new ActiveXObject("Microsoft.XMLHTTP");
        if (refreshReq) {
            refreshReq.open("GET", window.location.href, true);
            refreshReq.send();
        }
    }
    setTimeout("refreshSession();", 60000);
}
setTimeout("refreshSession();", 60000);

function goTo(id)
{
	//alert("http://www.callfromweb.com/dev/service.php?sect="+id);
	loadXMLMenu("/content.php?s=m"+id);
	loadXMLContent("/content.php?s=c"+id);
}

function loadXMLMenu(url) {
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
    // alert("XMLHttpRequest");
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChangeMenu;
        req.open("GET", url, true);
        req.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
    // alert("ActiveXObject");

        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChangeMenu;
            req.open("GET", url, true);
            req.send();
        }
    }
}

function processReqChangeMenu() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            // ...processing statements go here...

el = document.getElementById("menu");

sHTML = req.responseText;
//alert("Menu OK: " +  sHTML);
el.innerHTML = sHTML;

        } else {
            alert("There was a problem retrieving the XML data:\n" +
                req.statusText);
        }
    }
}

function loadXMLContent(url) {
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
    // alert("XMLHttpRequest");
        req1 = new XMLHttpRequest();
        req1.onreadystatechange = processReqChangeContent;
        req1.open("GET", url, true);
        req1.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
    // alert("ActiveXObject");

        req1 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req1) {
            req1.onreadystatechange = processReqChangeContent;
            req1.open("GET", url, true);
            req1.send();
        }
    }
}

function processReqChangeContent() {
    // only if req shows "loaded"
    if (req1.readyState == 4) {
        // only if "OK"
        if (req1.status == 200) {
            // ...processing statements go here...

el1 = document.getElementById("content");

sHTML1 = req1.responseText;
//alert("Content OK: " +  sHTML1);
el1.innerHTML = sHTML1;

        } else {
            alert("There was a problem retrieving the XML data:\n" +
                req1.statusText);
        }
    }
}

function numbersonly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) ||
    (key==9) || (key==13) || (key==27) )
   return true;

// numbers
else if ((("0123456789*#").indexOf(keychar) > -1))
   return true;

// decimal point jump
else if (dec && (keychar == "."))
   {
   myfield.form.elements[dec].focus();
   return false;
   }
else
   return false;
}

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
countfield.value = maxlimit - field.value.length;
}

