var jah_indicator = '<img src="./files/indicator.gif" alt="Loading" />';
var jah_error = '';

function showDept(index)
{
  /*document.getElementById('mapcontent').innerHTML = 'Adressen zu '+index;*/
    jah('./files/show_address.php?i='+index, 'mapcontent', 'on', '');
}
function mouseOver(imgId, id, current)
{
 var img = document.getElementById(imgId)
 img.src ="files/client"+id+"_active.jpg";
}
function mouseOut(imgId, id, current)
{
 var img = document.getElementById(imgId)
 if (id == current) {
      img.src ="files/client"+id+"_active.jpg";
 } else {
      img.src ="files/client"+id+".jpg";
 }
}

/**
 * tabView, set style for div's in tabview
 * and set class of clicked tab
 */
function viewTab1()
{
	if(document.getElementById) {
		a=document.getElementById('tabctl1');
		b=document.getElementById('tabctl2');
		adiv=document.getElementById('tab1');
		bdiv=document.getElementById('tab2');
		a.className='active';
		b.className='inactive';
        bdiv.style.display = 'none';
		adiv.style.display = 'block';
		return (true);
	}
	return (false);
}
function viewTab2()
{
	if(document.getElementById) {
		a=document.getElementById('tabctl2');
		b=document.getElementById('tabctl1');
		adiv=document.getElementById('tab2');
		bdiv=document.getElementById('tab1');
		a.className='active';
		b.className='inactive';
        bdiv.style.display = 'none';
		adiv.style.display = 'block';
		return (true);
	}
	return (false);
}

/**
 * JAH AJAX
 */
function jah(url, id, showIndicator, jah_error)
{
    if (showIndicator == 'on') {
    	// replace with progress indicator
		document.getElementById(id).innerHTML = jah_indicator;
	}
    // native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = function() {jahDone(id, jah_error);};
        req.open("GET", url, true);
        req.send(null);
    // IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = function() {jahDone(id, jah_error);};
            req.open("GET", url, true);
            req.send();
        }
    }
    return (true);
}

/**
 * Handles the result of the jah() XMLHttp Request
 */
function jahDone(id, jah_error)
{
    // only if req is "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            results = req.responseText;
            document.getElementById(id).innerHTML = results;
            return (true);
        }
        else {
            // the request wasnt answered OK
            document.getElementById(id).innerHTML = jah_error;
            return (false);
        }
    }
}