//----------------------------FUNÇÃO FLASH-------------------------------------------//

function get_flash(arquivo, largura, altura, bgcolor, id, qualidade, alinhamento,transparente,pgphp) {
	obj = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabsflash/swflash.cab#version=8,0,0,0" width="'+largura+'" height="'+altura+'" id="'+id+'" align="'+alinhamento+'">';
	obj+= '<param name="allowScriptAccess" value="sameDomain" />';
	obj+= '<param name="movie" value="'+arquivo+'" />';
	obj+= '<param name="quality" value="'+qualidade+'" />';
	if(transparente == true) {
		obj+= '<param name="wmode" value="transparent" />';
	}
	obj+= '<param name="bgcolor" value="'+bgcolor+'" />';
	obj+= '<param name="FlashVars" value="pg='+pgphp+'" />';
	obj+= '<embed src="'+arquivo+'" '+((transparente==true)?'wmode="transparent"':'')+'" quality="'+qualidade+'" bgcolor="'+bgcolor+'" FlashVars="pg='+pgphp+'" width="'+largura+'" height="'+altura+'" name="'+id+'" align="'+alinhamento+'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	obj+= '</object>';
	document.write(obj);
}

//----------------------------FUNÇÃO ABAS-------------------------------------------//
function abre(id) {
	if(window.document.getElementById(id).style.display == 'none') { 
		window.document.getElementById(id).style.display = '';
		window.document.getElementById(id).src = 'imagens/seta_up.gif';
	} else { 
		window.document.getElementById(id).style.display = 'none'; 
		window.document.getElementById(id).src = 'imagens/seta_down.gif';
	}
}

//----------------------------FUNÇÃO FALE CONOSCO-------------------------------------------//

function faleConosco() {
	
	var msg = "";
	
	if(window.document.getElementById('nome1').value == ""){
		msg = " - Informe seu nome;\n";
	}
	
	if(window.document.getElementById('empresa1').value == ""){
		msg = msg + " - Informe sua empresa;\n";
	}
	
	if(window.document.getElementById('telefone1').value == ""){
		msg = msg + " - Informe seu telefone;\n";
	}
		
	if(window.document.getElementById('email1').value == ""){
		msg = msg + " - Informe seu e-mail;\n";
	}
	
	if(window.document.getElementById('mensagem1').value == ""){
		msg = msg + " - Digite sua mensagem.\n";
	}
	
	
	if(msg)
		alert("Atenção!\n\n" + msg);
	else
		window.document.FrmFaleConosco.submit();

}


//----------------------------FUNÇÃO FORNECEDOR-------------------------------------------//

function fornecedor() {
	
	var msg = "";
	
	if(window.document.getElementById('nome2').value == ""){
		msg = " - Informe seu nome;\n";
	}
	
	if(window.document.getElementById('empresa2').value == ""){
		msg = msg + " - Informe sua empresa;\n";
	}
	
	if(window.document.getElementById('telefone2').value == ""){
		msg = msg + " - Informe seu telefone;\n";
	}
	
	if(window.document.getElementById('email2').value == ""){
		msg = msg + " - Informe seu e-mail;\n";
	}
	
	
	if(msg)
		alert("Atenção!\n\n" + msg);
	else
		window.document.FrmFornecedor.submit();

}


//----------------------------FUNÇÃO TRABALHE CONOSCO-------------------------------------------//

function trabalheConosco() {
	
	var msg = "";
	
	if(window.document.getElementById('nome').value == ""){
		msg = " - Informe seu nome;\n";
	}
	
	if(window.document.getElementById('email').value == ""){
		msg = msg + " - Informe seu e-mail;\n";
	}
	
	if(window.document.getElementById('telefone').value == ""){
		msg = msg + " - Informe seu telefone;\n";
	}
	
	if(window.document.getElementById('celular').value == ""){
		msg = msg + " - Informe seu telefone celular;\n";
	}
	
	if(window.document.getElementById('endereco').value == ""){
		msg = msg + " - Digite seu endereço.\n";
	}
	
	if(window.document.getElementById('cidade').value == ""){
		msg = msg + " - Digite sua cidade.\n";
	}
	
	if(window.document.getElementById('estado').value == ""){
		msg = msg + " - Digite seu estado.\n";
	}

	if(window.document.getElementById('curso').value == ""){
		msg = msg + " - Digite seu curso.\n";
	}
	
	if(window.document.getElementById('instituicao').value == ""){
		msg = msg + " - Digite sua instituição.\n";
	}
	
	if(window.document.getElementById('turno').value == ""){
		msg = msg + " - Digite seu turno e período.\n";
	}
	
	if(window.document.getElementById('conclusao').value == ""){
		msg = msg + " - Digite a conclusão do curso.\n";
	}
	
	if(window.document.getElementById('atividades').value == ""){
		msg = msg + " - Digite suas atividades extra curriculares.\n";
	}
	
	
	
	if(window.document.getElementById('exp1_empresa').value == ""){
		msg = msg + " - Digite sua empresa.\n";
	}
	
	if(window.document.getElementById('exp1_segmento').value == ""){
		msg = msg + " - Digite seu segmento.\n";
	}
	
	if(window.document.getElementById('exp1_cargo').value == ""){
		msg = msg + " - Digite seu cargo.\n";
	}
	
	if(window.document.getElementById('exp1_periodoinicial').value == ""){
		msg = msg + " - Digite o periodo inicial.\n";
	}
	
	if(window.document.getElementById('exp1_periodofinal').value == ""){
		msg = msg + " - Digite o periodo final.\n";
	}
	
	if(msg)
		alert("Atenção!\n\n" + msg);
	else
		window.document.FrmTrabalheConosco.submit();

}
	
//----------------------------FUNÇÃO BARRA TOPO / BUSCA e LOGIN------------------------------------------//

function barratopo(id){
	
	if(id=="formbusca"){
		
		document.getElementById("formlogin").style.display = "none";
		document.getElementById("formbusca").style.display = "";
		
		document.getElementById("imagembusca").src = "imagens/botao_busca1.gif";
		document.getElementById("imagemlogin").src = "imagens/botao_login2.gif";
		
		document.getElementById("imagembusca").style.cursor = "default";
		document.getElementById("imagemlogin").style.cursor = "pointer";
	} else {
		document.getElementById("formlogin").style.display = "";
		document.getElementById("formbusca").style.display = "none";
		
		document.getElementById("imagembusca").src = "imagens/botao_busca2.gif";
		document.getElementById("imagemlogin").src = "imagens/botao_login1.gif";
		
		document.getElementById("imagembusca").style.cursor = "pointer";
		document.getElementById("imagemlogin").style.cursor = "default";
	}
	
}


//----------------------------FUNÇÃO LEIA MAIS AGENDA------------------------------------------//

function agendamais(id){
	if(document.getElementById(id+"_cha").style.display == ""){
		document.getElementById(id+"_cha").style.display = "none";
		document.getElementById(id+"_cor").style.display = "";
		document.getElementById(id+"_ima").src = "imagens/icon_leiamenos.gif";
	}else{
		document.getElementById(id+"_cha").style.display = "";
		document.getElementById(id+"_cor").style.display = "none";
		document.getElementById(id+"_ima").src = "imagens/icon_leiamais.gif";
	}
}



//----------------------------FUNÇÃO LEIA MAIS PORTFOLIO------------------------------------------//

function leiamais(id){
	if(document.getElementById(id+"_res").style.display == ""){
		document.getElementById(id+"_res").style.display = "none";
		document.getElementById(id+"_cor").style.display = "";
		document.getElementById(id+"_ima").src = "imagens/icon_leiamenos.gif";
	}else{
		document.getElementById(id+"_res").style.display = "";
		document.getElementById(id+"_cor").style.display = "none";
		document.getElementById(id+"_ima").src = "imagens/icon_leiamais.gif";
	}
}

//----------------------------FUNÇÃO GALERIA DE FOTOS PORTFOLIO------------------------------------------//

function fotosmais(id){
	
	if(document.getElementById(id+"_maisfoto").style.display == ""){
		document.getElementById(id+"_maisfoto").style.display = "none";
		document.getElementById(id+"_fot").src = "imagens/icon_foto.gif";

	} else {
		document.getElementById(id+"_maisfoto").style.display = "";
		document.getElementById(id+"_fot").src = "imagens/icon_foto2.gif";
	}
	
}

//----------------------------FUNÇÃO VIDEOS PORTFOLIO------------------------------------------//

function videosmais(id){
	if(document.getElementById(id+"_maisvideos").style.display == ""){
		document.getElementById(id+"_maisvideos").style.display = "none";
		document.getElementById(id+"_videos").src = "imagens/icon_video.gif";
	}else{
		document.getElementById(id+"_maisvideos").style.display = "";
		document.getElementById(id+"_videos").src = "imagens/icon_video2.gif";
	}
}

//----------------------------FUNÇÃO RESIZE BACKGROUND------------------------------------------//

/*
$(document).ready( function(){
	function resizeDivCenter()
	{
		var viewportH = $(window).height();			   
		var divConteudoH = $('#conteudo').height();
		var contentH = $('#fundo').height();
		
		if(contentH < viewportH)
		{
			$('#fundo').css({ "height":"100%" });
		}
	}
	$(window).load(function()
	{
		$('#fundo').css({ height:$(window).height()});
	});
	$(window).resize(function()
	{ 
		$('#fundo').css({ height:$(window).height()});
	});
	

});
*/


/*$(document).ready(function(){
	function resizeDivCenter()
	{
		var viewportH = $(window).height();			   
		var divCenterH = $('#divCenter').height();
		var contentH = $('#content').height();
		
		if(contentH < viewportH)
		{
			$('#divCenter').css({ "height":"100%" });
		}
	}
	$(window).load(function()
	{
		resizeDivCenter();
	});
	$(window).resize(function()
	{ 
		resizeDivCenter();
	});

});*/




//----------------------------FUNÇÃO PAGE------------------------------------------//

function Page(cd_sesit, p){
	document.location.href = "?cd_sesit="+cd_sesit+"&p="+p;
}

//----------------------------FUNÇÃO ORDENA------------------------------------------//

function ordena(mod){
	document.location.href = "?mod="+mod;
}
//----------------------------FUNÇÃO BUSCA------------------------------------------//

function ValidaBusca() {

	var msg ="";

	if(window.document.getElementById('ds_busca').value == "palavra chave"){
		msg = "Digite uma palavra chave\n";
	}

	if(msg == ""){
		window.document.formBusca.submit();
	}else{
		alert("ATENÇÃO!!\n\n"+msg);
		return false;
	}

}
//----------------------------FUNÇÃO ÁREA RESTRITA------------------------------------------//
/*
function ValidaAreaRestrita() {

	var msg ="";

	if(window.document.getElementById('ds_usuin_email').value == "login"){
		msg = "Digite seu login\n";
	}
	
	if(window.document.getElementById('ds_usuin_senha').value == "senha"){
		msg = msg + "Digite sua senha\n";
	}
	
	if(msg == ""){
		var frm;
		var frm = $('#frmLogar').get(0); frm.e.value='E'; FivecomUtil.submitForm('#frmLogar', '#msgLogin');
		return frm;
	}else{
		alert("ATENÇÃO!!\n\n"+msg);
		return false;
	}

}

function ValidaEnviarEmail() {

	var msg ="";

	if(window.document.getElementById('ds_usuin_email').value == "login"){
		msg = "Digite seu login\n";
	}
	
	if(msg == ""){
		var frm = $('#frmLogar').get(0); frm.e.value='L'; FivecomUtil.submitForm('#frmLogar', '#msgLogin');
		return frm;
		
	}else{
		alert("ATENÇÃO!!\n\n"+msg);
		return false;
	}

}
*/
//----------------------------FUNÇÃO------------------------------------------//

/************************** VALIDA CPF *************************/
function validaCPF(campo) {
	if(campo){
		cpf = new String(campo.value);
		cpf = cpf.replace(".","");
		cpf = cpf.replace(".","");
		cpf = cpf.replace("-","");
	
		valor = true;
		erro = new String;
		if (cpf.length < 11) erro += "Sao necessarios 11 digitos para o CPF! \n\n"; 
		var nonNumbers = /\D/;
		if (nonNumbers.test(cpf)) erro += "A verificacao de CPF suporta apenas numeros! \n\n";	
		if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){
			  erro += "Numero de CPF invalido!"
		}
		var a = [];
		var b = new Number;
		var c = 11;
		for (i=0; i<11; i++){
			a[i] = cpf.charAt(i);
			if (i < 9) b += (a[i] *  --c);
		}
		if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
		b = 0;
		c = 11;
		for (y=0; y<10; y++) b += (a[y] *  c--); 
		if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
		if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])){
			erro +="Dados incorretos.\nDigite novamente!";
		}
		if (erro.length > 0){
			alert(erro);
			window.document.getElementById(campo.id).value = "";
			return false;
		}
		return true;
	}
}

// chamando o lightbox
$(function() {
	// Use this example, or...
	$('a[@rel*=lightbox]').lightBox({
	overlayBgColor: '#000',
	overlayOpacity: 0.6,
	imageLoading: '/imagens/lightbox-ico-loading.gif',
	imageBtnClose: '/imagens/lightbox-btn-close.gif',
	imageBtnPrev: '/imagens/lightbox-btn-prev.gif',
	imageBtnNext: '/imagens/lightbox-btn-next.gif',
	containerResizeSpeed: 350,
	txtImage: 'Imagem',
	txtOf: 'de'
   });
});



function fotosAjax(cod, param, Url){
	
	if( document.getElementById( cod+"_maisfoto" ).style.display == ""){
		document.getElementById( cod+"_maisfoto" ).style.display = "none";
		document.getElementById( cod+"_fot" ).src = "imagens/icon_foto.gif";
	} 
	else{
		$.ajax(
			{
				url: Url,
				data: {	
						'cd_matia' : cod,
						'onde' : param
				},
				type: "GET",
				cache: false,
				async: true,
				beforeSend: function(xmlhttprequest){
					document.getElementById( cod+"_maisfoto" ).style.display = "";
					document.getElementById( cod+"_fot" ).src = "imagens/icon_foto2.gif";					
					
					//$('#'+cod+"_maisfoto").html( "<div ><img height=\"16\" width=\"16\" src=\"imagens/ajax-loader.gif\" style=\"marngin-right:6px;float:left;\"/><p style=\"float:left;\">Carregando ...</p></div>" );
				},
				error: function (XMLHttpRequest, textStatus, errorThrown) {
				  
				},
				complete: function(xmlhttprequest){
					$('#loading').hide();
				},
				success: function(html){
					if( html ){
						$('#'+cod+"_maisfoto").html(html);
						
						jQuery('#mycarousel_'+cod).jcarousel({scroll:5})
						
						$('a[@rel*=lightbox]').lightBox(
							{
								overlayBgColor: '#000',
								overlayOpacity: 0.6,
								imageLoading: '/imagens/lightbox-ico-loading.gif',
								imageBtnClose: '/imagens/lightbox-btn-close.gif',
								imageBtnPrev: '/imagens/lightbox-btn-prev.gif',
								imageBtnNext: '/imagens/lightbox-btn-next.gif',
								containerResizeSpeed: 350,
								txtImage: 'Imagem',
								txtOf: 'de'
						   }
						);
					}
				}
			}
		);
	}		
}


function videosAjax(cod, param, Url){
	
	if( document.getElementById( cod+"_maisvideos" ).style.display == ""){
		document.getElementById( cod+"_maisvideos" ).style.display = "none";
		document.getElementById( cod+"_vid" ).src = "imagens/icon_video.gif";
	} 
	else{
		$.ajax(
			{
				url: Url,
				data: {	
						'cd_matia' : cod,
						'onde' : param
				},
				type: "GET",
				cache: false,
				async: true,
				beforeSend: function(xmlhttprequest){
					document.getElementById( cod+"_maisvideos" ).style.display = "";
					document.getElementById( cod+"_vid" ).src = "imagens/icon_video2.gif";					
					
					//$('#'+cod+"_maisfoto").html( "<div ><img height=\"16\" width=\"16\" src=\"imagens/ajax-loader.gif\" style=\"marngin-right:6px;float:left;\"/><p style=\"float:left;\">Carregando ...</p></div>" );
				},
				error: function (XMLHttpRequest, textStatus, errorThrown) {
				  
				},
				complete: function(xmlhttprequest){
					$('#loading').hide();
				},
				success: function(html){
					if( html ){
						$('#'+cod+"_maisvideos").html(html);
					}
				}
			}
		);
	}		
}


