// Arredondamento de valores DZ Stats
function Arredonda( valor , casas ){
   var novo = Math.round( valor * Math.pow( 10 , casas ) ) / Math.pow( 10 , casas );
   return( novo );
}

// Links Externos
	jQuery(function() {
		jQuery('a[rel*=externo]').click( function() {
			window.open(this.href);
			return false;
		});
	});
	
	jQuery(document).ready(function() {
		
// DZ Stats
		var pVisible = false;
		jQuery(".stats a.explica").click( function() {
            if(pVisible){ pVisible = false; }else{ pVisible = true; }
			jQuery("ul.contador li p").slideToggle();
			return false;
		});
		jQuery(".stats a.saber").click( function() {
	        if(pVisible){				
				jQuery("ul.contador li p").css("display", "block");				
			}else{				
				jQuery("ul.contador li p").css("display", "none");				
			}
			jQuery("ul.contador li.outros").slideToggle();
			return false;
		});
		
// Filtro de Tags
		jQuery("div.mostraEsconde a.mostra").click( function() {
			jQuery(this).toggleClass("esconde");
			if (jQuery(this).hasClass("esconde")) {
				jQuery("div.filtroTags ul.outras").fadeIn();
			}else{
				jQuery("div.filtroTags ul.outras").slideUp("fast");
			}
			return false;
		});
		
// Imagens de Clientes
		jQuery("div.filtroClientes ul.clientes li a.logo").mouseover( function() {
			jQuery("img",this).css("margin-top","-75px");
		});
		jQuery("div.filtroClientes ul.clientes li a.logo").mouseout( function() {
			jQuery("img",this).css("margin-top","0");
		});
	});

// funcao para criacao de cookies
function GerarCookie(strCookie, strValor, lngDias){
    var dtmData = new Date();
    if(lngDias) {
        dtmData.setTime(dtmData.getTime() + (lngDias * 60 * 1000));
        var strExpires = "; expires=" + dtmData.toGMTString();
    } else {
        var strExpires = "";
    }
    document.cookie = strCookie + "=" + strValor + strExpires + "; path=/";
}

// Verificao formulario comentarios
function ValidaFormComentarios(FormLogin){	
	if (FormLogin.txtNome.value == '') {
		FormLogin.txtNome.focus();
		document.getElementById("txtNome_MSG").innerHTML = 'Por favor, digite seu nome.';
		return false;
	} else {
		document.getElementById("txtNome_MSG").innerHTML = '';
	}
	
	if (!FormLogin.txtEmail.value.match(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/)) {
		FormLogin.txtEmail.focus();
		document.getElementById("txtEmail_MSG").innerHTML = 'Preencha corretamente seu email.';
		return false;
	} else {
		document.getElementById("txtEmail_MSG").innerHTML = '';
	}
	
	if (FormLogin.txtComentario.value == '') {
		FormLogin.txtComentario.focus();
		document.getElementById("txtComentario_MSG").innerHTML = 'Digite o seu comentário.';
		return false;
	} else {
		document.getElementById("txtComentario_MSG").innerHTML = '';
	}
	
	if (FormLogin.txtCap.value == '') {
		FormLogin.txtCap.focus();
		document.getElementById("txtCap_MSG").innerHTML = 'Digite o código de segurança.';
		return false;
	} else {
		document.getElementById("txtCap_MSG").innerHTML = '';
	}
}

// Verificao formulario cadastro
function ValidaFormCadastro(FormLogin){	
	if (FormLogin.txtNome.value == '') {
		FormLogin.txtNome.focus();
		document.getElementById("txtNome_MSG").innerHTML = 'Por favor, digite seu nome.';
		return false;
	} else {
		document.getElementById("txtNome_MSG").innerHTML = '';
	}
	
	if (!FormLogin.txtEmail.value.match(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/)) {
		FormLogin.txtEmail.focus();
		document.getElementById("txtEmail_MSG").innerHTML = 'Preencha corretamente seu email.';
		return false;
	} else {
		document.getElementById("txtEmail_MSG").innerHTML = '';
	}
}

// Verificao formulario expresso
function ValidaFormCadastroHome(FormLogin){	
	if (FormLogin.txtNomeExpresso.value == '') {
		FormLogin.txtNomeExpresso.focus();
		return false;
	}
	
	if (!FormLogin.txtEmailExpresso.value.match(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/)) {
		FormLogin.txtEmailExpresso.focus();
		return false;
	}
	
	GerarCookie("nomeDZ", FormLogin.txtNomeExpresso.value, 7); // tempo em horas
	GerarCookie("emailDZ", FormLogin.txtEmailExpresso.value, 7);
}

// Verificao formulario contato
function ValidaFormContato(FormLogin){	
	if (FormLogin.txtNome.value == '') {
		FormLogin.txtNome.focus();
		document.getElementById("txtNome_MSG").innerHTML = 'Por favor, digite seu nome.';
		return false;
	} else {
		document.getElementById("txtNome_MSG").innerHTML = '';
	}
	
	if (!FormLogin.txtEmail.value.match(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/)) {
		FormLogin.txtEmail.focus();
		document.getElementById("txtEmail_MSG").innerHTML = 'Preencha corretamente seu email.';
		return false;
	} else {
		document.getElementById("txtEmail_MSG").innerHTML = '';
	}
	
	if (FormLogin.txtMensagem.value == '') {
		FormLogin.txtMensagem.focus();
		document.getElementById("txtMensagem_MSG").innerHTML = 'Por favor, digite sua mensagem.';
		return false;
	} else {
		document.getElementById("txtMensagem_MSG").innerHTML = '';
	}
	
	if (FormLogin.txtCap.value == '') {
		FormLogin.txtCap.focus();
		document.getElementById("txtCap_MSG").innerHTML = 'Por favor, digite o código de segurança.';
		return false;
	} else {
		document.getElementById("txtCap_MSG").innerHTML = '';
	}
}

function ValidaFormOrcamento(FormLogin){	
	if (FormLogin.txtNomeC.value == '') {
		FormLogin.txtNomeC.focus();
		document.getElementById("txtNomeC_MSG").innerHTML = 'Por favor, digite seu nome.';
		return false;
	} else {
		document.getElementById("txtNomeC_MSG").innerHTML = '';
	}
	
	if (!FormLogin.txtEmailC.value.match(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/)) {
		FormLogin.txtEmailC.focus();
		document.getElementById("txtEmailC_MSG").innerHTML = 'Preencha corretamente seu email.';
		return false;
	} else {
		document.getElementById("txtEmailC_MSG").innerHTML = '';
	}
	
	if (FormLogin.txtTelefoneC.value == '') {
		FormLogin.txtTelefoneC.focus();
		document.getElementById("txtTelefoneC_MSG").innerHTML = 'Por favor, digite seu telefone.';
		return false;
	} else {
		document.getElementById("txtTelefoneC_MSG").innerHTML = '';
	}
	
	if (FormLogin.txtEmpresaC.value == '') {
		FormLogin.txtEmpresaC.focus();
		document.getElementById("txtEmpresaC_MSG").innerHTML = 'Por favor, digite sua empresa.';
		return false;
	} else {
		document.getElementById("txtEmpresaC_MSG").innerHTML = '';
	}
	
	if (FormLogin.txtCNPJC.value == '') {
		FormLogin.txtCNPJC.focus();
		document.getElementById("txtCNPJC_MSG").innerHTML = 'Por favor, digite o CNPJ da sua empresa.';
		return false;
	} else {
		document.getElementById("txtCNPJC_MSG").innerHTML = '';
	}
	
	if (FormLogin.txtCapC.value == '') {
		FormLogin.txtCapC.focus();
		document.getElementById("txtCapC_MSG").innerHTML = 'Por favor, digite o código de segurança.';
		return false;
	} else {
		document.getElementById("txtCapC_MSG").innerHTML = '';
	}
}

function ValidaFormCurriculo(FormLogin){	
	if (FormLogin.txtNomeCurriculo.value == '') {
		FormLogin.txtNomeCurriculo.focus();
		document.getElementById("txtNomeCurriculo_MSG").innerHTML = 'Por favor, digite seu nome.';
		return false;
	} else {
		document.getElementById("txtNomeCurriculo_MSG").innerHTML = '';
	}
	
	if (!FormLogin.txtEmailCurriculo.value.match(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/)) {
		FormLogin.txtEmailCurriculo.focus();
		document.getElementById("txtEmailCurriculo_MSG").innerHTML = 'Preencha corretamente seu email.';
		return false;
	} else {
		document.getElementById("txtEmailCurriculo_MSG").innerHTML = '';
	}
	
	if (FormLogin.file_original.value == '') {
		FormLogin.file_original.focus();
		document.getElementById("file_original_MSG").innerHTML = 'Arquivo inválido. <br />Formatos permitidos: .doc e .pdf';
		return false;
	} else {
		arquivo = (FormLogin.file_original.value);
		tipo = arquivo.substring(arquivo.length-4,arquivo.length);
		tipo = tipo.toLowerCase()
		
		if ((tipo == ".pdf") || (tipo == ".doc")) {} else {
			FormLogin.file_original.focus();
			document.getElementById("file_original_MSG").innerHTML = 'Arquivo inválido. <br />Formatos permitidos: .doc e .pdf';
			return false;
		}
		document.getElementById("file_original_MSG").innerHTML = '';
	}
	
	if (FormLogin.txtCapCurriculo.value == '') {
		FormLogin.txtCapCurriculo.focus();
		document.getElementById("txtCapCurriculo_MSG").innerHTML = 'Por favor, digite o código de segurança.';
		return false;
	} else {
		document.getElementById("txtCapCurriculo_MSG").innerHTML = '';
	}
}

//Inicia google maps
function IniciaMapa() {
    var myOptions = {
      zoom: 16,
      center: new google.maps.LatLng(-30.022579, -51.201277),
      mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
      navigationControl: true,
      navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	var image = 'imagens/bullet_mapa_dz.png';
	var myLatLng = new google.maps.LatLng(-30.022589, -51.201055);
  	var beachMarker = new google.maps.Marker({
      position: myLatLng,
      map: map,
      icon: image
	  //title:"Clique para mais informações"
  	});
	//var contentString = '<div id="content" style="height:300px;">'+
    //'<p><b>DZ Estúdio - A gente pensa internet</b><br />' +
    //'Tobias da Silva, 22 / 202<br />Porto Alegre - RS, 90570-020<br />(0xx)51 3084-4313'+
    //'</div>';
	//var infowindow = new google.maps.InfoWindow({
	//	content: contentString,
	//	Height: '300px'
	//});
	
	//google.maps.event.addListener(beachMarker, 'click', function() {
	//  infowindow.open(map,beachMarker);
	//});
}
