function initAjaxLinks()
{
    var _menu = $('#ajax-menu .ajax-menu a.ajax');
    _menu.each(function (i) {
        var _href = this.href;
        if(this.rel.length > 0 && this.rev.length > 0)
        {
            this.ajaxhref = _href;
            this.ajaxrel = this.rel;
            this.ajaxrev = this.rev;
            this.rel='';
            this.rev='';
            this.href = 'javascript:;';
            $(this).bind("click", function () {
					$('#ajax-menu .ajax-menu a.ajax').each(function (i){
                    		$(this).removeClass('active');
						});
					$(this).addClass('active');
                    getRequest({act:'post', cat_id:this.ajaxrel, p_id: this.ajaxrev}, '#ajax-posts');
                });
        }
    });

    var _pager = $('#ajax-pager a.ajax');
    _pager.each(function (i) {
        var _href = this.href;
        if(this.rel.length > 0 && this.rev.length > 0)
        {
            this.ajaxhref = _href;
            this.ajaxrel = this.rel;
            this.ajaxrev = this.rev;
            this.rel='';
            this.rev='';
            this.href = 'javascript:;';
            $(this).bind("click", function () {
                    getRequest({act:'menu', cat_id:this.ajaxrel, offset: this.ajaxrev}, '#ajax-menu');
                });
        }
    });
}

function getRequest(params, selector){
    $.post('/', params,
        function(data){
            var tab=$(''+selector+'');
            tab.fadeOut("fast", function () {
                tab.html('');
	            tab.append(data);
	            tab.fadeIn("fast", function () {
					initAjaxLinks();
		      	});
		      });
        }, "html");
}
$(document).ready(function () {
	var _pager = $('select.selecttourl');
	_pager.bind("change", function () { if ($(this).val()) window.location = $(this).val(); });
	initAjaxLinks();

	var _searchInput = $('div.search-form .text');
	_searchInput.bind("focus", function() { $(this).val(''); });
});