function goto(page){
    if(page == "index"){
		$(document).attr("title", "Unpleasantville: Home");
    }else if(page == "buy"){
		var params = {
			"cmd":"_s-xclick",
			"hosted_button_id":"37C28E5UL6BNN",
		}
		
		var form = document.createElement("form");
		form.setAttribute("method", "post");
		form.setAttribute("action", "https://www.paypal.com/cgi-bin/webscr");
		
		for(var key in params) {
			var hiddenField = document.createElement("input");
			hiddenField.setAttribute("type", "hidden");
			hiddenField.setAttribute("name", key);
			hiddenField.setAttribute("value", params[key]);
	
			form.appendChild(hiddenField);
		}
        document.body.appendChild(form);
		form.submit();
		return false;
	}else if(page == "trailer"){
		$(document).attr("title", "Unpleasantville: Official Trailer");
		mainDialog.dialog('option', 'title', 'Official Trailer');
		
		$("#dialog").dialog("option", 'buttons', {
			"Close": function(){
				$(this).dialog("close");
			}
		});
        
        $("#dialog").html($("#trailer").html());
        mainDialog.dialog('open');
	}
}

$(document).ready(function(){
	$('#content').css('display', "visible");
	$('body').append("<div id='dialog'></div>");
	mainDialog=$("#dialog").dialog({
		width:700,
		height:510,
		position: 'center',
		draggable: false,
		resizable: false,
		modal: false,
		autoOpen: false,
		show: {
			effect: "drop",
			speed: 1000,
		},
		hide: {
			effect: "drop",
			speed: 1000,
		},
		buttons: {
			"Close": function(){
				$(this).dialog("close");
			}
		},
		close: function(){
			goto("index");
		}
	});
});
