$(document).ready(function(){
	$('#search_input').focus(function(){
		if($(this).val() == 'Cauta pe site'){
			$(this).val('');
		}
	});
	
	$('#search_input').blur(function(){
		if($(this).val() == ''){
			$(this).val('Cauta pe site');
		}
	});
	
	if ($('#center_news_container').length) {
		var categorie_id = $(document).getUrlParam("categorie_id");
		if (categorie_id == null || categorie_id == undefined){
			categorie_id = '';
        }
        var tag = $(document).getUrlParam("tag");
        if (tag == null || tag == undefined){
        	tag = '';
        }
		getCenterNewsTable(0,0,categorie_id,tag);
	}
});
function getCenterNewsTable(page,news_per_page,categorii_id,tag){
	//$('#center_news_container').append("<center><div id='center_news_loader'><img src='images/center_news_loader.gif' /></div></center>");
	if (page == 0 || page == ''){
		page = 1;
	}
	if (news_per_page == 0 || news_per_page == ''){
		news_per_page = NEWS_PER_PAGE;
	}
	
	$.ajax({
		  type: "GET",
		  url: "news.ajax.php",
		  data:{action:'getNewsTables',page:page, ipp:news_per_page, categorii_id:categorii_id, tag:tag},
		  cache:false,
		  success: function(response){
			  $('#center_news_container').html(response);
		  },
		  complete:function(){
				Shadowbox.setup();
			}
		});
}


function show_error(message) {
	$('.error').html(message);
	fadein('.error');
	$('.error').click(function() {
		fadeout('.error');
	});
}

function show_message(message) {
	$('.success').html(message);
	fadein('.success');
	$('.success').click(function() {
		fadeout('.success');
	});
}
function fadein(element) {
	$(element).hide();
	$(element).fadeIn("slow");
}

function fadeout(element) {
	$(element).fadeOut("slow");
}