var menuitem1off = new Image;
var menuitem2off = new Image;
var menuitem3off = new Image;
var menuitem4off = new Image;
var menuitem5off = new Image;
var menuitem6off = new Image;
var menuitem1on = new Image;
var menuitem2on = new Image;
var menuitem3on = new Image;
var menuitem4on = new Image;
var menuitem5on = new Image;
var menuitem6on = new Image;
menuitem1off.src = baseurl+'img/menup_quemsomos_off'+sufixo+'.gif';
menuitem2off.src = baseurl+'img/menup_oqfazemos_off'+sufixo+'.gif';
menuitem3off.src = baseurl+'img/menup_tecqusamos_off'+sufixo+'.gif';
menuitem4off.src = baseurl+'img/menup_clitrab_off'+sufixo+'.gif';
menuitem5off.src = baseurl+'img/menup_trabconosco_off'+sufixo+'.gif';
menuitem6off.src = baseurl+'img/menup_entrecontato_off'+sufixo+'.gif';

menuitem1on.src = baseurl+'img/menup_quemsomos_on'+sufixo+'.gif';
menuitem2on.src = baseurl+'img/menup_oqfazemos_on'+sufixo+'.gif';
menuitem3on.src = baseurl+'img/menup_tecqusamos_on'+sufixo+'.gif';
menuitem4on.src = baseurl+'img/menup_clitrab_on'+sufixo+'.gif';
menuitem5on.src = baseurl+'img/menup_trabconosco_on'+sufixo+'.gif';
menuitem6on.src = baseurl+'img/menup_entrecontato_on'+sufixo+'.gif';

var ativo;




function loadmenu(){
todos = true;

for(i=1; i<=6; i++){
					
			if("menuitem"+i+"off.src" == false){
					todos = false;
					i=1000;
					loadmenu();
				}
				
			if("menuitem"+i+"on.src" == false){
					todos = false;
					i=1000;
					loadmenu();
				}	
	}	
	return true;
}




var firstload = true;

reEmail = /^[\w-]+(\.[\w-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;

function validacampos(formulario)
{
	var elementos = formulario.elements;
	var error = "";
	
	if(sufixo == "")
	{
		var msn = "Por favor preencha o(s) campo(s):\n";
	}
	else
	{
		var msn = "Please fill out the field(s):\n";
	}

		if(elementos[5].value == "")
		{
			if(sufixo == "")
			{
				msn += " - Nome\n";
				
			}
			else
			{
				msn += " - Name\n";
			}
			error+=1;
		}
		
		if(elementos[6].value == "" || elementos[6].value.indexOf('@')==-1 || elementos[6].value.indexOf('.')==-1)
		{
			msn += " - E-mail\n";
			error+=1;
		}
		
		if(elementos[9].value == "")
		{
			if(sufixo == "")
			{
				msn += " - Arquivo";
			}
			else
			{
				msn += " - File";	
			}
			error+=1;
		}
		if(error != "")
		{
			alert(msn);
		}
		
		else
		{
			document.getElementById('form').action = baseurl+"mail_novo.php";
			document.getElementById('form').submit();		
			enviaform('formenvia');		
			return true;
		}
}







/*function validacampos(){
	valida = false;
	alert(sufixo)
	nome = document.getElementById('nome').value;
	
	if((nome != "" || nome.length > 1) && validamails()){
			document.getElementById('form').action = baseurl+"mail_novo.php";
			document.getElementById('form').submit();		
			enviaform('formenvia');		
			return true;			
		}
	else{
			if(sufixo != ""){
			alert("Please, put your name ande e-mail correct");	
			}
			else{
				alert('Por favor, preencha o seu nome e e-mail corretamente');
			}
			return false;
		}
	
	}

function validamails(){
	envia = false;
	mails = new Array(document.getElementById('email').value);	
	for(i=0; i < mails.length; i++){
		if (reEmail.test(mails[i])) {
			envia = true
		} else if (mails[i] != null && mails[i] != "") {
			envia = false;
			i = mails.length + 1;		
		}			
	}
	
	
	return envia;
	
}*/

function ativa(layer,time){
var mySlide = new Fx.Style('contsite', 'opacity').set(0);	
	mySlide.start(1);

	if(ativo == null){

	$(layer).style.backgroundColor = "#ffffff";
	$(layer+"int").style.visibility = "visible";
	for( var i = 0; i < $$('#' + layer + ' img').length; i++ ) {		  
		  $$('#' + layer + ' img')[i].src = baseurl+'img/menup_'+layer+'_on'+sufixo+'.gif';
		}
	
	ativo = layer;
	}
	else{

	$(ativo).style.backgroundColor = "transparent";
	$(layer).style.backgroundColor = "#ffffff";
	$(ativo+"int").style.visibility = "hidden";
	$(layer+"int").style.visibility = "visible";
	for( var i = 0; i < $$('#'+ativo+' img').length; i++ ) {		  
		  $$('#' + ativo + ' img')[i].src = baseurl+'img/menup_'+ativo+'_off'+sufixo+'.gif';
		}	
	for( var i = 0; i < $$('#' + layer + ' img').length; i++ ) {		  
		  $$('#' + layer + ' img')[i].src = baseurl+'img/menup_'+layer+'_on'+sufixo+'.gif';
		}
	
	ativo = layer;
	}
	
}


function menuat(layer,state){
	if(ativo != layer){
		if(state==1){
			for( var i = 0; i < $$('#' + layer + ' img').length; i++ ) {		  
		 		 $$('#' + layer + ' img')[i].style.visibility = 'hidden';
			}
			
			
			$(layer+"int").style.visibility = "visible";
			$(layer+"int").style.backgroundColor = "#ffffff";
			$(layer).style.backgroundColor = "#ffffff";
			
						
			for( var i = 0; i < $$('#' + layer + ' img').length; i++ ) {		  
		 		 $$('#' + layer + ' img')[i].src = baseurl+'img/menup_'+layer+'_on'+sufixo+'.gif';
				 $$('#' + layer + ' img')[i].style.visibility = 'visible';
			}
		}
		else{
			for( var i = 0; i < $$('#' + layer + ' img').length; i++ ) {		  
		 		 $$('#' + layer + ' img')[i].style.visibility = 'hidden';
			}
			$(layer).style.backgroundColor = "transparent";
			$(layer+"int").style.backgroundColor = "transparent";
			$(layer+"int").style.visibility = "hidden";
			
			
			
			for( var i = 0; i < $$('#' + layer + ' img').length; i++ ) {		  
		 		 $$('#' + layer + ' img')[i].src = baseurl+'img/menup_'+layer+'_off'+sufixo+'.gif';
				 $$('#' + layer + ' img')[i].style.visibility = 'visible';
			}
		}
	}
}






function Acc(){	
	var mySlide = new Fx.Style('contsite', 'opacity').set(0);	
	$('contsite').style.padding = "22px";
	$('contsite').style.paddingTop = "18px";
	$('contsite').style.paddingBottom = "2px";
	$('contsite').style.width = "846px";

		if($('accordion')){
			if(!window.ie7){
				bott = "toggler.setStyle('background-position','bottom');";				
				}
				else{
					bott = "";
					}
			var accordion = new Accordion('h3.atStart', 'div.atStart', {
				opacity: false,
				onActive: function(toggler, element){
				toggler.setStyle('color', 'black');
				toggler.setStyle('font-weight', 'bold');
				toggler.setStyle('font-size', '10px');
				toggler.setStyle('background-image','url(img/ico_menos2.gif)');
				toggler.setStyle('background-repeat','no-repeat');
				eval(bott)
			},
			
			onBackground: function(toggler, element){
				toggler.setStyle('color', 'black');
				toggler.setStyle('font-weight', 'bold');
				toggler.setStyle('font-size', '10px');
				toggler.setStyle('background-image','url(img/ico_mais2.gif)');				
				toggler.setStyle('background-repeat','no-repeat');				
				eval(bott)
			}
			
		}, $('accordion'));
			
			
		
	}	
	mySlide.start(0,1);
	mntTrab(1);	
	firstload = false;
}


function trtb(alias, nft, bt){

		$("tl_"+alias).src = "img/tb/tb_"+alias+"_"+nft+".jpg";

	}



function tplsit(i){
var bt01 = new Image;
var bt02 = new Image;
var bt03 = new Image;
var bt04 = new Image;
var bt05 = new Image;

var bt01off = new Image;
var bt02off = new Image;
var bt03off = new Image;
var bt04off = new Image;
var bt05off = new Image;

bt01.src = 'img/bt_01_on.gif';
bt02.src = 'img/bt_02_on.gif';
bt03.src = 'img/bt_03_on.gif';
bt04.src = 'img/bt_04_on.gif';
bt05.src = 'img/bt_05_on.gif';

bt01off.src = 'img/bt_01_off.gif';
bt02off.src = 'img/bt_02_off.gif';
bt03off.src = 'img/bt_03_off.gif';
bt04off.src = 'img/bt_04_off.gif';
bt05off.src = 'img/bt_05_off.gif';


tpl = '<div style="width:283px">'+"\n";
tpl += '<div id="tl_'+ALIAS[i]+'_dd"><img src="img/tb/tb_'+ALIAS[i]+'_1.jpg" id="tl_'+ALIAS[i]+'" class="tb"/></div>'+"\n";



tpl += '<div style="width:27px" class="mntb">'+"\n";

if(NFOTOS[i] >=2){
		for(j=1; j<=NFOTOS[i]; j++){
				if(j==1){
						tpl += '<img src="img/bt_0'+j+'_on.gif" width="19" height="19"  id="bt_'+ALIAS[i]+'_'+j+'" onclick="trtb(\''+ALIAS[i]+'\','+j+', this.id)" /><br />'+"\n";
					}
				else{
						tpl += '<img src="img/bt_0'+j+'_on.gif" width="19" height="19"  id="bt_'+ALIAS[i]+'_'+j+'" onclick="trtb(\''+ALIAS[i]+'\','+j+', this.id)" /><br />'+"\n";
					}
			}
	}

	if(SITE[i] != " " && SITE[i] != null){
		tpl += '<div><a href="'+SITE[i]+'" target="_blank">ver</a></div>'+"\n";
	}
tpl += '</div>'+"\n";
tpl += '</div> '+"\n";

return tpl;

}

function soNums(e)
{

    if (document.all){var evt=event.keyCode;}

    else{var evt = e.charCode;}

    if (evt <20 || (evt >47 && evt<58))
    {
   		ChecarTAB();
   		return true;
   	}

   ChecarTAB();

   return false;

}
   
function PararTAB(quem)
{
   VerifiqueTAB=false;
}

function ChecarTAB()
{
   VerifiqueTAB=true;
}

    

function mntTrab(pagina, init){
	
anterior = false;
proximo = false;
atual = pagina;


if($('itensnaveg')){
	$('txtcl').innerHTML = "Selecionamos  alguns trabalhos para que voc&ecirc; possa nos conhecer um pouco melhor: ";
	$('abaclien').src = "img/aba_clientes_off.gif";
    $('abatrab').src = "img/aba_trabalhos_on.gif";
	
	$('contsite').style.padding = "10px";		
	$('contsite').style.paddingTop = "18px";
	$('contsite').style.width = "870px";
	cont = 1;	
	if(pagina != 1 && pagina != null){
	anterior = true;
	proximo = true;
	atual = pagina;
	pagina--;
	inicial =  (pagina * 6)+1;
	final = (pagina * 6) + 7;
	}
	else{
	anterior = false;
	proximo = true;
	atual = pagina;
	inicial =  pagina;
	final = pagina + 6;	
		}
	
	if(final >= NOMESITE.length){
		final =  NOMESITE.length;
		proximo = false;
		}
	
	var sites = '';
	
	for(i=inicial; i<final; i++){	
			sites += tplsit(i);
			if(cont==3){
				sites += '<div style="width:100%; height:16px"></div>'+"\n";
				}
			cont++;
		}
	
	nav = "";
	
	if(anterior){
		na = atual - 1;
		itant = '<a href="javascript:vsoid()" onclick="mntTrab('+na+')" class="ativo">Anterior</a>';
		}
	else{
		itant = '<span class="inativo">Anterior</span>';
		}
	
	if(proximo){
		np = atual + 1;
		itprox = '<a href="javascript:vsoid()" onclick="mntTrab('+np+')" class="ativo">Pr&oacute;ximo</a>';
		}
	else{
		itprox = '<span class="inativo">Pr&oacute;ximo</span>';
		}
	
	
	nav = itant + '&nbsp;&nbsp;&nbsp;&nbsp;' + itprox;
	
	if(cont > 1){
		$('itensnaveg').innerHTML = nav;
		$('itensnaveg').style.display = "inline";
	}
	else{
		$('itensnaveg').style.display = "none";
		}
	
	$('qqint').innerHTML = sites;
	$('qqint').style.padding = "5px";
	$('qqint').style.paddingLeft = "10px";	
	$('qqint').style.paddingRight = "0px";
	

	
	}
}


function mntCli(pagina){
$('txtcl').innerHTML = "Para quem  j&aacute; trabalhamos:";
$('abaclien').src = "img/aba_clientes_on.gif";
$('abatrab').src = "img/aba_trabalhos_off.gif";

	
total = 1;	
anterior = false;
proximo = false;
atual = pagina;

if($('itensnaveg')){
	$('contsite').style.padding = "10px";		
	$('contsite').style.paddingTop = "18px";
	$('contsite').style.width = "870px";
	cont = 1;	
	if(pagina != 1 && pagina != null){
	anterior = true;
	proximo = true;
	}
	else{
	anterior = false;
	proximo = true;
		}
	
	if(pagina >= total){		
		proximo = false;
		}
	
	
	if(anterior){
		na = atual - 1;
		itant = '<a href="javascript:vsoid()" onclick="mntCli('+na+')" class="ativo">Anterior</a>';
		}
	else{
		itant = '<span class="inativo">Anterior</span>';
		}
	
	if(proximo){
		np = atual + 1;
		itprox = '<a href="javascript:vsoid()" onclick="mntCli('+np+')" class="ativo">Pr&oacute;ximo</a>';
		}
	else{
		itprox = '<span class="inativo">Pr&oacute;ximo</span>';
		}
	
	
	nav = itant + '&nbsp;&nbsp;&nbsp;&nbsp;' + itprox;
	
	sites = '<img src="img/clientes_'+pagina+'.jpg" width="819" height="258" id="fgclient">';
	
	
	if(cont > 1){
		$('itensnaveg').innerHTML = nav;
		$('itensnaveg').style.display = "inline";
	}
	else{
		$('itensnaveg').style.display = "none";
		}
		
	
	$('qqint').innerHTML = sites;
	
	$('qqint').style.padding = "5px";
	$('qqint').style.paddingLeft = "10px";	
	$('qqint').style.paddingRight = "0px";
	}
}


function vsoid(){

	}


function enviaform(div){
	$(div).style.visibility = "hidden";
	$(div+"_cortina").style.backgroundImage = "url("+baseurl+"img/ajax-loader.gif)";
	$(div+"_cortina").style.backgroundRepeat = "no-repeat";
	$(div+"_cortina").style.backgroundPosition = "center";
	
	}
	
	
window.addEvent('domready', function() {	
	if(!window.ie7){

					bott = "toggler.setStyle('background-position','bottom');";

					}

					else{

						bott = "";

						}

	

	var accordion = new Accordion('h3.atStart', 'div.atStart', {

			opacity: false,

			onActive: function(toggler, element){

			toggler.setStyle('color', 'black');

			toggler.setStyle('font-weight', 'bold');

			toggler.setStyle('font-size', '10px');

			toggler.setStyle('padding', '0px');

			toggler.setStyle('background-image','url('+baseurl+'img/ico_menos2.gif)');

			toggler.setStyle('background-repeat','no-repeat');

			eval(bott)

			

		},

		

		onBackground: function(toggler, element){

			toggler.setStyle('color', 'black');

			toggler.setStyle('font-weight', 'bold');

			toggler.setStyle('font-size', '10px');

			toggler.setStyle('background-image','url('+baseurl+'img/ico_mais2.gif)');				

			toggler.setStyle('background-repeat','no-repeat');

			

			toggler.setStyle('padding', '0px');

			eval(bott)

	

		}

	}, $('accordion'));

	

	



});



