<!-- version 1.0

var ehFeriado = 0;

function indicarSite ()
	{
	var szURL = "http://www.sampaonline.com.br/convitesite.htm?"+document.URL+"&"+InserirSeparador (document.title);
	self.location=szURL;
	}

function InserirSeparador (wParam)
	{
	if (wParam.indexOf (" ") < 0) return (wParam);
	var aArray = new Array;
	aArray = wParam.split (" ");
	var szResult = new String;
	var nIndex = -1;
	while (++nIndex < aArray.length)
		{
		szResult += aArray[nIndex]+"+";
		}
	return (szResult);
	}


function mostrarRelogio ()
	{
	NewWindow = open ("http://www.sampaonline.com.br/horacerta.htm","Relogio", "toolbar=no,scrollbars=no,location=no,directories=no,status=no,menubar=no,left=0,top=0");
	NewWindow.moveTo(00,00);
	NewWindow.resizeTo (0, 0);
	var y = 0;
	for (x = 0; x < 15; x++)
		{
		NewWindow.resizeBy (x, y);
		if (y < 5) ++y;
		}
	for (x = 0; x < 75; x++)
		{
		NewWindow.moveTo (x, x);
		}
	}		

function calcularSeguro (formulario)
	{
	if (document.forms[0].anodefabricacao.selectedIndex < 1) { alert ("Por favor selecione o Ano de Fabricação."); return; }
	if (document.forms[0].fabricantes.selectedIndex < 1) { alert ("Por favor selecione o fabricante."); return; }
	sLocation = "http://www.sampaseguros.com.br/automoveis.htm?fabricante="+document.forms[0].fabricantes[document.forms[0].fabricantes.selectedIndex].text+"&anodefabricacao="+document.forms[0].anodefabricacao[document.forms[0].anodefabricacao.selectedIndex].text;
	NewWindow = open (sLocation, "sampaseguros", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=720,height=495,left=12,top=12,alwaysRised=yes");
	}

function processSelectedOptionDC (formulario)
	{
	var index = formulario.Ramos.selectedIndex;
	if (index > 0)
		{
		var szNewlocation;
		szNewlocation = "http://www.sampaonline.com.br/comercios/"+formulario.Ramos.options [index].value+".htm?bairro="+formulario.bairros[formulario.bairros.selectedIndex].value+"&origem=deliverychannel";
		NewWindow = open (szNewlocation,"SampaOnline", "toolbar=no,scrollbars=yes,location=no,directories=no,status=yes,menubar=no,width=520,resizable=yes");	
		}
	}

function mostrarProgramacaoCinema ()
	{
	var index = document.forms[0].SalasDeCinema.selectedIndex;
	if (index < 1) return; 
	sLocation = document.forms[0].SalasDeCinema.options [index].value;
	NewWindow = open (sLocation, "cinema", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=580,height=395,left=12,top=12,alwaysRised=yes");
	}

// ver homepages/mainfncout.txt

function setURLBairro ()
	{
	var szDocumentURL = window.location; 
	document.forms[0].wparams.value = szDocumentURL; 
	var szParametro = document.forms[0].wparams.value; 
	var szURLBairro = extractParams (szParametro, 1);
	if (szURLBairro == "null")  szURLBairro = document.URL;
	if (szURLBairro.indexOf ("moema.") > 0)			return ("moema.com");
	if (szURLBairro.indexOf ("campobelo.") > 0)		return ("campobelo.com");
	if (szURLBairro.indexOf ("jardinsonline") > 0)		return ("jardinsonline.com");
	if (szURLBairro.indexOf ("itaim.") >= 0)		return ("itaim.com.br");
	if (szURLBairro.indexOf ("brooklin.") >= 0)     	return ("brooklin.com.br");
	if (szURLBairro.indexOf ("santoamaroonline.") >= 0)   	return ("santoamaroonline.com.br");
	if (szURLBairro.indexOf ("marajoara.") >= 0)		return ("jardimmarajoara.com.br");
	if (szURLBairro.indexOf ("higienopolis.") >= 0)		return ("higienopolis.com");
	if (szURLBairro.indexOf ("vilamarianaonline.") >= 0)    return ("vilamarianaonline.com");
	if (szURLBairro.indexOf ("morumbionline.") >= 0)    	return ("morumbionline.com.br");
	if (szURLBairro.indexOf ("bairrotatuape.") >= 0)    	return ("bairrotatuape.com.br");
	if (szURLBairro.indexOf ("bairrodalapa.") >= 0)    	return ("bairrodalapa.com.br");
	if (szURLBairro.indexOf ("santana.") >= 0)    		return ("santana.com.br");
	if (szURLBairro.indexOf ("pinheirosonline.") >= 0)    	return ("pinheirosonline.com");
	return ("sampaonline.com.br");
	}

function setSiteId (szDocumentURL)
	{

	if (szDocumentURL.indexOf("campobelo.com") >= 0) 		return ("Cbelo");
	if (szDocumentURL.indexOf("brooklin.com.br") >= 0) 		return ("Brooklin");
	if (szDocumentURL.indexOf("itaim.com.br") >= 0) 		return ("Itaim");
	if (szDocumentURL.indexOf("santoamaroonline.com.br") >= 0) 	return ("Samaro");
	if (szDocumentURL.indexOf("jardimmarajoara.com.br")  >= 0) 	return ("Marajoara");
	if (szDocumentURL.indexOf("moema.com")  >= 0) 			return ("Moema");
	if (szDocumentURL.indexOf("jardinsonline.com") >= 0) 		return ("Jardins");
	if (szDocumentURL.indexOf("higienopolis.com")  >= 0) 		return ("Higienopolis");
	if (szDocumentURL.indexOf("santana.com")  >= 0) 		return ("Santana");
	return ("Sampa");
	}

function setSiteName (szSiteId)
	{
	if (szSiteId == "Brooklin") return ("Brooklin");
	if (szSiteId == "Itaim") return ("Itaim");
	if (szSiteId == "Moema") return ("Moema");
	if (szSiteId == "Samaro") return ("Santo Amaro");
	if (szSiteId == "Marajoara") return ("Jardim Marajoara");
	if (szSiteId == "Cbelo") return ("Campo Belo");
	if (szSiteId == "Jardins") return ("Jardins");
	if (szSiteId == "Higienopolis") return ("Higienopolis");
	return ("Sampa Online");
	}

function setDomain (szDocumentURL)
	{
	return ("www.")+szDocumentURL;
	}

function isMainPage()
	{
	var szDocumentURL = window.location; 
	document.forms[0].wparams.value = szDocumentURL; 
	var szParametro = document.forms[0].wparams.value; 
	var szMainPage = extractParams (szParametro, 1);
	if (szMainPage == "null")  return (true);
	else return (false);
	}

function setFullDomain (szDomain)
	{
	var szFullDomain = "http://"+szDomain;
	return (szFullDomain);
	}

function ValidarOpiniao (PesquisaDeOpiniao)
	{
	var bad = false;
	var szAlert;
	var nEscolhaFilme, nEscolhaAvaliacao;
	var nEscolhaFilme = PesquisaDeOpiniao.espetaculos.selectedIndex;
	if (nEscolhaFilme > 0)
		{
   		nEscolhaAvaliacao = PesquisaDeOpiniao.avaliacao.selectedIndex;
		if (nEscolhaFilme > 0 && nEscolhaAvaliacao  > 0) PesquisaDeOpiniao.submit();
		}
	}

function ProcessarRecomendacao (FormRecomendacao)
	{
	var nOpcao = FormRecomendacao.estabelecimentos.selectedIndex;
	if (nOpcao > 0)
		{
		var szWindowName = FormRecomendacao.estabelecimentos[nOpcao].value;
		if (szWindowName == "outros") self.location = "http://www.sampaonline.com.br/vizinhorecomenda.htm";
		else 
			{
			NewWindow = open ("testemunho.htm", szWindowName, "toolbar=no,scrollbars=yes,location=no,directories=no,status=yes,menubar=no,width=640");
			}
		}
	}

function mostrarRecomendacoes (FormRecomendacao)
	{
	var nOpcao = FormRecomendacao.estabelecimentos.selectedIndex;
	if (nOpcao > 0)
		{
		var szURL = "http://www.sampaonline.com.br/recomendacoes/"+FormRecomendacao.estabelecimentos[nOpcao].value+".htm";
		NewWindow = open (szURL, "Recomendacoes", "toolbar=no,scrollbars=yes,location=no,directories=no,status=yes,menubar=no,width=640");
		}
	}

function ProcessarBoletim (bairro, szAcao)
	{
	found = new Boolean;
	found = false;
	for (nIndex = 0;nIndex < document.forms.length;nIndex++)
		{
		if (document.forms[nIndex].name == "formBoletim" )
			{
			found = true;
			break;		
			}
		}
	if (!found) return;
	if (document.forms[nIndex].emailboletim.value == "")
		{
		alert ("Por favor informe seu endereço de e-mail.");
		document.forms[nIndex].emailboletim.focus();
		return;
		}
//	Valido ?		
	bad = new Boolean;
	bad = false;
	bad = ValidarEnderecoDeEmail (document.forms[nIndex].emailboletim.value);
	if (bad) return;
	document.forms[nIndex].enderecoboletim.value = "boletim@"+document.forms[0].szURLBairro.value;
	document.forms[nIndex].acao.value = szAcao;
	document.forms[nIndex].bairroboletim.value = bairro;
	document.forms[nIndex].submit();			
	}

function inscreverNoBoletim (bairro, szAcao)
	{
//	só é chamada da página principal
	if (document.forms[2].emailboletim.value == "")
		{
		alert ("Por favor informe seu endereço de e-mail.");
		document.forms[2].emailboletim.focus();
		return;
		}
	bad = ValidarEnderecoDeEmail (document.forms[2].emailboletim.value);
	if (bad) return;
	document.forms[2].enderecoboletim.value = "boletim@"+document.forms[0].szURLBairro.value;
	document.forms[2].acao.value = szAcao;
	document.forms[2].bairroboletim.value = bairro;
	document.forms[2].success.value = "http://www.sampaonline.com.br/obrigado_boletim.htm?"+document.URL;
	document.forms[2].action = "http://www.sampaonline.com.br/cgi-local/mailtemp_inscricaoboletim.txt";
	document.forms[2].submit();			
	}

function ProcessarOpcaoPesquisa (formulario)
	{
	if (formulario.opcoespesquisa.selectedIndex > 0)
		{
		var szURL = formulario.opcoespesquisa[formulario.opcoespesquisa.selectedIndex].value;
		NewWindow = open ("","Link", "toolbar=no,scrollbars=yes,location=no,directories=no,status=yes,menubar=no,width=640,resizable=yes");
		NewWindow.self.location = szURL;
		}
	}

function switchPortalDeImoveis (formulario)
	{
	var bad = false;
	var szAlert;
	var nEscolhaProcura, nEscolhaImovel;
	var nEscolhaProcura = formulario.procura.selectedIndex;
	if (nEscolhaProcura > 0)
		{
   		nEscolhaImovel = formulario.imovel.selectedIndex;
		if (nEscolhaProcura > 0 && nEscolhaImovel  > 0) 
			{
			var szImoveisURL = "http://www.sampaonline.com.br/imoveis/ofertas/"+formulario.imovel[nEscolhaImovel].value+ formulario.procura[nEscolhaProcura].value+".htm";
			NewWindow = open (szImoveisURL, "Imoveis", "toolbar=no,scrollbars=yes,location=yes,directories=no,status=no,menubar=no");
			}
		}
	}

function SwitchTo (object)
	{
	if (object.selectedIndex < 1) return;
	if (object.options[object.selectedIndex].value.indexOf ("http:") >= 0) 
  	   {
 	   if (object.options[object.selectedIndex].value.charAt(0) == "+")
		{
//		NewWindow = open ("","SampaOnline");
		if (object.options[object.selectedIndex].value.indexOf ("?") > 0) eval("self.location='"+object.options[object.selectedIndex].value.substring(1)+"&site="+document.forms[0].szURLBairro.value+"'");
		else eval("self.location='"+object.options[object.selectedIndex].value.substring(1)+"?site="+document.forms[0].szURLBairro.value+"'");
		}
	   else 
		{
		if (object.options[object.selectedIndex].value.indexOf ("?") > 0) eval("self.location='"+object.options[object.selectedIndex].value+"&site="+document.forms[0].szURLBairro.value+"'");
		else eval("self.location='"+object.options[object.selectedIndex].value+"?site="+document.forms[0].szURLBairro.value+"'");
		}
	   }
	else 
  	   {
	   var szURL = "http://www."+document.forms[0].szURLBairro.value+"/"+object.options[object.selectedIndex].value;
	   eval("self.location='"+szURL+"'");
	   }
	}

function extractParams (szText, varPos)
	{
	var nPass = 0
	var lPos = szText.indexOf("?")
	if (lPos < 0) return ("null");
	else ++lPos;
	var szTempText;
	while (true)
		{
		rPos = szText.indexOf("&", lPos+1);
		if (rPos < 0) szTempText = szText.substring(lPos); 
		else szTempText = szText.substring(lPos, rPos); 
		if (++nPass == varPos) break;
		if (rPos < 0) return ("null");
		lPos = rPos + 1;		
		}
	rPos = szTempText.indexOf("=")+1;
	var szReturnVar = szTempText.substring(rPos); 
	return (szReturnVar);
	}

function processSelectedOption (formulario)
	{
	var index = formulario.Ramos.selectedIndex;
	if (index > 0)
		{
		var szNewlocation;
		var szSelecao = formulario.Ramos.options [index].value;
		if (szSelecao.charAt(0) == '+') 
			{
			var szRamo = szSelecao.substr (1, (szSelecao.length - 1));
			szNewlocation = "http://www.sampaonline.com.br/comercios/"+szRamo+".htm?bairro="+document.forms[0].SiteId.value;
			}
		else szNewlocation = "http://www."+document.forms[0].szURLBairro.value+"/"+formulario.Ramos.options [index].value+".htm";
		NewWindow = open (szNewlocation, "SampaOnline", "toolbar=no,scrollbars=yes,location=no,directories=no,status=yes,menubar=no,width=520,resizable=yes");	
		}
	}

function processSelectedOptionSO (formulario)
	{
	var currentBairro;
	var index = formulario.Ramos.selectedIndex;
	if (index > 0)
		{
		szNewlocation = formulario.Ramos.options [index].value;
		NewWindow = open (szNewlocation,"SampaOnline", "toolbar=no,scrollbars=yes,location=no,directories=no,status=yes,menubar=no,width=640,resizable=yes");
		}
	}

function processarRespostaQuizCultural (szReposta)
	{
	for (nIndex = 0; nIndex < document.forms.length; nIndex++)
		{
		if (document.forms[nIndex].name == "quiz") break;
		alert (document.forms[nIndex].name);
		}
	if (nIndex < document.forms.length) 
		{
		document.forms[nIndex].success.value = "http://www.sampaonline.com.br/quizcultural.htm?resposta="+szReposta;
		document.forms[nIndex].submit();
		}
	}

function contatarAutoridade (idAutoridade)
	{
	var szURL = "http://www.sampaonline.com.br/falecom_autoridade.htm?idautoridade="+idAutoridade;
	NewWindow = open (szURL, "Falecom", "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=620,height=460,left=5,top=5,alwaysRised=yes");
	}

function preLoadImages () 
	{ 
	szImgSrc = new String;
 	var currentDoc = document; 
	if (!currentDoc.preLoadedImages) currentDoc.preLoadedImages = new Array();
	for (i=1; i <= topFoto; i++)		
		{	
		j = i - 1;
		currentDoc.preLoadedImages [j]     = new Image; 
		currentDoc.preLoadedImages [j].src = "fotos/fototh0"+i+".jpg";
		}
	}

function mudaFoto()
	{
	currentFoto += 1;
	if (currentFoto > topFoto) currentFoto = 1;
	found = new Boolean;
	found = false;
  	var currentDoc = document; 
var szString;
	for (currImgPos =0; currImgPos < currentDoc.images.length; currImgPos ++)
		{
		currentDoc.forms[0].wparams.value = currentDoc.images[currImgPos].src;
		szImgSrc = currentDoc.forms[0].wparams.value;
		if (szImgSrc.indexOf ("fototh") >= 0) { found = true; break; }
		}
	if (!found) { return; }
	j = currentFoto - 1;
	currentDoc.images [currImgPos].src = currentDoc.preLoadedImages [j].src;
	clearTimeout (timer);
	timer=setTimeout ("mudaFoto()", 1500);
	}

//-->

