function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function viewImage(base, element, width, height) {
	window.open(base + 'imageView.php?img=' + escape(element), 'viewer', 'scrollbar=no,scrolling=no,toolbar=no,statusbar=no,width=' + (width + 20) + ',height=' + (height + 60));
}

function resetBooklink(lnk) {
	lnk.href='javascript: doBookmark(lnk);';
}

function doBookmark(lnk) { 
	title = top.document.title;
	url = top.location.href;

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title);
	} else if(window.opera && window.print) { // Opera Hotlist
		resetBooklink(lnk);
		return true; 
	} else {
		resetBooklink(lnk);
		alert("We are sorry for the inconvenience but your browser does not support this feature. You must manually add this page to your bookmarks.");
	}
}

function setBookmark(lnk) { 
	if(window.opera && window.print) { // Opera Hotlist
		lnk.href = top.location.href;
		lnk.title = top.document.title;
	}
}

function loadCidades(sectID, path) {
	famObj = MM_findObj('bairro');
	for (i=famObj.options.length-1; i>=0; i--)
		famObj.options[i] = null;
	engine.document.location.href=path+'list_bairros.php?cidade=' + sectID;
}

function swapImage(newImage) {
	famObj = MM_findObj('thePic');
	famObj.src=newImage;
}
