var isIE = document.all?true:false;
ua = navigator.userAgent; 
agt = navigator.userAgent.toLowerCase(); 

HM_DOM = (document.getElementById) ? true : false; 
HM_IE = (document.all) ? true : false; 
HM_IE4 = HM_IE && !HM_DOM; 
HM_Mac = (navigator.appVersion.indexOf("Mac") != -1); 
HM_IE4M = HM_IE4 && HM_Mac; 

function showSelect() {
	if(HM_IE || HM_IE4) { 
		var obj; 
		if (document.all) { 
			for(var i = 0; i < document.all.tags('select').length; i++) { 
				obj = document.all.tags('select')[i]; 
				if(!obj || !obj.offsetParent) 
					continue; 
				obj.style.visibility = 'visible';
			} 
		} else { 
			for(var i = 0; i < document.forms.length; i++) { 
				for(var j = 0; j < document.forms[i].elements.length; j++) { 
					document.forms[i].elements[j].visibility = 'show'; 
				} 
			} 
		} 
	} 
} 

function hideSelect() { 
	if(HM_IE || HM_IE4) { 
		var obj; 
		if (document.all) { 
			for(var i = 0; i < document.all.tags("select").length; i++) { 
				obj = document.all.tags("select")[i]; 
				if(!obj || !obj.offsetParent) 
					continue; 
				obj.style.visibility = 'hidden'; 
			} 
		} else { 
			for(var i = 0; i < document.forms.length; i++) { 
				for(var j = 0; j < document.forms[i].elements.length; j++) { 
					document.forms[i].elements[j].visibility = 'hide'; 
				} 
			} 
		} 
	} 
}
function showHelpTekst(code,imageObj){
    
    strUrl = 'helptext.aspx?code='+code;
    //global_code = imageObj.id;
    loadXMLDoc(strUrl,'helptext',imageObj.id);    
}

 

function setHelpTekst(xmlhttp,id)
{   

   strTitle = "";
   strText = "";
   objRoot = xmlhttp.responseXML;

   strTitle = getElementTextNS("", "TITLE",objRoot,0)
   strText = getElementTextNS("", "CONTENT",objRoot,0)
   displayHelpText(strTitle,strText,id);
}

function displayHelpText(strTitle,strContent,id){
    var toppos;
    var leftpos;
    var parentId = id;
    //alert(parentId);
    var parentObj = document.getElementById(parentId);
    
    var toppos = findPosY(parentObj) + parentObj.height;
    var leftpos = findPosX(parentObj)+ parentObj.width;
    //alert(parentObj.width + ' '+ leftpos);
    
    var helpContainer = document.getElementById('helpcontainer');
    if(helpContainer==null){
        helpContainer = document.createElement('div');
        helpContainer.className = "helpdiv";
        helpContainer.id='helpcontainer';
        document.getElementsByTagName("BODY")[0].appendChild(helpContainer);
    }
    helpContainer.style.display="block";
    helpContainer.innerHTML = "";
    
    /*These variables are set in the CSS*/
    //helpContainer.style.top=toppos;
    //helpContainer.style.left=leftpos-350;;
    
    
    var topContainer = document.createElement('div');
    topContainer.className = "helptop";
    
    var titleContainer = document.createElement('div');
    titleContainer.className = "helptitle";
    titleContainer.innerHTML = strTitle;
    
    var closeContainer = document.createElement('div');
    closeContainer.className = "helpclose";
    closeContainer.innerHTML = "Sluiten";
    closeContainer.onclick=closeHelpContainer;
    
    var contentContainer = document.createElement('div');
    contentContainer.className = "helpcontent";
    contentContainer.innerHTML = strContent;
   
    //alert(contentContainer.innerHTML);
    
    
    topContainer.appendChild(titleContainer);
    topContainer.appendChild(closeContainer);
    
    helpContainer.appendChild(topContainer);
    helpContainer.appendChild(contentContainer);
    hideSelect();
    
}   

function closeHelpContainer(){
    var helpContainer = document.getElementById('helpcontainer');
    if(helpContainer!=null){
        helpContainer.style.display="none";
    }
    showSelect();
}
// retrieve text of an XML document element, including
// elements using namespaces
function getElementTextNS(prefix, local, parentElem, index) {
    var result = "";
    if (prefix && isIE) {
        // IE/Windows way of handling namespaces
        result = parentElem.getElementsByTagName(prefix + ":" + local)[index];
    } else {
        // the namespace versions of this method 
        // (getElementsByTagNameNS()) operate
        // differently in Safari and Mozilla, but both
        // return value with just local name, provided 
        // there aren't conflicts with non-namespace element
        // names
        result = parentElem.getElementsByTagName(local)[index];
    }
    if (result) {
        // get text, accounting for possible
        // whitespace (carriage return) text nodes 
        if (result.childNodes.length > 1) {
            return result.childNodes[1].nodeValue;
        } else {
            return result.firstChild.nodeValue;    		
        }
    } else {
        return "n/a";
    }
}
