/*$(document).ready(function() {
    $('.slideshow').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		speed:  'fast',
    timeout: 6000

	});
});
/**
* Classe com funções úteis.
* Métodos:
* get_flash(), url(_url), urlBlank(_url)
*/
var Uteis = {
	get_flash: function(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/cabs/flash/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);
	},
	url: function(_url){
		document.location.href = _url;
	},
	urlBlank: function(_url){
		window.open(_url);
	},
	ge : function(elementId){
		element = document.getElementById(elementId);
		return element;
	},
	ga : function(elementsTag){
		elements = document.getElementsByTagName(elementsTag);
		return elements;
	},
	format: function (src, mask) {
		var i = src.value.length;
		var saida = mask.substring(0,1);
		var texto = mask.substring(i)
		if (texto.substring(0,1) != saida) {
			src.value += texto.substring(0,1);
		}
	},
	limpaInput : function(element){
		if(element.value == 'busca'){element.value = '';}
	}
}

var Validate = {
	email : function(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;
    }
	},
	
	cpf : function(cpf){
		var c = cpf;
		if((c = c.replace(/[^\d]/g,"").split("")).length != 11) return false;
		if(new RegExp("^" + c[0] + "{11}$").test(c.join(""))) return false;
		for(var s = 10, n = 0, i = 0; s >= 2; n += c[i++] * s--);
		if(c[9] != (((n %= 11) < 2) ? 0 : 11 - n)) return false;
		for(var s = 11, n = 0, i = 0; s >= 2; n += c[i++] * s--);
		if(c[10] != (((n %= 11) < 2) ? 0 : 11 - n)) return false;
		return true;
	},
	
	cnpj : function(cnpj){
		var b = [6,5,4,3,2,9,8,7,6,5,4,3,2], c = cnpj;
		if((c = c.replace(/[^\d]/g,"").split("")).length != 14) return false;
		for(var i = 0, n = 0; i < 12; n += c[i] * b[++i]);
		if(c[12] != (((n %= 11) < 2) ? 0 : 11 - n)) return false;
		for(var i = 0, n = 0; i <= 12; n += c[i] * b[i++]);
		if(c[13] != (((n %= 11) < 2) ? 0 : 11 - n)) return false;
		return true;
	},
	
	inputs : function(form){
		inputs = form.getElementsByTagName('input');
		i = inputs.length;
		msg = "";
		var erMail = new RegExp(/email+|e-mail+/);
		var erCnpj = new RegExp(/cnpj+|CNPJ+/);
		while(i--){
			if(inputs[i].type == 'text'){
				if(inputs[i].title != '' && inputs[i].value == ''){
					msg += "O campo "+inputs[i].title+" é obrigatório\n";
					inputs[i].style.backgroundColor = "#ffe4cc";
				}else{
					// verifica se é um campo email, para fazer a validação
					if(erMail.test(inputs[i].name)){
						if(Validate.email(inputs[i].value)){
							inputs[i].style.backgroundColor = "";
						}else{
							msg += "O campo "+inputs[i].title+" é inválido\n";
							inputs[i].style.backgroundColor = "#ffe4cc";
						}
					// Verifica se é um cnpj
					}else if (erCnpj.test(inputs[i].name)){
						if(Validate.cnpj(inputs[i].value)){
							inputs[i].style.backgroundColor = "";
						}else{
							msg += "O campo "+inputs[i].title+" é inválido\n";
							inputs[i].style.backgroundColor = "#ffe4cc";
						}
					}else{
						inputs[i].style.backgroundColor = "";
					}
				}
			}// if text
		}
		return msg;
	},
	
	textareas : function(form){
		textareas = form.getElementsByTagName('textarea');
		i = textareas.length;
		msg = "";
		while(i--){
			if(textareas[i].title != '' && textareas[i].value == ''){
				msg += "O campo "+textareas[i].title+" é obrigatório\n";
				textareas[i].style.backgroundColor = "#ffe4cc";
			}else{
				textareas[i].style.backgroundColor = "";
			}
		}
		return msg;
	},
	
	selects : function(form){
		selects = form.getElementsByTagName('select');
		i = selects.length;
		msg = "";
		while(i--){
			if(selects[i].title != '' && selects[i].value == ''){
				msg += "O campo "+selects[i].title+" é obrigatório\n";
				selects[i].style.backgroundColor = "#ffe4cc";
			}else{
				selects[i].style.backgroundColor = "";
			}
		}
		return msg;
	}
}/* Validate */

/**
* Classe de controle do formulário Login.
*/
var Lgin = {
	vars : {
		form : null,
		inputs : null,
		textareas : null
	},
	/* Envia o formulário */
	submit : function(){
		this.vars.form = Uteis.ge('formLogin');
		this.vars.inputs = Validate.inputs(this.vars.form);
		this.vars.textareas = Validate.textareas(this.vars.form);
		msg = this.vars.inputs + this.vars.textareas;
		//alert(msg);
		if(msg == ""){
			this.vars.form.submit();
		}
		if(msg != ""){
		alert(msg);
		return false;
		}
	}
}

/**
* Classe de controle do formulário Contato.
*/
var Contato = {
	vars : {
		form : null,
		inputs : null,
		textareas : null
	},
	/* Envia o formulário */
	submit : function(){
		this.vars.form = Uteis.ge('formContato');
		this.vars.inputs = Validate.inputs(this.vars.form);
		this.vars.textareas = Validate.textareas(this.vars.form);
		msg = this.vars.inputs + this.vars.textareas;
		//alert(msg);
		if(msg == ""){
			this.vars.form.submit();
		}
		else{
		alert(msg);
		}
		return false;
	}
}

/**
* Classe que controla o formulário associe-se
*/
var Associese = {
	vars : {
		form : null,
		inputs : null
	},
	
	submit : function(){
		this.vars.form = Uteis.ge('formAssociese');
		this.vars.inputs = Validate.inputs(this.vars.form);
		msg = this.vars.inputs;
		if(msg == ''){
			return true;
		}else{
			alert(msg);
			return false;
		}
	}
} // associese

var Busca = {
	vars : {
		form : null,
		campo : null
  },
	submit : function(){
		this.vars.form = Uteis.ge('formBusca');
		this.vars.campo = Uteis.ge('busca');
		if(this.vars.campo.value == ''){
			alert("O campo 'busca' não pode ser vazio.");
    }else{
			this.vars.form.submit();
    }
		return false;
  }
}

var Trabalhe = {
	vars : {
		form : null,
		textareas : null,
		inputs : null,
		selects : null
  },
	submit : function(){
		this.vars.form = Uteis.ge('formTrabalhe');
		this.vars.inputs = Validate.inputs(this.vars.form);
		this.vars.selects = Validate.selects(this.vars.form);
		this.vars.textareas = Validate.textareas(this.vars.form);
		msg = this.vars.inputs+this.vars.textareas+this.vars.selects;
		if(msg == ''){
			
		}else{
			alert(msg);
			return false;
		}
  }
}

var Indicar = {
	vars : {
		form : null
	},
	showOrHide : function(){
		this.vars.form = Uteis.ge('formIndicar');
		if(this.vars.form.style.display == 'none'){
			this.vars.form.style.display = '';
		}else{
			this.vars.form.style.display = 'none';
		}
		return false;
	},
	submit : function(){
		this.vars.form = Uteis.ge('formIndicar');
		msg = Validate.inputs(this.vars.form);
		msg += Validate.textareas(this.vars.form);
		if(msg == ''){
			return true;
		}else{
			alert(msg);
			return false;
		}
	}
}

var Classificado = {
	vars : {
		form : null
	},
	showOrHide : function(){
		this.vars.form = Uteis.ge('formGuias');
		if(this.vars.form.style.display == 'none'){
			this.vars.form.style.display = '';
		}else{
			this.vars.form.style.display = 'none';
		}
		return false;
	},
	submit : function(){
		this.vars.form = Uteis.ge('formGuias');
		msg = Validate.inputs(this.vars.form);
		msg += Validate.textareas(this.vars.form);
		if(msg == ''){
			return true;
		}else{
			alert(msg);
			return false;
		}
	}
}

function AlterarSenha(){

	var msg = "";
	if(window.document.frmSenha.SConf1.value == ''){
		msg = " - Sua Senha!\n";
	}
	if(window.document.frmSenha.SConf2.value == ''){
		msg = msg + " - Sua Senha de Confirmação!\n";
	}
	if(document.frmSenha.SConf1.value != document.frmSenha.SConf2.value){
		msg = msg + " - Sua Senha dever ser igual a confirmação!\n";
	}
	if(msg == ""){
		document.frmSenha.submit();
		return true;
	}else{
		alert("Preencha os campos corretamente.\n\n"+msg);
		return false;
	}	
}

function AlterarEmail(){
	var msg = "";
	if(window.document.frmEmail.email.value == ''){
		msg = " - Sua Senha!\n";
	}
	if(msg == ""){
		document.frmEmail.submit();
		return true;
	}else{
		alert("Preencha os campos corretamente.\n\n"+msg);
		return false;
	}	
}

function Popup(Url, Titulo, Width, Height, Scrollbar) 
{
    window.open(Url, Titulo, 'width='+Width+', height='+Height+', scrollbars='+Scrollbar+', status=no, resizable, top='+((screen.availHeight/2)-(Height/2))+', left='+((screen.availWidth/2)-(Width/2)))
}

function mostraAbas(Id){
	document.getElementById('li_Senha').className='';
	document.getElementById('Senha').style.display='none';
	document.getElementById('li_Login').className='';
	document.getElementById('Login').style.display='none';
	document.getElementById(Id).style.display='';
    document.getElementById('li_'+Id).className='ativos';
}

/*
Parceiros = {};
Parceiros.num = 1;
Parceiros.total = 12;
Parceiros.picture = new Array();
Parceiros.picture[1]  = 'imagens/parceiros/parc1.gif';
Parceiros.picture[2]  = 'imagens/parceiros/aracruz.gif';
Parceiros.picture[3]  = 'imagens/parceiros/der-es.gif';
Parceiros.picture[4]  = 'imagens/parceiros/dnit.gif';
Parceiros.picture[5]  = 'imagens/parceiros/petrobras.gif';
Parceiros.picture[6]  = 'imagens/parceiros/samarco.gif';
Parceiros.picture[7]  = 'imagens/parceiros/sinaenco.gif';
Parceiros.picture[8]  = 'imagens/parceiros/sindicon.gif';
Parceiros.picture[9]  = 'imagens/parceiros/sindicon2.gif';
Parceiros.picture[10]  = 'imagens/parceiros/sindopem.gif';
Parceiros.picture[11]  = 'imagens/parceiros/vale.gif';
Parceiros.picture[12]  = 'imagens/parceiros/vitoria_futuro.gif';
Parceiros.trocaImagem = function(op){
	if(op == '-'){
		this.num = this.num - 1;
		if(this.num < 1)
			this.num = this.total;
	}
	if(op == '+'){
		this.num = this.num + 1;
		if(this.num > this.total)
			this.num = 1;
	}
	//target = document.getElementById('parceiros').getElementsByTagName('img')[0];	
	alpha = 0;
	timer = (0.1*1000)/50;
	this.setAlpha(target, 0);
	target.src = this.picture[this.num];

	var i = setInterval(
			function() {
				if (alpha >= 100)
					clearInterval(i);
				Parceiros.setAlpha(target, alpha);
				alpha += 3;
			}, timer);
}// troca imagem

Parceiros.temporizador = function(){
	this.trocaImagem("+");
}

Parceiros.setAlpha = function(target, alpha) {
	target.style.filter = "alpha(opacity="+ alpha +")";
	target.style.opacity = alpha/100;
}

intervalo = window.setInterval(function() { Parceiros.temporizador()}, 3000);*/
