function setZIndex(obj,z){
	if(obj!=undefined){
		obj.style.zIndex=z
	}
}

function setAlpha(target, alpha) {
	target.style.filter = "alpha(opacity="+ alpha +")";
	target.style.opacity = alpha/100;
}

function insereFlash2(filename,name,largura,altura){
	var randomnumber=Math.floor(Math.random()*9999)
	eval("var "+name+randomnumber+" = new Flash(filename, name, largura, altura);")
	eval(name+randomnumber+".addParameter('quality', 'high')");
	eval(name+randomnumber+".addParameter('width', '"+largura+"')");
	eval(name+randomnumber+".addParameter('height', '"+altura+"')");
	eval(name+randomnumber+".addParameter('menu', 'false')");
	eval(name+randomnumber+".addParameter('scale', 'noScale')");
	eval(name+randomnumber+".addParameter('wmode', 'transparent')");
	//eval(name+"O.write()");
	document.write(eval(name+randomnumber));
}

function insereFlash(filename,name,largura,altura){

			AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', largura,
			'height', altura,
			'src', 'a',
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', 'a',
			'bgcolor', '#ffffff',
			'name', 'a',
			'menu', 'true',
			'allowScriptAccess','sameDomain',
			'movie', filename,
			'salign', ''
			); //end AC code
	
}

var intervalPhoto
function photoNav(ac,largura){
	objAlbum = document.getElementById('imagensAlbum')
	
	if(ac=='next'){
		intervalPhoto = setInterval(function(){
			window.status = objAlbum.offsetLeft
			if(objAlbum.offsetLeft>-largura)
			objAlbum.style.left = objAlbum.offsetLeft - 25 + "px";
		},10)
		//eval(new Tween(objAlbum.style, 'left', Tween.strongEaseOut, objAlbum.offsetLeft, objAlbum.offsetLeft+80, .2, 'px')).start();
	}
	
	if(ac=='prev'){
		intervalPhoto = setInterval(function(){
			window.status = objAlbum.offsetLeft
			if(objAlbum.offsetLeft<=0)
			objAlbum.style.left = objAlbum.offsetLeft + 25 + "px";
			
		},10)
		//eval(new Tween(objAlbum.style, 'left', Tween.strongEaseOut, objAlbum.offsetLeft, objAlbum.offsetLeft+80, .2, 'px')).start();
	}
}

function mostraForm(form){
	
	if(document.getElementById('msgEnviado')!=null)
	document.getElementById('msgEnviado').style.display='none';
	
	for(x=1;x<=3;x++){
		if(form==x){
		document.getElementById('form'+x).style.display='block';
		document.getElementById('tit'+x).src='images/tit_contatos_'+x+'_over.gif';
		}else{
		document.getElementById('form'+x).style.display='none';
		document.getElementById('tit'+x).src='images/tit_contatos_'+x+'_normal.gif';
		}
	}
}

function init_dw_Scroll() {
	var wndo = new dw_scrollObj('wn', 'lyr1');
	wndo.setUpScrollbar("dragBar", "track", "v", 1, 1);
	wndo.setUpScrollControls('scrollbar');
}
		
window.onload = function(){
	startMenu();
	atualizaObj('start');
	
	
	document.getElementById('loading').style.display='none';
	document.getElementById('allCont').style.display='block';
	
	if(document.getElementById('scrollbar')!=null && document.getElementById('wn')!=null){
		init_dw_Scroll();
	};
	//alert(document.getElementById('lyr1').offsetHeight);
	if(document.getElementById('scrollbar')!=null && document.getElementById('wn')!=null){
		
		if(parseInt(document.getElementById('lyr1').offsetHeight)<parseInt(document.getElementById('wn').offsetHeight)){
			document.getElementById('scrollbar').style.display = 'none';
		}else{
			document.getElementById('scrollbar').style.display = 'block';
		}
		
	}
	
}

window.onresize = function(){
	atualizaObj('resize');
	
	if(document.getElementById('scrollbar')!=null && document.getElementById('wn')!=null && document.getElementById('lyr1')!=null){
		init_dw_Scroll();
		
		if(parseInt(document.getElementById('lyr1').offsetHeight)<parseInt(document.getElementById('wn').offsetHeight)){
			document.getElementById('scrollbar').style.display = 'none';
		}else{
			document.getElementById('scrollbar').style.display = 'block';
		}
	
	};
}

function fadeOut(id, time) {
	target = document.getElementById(id);
	alpha = 70;
	
	//timer = (time*1000)/5;
	timer = time
	var v = setInterval(
			function() {
				if (alpha <= 0){
					clearInterval(v);
					target.style.top=6000;
					}
				setAlpha(target, alpha);
				alpha -= time*3;
			}, timer);
}

function fadeIn(id, time) {
	target = document.getElementById(id);
	
	alpha = 0;
	
	//timer = (time*1000)/500;
	timer = time
	var u = setInterval(
			function() {
				if (alpha >= 70)
					clearInterval(u);
				setAlpha(target, alpha);
				alpha += time*3;
			}, timer);
}

function validaFormContato(form){
	
	var erro = ""
	
	if(form.nome.value==""){
		erro = " - Informe seu nome.\n";	
	}
	if(form.email.value==""){
		erro = erro + " - Informe seu email. \n";	
	}
	if(form.estado.value==""){
		erro = erro + " - Informe seu estado. \n";	
	}
	if(form.mensagem.value==""){
		erro = erro + " - Digite a mensagem. \n";	
	}
	
	if(erro!=""){
		alert("Algun(s) erro(s) foram encontrado(s):\n\n" + erro );
		return false;
	}else{
		return true;
	}
}