function redond(){
	Nifty("#content1","big transparent fixed-height");
	Nifty("#content2","big transparent fixed-height");
	Nifty("#content3","big transparent fixed-height");
	Rounded("#formulario","big transparent");
	Rounded("#error","big transparent fixed-height");
}

function swap(n){
	var tmp= $('ic'+n).style.zIndex;
	$('ic'+n).style.zIndex= $('ic'+n+'b').style.zIndex;
	$('ic'+n+'b').style.zIndex= tmp;
}

function mostrar(n){
	var n= parseInt(n) || 0;
	var texto= new Array('','DISEÑO','DESARROLLO','BUSCADORES');
	if (n!=1){
		$('ic1').style.zIndex= 1;
		$('ic1b').style.zIndex= 2;
		$('content1').style.display= 'none';
	}
	if (n!=2){
		$('ic2').style.zIndex= 1;
		$('ic2b').style.zIndex= 2;
		$('content2').style.display= 'none';
	}
	if (n!=3){
		$('ic3').style.zIndex= 1;
		$('ic3b').style.zIndex= 2;
		$('content3').style.display= 'none';
	}
	swap (n);
	$('bla').innerHTML= texto[n];
	$('content'+n).style.display= 'block';
}

function createRequestObject() {
	var ro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer") {
		ro = new ActiveXObject("Microsoft.XMLHTTP");	
	} else {
		ro = new XMLHttpRequest();	
	}
	return ro;
}

var http = createRequestObject();

function trim (txt){
	return txt.replace(/^s+|s+$/g,'');
}

function validarForm(){
	var nombre= trim($('nombre').value);
	var email= trim($('email').value);
	var telefono= trim($('telefono').value);
	var coment= trim($('coment').value);
	
	if ((nombre == '') || (email == '') || (telefono == '') || (coment == '')){
		$('error').innerHTML= '<br><br><center>¡ATENCIÓN!</center><br><br>Rellene todos los campos del formulario para que podamos contactar con usted.<br><br><center><a href="javascript:;" onclick="resetError();">CERRAR</a></center><br><br>';
		Rounded("#error","big transparent fixed-height");
		$('error').style.display= 'block';
	} else {
		enviarForm();
	}
}

function enviarForm(){
	var nombre= $('nombre').value;
	var email= $('email').value;
	var telefono= $('telefono').value;
	var coment= $('coment').value;
	
	$('error').style.display= 'block';
	
	var url_envio = 'mailer.php';
	http.open('post',url_envio,true);
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.setRequestHeader('Accept-Charset', 'UTF-8');
	http.onreadystatechange = handleenviarForm;
	http.send('nombre='+nombre+'&email='+email+'&telefono='+telefono+'&comentario='+coment);
}

function handleenviarForm(){
	if(http.readyState == 4) {
		var txt = http.responseText;
		if (txt == 'ERROR'){
			$('error').innerHTML= '<br><br>Se produjo un error.<br>Inténtelo de nuevo más tarde.<br><br><center><a href="javascript:;" onclick="resetError(1);">VOLVER</a></center><br><br>';
			Rounded("#error","big transparent fixed-height");
		} else {
			$('error').style.display= 'none';
			sdcHide();
			$('nombre').value='';
			$('email').value='';
			$('telefono').value='';
			$('coment').value='';
			
		}
	}
}

function resetError(cerrar){
	var cerrar= cerrar || 0;
	$('error').style.display= 'none';
	$('error').innerHTML= '<br><br><img src="imagenes/loading.gif" border="0" hspace="10" align="absmiddle">enviando datos...<br><br><br>';
	Rounded("#error","big transparent fixed-height");
	if (cerrar){
		sdcHide();
		$('nombre').value='';
		$('email').value='';
		$('telefono').value='';
		$('coment').value='';
	}
}