// JavaScript Document

function trocaimg(oid){
	var vti_imgt = oid.src; //document.getElementById(oid).src;
	var vti_pasta = "media/images/static/";
	var bloco2 = vti_imgt.split("/");
	var bloco = bloco2[bloco2.length-1].split(".");
	var vti_img = bloco[0];
	if(String(vti_img).indexOf('over') > 0 ){
		vti_img = vti_img.slice(0, vti_img.length-5);
		//document.getElementById(oid)
		oid.src = vti_pasta + vti_img + ".png";
	} else {
		//document.getElementById(oid)
		oid.src = vti_pasta + vti_img + "_over.png";
	}
}

function acertamenucursos(){
	/*if (document.all){
		alert(document.body.clientWidth);
		alert(document.getElementById('m_cursos').style.left);
		document.getElementById('m_cursos').style.left = String(parseInt(parseInt(document.body.clientWidth) / 2 - 133) + "px");
	} else {
		alert(document.body.clientWidth);
		alert(document.getElementById('m_ipf').style.left);
		document.getElementById('m_cursos').style.left = String(parseInt(parseInt(window.innerWidth) / 2 - 133) + "px");
	}*/
	document.getElementById('m_cursos').style.left = String(parseInt(parseInt(document.body.clientWidth) / 2 - 133) + "px");
}

function acertamenuipf(){
	document.getElementById('m_ipf').style.left = String(parseInt(parseInt(document.body.clientWidth) / 2 + 20) + "px"); // + 178
}

function acertamenuactividade(){
	document.getElementById('m_actividade').style.left = String(parseInt(parseInt(document.body.clientWidth) / 2 + 75) + "px"); // + 20
}

function acertamenugalerias(){
	document.getElementById('m_galerias').style.left = String(parseInt(parseInt(document.body.clientWidth) / 2 + 230) + "px"); // + 178
}

// ff mac
function acertamenucursos_mac(){
	document.getElementById('m_cursos').style.left = String(parseInt(parseInt(document.body.clientWidth) / 2 - 121) + "px");
}

function acertamenuipf_mac(){
	document.getElementById('m_ipf').style.left = String(parseInt(parseInt(document.body.clientWidth) / 2 + 32) + "px");  // 184
}

function acertamenuactividade_mac(){
	document.getElementById('m_actividade').style.left = String(parseInt(parseInt(document.body.clientWidth) / 2 + 82) + "px"); // 33
}

function acertamenugalerias_mac(){
	document.getElementById('m_galerias').style.left = String(parseInt(parseInt(document.body.clientWidth) / 2 + 230) + "px"); // + 178
}




// enviar amigo
function acertaenviaramigo(){
	document.getElementById('d_enviaramigo').style.display = 'none';
	document.getElementById('d_enviaramigo').style.left = String(parseInt(parseInt(document.body.clientWidth) / 2 + 40) + "px");
}

function myResize(){
	acertamenucursos();
	acertamenuipf();
	acertamenuactividade();
	acertaenviaramigo();
}

function limpacamposamigo(){
	document.getElementById('nomeamigo').value = "";
	document.getElementById('emailamigo').value = "";
	document.getElementById('seunome').value = "";
	document.getElementById('mensagemamigo').value = "";
}

function mostramenu(oid){
	if(document.getElementById(oid).style.display == 'none'){
		document.getElementById(oid).style.display = 'block';
	} else {
		document.getElementById(oid).style.display = 'none';
	}
}

function escondemenus(){
	document.getElementById('m_cursos').style.display = 'none';
	document.getElementById('m_ipf').style.display = 'none';
	document.getElementById('m_actividade').style.display = 'none';
	document.getElementById('m_galerias').style.display = 'none';
}

function verificadados(){
	if(document.getElementById('nome').value != ""){
		if(document.getElementById('email').value != ""){
			var omail = String(document.getElementById('email').value);
			var tempArray = omail.split("@");
			if(tempArray.length > 1){
				if(tempArray[1].indexOf(".")>2){
					alert('Obrigado por se inscrever na nossa newsletter.');
					return true;
				} else {
					alert("O email não é válido");
					return false;
				}
			} else {
				alert("O email não é válido");
				return false;
			}
		} else {
			alert('Preencha campo "Email", por favor.');
			return false;
		}
	} else {
		alert('Preencha campo "Nome", por favor.');
		return false;
	}
}

function limpaipt(oid){
	if(String(document.getElementById(oid).value)==" nome"){
		document.getElementById(oid).value="";
	}
	if(String(document.getElementById(oid).value)==" email"){
		document.getElementById(oid).value="";
	}
}

function fazurlnewsletter(){
	var url = String(window.location);
	//var meio = url.split("?");
	//document.getElementById('url').value=String(meio[0]);
	document.getElementById('url').value=url;
	document.getElementById('urlamigo').value=url;
}

function fazalerta(){
	var url = String(window.location);
	var meio = url.split("?");
	if(meio.length > 1){
		var outromeio = String(meio[1]).split("=");
		if(String(outromeio[1]) == "1" && String(outromeio[0]) == "msg"){
			alert('Obrigado por se inscrever na nossa newsletter.');
		}
	}
}