function checkforblanks() {
	for (var i=0; i<arguments.length; i+=2) {
		if (!arguments[i]) {
			alert("El campo " + arguments[i+1] + " es obligatorio.");
			return false;
		}
	}
	return true;
}

function validate1() {
	var isFull = checkforblanks(document.getElementById("nombre").value, "[Nombre]",
	document.getElementById("telefono").value, "[Teléfono]",
	document.getElementById("horario").value, "[Horario de contacto]");
	if (!isFull) {
		return false;
	}
}

function validate2() {
	var isFull = checkforblanks(document.getElementById("nombre").value, "[Nombre / Empresa]",
	document.getElementById("email").value, "[E-Mail]",
	document.getElementById("comentarios").value, "[Comentarios]");
	if (!isFull) {
		return false;
	}
	var dirmail = document.getElementById("email").value;
	var filter = /^.+@.+\..{2,4}$/;
	if (!filter.test(dirmail)) {
		alert("La dirección de correo electrónico no es correcta.");
		return false;
	}
}

function MailLink (texto,usuario,dominio,tld) {
	var arroba = '@';
	var punto = '.';
	var etiqueta = 'ma' + '' + 'il';
	var dospuntos = 'to:';
	var localizador = usuario;
	localizador = localizador + arroba + dominio;
	localizador = localizador + punto + tld;
	if(texto=='') {
		texto = localizador;
	}
	document.write('<a href="' + etiqueta + dospuntos + localizador + '">' + texto + '</a>');
}

function fCapa(id) {
	if (document.getElementById(id).style.display=='block') {
		document.getElementById(id).style.display='none';
	} else {
		document.getElementById(id).style.display='block';
	}
}

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

function showDark() {
	document.getElementById("dark").style.display = 'inline';
	document.getElementById("dark").style.height = getDocHeight()+'px';
}

function showVideo(parametro) {
	var strVideo = '';
	strVideo = strVideo + '<object width="494" height="400">';
	strVideo = strVideo +  '<param name="movie" value="http://www.youtube.com/v/'+parametro+'&color1=0xb1b1b1&color2=0xcfcfcf&hl=en_US&feature=player_embedded&fs=1&rel=0"></param>';
	strVideo = strVideo +  '<param name="allowFullScreen" value="true"></param>';
	strVideo = strVideo +  '<param name="allowScriptAccess" value="always"></param>';
	strVideo = strVideo +  '<embed src="http://www.youtube.com/v/'+parametro+'&color1=0xb1b1b1&color2=0xcfcfcf&hl=en_US&feature=player_embedded&fs=1&rel=0" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="494" height="324"></embed>';
	strVideo = strVideo +  '</object>';
	strVideo = strVideo + '<p><a href="javascript:hideVideo()">CERRAR</a></p>';
	document.getElementById("marcovideo").innerHTML = strVideo;
	document.getElementById("marcovideo").style.display = 'inline';

	var windowY = f_clientHeight();
	var scrollY = f_scrollTop();
	var divY = document.getElementById("marcovideo").offsetHeight;
	var topY = parseInt(windowY/2)-parseInt(divY/2)+scrollY;
	var strY = topY+'px';

	var windowX = f_clientWidth();
	var scrollX = f_scrollLeft();
	var divX = document.getElementById("marcovideo").offsetWidth;
	var leftX = parseInt(windowX/2)-parseInt(divX/2);
	var strX = leftX+'px';

	document.getElementById("marcovideo").style.top = strY;
	document.getElementById("marcovideo").style.left = strX;
	//showDark();
}

function showFoto(n,w,h) {
	var strImg = "catalogo/raelma-"+n+'.jpg';
	var newHtml = '<a href="javascript:hideFoto()"><img class="galeria" width="'+w+'" height='+h+'" src="'+strImg+'" alt="cerrar imagen" /></a>';
	newHtml = newHtml + '<a href="javascript:hideFoto()">CERRAR</a>';
	document.getElementById("marcofoto").innerHTML = newHtml;
	document.getElementById("marcofoto").style.display = 'inline';
	
	var windowY = f_clientHeight();
	var scrollY = f_scrollTop();
	var divY = document.getElementById("marcofoto").offsetHeight;
	var topY = parseInt(windowY/2)-parseInt(divY/2)+scrollY;
	var strY = topY+'px';

	var windowX = f_clientWidth();
	var scrollX = f_scrollLeft();
	var divX = document.getElementById("marcofoto").offsetWidth;
	var leftX = parseInt(windowX/2)-parseInt(divX/2);
	var strX = leftX+'px';

	document.getElementById("marcofoto").style.top = strY;
	document.getElementById("marcofoto").style.left = strX;
	//showDark();
}

function hideFoto(dato) {
	document.getElementById("marcofoto").innerHTML = '';
	document.getElementById("marcofoto").style.display = 'none';
	//document.getElementById("dark").style.display = 'none';
}

function hideVideo(dato) {
	document.getElementById("marcovideo").innerHTML = '';
	document.getElementById("marcovideo").style.display = 'none';
	//document.getElementById("dark").style.display = 'none';
}
