var maxFont = 20;
var minFont = 14;
var hh=0;
var inter;

$(document).ready(function() {
	$('#usernameLoading').hide();
	$('#username').blur(function(){
	  $('#usernameLoading').show();
      $.post("/include/check.php", {
        username: $('#username').val()
      }, function(response){
        $('#usernameResult').fadeOut();
        setTimeout("finishAjax('usernameResult', '"+escape(response)+"')", 400);
      });
    	return false;
	});
});

function finishAjax(id, response) {
  $('#usernameLoading').hide();
  $('#'+id).html(unescape(response));
  $('#'+id).fadeIn();
} //finishAjax

function hideShow(divID){
	var d = document.getElementById(divID);
	d.style.display =(d.style.display != 'none' )? 'none':'block';
}

function upFontSize(divID){
	
	var p = document.getElementById(divID);
	if(p.style.fontSize) {
		var s = parseInt(p.style.fontSize.replace("px",""));
	} else {
		var s = 14;
	}
	
	if(s != maxFont) {
		s += 1;
	}	
	
	p.style.fontSize = s+"px"	
}

function downFontSize(divID){
	
	var p = document.getElementById(divID);
	if(p.style.fontSize) {
		var s = parseInt(p.style.fontSize.replace("px",""));
	} else {
		var s = 14;
	}
	
	if(s != minFont) {
		s -= 1;
	}	
	
	p.style.fontSize = s+"px"
}

function resize(divID){
	
	var p = document.getElementById(divID);
	var s = parseInt(p.style.height.replace("px",""));
	
	if(s == 0) p.style.height = 150+"px"
	else p.style.height = 0+"px"
}

function ShowBox(){
	
	if(hh==80){
		clearInterval(inter);
		return;
	}

	obj = document.getElementById("top_center");
	obj.style.visibility = 'visible';
	hh+=2;
	obj.style.height = hh + 'px';
}

function HideBox(){

	obj = document.getElementById("top_center");

	if(hh==2){
		obj.style.visibility = 'hidden';
		obj.style.height = '0.1em';
		clearInterval(inter);
		return;
	}
	
	hh-=2;
	obj.style.height = hh + 'px';
}