var loading = '<div id="loading">'+
				'<p>please wait.  loading...</p>'+
			'</div>';
			
var comments_loading = '<div class="comments_loading">'+
					'<p>please wait. comments loading...</p>'+
					'</div>';
			
var loading_tumblr = "<div class='loader'><p><img src='gs/tumblr_sm.gif'></img> Please wait. Loading Tumblr Blog. . .</p></div>";

function showMessageBox(message) {
	if(message.length > 0) {
		$('#messages .inner').html(message);
		$('#messages').css('top', $(document).scrollTop()+50).jqmShow();
		setTimeout('closeMessageBox()', 1000);
	}
}
function showMessageBoxWithTimeout(message,timeout) {
	if(message.length > 0) {
		$('#messages .inner').html(message);
		$('#messages').css('top', $(document).scrollTop()+50).jqmShow();
		setTimeout('closeMessageBox()', timeout);
	}
}
function showErrorBoxWithTimeout(message,timeout) {
	$('#errors .inner').html(message);
	$('#errors').css('top', $(document).scrollTop()+50).jqmShow({overlay:0});
	setTimeout('closeErrorBox()', timeout);
}
function closeMessageBox() {
	$('#messages').jqmHide();
}
function showErrorBox(message) {
	$('#errors .inner').html(message);
	$('#errors').css('top', $(document).scrollTop()+50).jqmShow({overlay:0});
}
function closeErrorBox() {
	$('#errors').jqmHide();
}
function closeAllBoxes() {
	closeMessageBox();
	closeErrorBox();
	closeDialogBox();
	closeRegisterWindow();
}
function dialogBox(template, params) {
	var url = "_get.php?template="+template;
	$('#dialog .inner').html(loading).load(url, params);
	$('#dialog').css('top', $(document).scrollTop()+50).jqmShow();
}
function closeDialogBox() {
	$('#dialog').jqmHide();
}

function showRegisterWindow(){
	$('#registerwindow').html(loading).load("_get.php", {modal: "register"}, function(){}).css('top', $(document).scrollTop()+50).jqmShow();
}

function closeRegisterWindow() {
	$('#registerwindow').jqmHide();
}

function updateWithLoginLogout(){
	$('#user_block').html(loading).load("_get.php", {block: "login"});
	$('#the_list').html(loading).load("_get.php", {content: "list"});
	$('#suggestion').html(loading).load("_get.php", {content: "suggestion"});
}

function reloadList(){
	$('#vote').load("_get.php", {block: "suggestions"});
}

function reloadSuggestionContent(suggestion_id){
	$('#suggestion').load("_get.php", {content: "suggestion",suggestion_id:suggestion_id});
}

function hideSuggestionBox(){
	$("#suggest *").hide();
	$("#suggest").animate({height:0},500);
	$("#no_suggest").show().animate({height:80},500);
}

function logout(){
	$.get("_do.php",{action:"logout"},function(response){
		if(response=='1' || response == 1){
			showMessageBox("You were successfully logged out.");
			updateWithLoginLogout();
		}return false;
	});
}

function disableEnterKey(e)
{
     var key;     
     if(window.event)
          key = window.event.keyCode; //IE
     else
          key = e.which; //firefox     

     return (key != 13);
}


function sendMailTo(name, company, domain) {
  locationstring = 'mailto:' + name + '@' + 'famousandrew.com';
  window.location.replace(locationstring);
}


