

	function formatCurrency ( num ) {
		
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num)) {
			num = "0";
		}
		
			sign = (num == (num = Math.abs(num)));
			num = Math.floor(num*100+0.50000000001);
			cents = num%100;
			num = Math.floor(num/100).toString();

		if(cents<10) {
			cents = "0" + cents;
		}
		
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) {
			num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3));
		}
		return (((sign)?'':'-') + num + '.' + cents);
	}


	function dump(arr,level) {
		var dumped_text = "";
		if(!level) level = 0;
		
		//The padding given at the beginning of the line.
		var level_padding = "";
		for(var j=0;j<level+1;j++) level_padding += "    ";
		
		if(typeof(arr) == 'object') { //Array/Hashes/Objects
		 for(var item in arr) {
		  var value = arr[item];
		 
		  if(typeof(value) == 'object') { //If it is an array,
		   dumped_text += level_padding + "'" + item + "' ...\n";
		   dumped_text += dump(value,level+1);
		  } else {
		   dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
		  }
		 }
		} else { //Stings/Chars/Numbers etc.
		 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
		}
		return dumped_text;
	} 

	function maxPlan () {
		
		if (document.getElementById('areamoduletr').style.display == 'none' && document.getElementById('pright').style.display == 'none') {
			minimize('areamoduletr', '',  'mtb_b',  'mtb_t')
			minimize('pright', '',  'mlr_r',  'mlr_l');
		} else {
			minimize('areamoduletr', 'none',  'mtb_t',  'mtb_b');
			minimize('pright', 'none',  'mlr_l',  'mlr_r');
		}
		
	}
	
	function minimize (target_p, instance_p, target_i, icono_a) {
	
		objm = document.getElementById(target_p);
		obji = document.getElementById(target_i);
		
		objm.style.display = instance_p;
		obji.style.display = '';
		
		document.getElementById(icono_a).style.display = 'none';
		
		if (moduletabctrl) {
			document.getElementById(moduletabctrl).www = 'yes';
		}
	
	}
	
	function getEl ( id ) {
		
		return document.getElementById(id);
		
	}
	
	function doScrollRep ( where ) {
		
		for(var i=0; i<70; i++) {
			divicons.doScroll('down');
		}
		
	}

    function switchTitle ( target, txt ) {
    	
    	if (document.getElementById(target).title) {
    		document.getElementById(target).title = txt;
    	} else if (document.getElementById(target).alt) {
    		document.getElementById(target).alt = txt;
    	}

    }	
    
	function highlight ( field ) {
	    
	    if (document.getElementById(field)) {
		    document.getElementById(field).focus();
		    document.getElementById(field).select();
	    }

	}
    
	
	function switchShow (target, actual) {
	
		if (document.getElementById(target)) {
			document.getElementById(target).style.display = '';
		}
		if (document.getElementById(actual)) {
			document.getElementById(actual).style.display = 'none';
		}			
	
	}
	
	function getXML (url) {
	
			loadXMLDoc(url, parseXML);
	
	}
	
	function switchClass (target, classs) {
		
		if (document.getElementById(target)) {
		   document.getElementById(target).className = classs;			
		}
		
	}
	
	function updateRow () {
	 
		var table = document.getElementById(arguments[0]); 
		var rows  = table.getElementsByTagName("tr")[arguments[1]]; 
		var cells = rows.getElementsByTagName("td");
		
		for (var i=0; i<cells.length; i++) {
			
			cells[i].innerText = arguments[i + 2];
		}

	}	
	
	function switchShowOne (target) {
	
			if (!document.getElementById(target)) {
				return false;
			}
			
			obj = document.getElementById(target)
			
			if (obj.style.display == 'none') {
			   obj.style.display = '';
			   return true;
			} else {
			   obj.style.display = 'none';
			   return false;
			}
	
	}
	
	function setDisabled (target, able) {
		
		if (document.getElementById(target)) {
		   document.getElementById(target).disabled = able;			
		}		
		
	}
	
	function setChecked (target, able) {
		
		if (document.getElementById(target)) {
		   document.getElementById(target).checked = able;			
		}		
		
	}
	
	function switchDisplay (target, display) {
		
		if (document.getElementById(target)) {
			obj = document.getElementById(target)
			obj.style.display = display;
		}
		
	}		
	
	function setFocus (target) {
		
		document.getElementById(target).focus();
		
	}
	
	function setValue ( target, value ) {

			if (document.getElementById(target)) {
				document.getElementById(target).value = value;
			}
	
	}	
	
	function getValue ( target ) {
	
			if (document.getElementById(target)) {
				return document.getElementById(target).value;
			}
	
	}	
	
	function switchImg (target, source) {
		
		if (document.images[target]) {
			var cur_img = document.images[target].src;
			document.images[target].src = source;
			return cur_img;
		}
	
	}
	
	function recallxml () {
		
		loadXMLDoc(lasturl, lastfun);
		
	}		
	
	xmlctrl = 1;
	function loadXMLDoc(url,func) {
	 
	 	lasturl = url;
	 	lastfun = func;
	 	
//	 	xmlctrl
	 
		if (xmlBusy) {
		   setTimeout("recallxml()", 300);
		} else {
			switchDisplay('load', '');
			xmlBusy=true;

			if (window.XMLHttpRequest)  {
			     xmlhttp=new XMLHttpRequest();
			     xmlhttp.onreadystatechange=func;
			     xmlhttp.open("GET",url,true);
			     xmlhttp.send(null);
			 } else if (window.ActiveXObject) {
			     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			     if (xmlhttp) {
			            xmlhttp.onreadystatechange=func;
			            xmlhttp.open("GET",url,true);
			            xmlhttp.send();
			     }
			 }
		 	
		 }
	
	}
	
    function popup (theURL, winName, ancho, alto, features) { //v2.0

        var y = parseInt(window.screen.height / 2 ) - parseInt(alto / 2);
        var x = parseInt(window.screen.width / 2 ) - parseInt(ancho / 2);

        features += ", width=" + ancho + ", height=" + alto + ", ";
        features += "top=" + y + ", left=" + x;
        return window.open(theURL,winName,features);

    }	
	
	function writeConsole (content) {
	 
		 top.consoleRef = window.open('','myconsole',
		  'width=600,height=400'
		   +',menubar=0'
		   +',toolbar=0'
		   +',status=0'
		   +',scrollbars=1'
		   +',resizable=1');
		// top.consoleRef.document.open("text/html","replace");
		 top.consoleRef.document.writeln(
		  '<html><head><title>Console</title></head>'
		 +'<body bgcolor=white onLoad="self.focus()">'
		 +'<div style="height: 100%; border:1px solid red; font-size: 9pt; padding: 8px; background-color: #FFE2E2; font-family: monospace">'
		 +'<b>DEBUG:</b><br><br>'
		 +content
		 +'</div></body></html>'
		 );
		 //top.consoleRef.document.close()
		 
	}
	
	function getMSelectValue ( obj ) {
		
		var aux = new Array();
		var ele = document.getElementById(obj);
		var pointer = 0;
		for(var i=0; i<document.getElementById(obj).length; i++) {
			if (ele.options[i].selected) {
				aux[pointer] = ele.options[i].value;
				pointer++;
			}
		}
		return aux.join(',');
	}
	
	function getMSelectValue2 ( obj ) {
		
		var aux = new Array();
		var ele = document.getElementById(obj);
		var pointer = 0;
		for(var i=0; i<document.getElementById(obj).length; i++) {
			aux[pointer] = ele.options[i].value;
			pointer++;
		}
		return aux.join(',');
	}
	
	function getMText2 ( obj ) {
		
		var aux = new Array();
		var ele = document.getElementById(obj);
		var pointer = 0;
		for(var i=0; i<document.getElementById(obj).length; i++) {
			aux[pointer] = ele.options[i].text;
			pointer++;
		}
		return aux.join(',');
	}
	
	function MSelectall ( obj ) {
		
		var ele = document.getElementById(obj);
		for(var i=0; i<document.getElementById(obj).length; i++) {
			ele.options[i].selected = true;
		}
		//return aux.join(',');
	}
	
	function MDeselectall ( obj ) {
		
		var aux = new Array();
		var ele = document.getElementById(obj);
		for(var i=0; i<document.getElementById(obj).length; i++) {
			ele.options[i].selected = false;
		}
		
	}
	
	function selectByValues ( obj, values ) {
		
		var aux = values.split(",");
		var ele = document.getElementById(obj);
		
		for(var i=0; i<document.getElementById(obj).length; i++) {
			for(var b=0; b<aux.length; b++) {
				if (ele.options[i].value == aux[b]) {
					ele.options[i].selected = true;
				}
			}
		}
		
	}
	
	function sendXML ( url, func, varamandar ) {
		
//		 varamandar = url_encode(varamandar);
         if (window.XMLHttpRequest){
            xmlhttp=new XMLHttpRequest();
            xmlhttp.onreadystatechange=func;
            xmlhttp.open("POST",url,true);
            xmlhttp.setRequestHeader("Method", "POST "+url+" HTTP/1.1");
            xmlhttp.setRequestHeader("Content-Type","application/xml");
            xmlhttp.send(varamandar);
         } else if(window.ActiveXObject) {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			if (xmlhttp) {
               xmlhttp.onreadystatechange=func;
               xmlhttp.open("POST",url,true);
               xmlhttp.setRequestHeader("Method", "POST "+url+" HTTP/1.1");
               xmlhttp.setRequestHeader("Content-Type","application/xml");
               xmlhttp.send(varamandar);
            }
         }
		
	}
		
    function sendForm(formname, url, func, varamandar) {

         elform = document.getElementById(formname);
         //varamandar = '';

         for (i=0; i < elform.elements.length; i++) {
             ele = elform.elements[i];
             
             if (ele.type=="select-multiple" ) {
                 if (ele.length)
                 for (j=0;j<ele.length;j++) {
                 	if (sendselected && ele.options[j].selected) {
                 		varamandar = varamandar+'&'+ele.name+'%5B%5D='+ele.options[j].value;  
                 	} else if (!sendselected){
                 		varamandar = varamandar+'&'+ele.name+'%5B%5D='+ele.options[j].value;  
                 	}
                 }
             }

             if (ele.type=="select-one") {
                if (ele.value != '' && !sendnull) {
                   varamandar = varamandar+'&'+ele.name+'='+url_encode(ele.value);
                } else if (sendnull) {
                   varamandar = varamandar+'&'+ele.name+'='+url_encode(ele.value);
                }
             }
             
             if (ele.type=="checkbox" ) {
                if (ele.checked) {
                   varamandar = varamandar+'&'+ele.name+'='+ele.value;
                }
             }
             
             if (ele.type=="radio" ) {
                if (ele.checked) {
                   varamandar = varamandar+'&'+ele.name+'='+ele.value;
                }
             }             
             
             if (ele.type=="text" ) {
                if (ele.value != '' && !sendnull) {
                   varamandar = varamandar+'&'+ele.name+'='+url_encode(ele.value);
                } else if (sendnull) {
                   varamandar = varamandar+'&'+ele.name+'='+url_encode(ele.value);
                }
             }
             
             if (ele.type=="textarea" ) {
                   varamandar = varamandar+'&'+ele.name+'='+url_encode(ele.value);
             }             
             
             if (ele.type=="password" ) {
                   varamandar = varamandar+'&'+ele.name+'='+ele.value;
             } 
                          
             if (ele.type=="hidden" ) {
                if (ele.value != '') {
                   varamandar = varamandar+'&'+ele.name+'='+url_encode(ele.value);
                }
             }             

         }

         if (window.XMLHttpRequest){
            xmlhttp=new XMLHttpRequest();
            xmlhttp.onreadystatechange=func;
            xmlhttp.open("POST",url,true);
            xmlhttp.setRequestHeader("Method", "POST "+url+" HTTP/1.1");
            xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
            xmlhttp.send(varamandar);
         } else if(window.ActiveXObject) {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			if (xmlhttp) {
               xmlhttp.onreadystatechange=func;
               xmlhttp.open("POST",url,true);
               xmlhttp.setRequestHeader("Method", "POST "+url+" HTTP/1.1");
               xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
               xmlhttp.send(varamandar);
            }
         }

         //xmlBusy = true;
    }
    
    // url_encode version 1.0  
    function url_encode(str) {  
        var hex_chars = "0123456789ABCDEF";  
        var noEncode = /^([a-zA-Z0-9\_\-\.])$/;  
        var n, strCode, hex1, hex2, strEncode = "";  

        for(n = 0; n < str.length; n++) {  
            if (noEncode.test(str.charAt(n))) {  
                strEncode += str.charAt(n);  
            } else {  
                strCode = str.charCodeAt(n);  
                hex1 = hex_chars.charAt(Math.floor(strCode / 16));  
                hex2 = hex_chars.charAt(strCode % 16);  
                strEncode += "%" + (hex1 + hex2);  
            }  
        }  
        return strEncode;  
    }    
	
	function no_seleccion() {
	      
    	  tipo = event.srcElement.type;
    	  if (tipo == "text" || tipo == "file" || tipo == "textarea" || tipo == "password") {
    	  } else {
    	  	window.event.returnValue = false;
    	  }
	      
	}
	
	function fable() {
	      for (var i=0; i<arguments.length; i++) {
	      	
	      	  document.getElementById(arguments[i]).disabled = false;
	      
	      }
	}	
	
	function setPointer(theRowId, classRecover) {
		
		obj = document.getElementById(theRowId);
		
		if (obj.className == 'rowmarc') {
			obj1
		} else {
			obj.className = 'rowmarc';
		}
		
	}
	
	function goModal (url, w, h) {
		
	      var naProps = showModalDialog(url, 'Mdl', 
	        			'dialogHeight:' + h + 'px; dialogWidth:' + w + 'px; resizable:no; status:no; scroll: no');  
	        			
	      if (naProps != null)  {
	      	 eval(naProps);
	      }
		  
	}
	
	function selectAllCheckbox ( form_name, cmaster, namecheck ) {
		
	    formblock= document.getElementById(form_name);
		forminputs = formblock.getElementsByTagName('input');
		for (i = 0; i < forminputs.length; i++) {  
			if (forminputs[i].type == "checkbox" && forminputs[i].name.indexOf(namecheck) != -1) {
			    forminputs[i].checked = cmaster.checked;
			}  
		}
		setDisabled('see_perm' + form_name, false);
	}  
	
	function ajaxComboBox(url, value, comboBox) {
	    dest_combo = comboBox;
	    setDisabled(dest_combo, true);
	    url = url + value;
	    if (document.getElementById) { //Verifica se o Browser suporta DHTML.
	        if (window.XMLHttpRequest) {
	            xmlhttp = new XMLHttpRequest();
	            xmlhttp.onreadystatechange = ajaxComboBoxFill;
	            xmlhttp.open("GET", url, true);
	            xmlhttp.send(null);
	        } else if (window.ActiveXObject) {
	            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	            if (xmlhttp) {
	                xmlhttp.onreadystatechange = ajaxComboBoxFill;
	                xmlhttp.open("GET", url, true);
	                xmlhttp.send();
	            }
	        }
	    }
	}
	
	var selectedopt = false;
	
	function ajaxComboBoxFill () {
	    if (xmlhttp.readyState == 4 && xmlhttp.status == 200){  //Verifica se o arquivo foi carregado com sucesso.
	        var result = xmlhttp.responseXML;
	        selectedopt = null;
	        if(jsdebug==true) alert(xmlhttp.responseText);
	        var cidades = result.getElementsByTagName("option");
	        if (dest_combo[0]) {
	        	for(var i=0; i<dest_combo.length; i++) { if (!document.getElementById(dest_combo[i])) { return null; } }
	        } else if (!document.getElementById(dest_combo)) { return null; }
	        
	        if (dest_combo[0]) {
	        	for(var i=0; i<dest_combo.length; i++) { document.getElementById(dest_combo[i]).innerHTML = ""; }
	        } else { document.getElementById(dest_combo).innerHTML = ""; }
	        
	        for (var i = 0; i < cidades.length; i++) {
		        if (dest_combo[0]) {
		        	for(var c=0; c<dest_combo.length; c++) {
			 			new_opcao = create_option(cidades[i]);
			 			document.getElementById(dest_combo[c]).appendChild(new_opcao);
		        	}
		        } else {
		        	new_opcao = create_option(cidades[i]);
		        	document.getElementById(dest_combo).appendChild(new_opcao);
		        }
	        }
	        
	        if (selectedopt) {
	        	setTimeout("setValue(dest_combo, '" + selectedopt + "')", 50);
	        }
	        selectedopt = null;
	        setDisabled(dest_combo, false);
	    }
	}
	
	function create_option(cidade) { //Cria um novo elemento OPTION.

	    var new_opcao = document.createElement("option"); //Cria um OPTION.
	    if (!cidade.childNodes[0].data.match("SKIP")) {
	    	var texto = document.createTextNode(cidade.childNodes[0].data); //Cria um texto.
	    	var valor = cidade.getAttribute("value");
	    } else {
	    	var texto = document.createTextNode(""); //Cria um texto.
	    	var valor = "";
	    }
	    
	    if (cidade.getAttribute("selected")) {
	    	selectedopt = valor;
	    }
	    new_opcao.setAttribute("value", valor); //Adiciona o atributo de valor a nova op??o.
	    new_opcao.appendChild(texto); //Adiciona o texto a OPTION.
	    return new_opcao; // Retorna a nova OPTION.
	    
	}
	
	function menupress (id) {
		
		if (lastopt) {
			lastopt.className = 'nomarc';
		}
		
		obj = document.getElementById('menuopt' + id);
		obj.className = 'rowmarc';		
		lastopt = obj;
		
	}
	
	function removeAllOptions ( selectbox ) {
		if (!document.getElementById(selectbox)) { return }
		var i;
		for (i = document.getElementById(selectbox).options.length-1; i>=0; i--) {
			document.getElementById(selectbox).remove(i);
		}
	}	
	
	function cfm () {
		
		return confirm ('Seguro que desea eliminar?');
		
	}
	
	function move(fbox, tbox) {
	         var arrFbox   = new Array();
	         var arrTbox   = new Array();
	         var arrLookup = new Array();
	         var arraux    = new Array();
	         var i;
	         var next      = null;
	         var prev      = null;
	         fbox = document.getElementById(fbox);
	         tbox = document.getElementById(tbox);
	
	         for (i = 0; i < tbox.options.length; i++) {
	             arrLookup[tbox.options[i].text] = tbox.options[i].value;
	             arrTbox[i] = tbox.options[i].text;
	         }
	
	         var aLength = 0;
	         var tLength = arrTbox.length;
	         for (i = 0; i < fbox.options.length; i++) {
	             arrLookup[fbox.options[i].text] = fbox.options[i].value;
	             if (fbox.options[i].selected && fbox.options[i].value != "") {
	                arrTbox[tLength] = fbox.options[i].text;
	                tLength++;
	                arraux[aLength] = i;
	                aLength++;
	             }
	         }
	         
	         for (i = (arraux.length - 1); i >= 0; i--) {
	                fbox.remove(arraux[i]);
	                fbox.selectedIndex = arraux[i];
	         }
	         
	
	         arrTbox.sort();
	         tbox.length = 0;
	
	         for (c = 0; c < arrTbox.length; c++) {
	             var no = new Option();
	             no.value = arrLookup[arrTbox[c]];
	             no.text = arrTbox[c];
	             tbox[c] = no;
	         }
	         
	}	
	
	function setInner ( target, value ) {
		
		if (document.getElementById(target)) {
			document.getElementById(target).innerHTML = value;
		}
		
	}
	
	  function closemdl (e) {
	  	  
		  var kC  = (window.event) ? event.keyCode : e.keyCode;
		  var Esc = (window.event) ? 27 : e.DOM_VK_ESCAPE;

	  	  if (kC == 120) {
	  	  	 if (jsdebug) {
	  	  	 	jsdebug = false;
	  	  	 } else {
	  	  	 	jsdebug = true;
	  	  	 }
	  	  }
	  	  
	  	  if (kC == 119) {
	  	  	loadXMLDoc(lasturl, lastfun);
	  	  }
	  	  
	  	  if (window.name = "Mdl" && kC == Esc) {
	  	  	window.close();
	  	  }
	  	
	  }
	  
	  function setClass (id, classe) {
		
		  if (document.getElementById(id)) {
			  document.getElementById(id).className = classe;
		  }
		
	  }
	  
	  function expandNode ( id, modify ) {
	  	  
	  	  if (!modify) {
	  	  	modify = "";
	  	  }
	  	  // change arrow icon
	  	  if (document.images['plus_' + id].src == style_base + 'arrow_down.gif' && modify == "") {
	  	  	
	  	  	switchImg ('plus_' + id, style_base + 'arrow_right.gif');
	  	  	switchDisplay ('child_' + id, 'none');
	  	  	
	  	  } else {
	  	  	
	  	  	child_node = id;
	  	  	loadXMLDoc(uri_entry + '/core/expand/' + id + '/' + modify, parseNode); // call data
	  	  	switchImg ('plus_' + id, style_base + 'arrow_down.gif');
	  	  	
	  	  }
	  	  
	  }
	  
	  function ableNav ( txtdes, txtact ) {
	  	  
	  	  if (!document.getElementById('enabledrawv')) {
	  	  	return;
	  	  }
	  	  
	  	  if (cargaplane) {
		  	  switchTitle("btn_nav", txtact);
		  	  switchImg("btn_nav", icon_dir + '_plane.gif');
		  	  switchImg("btn_planeh", icon_dir + '_planeh.gif');
		  	  cargaplane = false;
	  	  } else {
	  	  	  switchTitle("btn_nav", txtdes);
	  	  	  switchImg("btn_nav", icon_dir + 'plane.gif');
	  	  	  if (has_hist) {
	  	  	  	 switchImg("btn_planeh", icon_dir + 'planeh.gif');
	  	  	  } else {
	  	  	  	 switchImg("btn_planeh", icon_dir + '_planeh.gif');
	  	  	  }
		  	  cargaplane = true;	  	  	  
	  	  }
	  	
	  }
	  
	  function ableLM ( txtdes, txtact ) {
	  	  
	  	  if (!document.getElementById('enabledrawv')) {
	  	  	return;
	  	  }
	  	  
	  	  if (cargamodule) {
		  	  switchTitle("btn_lm", txtact);
		  	  switchImg("btn_lm", icon_dir + '_module.gif');
		  	  cargamodule = 0;
		  	  minimize('areamoduletr', 'none',  'mtb_t',  'mtb_b');
	  	  } else {
	  	  	  switchTitle("btn_lm", txtdes);
	  	  	  switchImg("btn_lm", icon_dir + 'module.gif');
		  	  cargamodule = 1;
		  	  minimize('areamoduletr', '',  'mtb_b',  'mtb_t');
	  	  }
	  	
	  }	  
	  
	  function ableSearch () {
	  	  
	  	  switchDisplay("tree_div", "none");
	  	  switchDisplay("search_div", "");
	  	  setFocus("search_txt");
	  	
	  }	
	  
	  function ableHistoric() {
	  	  
	  	  if (cargaplane && has_hist) {
		  	  switchShow('historic_div', 'tree_div');
		  	  loadXMLDoc(uri_entry + '/graph/getHistoricAction', parseAction);
	  	  }
	  	
	  }		  
	  
	  function ableDraw () {
	  	
		  if (document.getElementById('enabledrawv').value == 2) {
			 document.getElementById('enabledrawv').value = 0;
			 switchImg("btn_draw", icon_dir + '_edit.gif');
			 return;
		  }
		  
		  if (document.getElementById('enabledrawv').value == 1) {
			 document.getElementById('enabledrawv').value = 2;
			 switchImg("btn_draw", icon_dir + 'edit_fast.gif');
			 return;			 
		  }
		  
		  if (document.getElementById('enabledrawv').value == 0) {
			 document.getElementById('enabledrawv').value = 1;
			 switchImg("btn_draw", icon_dir + 'edit.gif');
			 return;
		  }
	  	
	  }
	  
	  function ableZL ( txtdes, txtact ) {
	  	
		  if (zl) {
			 zl = false;
			 switchTitle("btn_zoomloc", txtact);
			 switchImg("btn_zoomloc", icon_dir + '_zoomloc.gif');
		  } else {
			 zl = true;
			 switchTitle("btn_zoomloc", txtdes);
			 switchImg("btn_zoomloc", icon_dir + 'zoomloc.gif');			 
		  }
	  	
	  }	  
	  
	  var atab = 1;
	  var lastGuide = null;
	  var arrMdlNum = new Array();
	  var setSizeState = true;
	  
	  function tab ( id, module_name, node_id ) {
		
		  if (lastGuide != null && arrMdlNum[lastGuide]) { 
		  	module_name = lastGuide; 
		  	id = arrMdlNum[module_name];
		  }
		  if (!document.getElementById("tab_t_" + id)) { return false;}
		
		  if (!document.getElementById(module_name).innerHTML) {
			  loadXMLDoc(uri_entry + "/" + module_name + "/display/" + node_id, parseXML);
		  }
		  setSizeState = false;
		  switchShowOne(module_name);
		  switchShowOne(module_name + "_aux");
		  setSizeState = true;
		  		  
		  if (document.getElementById(moduletabctrl)) {
			  switchShowOne(moduletabctrl);
			  switchShowOne(moduletabctrl + "_aux");
		  }
		  moduletabctrl = module_name;
		  
		  if (id > atab) {

		 	  switchImg ("tab_s_" + atab, style_base + "h1_2.gif");
			  switchImg ("tab_s_" + (atab - 1), style_base + "h1_2.gif");

		  } else {

			  switchImg ("tab_s_" + (atab - 1), style_base + "h1_2.gif");
			  switchImg ("tab_s_" + atab, style_base + "h1_2.gif");
			
		  }
		
		  switchImg ("tab_s_" + (id - 1), style_base + "h1.gif");
		  switchImg ("tab_s_" + id, style_base + "hs.gif");
			
		  if (document.getElementById("tab_t_" + atab)) {
			  document.getElementById("tab_t_" + atab).style.backgroundImage = "url('" + style_base + "bg2.gif')";
		  }

		  document.getElementById("tab_t_" + id).style.backgroundImage = "url('" + style_base + "bg1.gif')";
		 
		  switchClass("tab_t_" + atab, "tabtitle tab_desactive");
		  switchClass("tab_t_" + id, "tabtitle tab_active");
			
		  atab = id;
		  
		  if (ctrlStMd[module_name] != StMd && arrObjs[module_name]) {
		  	  ctrlStMd[module_name] = StMd;
		  	  eval(moduletabctrl + "Focus('mx')");
		  } else if (ctrlStMd[module_name] != StMd) {
		  	  //loadXMLDoc(uri_entry + "/" + module_name + "/display/" + node_id, parseXML);
		  }
		  
		  lastGuide = null;
		
	  }
	  
	  function refreshGrid ( obj ) {
	  	
	  	  eval(moduletabctrl + "Focus('mn')");
	  	
	  }
		
	  function addtab ( title, module_name, node_id ) {
			 
		  tabctrl = tabctrl + 1;
		  arrMdlNum[module_name] = tabctrl;
		  ctrlStMd[module_name] = 1;
		  out = '<div id="tab_' + tabctrl + '" style="float: left">' +				   
		  '<div onclick="tab(' + tabctrl + ', \'' + module_name + '\', ' + node_id +')" id="tab_t_' + tabctrl + '" class="tabtitle tab_desactive">' + title + '</div>' +
		  '<div style="float: left"><img vspace=0 hspace=0 name="tab_s_' + tabctrl + '" align="absmiddle" src="' + style_base + 'h1_2.gif" border=0></div>' +
		  '</div>';
		  
		  setInner("tab_row", document.getElementById("tab_row").innerHTML + out);
		  setInner("module_area", document.getElementById("module_area").innerHTML + "<div style='width: 100%; height: 100%;display: none' id='" + module_name + "' onpropertychange='if (setSizeState)" + module_name + "Focus(1)'></div>");
		  setInner("module_aux", document.getElementById("module_aux").innerHTML + "<div style='display: none' id='" + module_name + "_aux'></div>");
			   
	  }
	  
	  function addTabCell ( title, index, prefix, div, place, active ) {
			 
		  out = '<div id="' + prefix + '_' + index + '" style="float: left">' +
			   	'<div onclick="tabmant(' + index + ', \'' + div + '\')" id="' + prefix + '_t_' + index + '" class="tabtitle tab_desactive">' + title + '</div>' +
			   	'<div style="float: left"><img vspace=0 hspace=0 name="' + prefix + '_s_' + index + '" align="absmiddle" src="' + style_base + 'h1_2.gif" border=0></div>' +
			   	'</div>';
		  
		  setInner(place, document.getElementById(place).innerHTML + out);
			   
	  }
	  
	  function include(arquivo){
	
		  var novo = document.createElement("<script>");
		  var doce = document.getElementsByTagName('body').item(0);
		  novo.setAttribute('type', 'text/javascript');
		  novo.setAttribute('src', www + "style/javascript/" + arquivo);
		  doce.appendChild(novo);
		 
	  }
	  
	  function includes () {
		  
		  //include("parses.js");
		  //tab_mant		  include("tab_mant.js");
		  //include("svgctrl.js");
		  //include("grid.js");
		  
	  }
	  
	  function getInner ( target ) {
	  	
		  if (document.getElementById(target)) {
			 return document.getElementById(target).innerHTML;
		  }
	  	
	  }
	  
	  function catchKey ( code ) {
	  	
	  	  if (window.event.keyCode == code) {
	  	  	 return true;
	  	  } else {
	  	  	 return false;
	  	  }
	  	
	  }
	  
     function sImgAdapter ( target, status ) {
   
   	    if (status) {
	   	    switchImg('coll' + target, style_base + 'collapse.gif');
   	    } else {
		    switchImg('coll' + target, style_base + 'descollapse.gif');  	   
   	    }
   	   
   
     }
	  
	  
	  document.onkeydown = closemdl; // no select document	
	  document.onselectstart = no_seleccion; // no select document
    
	  // variables
	  var child_node     = "0";
	  var lastid         = null;
	  var lastclass      = null;
	  var jsdebug        = false;
	  var xmlBusy        = false;
	  var lasturl        = null;
	  var lastfun        = null;	
	  var lastopt        = null;
	  var xmlhttp        = null;
	  var sendnull       = false;
	  var sendselected   = false;
	  var dest_combo     = null;
	  var cargaplane     = false;
	  var cargamodule    = 1;
	  var lastobj        = "";
	  var has_hist       = false;
	  var tabctrl        = 1;
	  var moduletabctrl  = null;
	  var handles_update = null;
	  var zl             = false;
	  var ctrlStMd       = new Array();
	  var StMd           = 1;
	  var currentAdvSearchMdl = null;
	

