//Crea un objeto XML-http
function getXmlHttpObject() {
	var xmlhttp;
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {
				try {
					xmlhttp = new XMLHttpRequest();
				}
				catch (e) {
					xmlhttp = false;
					alert ('Error');
				}
			}
		}
	return xmlhttp;
}

//Porcesar la peticion XMLHttpReuest
function procesarajax(archivo,id,metodo,datos) {
	//Obtener el objeto XMLHttpRequest a utilizar
	xmlhttp = getXmlHttpObject();
	if (metodo=="get") {
		if (datos!="") {
			document.getElementById(datos).disabled=false;
		}
		xmlhttp.open("GET",archivo,true);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState==1) {
				document.getElementById(id).innerHTML = "<img src='imagenes/cargar.gif' width='17' style='margin-right:5px' /> Cargando ...";
			} else if (xmlhttp.readyState==4 && xmlhttp.status==200) {
				document.getElementById(id).innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null); //Como es GET no mandamos nada en al cuerpo
	} else {
		xmlhttp.open("POST",archivo,true);
		xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState==1) {
				document.getElementById(id).innerHTML = "<div style='padding:5px 0px 5px 0px;text-align:center'><img src='imagenes/cargar.gif' style='margin-right:10px' /> Cargando ...</div>";
			} else if (xmlhttp.readyState==4 && xmlhttp.status==200) {
				document.getElementById(id).innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(datos); //Como es GET no mandamos nada en al cuerpo
	}
}

//Recoleccion de datos del formulario
function datosformulario (formulario) {
	var datos="";
	//Recorro el formulario obteniendo los valores
	for (var i=0;i<formulario.elements.length;i++) {
		datos +=formulario.elements[i].name+"="+escape(formulario.elements[i].value)+"&";
	}
	return datos;
}
//Ingresar formulario
function ingresarform(formulario,archivo,id) {
	var datos = datosformulario(formulario);
	datos = datos.replace(/\+/g,'*'); //No se banca el caracter +
	procesarajax(archivo,id,"post",datos);
}

function mostrar(nombre,foto,idservicio){  
document.getElementById(idservicio+'foto1').style.opacity='.60';
document.getElementById(idservicio+'foto2').style.opacity='.60';
document.getElementById(idservicio+'foto3').style.opacity='.60';
document.getElementById(idservicio+'foto4').style.opacity='.60';
document.getElementById(idservicio+'foto1').style.filter='alpha(opacity=50)';
document.getElementById(idservicio+'foto2').style.filter='alpha(opacity=50)';
document.getElementById(idservicio+'foto3').style.filter='alpha(opacity=50)';
document.getElementById(idservicio+'foto4').style.filter='alpha(opacity=50)';
document.getElementById(nombre).style.opacity='1';
document.getElementById(nombre).style.filter='alpha(opacity=100)';
document.getElementById(idservicio+'foto').src=foto;
}
function sintrans(nombre){  
valor=document.getElementById(nombre).style.opacity;
if (valor!='1') {
	document.getElementById(nombre).style.opacity='.99';
	document.getElementById(nombre).style.filter='alpha(opacity=100)';
	}
} 
function trans(nombre){  
valor=document.getElementById(nombre).style.opacity;
if (valor!='1') {
	document.getElementById(nombre).style.opacity='.50';
	document.getElementById(nombre).style.filter='alpha(opacity=50)';
	}
}
function abrir(archivo,w,h,nombre) { 
		var windowprops= "top=0,left=0,toolbar=no,location=no,status=no,menubar=no,scrollbars=no, resizable=no,width=" + w + ",height=" + h;
	window.open(archivo,nombre,windowprops);
} 
