/*------------------------------------------------------------------------
# G3 Site - Version 1.0
# ------------------------------------------------------------------------
# Copyright (C) 2007-2010 G3 Brasil Comunicação e Marketing Ltda, All Rights Reserved.
# Author: G3 - z4n6uz
# Websites:  http://www.agenciag3brasil.com.br
-------------------------------------------------------------------------*/



	
function openLoad()
{
	window.scroll(500,500);
	
	imgMenu = new ImgMenus();
	barra = new MoveBarra();
	janela = new JanelaConteudo();
	contato = new FormContato();
	imgMenu.setImgMenus();
	
	
	document.getElementById("inicial").setAttribute("onclick","barra.moveBarraBot()");
	(new Image(100,78)).src = "img/carregando.gif";
}



function FormContato() 
{
	var _text;
	
	this.limparInput = limparInput;
	this.retornarTexto = retornarTexto;
	this.limparTodos = limparTodos;
	
		
	function limparInput(obj,text)
	{
		obj.value="";
		_text= text;
	}
	
	function retornarTexto(obj)
	{
		if(obj.value=="")
			obj.value=_text;
	}
	
	function limparTodos()
	{
		document.getElementById("nome").value="Nome";
		document.getElementById("email").value="E-mail";
		document.getElementById("telefone").value="Telefone ou Celular";
		document.getElementById("mensagem").value="Mensagem";
	}
}



function MoveBarra()
{
	this.pos=700;
	this.bar = document.getElementById("barramen");
	this.inter;
	
	
	this.moveBarraTop = moveBarraTop;
	this.moveBarraBot = moveBarraBot;
	this.sobBarra = sobBarra;
	this.desceBarra = desceBarra;
	
	function moveBarraTop()
	{
		this.inter = setInterval('barra.sobBarra()',10);
	}
	
	function moveBarraBot()
	{
		this.inter = setInterval('barra.desceBarra()',10);
	}
	
	function sobBarra()
	{
		if(this.pos>10)
		{
			this.bar.style.marginTop=(this.pos-=20)+"px";
			document.getElementById("topbar").style.display="none";
			window.scroll(this.pos,this.pos);
		}
		else
		{
			clearInterval(this.inter);
			janela.setJanela(imgMenu.imgmenuclicked);
		}
		
	}
	
	
	function desceBarra()
	{
		if(this.pos<700)
		{
			this.bar.style.marginTop=(this.pos+=20)+"px";
			window.scroll(this.pos,this.pos);
		}
		else
		{
			clearInterval(this.inter);
			janela.desativaJanela();
			document.getElementById("topbar").style.display="block";
		
			document.getElementById("imgm"+imgMenu.imgmenuclicked).src="img/imgm"+imgMenu.imgmenuclicked+".png";
			imgMenu.imgmenuclicked=0;
		
		}
		
	}
	
}


function ImgMenus()
{
	
	this.imgmenuclicked=0; 
	this.objmenu = document.getElementById("men");
	
	this.setImgMenuClicked = setImgMenuClicked;
	this.setImgMenus = setImgMenus;
	this.setImgMenuOver = setImgMenuOver;
	this.setImgMenuOut = setImgMenuOut;

	function setImgMenus()
	{
		
		for(i=1; i<5; i++)
		{
			(new Image(88,50)).src = "img/imgm"+i+"-over.png";
		
			m = document.createElement("a");
			m.setAttribute("class","menu");
			currentFile = document.createElement("img");
			currentFile.setAttribute("src","img/imgm"+i+".png");
			currentFile.setAttribute("id","imgm"+i);
			currentFile.setAttribute("onclick","imgMenu.setImgMenuClicked(this,"+i+")");
			currentFile.style.marginTop="20px";
			currentFile.style.height="50px";
			m.setAttribute("onmouseover","imgMenu.setImgMenuOver("+i+",'imgm"+i+"-over.png')");
			m.setAttribute("onmouseout","imgMenu.setImgMenuOut("+i+",'imgm"+i+".png')");
			m.appendChild(currentFile);
			this.objmenu.appendChild(m);
		}
	}
	
	function setImgMenuClicked(link,i)
	{
		
		if(this.imgmenuclicked!=i)
		{
			if(this.imgmenuclicked)
			{
				document.getElementById("imgm"+this.imgmenuclicked).src="img/imgm"+this.imgmenuclicked+".png";
			}
			
			this.imgmenuclicked = i;	
			
			if(barra.pos>10)
				barra.moveBarraTop();
			else
				janela.setJanela(this.imgmenuclicked);
		}
	}
	
	function setImgMenuOver(i,img)
	{
		obj = document.getElementById("imgm"+i);
		if(i!=this.imgmenuclicked)
		{
			obj.src="img/"+img;
		}
		
	}
	
	function setImgMenuOut(i,img)
	{
		obj = document.getElementById("imgm"+i);
		if(i!=this.imgmenuclicked)
		{

			obj.src="img/"+img;

		}
	}

}


function JanelaConteudo()
{

	this.janelaativa=0;

	
	this.setJanela = setJanela;
	this.desativaJanela = desativaJanela;
	this.openNots = openNots;
	this.retornaGrupo = retornaGrupo;
	
	function setJanela(j)
	{
		if(this.janelaativa)
		{
			this.janelaativa.style.zIndex=-1;
			this.janelaativa.style.display="none";
		}
		
		this.janelaativa =  document.getElementById("cont"+j);
		this.janelaativa.style.zIndex=2;
		this.janelaativa.style.display="block";
	}
	
	function desativaJanela()
	{
		this.janelaativa.style.display="none";
		this.janelaativa=0;
	}
	
	function openNots(n)
	{
		
		ajaxLoad("men/nots?op="+n,"cont-grupo-nots");
	}
	
	function retornaGrupo()
	{
		ajaxLoad("men/nots?op=0","cont-grupo-nots");
	}

}




