// JavaScript Document
function displayBlock(id,a,t) {
	document.getElementById(id).style.display=a;
	insereHTML(a,t);
}
function insereHTML(v,t) {
	var html;
	var texto;
	var tipo;
	if (v=="block") {
		texto="Fechar o vídeo";
		tipo="none";
	} else {
		tipo="block";
		if (t=="fuji") { texto="Veja um vídeo sobre as 36 vistas do Monte Fuji"; }
		if (t=="henri") { texto="Veja um vídeo sobre as 36 vistas da Torre Eiffel por Henri Rivière"; }
		if (t=="juillard") { texto="Veja um vídeo sobre as 36 vistas da Torre Eiffel por André Juillard"; }
		if (t=="cristo") { texto="Veja um vídeo sobre as 36 vistas do Cristo Rendentor"; }
	}
	html="<a href=\"javascript:displayBlock('youtube','"+tipo+"','"+t+"');\"><strong>"+texto+"</strong></a>";
	document.getElementById("displayYoutube").innerHTML=html;
}
function changeSrc(e,img,a) {
	if(a=="hover") {
		document.getElementById(e).src="img/"+img+"Over.jpg";
	}
	if (a=="out") {
		document.getElementById(e).src="img/"+img+".jpg";
	}
}
function acertaHeight() {
	/*document.getElementById('columLeftContent').style.height;*/
}
function SetBorder(e,b,o) {
	var op, vis;
	if (o=='true') {
		op = '0.5';
		vis = 'hidden';
	} else {
		op = '1';
		vis = 'visible';
	}
	document.getElementById('foto'+e).style.border=b;
	document.getElementById('foto'+e).style.opacity=op;
	document.getElementById('msg'+e).style.visibility=vis;
	
}
function enviaForm() {
	if (document.getElementById("nome").value.length<3) {
		alert("O campo 'nome' deve possuir no minimo 3 caracteres.");
	} else if (document.getElementById("titulo").value.length<3) {
		alert("Insira um titulo para a imagem, com mais de 3 caracteres.");
	} else if (document.getElementById("legenda").value.length<10) {
		alert("Insira uma legenda com no minimo 10 caracteres.");
	} else if (document.getElementById("file").value.length<3) {
		alert("Insira uma imagem para ser carregada.");
	} else if (checkMail(document.getElementById("email").value)==true) {
		document.getElementById("enviaImagem").submit();
	} else {
		alert("Insira um e-mail valido.");
	}
}
function checkMail(mail) {
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if (typeof(mail) == "string") {
        if(er.test(mail)) { return true; }
    } else if (typeof(mail) == "object") {
			if (er.test(mail.value)) { return true; }
    } else { return false; }
}