/*		FUNCION PARA CREAR EL OBJETO AJAX	*/
function Ajax(){
	var xmlhttp=false;
 	try {	
 			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 	} 
 	catch (e) {
 		try {
 			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 		}
 		catch (E) {	xmlhttp = false;	}
 	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function loadImg(showDiv){
//alert(showDiv)
	var msgDiv = document.getElementById(showDiv);
	msgDiv.innerHTML='<div id="loadImg" ><h3><img src="images/loading.gif" border="0" alt="">cargando...</h3></div>';
}

function loadImgMsg(showDiv, msg){
//alert(showDiv)
	var msgDiv = document.getElementById(showDiv);
	msgDiv.innerHTML='<div id="loadImg" ><h3><img src="images/loading.gif" border="0" alt="">'+msg+'...</h3></div>';
}

function abrir(id){
	try{
		var obj = Ajax();
		var params = null;
		var msgDiv = document.getElementById('info');
		var buscadorDiv = document.getElementById('buscador');
		var derechaDiv = document.getElementById('derecha');
		var url='portada.php';
		msgDiv.style.width='543px';
		buscadorDiv.style.display='block';
		derechaDiv.style.display='block';

		switch(id){
			case 'portada': 
					url='portada.php';
					break;
			case 'disenoweb': 
					url='disenoweb.php';
					break;
			case 'desarrollo': 
					url='desarrollo.php';
					break;
			case 'hosting': 
					url='hosting.php';
					break;
			case 'proyectos': 
					url='proyectos.php';
					break;
			case 'contacto':
					buscadorDiv.style.display='none';
					derechaDiv.style.display='none';
					url='contacto.php';
					msgDiv.style.width='800px';
					break;
			default:
				buscadorDiv.style.display='none';
				derechaDiv.style.display='none';
				url='404.php';
				break;
		}

		obj.open('POST',url,true);
		obj.onreadystatechange = function (){
			if(obj.readyState == 1){
				loadImg('info');
			}
			if(obj.readyState == 4){
			
				msgDiv.innerHTML = obj.responseText;
				return;
			}
		}
		obj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		obj.send(params);
	}
	catch(e){ alert(e.message); return;}
}

function enviar_correo(){
	try{
		var nombre	= document.getElementById('nombre');
		var email	= document.getElementById('email');
		var telefono	= document.getElementById('telefono');
		var asunto	= document.getElementById('asunto');
		var comentario	= document.getElementById('comentario');
		
		var valida =  false;
		if(nombre.value==''){
			nombre.className='campo_vacio';
			nombre.focus();
			valida = true;
		}	else { nombre.className='';}

		if(email.value==''){
			email.className='campo_vacio';
			email.focus();
			valida = true;
		}	else { email.className='';}

		if(asunto.value==''){
			asunto.className='campo_vacio';
			asunto.focus();
			valida = true;
		}	else { asunto.className='';}

		if(comentario.value==''){
			comentario.className='campo_vacio';
			comentario.focus();
			valida = true;
		}	else { comentario.className='';}
		if(valida){	return;	}
		

// 		return;
		var info = nombre.value+'|'+email.value+'|'+telefono.value+'|'+asunto.value+'|'+comentario.value;
// 		alert(info);

		obj = new Ajax();
		var msgDiv = document.getElementById('contacto_formulario');

		obj.open('POST','enviar_comentario.php',true);
		obj.onreadystatechange = function (){
			if(obj.readyState == 1 ){
				msgDiv.innerHTML=cargando('contacto_formulario');
			}
			if(obj.readyState == 4 ){
				msgDiv.innerHTML='';
				msgDiv.innerHTML= obj.responseText;
				return;
			}
		}
		obj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		obj.send('info='+info);
	}
	catch(e){ alert(e.error); }
}

function buscarDominio(){
	try{
		var dominio = document.getElementById('dominio');
		var ext = document.getElementById('extencion');
		var msgDiv = document.getElementById('resultadoBusqueda');
		
		loadImgMsg('resultadoBusqueda', 'buscando')
		msgDiv.innerHTML = dominio.value+'.'+ext.value;
		
	}
	catch(e){ alert(e.message); return;}

}

function inicializaSitio(){

}
