// JavaScript Document
function divover(nomediv)
	{
	document.getElementById(nomediv).style.display='';
	if (nomediv=='lst_lang') document.getElementById("nomelang").className="texto_ativo";

	}

function divout(nomediv)
	{
	document.getElementById(nomediv).style.display='none';
	if (nomediv=='lst_lang') document.getElementById("nomelang").className="texto_nao_ativo";
	}

function change_color_area(img1,img2,img3)
	{
	document.getElementById("img_mkt").src="images/img-marketing" + img1 + ".gif";
	document.getElementById("img_des").src="images/img-design" + img2 + ".gif";
	document.getElementById("img_dev").src="images/img-development" + img3 + ".gif";
	}
			

var http_request = false;
function disparaAjax(valorcampo, nomecampo) {
	namefield = nomecampo;
	http_request = false;
	if (window.XMLHttpRequest) { 
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
		} else if (window.ActiveXObject) {
		try {
		http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		try {
   		http_request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
		}
	}

	if (!http_request) {
		alert('Erro.');
		return false;
		}
		
	http_request.onreadystatechange = resultado;
	http_request.open('GET', valorcampo, true);
	http_request.send(null);
}

function resultado() {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
		var resultado = http_request.responseText; // Texto retornado pela requisição do ajax.
		resultado = resultado.replace(/\+/g," "); // Substitue o "+" por um espaço.
		resultado = unescape(resultado); // Desfaz o que a função urlencode();
		document.getElementById(namefield).innerHTML =  resultado;
		} 
		else {
		alert('Ocorreu um erro.');
		}
	}
}

function send_form (formname) {
	var envia='s';
	var message_erro='Encontramos o(s) seguinte(s) erro(s) no seu formul\u00e1rio:<br /><br />';
	
	if (document.getElementById("name_form").value=='') {
		envia='n';
		document.getElementById("name_form").className="input_erro"
		message_erro+="- NOME est\u00e1 em branco<br />"; 
		}

	if (document.getElementById("email_form").value.length != 0 && (document.getElementById("email_form").value.indexOf("@") < 1) || (document.getElementById("email_form").value.indexOf('.') < 7)) {
		document.getElementById("email_form").className="input_erro"
		message_erro+="- EMAIL n\u00e3o \u00e9 v\u00e1lido<br />"; 
		envia='n';
		}

	if (document.getElementById("message_form").value=='') {
		envia='n';
		document.getElementById("message_form").className="text_area_erro"
		message_erro+="- MENSAGEM est\u00e1 em branco<br />"; 
		}
	
	if (envia=='s') {
		document.getElementById("contact_fields").style.visibility="hidden";
		document.getElementById("contact_send").style.visibility="visible";
		document.getElementById("contact_send").style.display="";
//		document.getElementById("ajaxload").style.display="";
		return true;
		}
	else {
		document.getElementById("mess_err_con").innerHTML=message_erro;
		return false;
		}  
}
  
function verify_len(field_value, field_name, field_class_erro) {
	if (field_value=="") {
		document.getElementById(field_name).className=field_class_erro
	}  
	else {
		document.getElementById(field_name).className=''
	}  
}
 
function anav (area_number) {
	document.getElementById("area_"+document.getElementById("area").value).className="";
	document.getElementById("area_"+document.getElementById("area").value).style.fontWeight="";
	document.getElementById("area_"+area_number).style.fontWeight="bold";
	document.getElementById("area_"+area_number).className="link_ativo";
	document.getElementById("area").value=area_number; 
	pnav("0")

	document.getElementById("pagina_0").style.display="";
	document.getElementById("pagina_1").style.display="";
	document.getElementById("pagina_2").style.display="";
	document.getElementById("pagina_3").style.display="";

	if (area_number=="design" | area_number=="sistemas") {
		document.getElementById("pagina_3").style.display="none";
	}

	if (area_number=="outros") {
		document.getElementById("pagina_1").style.display="none";
		document.getElementById("pagina_2").style.display="none";
		document.getElementById("pagina_3").style.display="none";
	}
	
	document.getElementById("box_area_portfolio_2").style.display="";
	document.getElementById("box_area_portfolio_1").style.display="";
	document.getElementById("job_page_box").style.display="";
}
  
function pnav(pagina) {
	document.getElementById("pagina_"+document.getElementById("page_ac").value).className="botao";
	document.getElementById("page_ac").value=pagina; 
	document.getElementById("pagina_"+pagina).className="botao_hover";
	disparaAjax('portfolio_change.asp?pag='+ pagina + '&area='+document.getElementById('area').value,'box_area_portfolio_change')
}

function showhide (divname,newstatus,valorsite) {
	
	document.getElementById(divname).style.display=newstatus;
	if (newstatus=='none' && divname=='popup') {
		document.getElementById("area_popup").style.display="none";
		document.getElementById("popup_pic_main").style.display="none";
	}
	
	if (newstatus=='none' && divname=='popup_pic_main') {
		document.getElementById("popup_pic").style.display="none";
	}
}
	
function popsc(divname_s1, newstatus_s1, valorsite_s1) {
	document.getElementById(divname_s1).style.display=newstatus_s1;
	disparaAjax('portfolio_popups.asp?client='+ valorsite_s1, 'area_popup')
}	

function showpic(imgname) {
	document.getElementById("popup_pic_main").style.display='';
	document.getElementById("popup_pic").style.display='';
	document.getElementById("img_popup").src="images/sspopups/" + imgname; 
}
  
function newsletter () {
	disparaAjax('newsletter.asp?email='+ document.getElementById("email").value+'&remover='+document.getElementById("remover").value, 'central_right_top')
}

function send_newsletter () {
	var envia='n';
	var message_erro='';
	
	var valoremail = document.getElementById("email").value;
	if (valoremail.length != 0 && (valoremail.indexOf("@") < 1) || (valoremail.indexOf('.') < 7)) {
		document.getElementById("email").className="input_erro"
		message_erro+="Erro: Por favor, entre com um email v\u00e1lido"; 
		document.getElementById("email").focus()
		document.getElementById("mensagem_news").innerHTML=message_erro;
		return false;


	}
	else {
		newsletter()
	}
}

function verify_email(valoremail) {
	obj.focus();
}

function submenu (newstatus, classeatual,opmenu,nomearea) {
	if (newstatus=='none')
	{
	document.getElementById('menuop'+opmenu).className=classeatual;
	}
	else
	{
	document.getElementById('menuop'+opmenu).className='link_ativo';
	}
	
	showhide('menu_'+nomearea, newstatus);
}

function definicoes (elemento)
	{
	var valoratual = document.getElementById("valoratual").value;
	valortop=document.getElementById(elemento).offsetTop;
	if (valoratual == "") { } else
	{
		document.getElementById(valoratual + "_t").className="def_title_naoativo";
		document.getElementById(valoratual).style.color="#1B1B1B";
		document.getElementById(valoratual+"_l").style.fontWeight="";
		document.getElementById(valoratual+"_l").className="";

	}

	document.getElementById(elemento + "_t").className="def_title_ativo";
	document.getElementById(elemento).style.color="#575847";
	document.getElementById(elemento+"_l").style.fontWeight="bold";
	document.getElementById(elemento+"_l").className="link_ativo";

	document.getElementById("central_def_2").scrollTop=valortop;
	document.getElementById("valoratual").value=elemento;
	}
	
function alterar_news ()
	{
	var valorr = document.getElementById("remover").value;
	
	if (valorr=='N') {
		document.getElementById("Enviar").value='Remover';
		document.getElementById("remover").value='S';
		document.getElementById("txt_remover").innerHTML="Cadastrar email na lista"
		document.getElementById("link_remover").title="Cadastrar email na lista"
		}
	else
	{
		document.getElementById("Enviar").value='Enviar';
		document.getElementById("remover").value='N';
		document.getElementById("txt_remover").innerHTML="Remover email da lista"
		document.getElementById("link_remover").title="Remover email na lista"
	}
	}
	
function areapt(area_number)
{
	document.getElementById("area_"+document.getElementById("area").value).className="";
	document.getElementById("area_"+document.getElementById("area").value).style.fontWeight="";
	document.getElementById("area_"+area_number).style.fontWeight="bold";
	document.getElementById("area_"+area_number).className="link_ativo";
	document.getElementById("area").value=area_number; 
	disparaAjax('portfolio_list.asp?area='+ area_number, 'portfolio')
}
	
function popup(theURL,winName,features,w,h) { //v2.0
  	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	var centro = ''
	if (features=='') {
		
	centro = 'left='+winl+',top='+wint;
	}
	else
	{
	centro = ',left='+winl+',top='+wint;
	}
	window.open(theURL,winName,features+centro);
}
