window.defaultUrl = "";

_c(function(){
	
	var s, bts, mais_fotos, menu, ec, ne;
	
	if(!empty(s = $t("SCRIPT", document)))
	{
		window.defaultUrl = s[0].src.toString().split("js/")[0];
	}
	
	if(!empty(menu=$("#coluna_esquerda ul.categorias")) && (menu=menu[0]))
	{
		FixSFMenu(menu);
	}
	
	if(!empty(ec=$("email-contato")))
	{
		ec.innerHTML = ec.innerHTML.replaceAll(" [dot] ", ".").replace(" [at] ", "@");
		ec.href = "mailto:" + ec.innerHTML;
	}
	
	if(!empty(mais_fotos = $("mais_fotos")))
	{
		mais_fotos.e("click", clickGaleria);
	}
	
	if(!empty(ne=$("newsletter_email")))
	{
		ne.e("focus", initValue);
	}
	
	//banner do topo...
	var fo = new Flash(window.defaultUrl + "swf/banner_" + document.body.className.toString() + ".swf", null, "360", "110");
	fo.addParameter("scale", "noscale");
	fo.addParameter("quality", "high");
	fo.addParameter("wmode", "transparent");
	fo.writeIn("banner");
	
	//marcas do rodapé...
	var marcas = new Flash(window.defaultUrl + "swf/rodape_" + document.body.className.toString() + ".swf?2", null, "260", "62");
	marcas.addVariable("defaultUrl", window.defaultUrl);
	marcas.writeIn("marcas");
	
	//form decoration...
	$("div.rowButton input").apply("e", "mouseover", function(){
		this.addClass("over");
		this.onmouseout = function()
		{
			this.remClass("over");
		}
	});
	$("form fieldset .c").apply("e", "focus", function(){
		this.addClass("focus");
		this.onblur = function()
		{
			this.remClass("focus");
		}
	});
	
});

function equalColuns()
{
	$("coluna_esquerda", "conteudo").read(function(){
		
		if(this[0].getHeight() > this[1].getHeight())
		{
			this[1].setHeight(this[0].getHeight());
		}
		else
		{
			//this[1].style.height = "auto";
		}
	});	
}

BodyLoad.add(equalColuns);

function someBanner()
{
	(b = $("banner_flutuante")).parentNode.removeChild(b);
}

function changeSite(s)
{
	if(window.defaultUrl.indexOf("/bypet/site") > -1)
	{
		window.location.href = window.defaultUrl + "?" + s;
	}
	else
	{
		window.location.href = "http://www." + s + ".com.br/";
	}
}

function showAguarde()
{
	//<div id="activity">Carregando Dados...</div>
	var d = $e("DIV", {id: "activity", innerHTML: "Carregando Dados..."});
	document.body.top(d);
}
function hideAguarde(){ $("activity").remove(); }

function clickGaleria(e)
{
	window.open(this.href.toString(), null, "width=650, height=465, status");
	
	this.cancelEvent(e || window.event);
	return false;
}

function $cake(s)
{
	s = s.split("_").join("/")
	s = s.split("/");
	for(var i=0; i<s.length; i++)
	{
		s[i] = s[i].substr(0, 1).toUpperCase() + s[i].substr(1);
	}
	s = s.join("");
	return s;
}

function fv(valor, o)
{
	if(o==undefined)
	{
		valor = valor.toString().replaceAll(".", ",").split(",");
		if(valor[1]==undefined) valor[1] = "00";
		for(var i=valor[1].length; i<2; valor[1]+="0", i++);
		valor[1] = valor[1].substr(0, 2);
		
		return "R$ " + valor.join(",");
	}
	else if(o)
	{
		return valor.toString().replaceAll("R$ ", "").toNumber();
	}
}
