
Event.observe(window, 'load', function() {
  //Event.observe('adicionarfavoritos', 'click', addBookmark);
  //Event.observe('definirpaginainicial', 'click', function(event){ setHomepage(); } );
});

function changePage (event, pag, max) {
  if(event.charCode!=0 || $F('changePage')<1 || $F('changePage')>max || isNaN($F('changePage'))) return;
  href= location.href
  posnpag= location.href.lastIndexOf('/'+ pag)
  window.location= href.substr(0, href.posnpag)+ $F('changePage');
 }
									   
function addBookmark () {
  if (document.all) window.external.AddFavorite(location.href, document.title);
  else if (window.sidebar) window.sidebar.addPanel(document.title, location.href, "")
 }
 
function setHomepage () {
 document.body.style.behavior='url(#default#homepage)';
 document.body.setHomePage(location.href);	 
}

function openPopup (id, popoptions) {
	url    = document.getElementById(id).getAttribute('href');
	target = id+'_popup';
	var nw = window.open(url, target, popoptions+',scrollbars=yes,resizable=yes,status=yes');
	if (nw) { return false; }
	return false;
}

function printVersion () {
	url    = document.getElementById("versaoimpressora").getAttribute('href');
	target = 'versaoimpressora_popup';
	var nw = window.open(url, target, 'width=600,height=480,scrollbars=yes,resizable=yes,status=yes');
	if (nw) { return false; } 
}

function sendFriend () {
 url    = document.getElementById("recomendaramigo").getAttribute('href');
 target = 'recomendaramigo_popup';
 var nw = window.open(url, target, 'width=500,height=400,scrollbars=yes,resizable=yes,status=yes');
 if (nw) { return false; } 
}

function doPopUp(e) {
	//set defaults - if nothing in rel attrib, these will be used
	var t = "standard";
	var w = "600";
	var h = "480";
	//look for parameters
	attribs = this.rel.split(" ");
	if (attribs[1]!=null) {t = attribs[1];}
	if (attribs[2]!=null) {w = attribs[2];}
	if (attribs[3]!=null) {h = attribs[3];}
	//call the popup script
	popUpWin(this.href,t,w,h);

	return false;
}
function popUpWin(url, type, strWidth, strHeight){
	closeWin();
		
	type = type.toLowerCase();
	
	if (type == "fullscreen"){
		strWidth = screen.availWidth;
		strHeight = screen.availHeight;
	}
	var tools="";
	if (type == "standard") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
	if (type == "console" || type == "fullscreen") tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left=0,top=0";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}
var newWindow = null;
function closeWin(){
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}

// Dinamiza popups: associar class=popup a cada link para gerar popup automaticamente
Event.observe(window, 'load', findPopUps, false);
function findPopUps() {
	return;
	popupx = $$('a.popup')

	popupx.each(
		function(s) {
			s.onclick = doPopUp;
			s.title = s.title + " [Abre em nova janela]";
		}
	)
}