// JavaScript Document
String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g,''); }

function LoadPage(page,campos,capa_contenedora) {
         // Set up request varible
	if (window.XMLHttpRequest) // if Mozilla, Safari etc
		xmlhttp = new XMLHttpRequest()
	else if (window.ActiveXObject) { // if IE
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP")
		} catch(e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
			} catch(e) {}
		}
	} else 
		return false 

		//cuerpo=document.getElementsByTagName('body')[0];
		//if (document.getElementById(usediv)!=null) cuerpo.removeChild(document.getElementById(usediv));
		//if (document.getElementById('alerta')!=null) cuerpo.removeChild(document.getElementById('alerta'));
		//var lw = document.createElement('div');
		var cc;
		cc=document.getElementById(capa_contenedora);
		//lw.setAttribute('id', usediv);
		cc.innerHTML ='<img src=\"../media/img/cargando.gif\" width=\"15\">Cargando...';
		//cuerpo.appendChild(lw);
         //try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");}  catch (e) { alert("Error: Could not load page.");}
         //Show page is loading
         //send data
 		 xmlhttp.open("POST", page,true);
         xmlhttp.onreadystatechange = function(){
                 //Check page is completed and there were no problems.
                 if ((xmlhttp.readyState == 4)) {
                        //Write data returned to page
						var cadena= new String(xmlhttp.responseText);
				
						//alert(cadena.trim());
//						if (cadena.trim()=="OK"){
//							cerrar('cargando');
//							location.href="salones_ls.asp";								
//						}else{				
								//var lw = document.createElement('div');
								//lw.setAttribute('id', 'alerta');
								//cerrar('cargando');	
								//cuerpo.appendChild(lw);			
	                        	cc.innerHTML = cadena.trim();
						//}
						
                 }
         }
        
		 xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		//alert(campos);

	
	xmlhttp.send(campos);
         
         //Stop any link loading normaly
         return false;
}

function fnQuitaAND(texto) {

texto=texto.replace('&','#33#');

return texto;

}

function pag_amp(p){
	cuerpo=document.getElementsByTagName('body')[0];
	var frm = document.createElement('form');
	frm.setAttribute("id","frmpag_amp");
	frm.setAttribute("method","post");
	frm.setAttribute("action","auxiliares_amp.asp");
	var pag = document.createElement('input');
	pag.setAttribute("type","hidden");
	pag.setAttribute("name","page");
	pag.setAttribute("id","page");
	pag.setAttribute("value",p);
	
	frm.appendChild(pag);
	cuerpo.appendChild(frm);
	frm.submit();
}

function paginar(p,o,s){
//	cuerpo=document.getElementsByTagName('body')[0];
//	var frm = document.createElement('form');
//	frm.setAttribute("id","frmpag_amp");
//	frm.setAttribute("method","post");
//	frm.setAttribute("action","auxiliares_amp.asp");
//	var pag = document.createElement('input');
//	pag.setAttribute("type","hidden");
//	pag.setAttribute("name","page");
//	pag.setAttribute("id","page");
//	pag.setAttribute("value",p);
//	var ord = document.createElement('input');
//	ord.setAttribute("type","hidden");
//	ord.setAttribute("name","select_order");
//	ord.setAttribute("id","select_order");
//	ord.setAttribute("value",o);
//	var subc = document.createElement('input');
//	subc.setAttribute("type","hidden");
//	subc.setAttribute("name","select_mostrar");
//	subc.setAttribute("id","select_mostrar");
//	subc.setAttribute("value",o);
//	
//	frm.appendChild(pag);
//	frm.appendChild(ord);
//	frm.appendChild(subc);
//	cuerpo.appendChild(frm);
//	frm.submit();
	var frm = document.getElementById("filtros_opciones");
	frm.action="auxiliares_amp.asp";
	var pag = document.createElement('input');
	pag.setAttribute("type","hidden");
	pag.setAttribute("name","page");
	pag.setAttribute("id","page");
	pag.setAttribute("value",p);
	frm.appendChild(pag);
	frm.submit();
}

function muestra(valor){
	document.getElementById("select_mostrar").value=valor;
	document.getElementById("filtros_opciones").action="auxiliares_amp.asp";
	document.getElementById("filtros_opciones").submit();
}
function orden(valor){
	document.getElementById("select_order").value=valor;
	document.getElementById("filtros_opciones").action="auxiliares_amp.asp";
	document.getElementById("filtros_opciones").submit();
}

function verficha(idf,cod){
	cuerpo=document.getElementsByTagName('body')[0];
	var frm = document.createElement('form');
	frm.setAttribute("id","frmficha");
	frm.setAttribute("method","post");
	frm.setAttribute("action","ficha.asp");
	var id = document.createElement('input');
	id.setAttribute("type","hidden");
	id.setAttribute("name","idficha");
	id.setAttribute("id","idficha");
	id.setAttribute("value",idf);	
	frm.appendChild(id);
	var codigo = document.createElement('input');
	codigo.setAttribute("type","hidden");
	codigo.setAttribute("name","codigo");
	codigo.setAttribute("id","codigo");
	codigo.setAttribute("value",cod);	
	frm.appendChild(codigo);
	cuerpo.appendChild(frm);
	frm.submit();
		
}