// Librerķa de clases java script 
// Autor Manolo

var ajax = {
	XMLHttpRequest: function() {
  		try { return new XMLHttpRequest(); }
 		catch (e) { try { return new ActiveXObject('Msxml2.XMLHTTP'); }
  		catch (e) { try { return new ActiveXObject('Microsoft.XMLHTTP'); }
  		catch (e) { return false; }}}
  		return false;
	},
	get: function(sFile,oParams,fnDone) {
		return this.request('GET',sFile,oParams,fnDone);
	},
	post: function(sFile,oParams,fnDone) {
		return this.request('POST',sFile,oParams,fnDone);
	},
	request: function(sMethod,sFileName,oParams,fnDone) {
		var oRequest = this.XMLHttpRequest();
		if (!oRequest) return true;
		var sParams = '';
		var sFile = sFileName.split('#');
		if(sMethod == 'GET') {
			oRequest.open('GET', sFile[0]+this.params(oParams,''), true);
		} else {
			sParams = this.params(oParams,'');
			oRequest.open('POST', sFile[0], true);
        	oRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		}
        oRequest.setRequestHeader('Referer',window.location);
        oRequest.onreadystatechange = function() {
        	if (oRequest.readyState == 4 && oRequest.status == 200) {
        		if(fnDone)
					fnDone(oRequest);
        		if(sFile[1])
        			ajax.action(oRequest,sFile[1]);
			}
        };
        oRequest.send(sParams);
		return false;
	},
	params: function(oParams,before) {
		var sParams = '';
		for(i in oParams) {
			if(sParams.length>0) sParams += '&';
			sParams += encodeURIComponent(i)+'='+encodeURIComponent(oParams[i]);
		}
		return before+sParams;
	},
	action: function(oRequest,container) {
        switch(container[0]) {
        	case '^': 
        		container = container.replace(/^\^/,'');
        		if(!document.getElementById(container)) return false;
        		var update = document.getElementById(container).innerHTML;
        		document.getElementById(container).innerHTML = oRequest.responseText + update;
        		break;
        	case '+': 
        		container = container.replace(/^\+/,'');
        		if(!document.getElementById(container)) return false;
        		document.getElementById(container).innerHTML += oRequest.responseText;
        		break;
        	default: 
	        	if(!document.getElementById(container)) return false;
				document.getElementById(container).innerHTML = oRequest.responseText;
        }
	}
};


function cargando(){
		 

	document.getElementById('cont').innerHTML = "<img aling='center' src='http://framework.amnetwork.es/img/cargando_gris_peke.gif'> <label>&nbsp;Cargando, espere un momento por favor ....</label>" 	
}
function cargandobarra(){
		 

	document.getElementById('localidad').innerHTML = "<img aling='center' src='http://framework.amnetwork.es/img/progressbar_green.gif'>" 	
}


function ocultarFX(obj1){
	if (document.getElementById(obj1).style.display == "none"){
		document.getElementById(obj1).style.display = '';
		document.getElementById(obj1).style.visibility="visible";
		document.getElementById(obj1).style.height = ''
		
		}
	else{
		document.getElementById(obj1).style.display="none";
		document.getElementById(obj1).style.visibility="hidden";
		document.getElementById(obj1).style.height = '0'
		
		
		}
	
	}
	function visibleFX(obj1){
		document.getElementById(obj1).style.display = '';
		document.getElementById(obj1).style.visibility="visible";
		document.getElementById(obj1).style.height = ''
	}
	function ocultarFF(obj1){
		document.getElementById(obj1).style.display="none";
		document.getElementById(obj1).style.visibility="hidden";
		document.getElementById(obj1).style.height = '0'
		
		}
 
<!--
function openAjax() {

	var ajax;
	try{
		ajax = new XMLHttpRequest();
	}catch(ee){
		try{
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				ajax = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				ajax = false;
			}
		}
	}
	return ajax;
}

function CpForm(FormName){
	comp = "document." + FormName;
	var frm = eval(comp);
	Cps = "";
	for (i=0; i<frm.length; i++){
		Cps = Cps + frm.elements[i].name + "=" + frm.elements[i].value + "&";
	}
	Cps = Cps.substring(0,Cps.length -1);
	return Cps;
}

function OpenAjaxPostCmd(pagina,camada,values,msg,divcarga,metodo,tpmsg) { 
	if(document.getElementById) {
		var ajax = openAjax();
		if(tpmsg=='1'){
			var exibeLoading = document.getElementById(divcarga);
		}
		var exibeResultado = document.getElementById(camada);
		if(metodo=='1'){
			ajax.open("POST", pagina, true);
			ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			ajax.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
			ajax.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
			ajax.setRequestHeader("Pragma", "no-cache");
			valor = CpForm(values)
		}else{
			valor = null
			ajax.open("GET", pagina + values, true);
		}
		ajax.onreadystatechange = function() {
			if(ajax.readyState == 1) {
				if(tpmsg=='1'){
					exibeLoading.style.display = 'inline';
					exibeLoading.innerHTML = msg
				}else{
					exibeResultado.innerHTML = msg
				}
			}
			if(ajax.readyState == 4) {
				if(tpmsg=='1'){
					exibeLoading.innerHTML = ""
					exibeLoading.style.display = 'none';
				}else{
					exibeResultado.innerHTML = ""
				}
				if(ajax.status == 200) {
					var resultado = null;
					resultado = ajax.responseText;
					resultado = resultado.replace(/\+/g," ");
					resultado = unescape(resultado);
					exibeResultado.innerHTML = resultado;
				} else {
					exibeResultado.innerHTML = "<br / ><br / ><center>An error occurred:</center><br / ><br / > <center>" + resultado + "</center>";
				}
			}
		}
		ajax.send(valor);
	}		 
}
//-->
 