//reload
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


// mensagem inicial
var msg = "";
function link(id)
{
	if(id == 0)
	{
		/*tl = new textlist( 
		"Seja Bem vindo ao novo Portal bocaiuva.COM!",
		"Escolha uma das opï¿½es do menu interativo e navegue pelo site.",
		"Utilize nossa pesquisa para encontrar o que vocï¿½procura.."
		);
		var x = 0; pos = 0;
		var l = tl[0].length;
		var max=0;
		setTimeout("textticker(0)", 1000);
		*/
		msg = "<b>Seja Bem vindo ao bocaiuva.COM!  Escolha uma das opções do menu.</b>";
	}

	if(id == 1)
	{
		msg = "Faça um tour pela cidade do Senhor do Bonfim. Conheça sua cultura...";

	}
	else if( id == 2)
	{
		msg = "Fique por dentro dos últimos acontecimentos em Bocaiúva e toda região.";

	}
	else if( id == 3)
	{
		msg = "Seu guia virtual de serviços em diversos seguimentos na cidade.";

	}
	else if( id == 4)
	{
		msg = "Não perca este AGITO! Muito entretenimento, diversão e informação.";

	}
	
	document.getElementById("mensagem").innerHTML = msg;
}

var max=0;
function textlist() 
{
	max=textlist.arguments.length;
	for (i=0; i<max; i++)
		this[i]=textlist.arguments[i];
}

tl = new textlist( 
	"Seja Bem vindo ao novo Portal bocaiuva.COM!",
	"Escolha uma das opï¿½es do menu interativo e navegue pelo site.",
	"Utilize nossa pesquisa para encontrar o que vocï¿½procura.."
	);
var x = 0; pos = 0;
var l = tl[0].length;

function textticker(msg) 
{
	if(tl)
	{
		document.getElementById("mensagem").innerHTML = tl[x].substring(0, pos) + "_";
		if(pos++ == l) 
		{
			pos = 0; 
			setTimeout("textticker(0)", 5000); 
			if(++x == max) x = 0; 
			l = tl[x].length;
		}
		else
		{
			setTimeout("textticker(0)", 120);
			//alert();
		}

	}
}

// popup
function popup(jan,width,height,id,scroll) 
{

   var left = 99;
   var top = 99;

   window.open('index.php?id='+id, jan, 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars='+scroll+', status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}

// Funï¿½es de manipulaï¿½o do Botï¿½ direito
var display_url=0
function showmenuie5()
{
	var rightedge=document.body.clientWidth-event.clientX
	var bottomedge=document.body.clientHeight-event.clientY
	if (rightedge<ie5menu.offsetWidth)
	ie5menu.style.left=document.body.scrollLeft+event.clientX-ie5menu.offsetWidth
	else
	ie5menu.style.left=document.body.scrollLeft+event.clientX
	if (bottomedge<ie5menu.offsetHeight)
	ie5menu.style.top=document.body.scrollTop+event.clientY-ie5menu.offsetHeight
	else
	ie5menu.style.top=document.body.scrollTop+event.clientY
	ie5menu.style.visibility="visible"
	return false
}

function hidemenuie5()
{
	ie5menu.style.visibility="hidden"
}

function highlightie5()
{
	if (event.srcElement.className=="menuitems")
	{
		event.srcElement.style.backgroundColor="highlight"
		event.srcElement.style.color="white"
		if (display_url==1)
		window.status=event.srcElement.url
	}
}

function lowlightie5()
{
	if (event.srcElement.className=="menuitems")
	{
		event.srcElement.style.backgroundColor=""
		event.srcElement.style.color="black"
		window.status=''
	}
}

function jumptoie5()
{
	if (event.srcElement.className=="menuitems")
	window.location=event.srcElement.url
}

// Adicionar a favoritos
function favoritos()
{
	window.external.AddFavorite("http://www.bocaiuva.com","bocaiuva.COM");
}

// Pï¿½ina Inicial
function inicial(vId)
{
	var ns = (navigator.appName == "Netscape");
	var ie = (navigator.appName == "Microsoft Internet Explorer");
	if(ie)
	{
		vId.style.behavior='url(#default#homepage)';
		vId.setHomePage('http://www.bocaiuva.com');
	} 
	else if(ns)
	{
		netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesWrite");
		navigator.preference("browser.startup.homepage", "http://www.bocaiuva.com");
	}
}

// Imprimir
function imprimir()
{
	var NS = (navigator.appName == "Netscape");
	var VERSION = parseInt(navigator.appVersion);
	if (NS)
	{
		window.print();
	}
	else
	{
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
		WebBrowser1.ExecWB(6, 2);
		WebBrowser1.outerHTML = "";
	}
}

// seleï¿½o de textos no site
function disableselect(e)
{
    return false
}

function reEnable()
{
    return true
}

document.onselectstart=new Function ("return false")
if (window.sidebar)
{
    document.onmousedown=disableselect
    document.onclick=reEnable
}




// contador de caracteres no torpedo

var erro = false
var field = document.formulario;
//Testa campos contra entrada de tipos de arquivos invalidos
function validaCaracter(campo,fieldname){
    erro = false
    var caracteresValidos = "abcdefghijklmnopqrstuvxwyzABCDEFGHIJKLMNOPQRSTUVXWYZï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½"
    eval('Ocampo = field.'+campo+'.value')
    for (i = 0; i < Ocampo.length; i++){ 
        var teste = Ocampo.charAt(i);
        if (caracteresValidos.indexOf(teste) == -1){
            alert("Por favor nï¿½ use caracteres especiais no campo "+fieldname);
            eval('field.'+campo+'.focus();')
            erro = true
        }
        if (erro == true){return false}
    }
}//fim validaCaracter

//Testa campos verificando se existe a string passada
function CharInString(campo,string,errormessage){
    erro = false
    eval('Ocampo = field.'+campo+'.value')
    eval('TestField = /'+string+'/i');//Busca pela extensao do arquivo passada no parametro stringtype case insensitive
    if (TestField.test(Ocampo) == false){//se nao tem gera erro
        erro = true;
        alert(errormessage);
    }
    if (erro == true){return false}
}//fim CharInString


//Testa campos verificando se existe a string passada
function CharNotInString(campo,string,errormessage){
    erro = false
    eval('Ocampo = field.'+campo+'.value')
    eval('TestField = /'+string+'/i');//Busca pela extensao do arquivo passada no parametro stringtype case insensitive
    if (TestField.test(Ocampo) == true){//se tem gera erro
        erro = true;
        alert(errormessage);
    }
    if (erro == true){return false}
}//fim CharNotInString

function checkEmail(campo,errormessage) {
    erro = false
    if (/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(eval('field.'+campo+'.value'))){
        return (true)
    }
    alert('Preencha corretamente o campo \"E-mail\" '+errormessage+' com um endereço de correio eletrônico válido (ex.: seunome@provedor.com.br)')
    erro = true
}

function noCharacter(campo,caracter){//remove caracter invalido caso ele esteja como ultimo na string  
    while(eval('field.'+campo).value.charAt(eval('field.'+campo).value.length-1)==caracter){
        eval('field.'+campo).value=eval('field.'+campo).value.substring(0,eval('field.'+campo).value.length-1);
    }
} 

function clearSpaces(campo){
    eval('Ocampo = field.'+campo+'.value')
    Pattern = /(\s+)/g;//Busca pela por espaï¿½s em toda a extensao da string
    Ocampo = Ocampo.replace(Pattern," ")//Troca espaï¿½s extras por um so espaco
    eval('field.'+campo+'.value = Ocampo')
}

function validaCheckBox(){//testa se existe um checkbox marcado
   var ok = 0;
   for (i =0; i < field.length; i++){
        if (field.elements[i].type == 'checkbox'){
            if (field.elements[i].checked == true){ok++}
        }
    }   
   if (ok == 0){
       alert("Por favor selecione pelo menos uma opção para alterar");
       return false;
   }
}//end function

function textCounter(campo, countcampo, maxlimit){//conta/mostra caracteres restantes e limita o tamanho do campo
    if (campo.value.length > maxlimit) //se passar do limite nao deixa entrar o caracter
        campo.value = campo.value.substring(0, maxlimit);
        //reduz o valor do campo de contadem
    else 
        countcampo.value = maxlimit - campo.value.length;
}

function removeEnter(campo){
    eval('Ocampo = field.'+campo+'.value')
    Pattern = /[\n\r]/g;//Busca pela por quebras de linhas em toda a extensao da string
    Ocampo = Ocampo.replace(Pattern," ")
    eval('field.'+campo).value = Ocampo//troca valor do campo pelo novo sem quebras de linha
}

// pop destaque

function pop(pagina)
{
	window.open(pagina,"",""); 
}

function pop_destaque(cod)
{
	//window.open(pagina,"",""s); 
	window.open('?id=109&cod='+cod,'destaque'+cod, 'width=700, height=450, top=15, left=15, scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=yes, resizable=no, fullscreen=no');
}

function enquete(id,op1,op2,op3,op4,op5,op6,tipo)
{
	if(tipo == 1)
	{
		var mostra = 0;

		if(op1 != 0 && document.getElementById(op1).checked == true) mostra = document.getElementById(op1).value;

		if(op2 != 0 && document.getElementById(op2).checked == true) mostra = document.getElementById(op2).value;

		if(op3 != 0 && document.getElementById(op3).checked == true) mostra = document.getElementById(op3).value;

		if(op4 != 0 && document.getElementById(op4).checked == true) mostra = document.getElementById(op4).value;

		if(op5 != 0 && document.getElementById(op5).checked == true) mostra = document.getElementById(op5).value;

		if(op6 != 0 && document.getElementById(op6).checked == true) mostra = document.getElementById(op6).value;

		if(mostra == 0) alert('Escolha umas das opções antes de votar!');
		else
		{
			window.open('?id=4&cod_enquete='+mostra, 'enquete', 'width=300, height=310, top=15, left=15, scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
		}
	}
	else
	{
		window.open('?id=4', 'enquete', 'width=300, height=300, top=15, left=15, scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');	
	}
}

// zoom noticias
var zoom = 1;
function Zoom(operacao, fator) 
{
	switch(operacao) 
	{
		case '-':
			//alert(zoom);
			zoom /= fator;
			if(zoom < 0.91) zoom = 0.909090;
			document.getElementById("zoom").style.zoom = zoom;
			
		break;
		case '=' :
			zoom = 1;
			document.getElementById("zoom").style.zoom = zoom;
		break;
		default :
			//alert(zoom);
			zoom *= fator;
			if(zoom > 1.464) zoom = 1.464;
			document.getElementById("zoom").style.zoom = zoom;
	}
}

// imprimir 
function print_com(news)
{
	window.open('?id=106&news='+news,'print', 'width=600, height=400, top=15, left=15, scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=yes, resizable=no, fullscreen=no');
}


// recomenda
function recomenda(tit,url)
{
	window.open('?id=107&tit='+tit+'&url='+url,'destaque', 'width=600, height=400, top=15, left=15, scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
	//window.alert(url);
}
function recomenda_form()
{
	
	if (document.cadastro.name_re.value == "")
	{
		alert("Informe seu nome!");
		return false;
	}
	else if (document.cadastro.email_re.value == "")
	{
		alert("Informe seu e-mail");
		return false;
	}
	else if (document.cadastro.name_0.value == "")
	{
		alert("Informe o nome do indicado!");
		return false;
	}
	else if (document.cadastro.email_0.value == "")
	{
		alert("Informe o e-mail do inidcado!");
		return false;
	}
	
}

var i=1;
function createCase()
{
    var tb = document.all('case');
	var tr1 = document.createElement("<tr id='tra_"+(i)+"'>");
	var tr2 = document.createElement("<tr id='trb_"+(i)+"'>");
	var tr3 = document.createElement("<tr id='trc_"+(i)+"'>");
	var td1 = document.createElement("<td>");
	var td2 = document.createElement("<td>");
	var td3 = document.createElement("<td>");
	var td4 = document.createElement("<td>");
	var td5 = document.createElement("<td>");
	var td6 = document.createElement("<td>");

	
	tb.appendChild(tr1);
	tr1.appendChild(td1);
	tr1.appendChild(td2);
	
	tb.appendChild(tr2);
	tr2.appendChild(td3);
	tr2.appendChild(td4);
	
	tb.appendChild(tr3);
	tr3.appendChild(td5);
	tr3.appendChild(td6);

	var c = document.createElement('<input name="name_'+i+'" type="text" id="name_'+i+'" size="30" class="forms" style="height:18;">');
    td1.innerHTML += "<font color='#666666' size='1' face='Verdana'><B>Nome:</B><font>";
	td2.appendChild(c)
	
	var d = document.createElement('<input name="email_'+i+'" type="text" id="email_'+i+'" size="30" class="forms" style="height:18;">');
    td3.innerHTML += "<font color='#666666' size='1' face='Verdana'><B>Email:</B><font>";
	td4.appendChild(d)
	
	
	td5.innerHTML += "";
	td6.innerHTML += "<div align='left'><input name='button' type='button' onClick='JavaScript:remove("+i+")'  style='cursor:hand; border-style:solid; border-width:0; color:#666666; font-size: 8 pt; font-family: Verdana; vertical-align: middle; letter-spacing: 0; font-weight: bold; height: 13; width: 73; background-color: #F8FAFC; padding-left:4; padding-right:4; padding-top:1; padding-bottom:1' value='- Remover'></div>";
	

	document.all("detalhes").value = i;
	i++;
	
}

function remove(id)
{
	if (confirm('Deseja remover esta indicação?'))
	{
		document.all("tra_"+id).removeNode(true);
		document.all("trb_"+id).removeNode(true);
		document.all("trc_"+id).removeNode(true);
	}
}

function newss_pop() 
{
   window.open('sub_newsletter.php','nwss', 'width=350, height=240, top=10, left=10, scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}

function newss()
{
	
	if (document.cadastro.nome.value == "")
	{
		alert("Campo obrigatório: Nome");
		return false;
	}
	else if (document.cadastro.email.value == "")
	{
		alert("Campo obrigatório: E-mail");
		return false;
	}
	else if (document.cadastro.cidade.value == "")
	{
		alert("Campo obrigatório: Cidade");
		return false;
	}
	else if (document.cadastro.pais.value == "")
	{
		alert("Campo obrigatório: País");
		return false;
	}
	else if (document.cadastro.uf.value == "0")
	{
		alert("Selecione o Estado");
		return false;
	}
	
}

function pop_banner(img, width, height, link)
{
	
	window.open('?id=110&img='+img+'&link='+link,'popbanner', 'width='+width+', height='+height+', top=15, left=15, scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}

function pop_tempo2()
{
	
	window.open('http://br.weather.com/weather/tenday/BRXX0363?day=0&vert=WeatherCity&pres=Bocaiuva%2C+Brasil#day','tempo', 'width=330, height=450, top=15, left=15, scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}

