window.onload = function(){ini();};

function ini(){
	var get=location.search;
	var bloque=get.substring(get.indexOf('bq')+3,get.indexOf('&'));
	var usu=get.substring(get.indexOf('usu')+0,25);
	if (get=="" || bloque=="inicio" || usu!=''){
		traeContenido('inicio.php','principal');
	}
}

function llama(url,contenedor){
	contenedor = contenedor || 'cuerpo'; // Valor por defecto
	traeContenido(url,contenedor);
	if (contenedor!='foto_galeria'){
		iniciaFotos();
	}
}

function escribe(){
	var valores='asunto='+document.getElementById('asunto').value+
				'&nombre='+document.getElementById('nombre').value+
				'&correo='+document.getElementById('correo').value+
				'&telefono='+document.getElementById('nombre').value+
				'&mensaje='+document.getElementById('mensaje').value+
				'&imagetext='+document.getElementById('imagetext').value+
				'&enviar='+document.getElementById('enviar').value;
	if (document.getElementById('mensaje').value==''){
		alert('No ha escrito nada en el mensaje...');
		document.getElementById('mensaje').focus();
	}else if (document.getElementById('imagetext').value==''){
		alert('Es necesario copiar lo que dice la imagen para evitar spam');
		document.getElementById('imagetext').focus();
	}else{
		traeContenidoPOST('inicio.php?bq=escribe','cuerpo',valores);
	}
}
function apuntarse(){
	var valores='correo='+document.getElementById('correo').value;
	if (document.getElementById('correo').value=='Tu email' ||
		document.getElementById('correo').value==''){
		alert('No se ha escrito nada en la casilla del correo');
		document.getElementById('correo').focus();
	}else{
		traeContenidoPOST('inicio.php?bq=apuntarse','tapiz',valores);
	}
}function habilita(){
	var valores='usuariOld='+document.getElementById('usuariOld').value+
				'&usuario='+document.getElementById('usuario').value;
	if (document.getElementById('usuario').value==''){
		alert('Por favor, indícanos cómo debemos llamarte');
		document.getElementById('usuario').focus();
	}else{
		traeContenidoPOST('inicio.php?bq=habilita','principal',valores);
	}
}