
	function showLoading(){
		var width = $('content').clientWidth;
		var height = $('content').clientHeight;
		//var html = '<table align="center" border="0" cellpadding="0" cellspacing="0" width="'+width+'" height="'+height+'">';
		var html = '<table align="center" border="0" cellpadding="0" cellspacing="0" width="'+width+'">';
		html += '<tr><td width="'+width+'" height="'+height+'" align="center" valign="middle" style="color: white;">';
		html += "<img align='absmiddle' src='" + URL_ROOT + "/public/images/loading_big.gif'/>";
		html += '</td></tr></table>';
		$('content').innerHTML = html;
		document.location = '#content';
	}

	function showPage(page){
		showContent(URL_ROOT+'/public/content.php?page='+page);
	}

	function showContent(url){
		// OnOff has banner at base
		//if(loop) clearInterval(loop);
		currentPicture = 0;
		showLoading();
		call_remote(url, "displayContent");
		// Google Analytics hit
		if(pageTracker) pageTracker._trackPageview(url);
	}
	
	
	function startPretty(){
		$j(document).ready(function(){
			$j("a[rel^='prettyPhoto']").prettyPhoto();
			$j("a[rel^='prettyPopin']").prettyPopin();
		});
	}
	
	function closePretty(){
		$j('#b_close').click();
	}	

	function showHome(){
		showContent(URL_ROOT+'/public/index2.php');
	}

	function displayContent(data){
		$('content').innerHTML = data;
		if(document.location.hash && document.location.hash != "#"){
			document.location = '#';
		}
		document.title = SYSTEM_NAME;
		startPretty();
	}

	function conditionalGo(url, id){
		if(theme != id){
			document.location = url;
		} else {
			showContent(url);
		}
	}

	function Picture(id, src, width, height, position){
		this.id = id;
		this.src = src;
		this.width = width;
		this.height = height;
		this.position = position;
	}

	function displayPicture(i){
		if( i < 0 ){
			i = images.length - 1;
		} else if(i >= images.length) {
			i = 0;
		}
		currentPicture = i;
		//$('current').innerHTML = i+1;		
		$('displayed').innerHTML = '<img id="displayed_img" width="'+images[i].width+'" height="'+images[i].height+'" src="'+URL_ROOT+'/public/images/black.gif"/>';
		$('displayed_img').src = images[i].src;
		document.location = "#photo" + images[i].id;
		var scrollLeft = 0;
		for(var j=0; j < i; j++){
			var imageWidth = 'landscape' == images[j].position ? 230 : 172;
			scrollLeft+= (5 + imageWidth +5);
		}
		$('album-div').scrollLeft = scrollLeft - (($('album-div').clientWidth - ('landscape' == images[i].position ? 210 : 157))/ 2) + 5;
		//$('album-div').scrollLeft = scrollLeft;
	}
	
	function displayFirstPicture(){
		if(oldAlbumContent) cancelEcard();
		displayPicture(0);		
	}
	
	function displayLastPicture(){
		if(oldAlbumContent) cancelEcard();
		displayPicture(images.length -1);		
	}

	function nextPicture(){
		if(oldAlbumContent) cancelEcard();
		displayPicture(currentPicture+1);
	}

	function previousPicture(){
		if(oldAlbumContent) cancelEcard();
		displayPicture(currentPicture-1);
	}

	function toogleSlideshow(){
		if(!slideshow){
			//$('slideshow_label').innerHTML = "parar";
			$('slideshow_button').src = URL_ROOT + "/public/images/slideshow_stop.gif";
			slideshow = setInterval("nextPicture()", 4000);
		} else {
			//$('slideshow_label').innerHTML = "iniciar";
			$('slideshow_button').src = URL_ROOT + "/public/images/slideshow_start.gif";
			clearInterval(slideshow);
			slideshow = null;
		}
	}

	function comment(){
		popUp(URL_ROOT+"/public/mural_item.php", 500, 370);
	}

	function ecard(event){
		var url = URL_ROOT+"/public/ecard.php?event="+event+"&picture="+images[currentPicture].src;
		call_remote(url, "showEcard");
	}

	var oldAlbumContent = null;

	function showEcard(data){
		if(!oldAlbumContent) oldAlbumContent = $('album-cell').innerHTML;
		$('album-cell').innerHTML = data;
	}

	function cancelEcard(){
		$('album-cell').innerHTML = oldAlbumContent;
	}

	function newPassword(){
		if(document.form1.email.value==""){
			alert("Por favor, antes nos diga qual é seu email");
			document.form1.email.focus();
			return;
		}
		if(confirm(I18N.CONFIRM_SEND_PASSW)){
			call_remote(URL_ROOT+"/public/send_password.action.php?email="+document.form1.email.value, "showResult");
		}
	}

	function validate(){
		if(document.form1.email.value=="" || document.form1.password.value==""){
			alert(I18N.INVALID_LOGIN);
			return false;
		}
		call_remote(URL_ROOT+"/public/login.action.php", "showResult", document.form1);
		document.form1.email.value="";
		document.form1.password.value="";
		return false;
	}

	function loadLoginPanel(){
		call_remote(URL_ROOT + "/public/login_panel.php", "showProfilePanel");
	}

	function loadProfilePanel(){
		call_remote(URL_ROOT + "/public/profile_panel.php", "showProfilePanel");
	}

	function showProfilePanel(data){
		$('login_area').innerHTML = data;
	}

	function subscribe_results(email){
		alert("Seu email <"+email+"> foi cadastrado com sucesso em nossa newsletter!");
		$('name').value = '';
		$('email').value = '';
		$('area_code').value = '';
		$('number').value = '';
		$('birthday').value = '';
	}
	
	function invite_results(email){
		alert("Sua lista de convidados foi enviada com sucesso!");
		$('guests_0').value = '';
		$('guests_1').value = '';
		$('guests_2').value = '';
		$('guests_3').value = '';
	}

	function unsubscribe_results(email){
		alert("E-mail <"+email+"> removido com sucesso de nossa newsletter!");
		//$('newsletter').value = '';
	}

	
