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 showMap(basePath, mapID) {
	window.open(basePath + 'map.php?addressID=' + mapID, 'mapViewer', 'height=720,width=780,scrollbars=no,scrolling=no,status=yes');
}

function fieldReset(obj, template) {
	if (template == 'name') {
		if (obj.value == 'Event name') {
			obj.value = '';
		}
	}
	
	if (template == 'keyword') {
		if (obj.value == '- palavra chave -') {
			obj.value = '';
		}
	}
	return true;
}

function fieldSet(obj, template) {
	if (template == 'name') {
		if (obj.value == '') {
			obj.value = 'Event name';
		}
	}
	
	if (template == 'keyword') {
		if (obj.value == '') {
			obj.value = '- palavra chave -';
		}
	}
	return true;
}

function resetForm(obj, quick) {
	if (quick == false) {
		if (obj.name.value == 'Event name') {
			obj.name.value = '';
		}
	}
	
	if (obj.keyword.value == 'Keyword') {
		obj.keyword.value = '';
	}
}

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 mailPage() {
	spObj = MM_findObj('mailPageForm');
	if (spObj.style.display == 'none' || spObj.style.display == '' || spObj.style.display == null) {
		spObj.style.display = 'block';
		document.mailPage.urladdress.value = escape(document.location.href);
		document.mailPage.pagetitle.value = escape(document.title);
	} else {
		spObj.style.display = 'none';
	}
}

function printPage(kind, id, base) {
	if (kind == 'evt') {
		urlID = 'eventID';
	}
	if (kind == 'ven') {
		urlID = 'venueID';
	}
	if (kind == 'fea') {
		urlID = 'featureID';
	}
	if (kind == 'mov') {
		urlID = 'filmID';
	}
	window.open(base + 'printable?' + urlID + '=' + id);
}

function doPrintPage() {
	window.print();
}

function showCommentNotify(elm) {
	obj = MM_findObj('notifyEml');
	if (elm.checked) {
		obj.style.display = 'block';
		document.commentForm.notifyEmail.value = '';
	} else {
		obj.style.display = 'none';
	}
}

function adicionar() {
	obj = MM_findObj('addFavoritos');
	if (obj.style.display == 'block') {
		obj.style.display = 'none';
	} else {
		obj.style.display = 'block';
		obj = MM_findObj('sendByMail');
		obj.style.display = 'none';
		obj = MM_findObj('shareButtons');
		obj.style.display = 'none';
	}
}

function addTo() {
	obj = MM_findObj('shareButtons');
	if (obj.style.display == 'block') {
		obj.style.display = 'none';
	} else {
		obj.style.display = 'block';
		obj = MM_findObj('sendByMail');
		obj.style.display = 'none';
		obj = MM_findObj('addFavoritos');
		obj.style.display = 'none';
	}
}

function sendEmail() {
	obj = MM_findObj('sendByMail');
	if (obj.style.display == 'block') {
		obj.style.display = 'none';
	} else {
		obj.style.display = 'block';
		obj = MM_findObj('shareButtons');
		obj.style.display = 'none';
		obj = MM_findObj('addFavoritos');
		obj.style.display = 'none';
	}
}

function printPage() {
	var address = document.location.href;
	if (address.indexOf('?') > 0) {
		toAdd = '&printable=yes';
	} else {
		toAdd = '?printable=yes';
	}
	window.open(address + toAdd);
}