
function showHide(id)
	{
	var obj = document.getElementById(id);
	if(obj.style.display == "")
		{
		obj.style.display = "none";
		}
	else
		{
		obj.style.display = "";
		 }
	}

function ajustaID(id,x,y,w,h)
	{
	var obj = document.getElementById(id);
	if (w!=''){ obj.style.width = w; }
	if (h!=''){ obj.style.height = h; }
	if (x!=''){ obj.style.left = x; }
	if (y!=''){ obj.style.top = y; }
	}

function Carregado()
	{
	showHide('lateral');
	}

function getWindowXY(tp)
	{
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		myWidth = window.innerWidth; myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
		myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		myWidth = document.body.clientWidth; myHeight = document.body.clientHeight;
	}
	if (tp == "X") { return myWidth; }
	if (tp == "Y") { return myHeight; }
	}

function getScrollXY(tp)
	{
	var scrOfX = 0, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
		scrOfY = window.pageYOffset; scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft;
	}
	if (tp == "X") { return scrOfX; }
	if (tp == "Y") { return scrOfY; }
	}

function MouseXY(e,tp) // works on IE6,FF,Moz,Opera7
	{ 
	if (!e) e = window.event;
	if (e)
		{ 
		if (e.pageX || e.pageY)
			{ // this doesn't work on IE6!! (works on FF,Moz,Opera7)
			mousex = e.pageX;
			mousey = e.pageY;
			}
		else if (e.clientX || e.clientY)
			{ // works on IE6,FF,Moz,Opera7
			mousex = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
			mousey = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
			algor = '[e.clientX]';
			if (e.pageX || e.pageY) algor += ' [e.pageX] '
			}
		}
	if (tp == "X") { return mousex; }
	if (tp == "Y") { return mousey; }
	}


function mapa(evt,var1,var2)
	{
	ajustaID('mapaend',215,MouseXY(evt,"Y")-130,'','');
	ajustaID('fundo','','','',document.getElementById("limites").clientHeight);
	showHide('fundo');
	showHide('mapaend');
	with (document.forms["mapaform"])
		{
		destino1.value=var1;
		destino2.value=var2;
		}
	}
 
function mapatrajeto(act)
	{
	showHide('fundo');
	showHide('mapaend');
	if (act == "no")
		{
		with (document.forms["mapaform"])
			{
			endori.value="";
			submit();
			}
		}
	}

function VitrineChave(evt,var1)
	{
	obj1 = document.getElementById('vitchave');
	obj2 = document.getElementById('VitChave'+var1);
	alert(obj1.innerHTML);
	alert(obj2.innerHTML);
	obj1.innerHTML = obj2.innerHTML;
	ajustaID(obj1,215,MouseXY(evt,"Y")-130,'','');
	showHide(obj1);
	}

function VitICO(tp,var1,var2)
	{
	obj = document.getElementById('VitICO'+var1);
	if (tp == "0") { obj.innerHTML="&nbsp;"; }
	if (tp == "1") { obj.innerHTML="Como chego aqui"; }
	if (tp == "2") { obj.innerHTML="Entre em contato"; }
	if (tp == "3") { obj.innerHTML="Acesse nosso site"; }
	if (tp == "4") { obj.innerHTML="Veja mais detalhes"; }
	if (tp == "5") { obj.innerHTML="Veja nossas ofertas"; }
	if (tp == "9") { obj.innerHTML=var2; }
	}


function Favorito(titulo,url)
	{
	if (window.sidebar) { window.sidebar.addPanel(titulo, url,""); } // firefox
	else if( window.external ) { window.external.AddFavorite( url, titulo); } // ie
	else if( window.opera && window.print) { return true; } // opera e outros
	}

function Imprimir(url)
	{
	window.open(url,"ImprimeVIT","width=600,height=500,directories=no,toolbar=yes,resizable=yes,menubar=yes,scrollbars=yes");
	}

function VitrineEmail(var1)
	{
	window.open("vitrine_email.php?codeps="+var1,"EmailVIT","width=500,height=300,directories=no,toolbar=no,resizable=yes,menubar=no,scrollbars=no");
	}

function Indique(var1)
	{
	window.open("indique.php?codeps="+var1,"IndiqueVIT","width=500,height=350,directories=no,toolbar=no,resizable=yes,menubar=no,scrollbars=no");
	}


function ContaChar(campo1,campo2,maximo)
	{
	if (campo1.value.length > maximo)
		{
		campo1.value = campo1.value.substring(0,maximo);
		alert( 'Esse campo não pode ter mais do que '+maximo+' caracteres.');
		return false;
		}
	else
		{
		campo2.value = maximo-campo1.value.length;
		}
	}


