function init(){
	//mostrar pesquisa
	url = window.location.href.split("?q=");
	if (url[1]!=undefined){
		document.location.href="#produtos";
	}
	//redim div's
	redim();
	//parse url
	parseUrl();
	window.onresize = function(){
		redim();
		parseUrl();
	};
	new PeriodicalExecuter(function(pe) {
		redim();
		parseUrl();
		tabColor();
	}, 1);
	Event.observe('menu', 'click', function() {   
			setTimeout('tabColor()', 150);
		}
	);
	$('loader').style.display = 'none';
}
function highlight(id){
//grava imagem em destaque
	$('foto').value=id;
	document.editProduto.submit();
}
function getSize () {
//obter dimensões
	var myHeight = 0;
	if (typeof (window.innerWidth) == 'number'){
		myHeight = window.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight){
		myHeight = document.documentElement.clientHeight;
	}else if (document.body && document.body.clientHeight){
		myHeight = document.body.clientHeight;
	}
	return (myHeight);
}
function redim(){
	h=getSize();
	bdyitmH= h - 155;
	$$(".bdyItem").each(function(item) {
		item.style.height=bdyitmH+"px";
	});
	$('bdy').style.height=bdyitmH+25+"px";
	$('produtosbox').style.height=bdyitmH-25+"px";
}
function parseUrl(){
	url = window.location.href.split("#");
	if (url[1]!=undefined){
		pos = findPos($(url[1]))[1]-findPos($('bdy'))[1];
		if (pos < $('bdy').scrollHeight && pos >= 0){
			$('bdy').scrollTop = pos;
		}else{
			$('bdy').scrollTop = 0;
			parseUrl();
		}
	}else{
		$('bdy').scrollTop = 0;
	}
}
function tabColor(){
	url = window.location.href.split("#");
	if (url[1]!=undefined){
		if (url[1]=="quemsomos"){
			$('tabQuemsomos').className='menuSelect';
			$('tabProdutos').className='menuItem';
			$('tabContactos').className='menuItem';
		}
		if (url[1]=="produtos"){
			$('tabQuemsomos').className='menuItem';
			$('tabProdutos').className='menuSelect';
			$('tabContactos').className='menuItem';
		}
		if (url[1]=="contactos"){
			$('tabQuemsomos').className='menuItem';
			$('tabProdutos').className='menuItem';
			$('tabContactos').className='menuSelect';
		}
	}
}
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}