var showingToolTip = false;

function loadWebContent(url, containerid, isCacheable){
	
    var pageRequest = false;

    if (window.XMLHttpRequest) { // if Mozilla, Safari etc
        pageRequest = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // if IE
        try {
            pageRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                pageRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    } else {
        return false;
    }

    pageRequest.onreadystatechange = function() {
                                          loadpage(pageRequest, containerid);
                                      }

    if (!isCacheable) { 
	    pageRequest.open('POST', url, true);
	} else { 
	    pageRequest.open('GET', url, true);	
	}

    pageRequest.send(null);
}

function loadToolTip(url, containerid){
	return loadWebContent(url, containerid, true);
}



function showToolTip(containerid, namespace){	
       clearTimeout(this.timer);
	this.timer=setTimeout('showToolTipFunc(\''+containerid+'\',\''+namespace+'\')','500');

}

function showToolTipDirect(containerid, namespace, tip){	
       clearTimeout(this.timer);
	this.timer=setTimeout('showToolTipFunc(\''+containerid+'\',\''+namespace+'\')','500');

		var html = tip;
		var container = document.getElementById(namespace + containerid);

		if (document.all) {
			html = html.replace(/<script/gi, "<script defer='defer'");
			container.innerHTML = html;
		}else {

			if ( container.hasChildNodes() )
			{
				while ( container.childNodes.length >= 1 )
			  	{
				 container.removeChild( container.firstChild );
			       }
			}
			var range = document.createRange();
			range.selectNodeContents(container);
			range.collapse(false);
			container.appendChild(range.createContextualFragment(html));
		}

}

function showToolTipFunc(containerid, namespace){ 

	if (!showingToolTip) {
		showingToolTip = true;
		var tooltiparea = document.getElementById(namespace + containerid);
		tooltiparea.style.position='absolute';
		tooltiparea.style.visibility='visible';
		tooltiparea.style.backgroundColor='#FFCC33';
       }
}

function hideToolTip(containerid, namespace){ 
       clearTimeout(this.timer);
	showingToolTip = false;
	var tooltiparea = document.getElementById(namespace + containerid);
	tooltiparea.style.position='absolute';
	tooltiparea.style.visibility='hidden';

}

function loadpage(pageRequest, containerid){
    if (pageRequest.readyState == 4 && (pageRequest.status==200 || window.location.href.indexOf("http")==-1)) {
		var html = pageRequest.responseText;
		var container = document.getElementById(containerid);

		if (document.all) {
			html = html.replace(/<script/gi, "<script defer='defer'");
			container.innerHTML = html;
		} else {
                     container.innerHTML = '';
			var range = document.createRange();
			range.selectNodeContents(container);
			container.appendChild(range.createContextualFragment(html));
		}
	}
}

function showPopup(_url, _name) {		
	window.open( _url, _name,  'menubar=no,titlebar=no,toolbar=no,resizable=yes,scrollbars=yes,fullscreen=no,height=0,width=0,left=350,top=150'); 
}
