jQuery.fn.resetDefaultValue = function() {
	function _clearDefaultValue() {
		var _$ = $(this);
		if ( _$.val() == this.defaultValue ) { _$.val(''); }
	};
	function _resetDefaultValue() {
		var _$ = $(this);
		if ( _$.val() == '' ) { _$.val(this.defaultValue); }
	};
	return this.click(_clearDefaultValue).focus(_clearDefaultValue).blur(_resetDefaultValue);
}

function AddFriend(username)
{
	OpenBox("/friends_add.php?username="+username);
}

function Delete()
{
	return confirm('Esti sigur ca vrei sa stergi?')?true:false;
}
function ObjectDelete(obiect,url)
{
	if (Delete())
	{
		$.ajax({
		  type: "GET",
		  url: url
		});
		$("#"+obiect).fadeOut("fast");	 
	}
	return false;	
}

function showComments(post_id)
{
	$("#comments_"+post_id).load("/forum_cat_comments.php?post_id="+post_id);
	$("#comments_"+post_id).toggle();
}

function addComments(post_id)
{
	$.ajax({
	  type: "POST",
	  url: "/forum_cat_comments.php?post_id="+post_id,
	  data: $("#frm_comment_add_"+post_id).serialize(),
	  processData: true,
	  success: function(data,text) {
		$("#msg_"+post_id).html(data);
	  }
	});
	
	_gaq.push(['_trackPageview','/fancafe/comment-status']);
	
	$("#frm_comment_add_"+post_id+" TEXTAREA ").val('');
}

function OpenBox(url){
	 $("#box_email").text('');
	 $("#box_email").load(url);
	 
	ttop=0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		ttop=window.pageYOffset;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
		ttop=document.documentElement.scrollTop;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
		ttop=document.body.scrollTop;
	}

	l = (myWidth-600)/2;
	t = (myHeight-500)/2+ttop ; 
	
	 $('#box_email').css('left',l+'px');
	 $('#box_email').css('top' , t+'px'); 
	 
	 $('#box_email').css('display','block');
}

function Close(name){
	//$("#box_email").text();
	$('#'+name).css('display','none');
} 
function captchaReload(id){
	var randomnumber=Math.floor(Math.random()*101);
	document.getElementById(id).src = "/captcha.jpg?"+randomnumber;
	$('#captcha').val('');
}
