function high(which2){
theobject=which2
highlighting=setInterval("highlightit(theobject)",50)
}
function low(which2){
clearInterval(highlighting)
if (which2.style.MozOpacity)
which2.style.MozOpacity=0.3
else if (which2.filters)
which2.filters.alpha.opacity=30
}

function highlightit(cur2){
if (cur2.style.MozOpacity<1)
cur2.style.MozOpacity=parseFloat(cur2.style.MozOpacity)+0.1
else if (cur2.filters&&cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}

// Funcoes
		function MascaraMoeda(objTextBox, SeparadorMilesimo, SeparadorDecimal, e, valor){
			 if (valor.length > 9){
				return false;
			 }
			 var sep = 0;
			 var key = '';
			 var i = j = 0;
			 var len = len2 = 0;
			 var strCheck = '0123456789';
			 var aux = aux2 = '';
			 var whichCode = (window.Event) ? e.which : e.keyCode;
			 if (whichCode == 13) return true;
			 key = String.fromCharCode(whichCode); // Valor para o código da Chave
			 if (strCheck.indexOf(key) == -1) return false; // Chave inválida
			 len = objTextBox.value.length;
			 for(i = 0; i < len; i++)
				  if ((objTextBox.value.charAt(i) != '0') && (objTextBox.value.charAt(i) != SeparadorDecimal)) break;
			 aux = '';
			 for(; i < len; i++)
				  if (strCheck.indexOf(objTextBox.value.charAt(i))!=-1) aux += objTextBox.value.charAt(i);
			 aux += key;
			 len = aux.length;
			 if (len == 0) objTextBox.value = '';
			 if (len == 1) objTextBox.value = '0'+ SeparadorDecimal + '0' + aux;
			 if (len == 2) objTextBox.value = '0'+ SeparadorDecimal + aux;
			 if (len > 2) {
				  aux2 = '';
				  for (j = 0, i = len - 3; i >= 0; i--) {
						if (j == 3) {
							 aux2 += SeparadorMilesimo;
							 j = 0;
						}
						aux2 += aux.charAt(i);
						j++;
				  }
				  objTextBox.value = '';
				  len2 = aux2.length;
				  for (i = len2 - 1; i >= 0; i--)
				  objTextBox.value += aux2.charAt(i);
				  objTextBox.value += SeparadorDecimal + aux.substr(len - 2, len);
			 }
			 return false;
		}
	//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
	//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
	function bloquearCTRL(){
		var ctrl=window.event.ctrlKey;
		var tecla=window.event.keyCode;
		if (ctrl && tecla==67) {event.keyCode=0; event.returnValue=false;}
		if (ctrl && tecla==86) {event.keyCode=0; event.returnValue=false;}
	}
function login(){

var usuario = document.getElementById('usuario');

var senha = document.getElementById('senha');
if(usuario.value!=''){
	if(senha.value!=''){
		document.login.submit();
		document.login.reset();
	}else{
		alert('Por favor, entre com uma senha         \n\n\n');
		senha.focus();
	}	
}else{
	alert('Por favor, entre com usuário         \n\n\n');
	usuario.focus();
}



}

function hidetrail(){ 
document.getElementById('banners').style.display= "none";
}

function swf($arquivo,$largura,$altura,$title)
{
	document.writeln('<object type="application/x-shockwave-flash" data="' + $arquivo + '" width="' + $largura + '" height="' + $altura + '" title="' + $title + '">');
	document.writeln('<param name="movie" value="flash/' + $arquivo + '">');
	document.writeln('<param name="wmode" value="transparent">');
	document.writeln('<param name="menu" value="false">');
	document.writeln('<param name="quality" value="high">');
	document.writeln('</object>');
}

function open_popup(pagina) {
 window.open(pagina, 'open_popup', 'width=600, height=500, top=100, left=100'); 
} 
function trSetColor(linha,cor)
{
	if ( cor == '' || typeof(linha.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        var celulas = linha.getElementsByTagName('td');
    }
    else if (typeof(linha.cells) != 'undefined') {
        var celulas = linha.cells;
    }
    else {
        return false;
    }

    var celulas_count  = celulas.length;
    for (var c = 0; c < celulas_count; c++) {
        celulas[c].style.backgroundColor = cor;
    }
    return true;
}


function indique() {
 var top_indique = "/imagens/estrutura/recomende_topo.jpg"
 window.open('/js/indicar/indique.php?url='+document.location.href+'&topo='+top_indique+'', 'Indicar', 'width=340, height=312, top=100, left=100'); 
} 



function changeColor(objDiv,css1,css2){
	if(objDiv.className == css1){	
	
		objDiv.className=css2;
	
	}else{
		objDiv.className=css1;
	}
}

function changeColor_not(objDiv){
	if(objDiv.className == 'fontMenuOver_not'){	
		objDiv.className='fontMenu_not';
	}else{
		objDiv.className='fontMenuOver_not';
	}
}

function changeColor_menu(objDiv){
	if(objDiv.className == 'fontMenuOver_menu'){	
		objDiv.className='fontMenu_menu';
	}else{
		objDiv.className='fontMenuOver_menu';
	}
}



function printer(div){
 conte=document.getElementById(div).innerHTML;
 
 pop=window.open("","print","width=670,height=500,scrollbars=1");
 pop.document.write('<link href="css.css" rel="stylesheet"/>');
 pop.document.write('<body leftmargin=0 topmargin=0 rightmargin=0 bottommargin=0>');
 pop.document.write('<center><table bgcolor=#ffffff><tr><td><img src=/imagens/estrutura/print_topo.jpg></td></tr><tr><td>');
 pop.document.write('<div style="width:100%">');
 pop.document.write('<div>');
 pop.document.write(conte);
 pop.document.write('</div>');
 pop.document.write('</td></tr><tr><td><span style="cursor:pointer" onclick="window.print();"><font size=1 face=verdana>&nbsp;&nbsp;&nbsp;&nbsp;<br><div align="right"><img src="/imagens/estrutura/bt_imprimir_n.jpg"></div></font></span><br></td></tr></table></center></body>');
pop.document.close();
}

function imprime_auto(id,anunciante_id){
	pop('/anuncios/html/auto_print.php?anunciante_id='+anunciante_id+'&anuncio_id='+id+'','print_anuncio','width=670,height=420,toolbar=0,status=,menubar=0,scrollbars=1,resizable=0,left=1,top=1');	
}

function imprime_imovel(id,anunciante_id){
	pop('/anuncios/html/imovel_print.php?anunciante_id='+anunciante_id+'&anuncio_id='+id+'','print_anuncio','width=670,height=500,toolbar=0,status=,menubar=0,scrollbars=0,resizable=0,left=1,top=1');	
}



function cadastro_ajax(email) {
 var url = '/scripts/cadastronews.php?user_email='+email;
  new Ajax.Request(url, {
  method: 'get'
  });
}


function switchMenu(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != "none" ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}

function abrefoto(imagem,nome)
{
	fotog.innerHTML = '<img src="'+imagem+'"  width=250 >';
}



function addSWF (URL, WIDTH, HEIGHT, TRANSPARENT)
{
document.write (' <object classid="clsid:27CDB6E-AE6D-11cf-96B8-444553540000" ');
document.write (' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" ');
document.write (' width="'+ WIDTH +'" height="'+ HEIGHT +'">');
document.write (' <param name="movie" value="'+ URL +'" />');
document.write (' <param name="quality" value="high" />');

if ( TRANSPARENT ) {
  document.write (' <param name="Wmode" value="Transparent" />'); 
}

document.write (' <embed src="'+ URL +'" quality="high" ');

if ( TRANSPARENT ) {
document.write (' Wmode = "transparent" ');
}

document.write (' pluginspage="http://www.macromedia.com/go/getflashplayer" ');
document.write (' type="application/x-shockwave-flash" width="'+ WIDTH +'" height="'+ HEIGHT +'"></embed> ');
document.write (' </object>');

}



var newwindow;
function poptastic(url)
{
	windet=window.open(url,'BOTAO1','scrollbars=yes,height=464,width=657,top=270,left=100');
	if (window.focus) {newwindow.focus()}
}


//---------------------------------------------------
// Função para mudar as tab dos menus
//---------------------------------------------------
 function muda_tab(tab) {
 	
 	if(tab==1){
		document.images.img_nt.src='imagens/estrutura/box_nt_agenda.jpg';
		$('agenda').style.display = 'block';
		$('escola').style.display = 'none';
		$('artigos').style.display = 'none';	
	}
	if(tab==2){
		document.images.img_nt.src='imagens/estrutura/box_nt_escola.jpg';
		$('agenda').style.display = 'none';
		$('escola').style.display = 'block';
		$('artigos').style.display = 'none';	
	}
	
	if(tab==3){
		document.images.img_nt.src='imagens/estrutura/box_nt_artigos.jpg';
		$('agenda').style.display = 'none';
		$('escola').style.display = 'none';
		$('artigos').style.display = 'block';	
	}
 }


//---------------------------------------------------
// MENUS E SUBMENUS
//---------------------------------------------------
var menu = {
    exibirDetalhes : function(id){
        // exbide a linha
        var nomeLinha = "sub_grupo_"+id;
		var nomeSpam = "spam_"+id;
        $(nomeLinha).toggle();

		if($(nomeLinha).visible()==false){
			
           	
			
			$(nomeSpam).removeClassName('img_seta_frente');
			$(nomeSpam).addClassName('img_seta_baixo');
		} else {

           
			
			$(nomeSpam).addClassName('img_seta_baixo2');
			$(nomeSpam).removeClassName('img_seta_baixo');
		}
    }
}
//---------------------------------------------------
// Função ajax padrao prototype
//---------------------------------------------------
function p_ajax(p_div_id, p_url, p_params) {
new Ajax.Updater(p_div_id, p_url, {
				  encoding: 'iso-8859-1',
				  method: 'post', 
				
			 	  parameters:p_params});
}

function cadastro_ajax(email,nome) {
 var url = '/scripts/cadastronews.php?user_email='+email+'&user_nome='+nome;
  new Ajax.Request(url, {
  method: 'get'
  });
}

function switchBody(theme){
	if (theme==1){
		  document.body.style.backgroundImage='url(http://www.adcascavel.com.br/imagens/estrutura/fundos/fundo_1_bg.jpg)'; 
		 document.body.style.backgroundRepeat='repeat'; 
	} 
	  
	if (theme==2){
		document.body.style.background="#e9f8ff"; 
	}
	if (theme==3){
		document.body.style.backgroundImage="url(http://www.adcascavel.com.br/imagens/estrutura/fundos/fundo_3_bg.jpg)"; 
		document.body.style.backgroundRepeat='repeat'; 
	}
		
}

function muda_theme(theme){
	var url = '/scripts/theme.php?theme='+theme+'';
	new Ajax.Request(url, { 
		method: 'get'
	});

	$('fundoSite').className = 'fundo_'+theme;
	switchBody(theme);
	p_ajax('copyright','/scripts/copy.php','theme='+theme+'');	
		
}


function pop(pagina,janela,parametros) {
 window.open(pagina, janela, parametros); 
} 
