function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function initialize(){
		MM_preloadImages('imagens/menu_01_.gif','imagens/menu_02_.gif','imagens/menu_03_.gif','imagens/menu_04_.gif','imagens/menu_05_.gif','imagens/menu_06_.gif','imagens/menu_07_.gif','imagens/menu_08_.gif','imagens/home_gale_01_.gif','imagens/home_gale_02_.gif');
}

//FUNCOES PARA ROLAGEM DE TEXTO NA DIV
function lib_bwcheck(){ //Browsercheck (needed)
this.ver=navigator.appVersion
this.agent=navigator.userAgent
this.dom=document.getElementById?1:0
this.opera5=(navigator.userAgent.indexOf("Opera")>-1 && document.getElementById)?1:0
this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
this.ie=this.ie4||this.ie5||this.ie6
this.mac=this.agent.indexOf("Mac")>-1
this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
this.ns4=(document.layers && !this.dom)?1:0;
this.ns=(this.dom) ?1:0;
this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5 || this.ns)
return this
}

function makeObj(obj,nest){
    nest=(!nest) ? "":'document.'+nest+'.'
this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight
this.up=goUp;this.down=goDown;
this.moveIt=moveIt; this.x=0; this.y=0;
    this.obj = obj + "Object"
    eval(this.obj + "=this")
    return this
}

function moveIt(x,y){
this.x = x
this.y = y
this.css.left = this.x+px
this.css.top = this.y+px
}

function goDown(move){
if (this.y>-this.scrollHeight+oCont.clipHeight){
  this.moveIt(0,this.y-move);
  if (loop) setTimeout(this.obj+".down("+move+")",speed)
}
}
function goUp(move){
if (this.y<0){
  this.moveIt(0,this.y-move)
  if (loop) setTimeout(this.obj+".up("+move+")",speed)
}
}

function scroll(speed){
if (scrolltextLoaded){
  loop = true;
  if (speed>0) oScroll.down(speed);
  else oScroll.up(speed)
}
}

function noScroll(){
loop = false
if (timer) clearTimeout(timer)
}

function scrolltextInit(){
oCont = new makeObj('divScrollTextCont')
oScroll = new makeObj('divText','divScrollTextCont')
oScroll.moveIt(0,0)
oCont.css.visibility = "visible"
scrolltextLoaded = true
}
//--------------------------------------------------------

//FUNÇÃO PARA VALIDAÇÃO DO FORMULÁRIO DE CONTATO
function ValidaContato(formContato){
	with (formContato){
		if (nome.value == "") {
			alert('Favor preencher o campo Nome!');
			nome.focus();
			return false;
		}
		if (email.value == "") {
			alert('Favor preencher o campo E-mail!');
			email.focus();
			return false;
		} else {
			var x = email.value;
			var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			if (!filter.test(x)) {
				alert('Formato de e-mail inválido!');
				email.focus();
				email.select();
				return false;
			}
		}
		if (assunto.value == "") {
			alert('Favor preencher o campo Assunto!');
			assunto.focus();
			return false;
		}
		if (mensagem.value == "") {
			alert('Favor preencher o campo Mensagem!');
			mensagem.focus();
			return false;
		}
		if (codigo_seguranca.value == "") {
			alert('Favor preencher o Código de Segurança!');
			codigo_seguranca.focus();
			return false;
		}
		return true;
	}
}

//FUNÇÃO PARA VALIDAÇÃO DO FORMULÁRIO DE LOGIN ANUNCIANTE (EXTRANET)
function ValidaLogin(formLogin){
	with (formLogin){
		if (USUARIO.value == "") {
			alert('Favor preencher o nome de Usuário!');
			USUARIO.focus();
			return false;
		}
		if (SENHA.value == "") {
			alert('Favor preencher a Senha!');
			SENHA.focus();
			return false;
		}
		return true;
	}
}

//AMPLIACAO DAS IMAGENS
function DisplayImage(picURL){
	var bImg = new Image();

	bImg.src = picURL.replace('imagens/','imagens/g');
	
	if ((bImg.width == 0) && (bImg.height == 0)) {
		bImg.width = 600;
		bImg.height = 600;
	}

	posx = (screen.width/2)-(bImg.width/2);
	posy = (screen.height/2)-(bImg.height/2);
	newWindow=window.open('','zoom','toolbar=no,width='+bImg.width+',height='+bImg.height+',left='+posx+',top='+posy);
	newWindow.document.write('\
	<html><head><\/head>\
	<body style="background-color: #BC9B6A;margin-left: 0px;margin-top: 0px;margin-right: 0px;margin-bottom: 0px;">\
	<a href="javascript:window.close()">\
		<img id="img_m" border="0" src="'+bImg.src+'">\
	</a>\
	<\/body><\/html>\
	');
	newWindow.document.close();
	newWindow.focus();
}

function abrirCategoria(cat){
	ajaxHTML('meioconteudo','anunciantes.inc.php?pcat='+cat+'&scat=0');	
	trocarTitulo(cat);
}

function abrirConteudo(cat){
	ajaxHTML('meioconteudo','conteudo.inc.php?secao=conteudo&cat='+cat+'&scat=0');	
	trocarTitulo(cat);
}

function abrirHotsite(cat, id){
	document.getElementById('fundok').style.display = 'block';
	document.getElementById('hot').style.display = 'block';
	ajaxHTML('hot','hotsite.php?secao=conteudo&pcat='+cat+'&scat=0&id='+id);
	document.getElementById('fundok').style.height = document.body.scrollHeight+25;
}

function fecharHotsite(cat){
	document.getElementById('fundok').style.display = 'none';
	document.getElementById('hot').style.display = 'none';
}

function atualizaHotsite(cat){
	ajaxHTML('hot','hotsite.php?secao=conteudo&cat='+cat+'&scat=0');
}

function trocarTitulo(num){
	document.getElementById('titulo_cat').src='images/tit_'+num+'.gif';
}

//FUNCAO PARA TROCA DE IMAGENS
function troca_imagem(obj, album, img, tam){
	document.getElementById(obj).src = 'resize.php?img=uploads/fotos/'+album+'/'+img+'&img_x='+tam;
}

function buscaRapida(){
	var qs='';
	if (document.getElementById('busca_rapida').BUSCA.value == ""){
		alert('Preencha o parâmetro para busca');
		return false;
	} else {
		qs += '?BUSCA='+document.getElementById('busca_rapida').BUSCA.value;
		alert(qs);
	}
	ajaxHTML('meioconteudo','anunciantes.inc.php'+qs);
}

function enterPress(){
	var keycode;
	if (window.event){
		keycode = window.event.keyCode;
	}else{
		if(e){
			keycode = e.which;
		}else{
			return true;
		}
	}
	
	if (keycode == 13){
		buscaRapida();
		return false;
	}else{
		return true;
	}
	/*
	if ((window.event ? event.keyCode : event.which) == 13){
		buscaRapida();
		return false;
	}
	*/
}

//TROCA DE BANNERS - SLIDE SHOW
function SlideShow(slideList, image, href, speed, name,nameList,links,target,tipo){
         this.slideList = slideList;
         this.image = image;
         this.href = href;
         this.speed = speed;
         this.name = name;
         this.current = 0;
         this.timer = 0;
		 this.nameList = nameList;
		 this.Link = links;
		 this.Target = target;
		 this.Tipo = tipo;
 }
 
function switchImage(imgName, hrefName, imgSrc, titulo, links, target, tipo){
	if (imgName=='bgtopo') {
		document.getElementById(imgName).background=imgSrc;
	} else {
		document.getElementById(imgName).src=imgSrc;
		document.getElementById(imgName).title=titulo;
		document.getElementById(imgName).alt=titulo;
		
		if (links != ''){
			if (tipo == 'jsc'){
				document.getElementById(hrefName).href='javascript:void(0);';
				document.getElementById(hrefName).onClick=function(){ links }
			} else { 
				document.getElementById(hrefName).href=links;
				document.getElementById(hrefName).onClick='';
				document.getElementById(imgName).target=target;
			}
		}
	}
}

function SlideShow_play(){
	with(this){
		if(current++ == slideList.length-1) current = 0;
		switchImage(image, href, slideList[current], nameList[current], Link[current], Target[current], Tipo[current]);
		clearTimeout(timer);
		timer = setTimeout(name+'.play()', speed);
	}
}
SlideShow.prototype.play = SlideShow_play;