
function module_click_header(guid)
{	
	document.getElementById('body-'+guid).style.display = (document.getElementById('body-'+guid).style.display == 'none' ? 'block' : 'none');
}

function module_click_x(guid)
{
	document.getElementById('hdr-'+guid).style.display = 'none';
	document.getElementById('body-'+guid).style.display = 'none';
}

function textfield_clear(field)
{
	if (field.defaultValue == field.value) 
		field.value = '';   
	else if (field.value == '') 
		field.value = field.defaultValue;
}


function getXHR()
{		
    try {
        // Firefox, Opera 8.0+, Safari, IE7+
        return new XMLHttpRequest();
    } 
    catch (e) 
    {
        // Internet Explorer
        try 
        {
            return new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e) 
        {
            return new ActiveXObject("Microsoft.XMLHTTP");
        }
    }    
    return null;
 }
 
function setElementInnerHTMLByDivToUrl(url, containerid)
{
	var page_request = false

	xhr = getXHR();
	
	if (!xhr)
		return;
	
	loadpage_test(containerid);	
	
	xhr.onreadystatechange=function(){ loadpage(xhr, containerid) }
	xhr.open("post",url,true);     
    xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
    xhr.send(null); 
}

var timerID = 0;
var ajaxtext;
var containerid_;

function loadpage(xhr, containerid)
{
	if (xhr.readyState == 4 && (xhr.status==200))
	{
		//document.getElementById(containerid).innerHTML=xhr.responseText
		ajaxtext = xhr.responseText;
		containerid_ = containerid;
		timerID = setTimeout("updatepage()", 600);   		
	}
}

function updatepage()
{
    clearTimeout( timerID );
    document.getElementById(containerid_).innerHTML=ajaxtext
    
}


function loadpage_test(containerid)
{	
	document.getElementById(containerid).innerHTML='loading...'
}

function popup(url, wtitle, wother)
{
	window.open(url,wtitle, wother);
}
