jQuery (function (){

	$('.client').hide();
    $('.menu-items li a').click(function(){    
        updateIndexes(this, '.right');
        return false;
    });
    $('.client-item a').click(function(){    
        updateIndexes(this, '.client');
        return false;
    });
	
	$("#private img").hover(function(){
		$(this).attr("src","/media/images/clients/private-over.jpg");
			}, function() {
		$(this).attr("src","/media/images/clients/private.jpg");
	});
	$("#public img").hover(function(){
		$(this).attr("src","/media/images/clients/public-over.jpg");
			}, function() {
		$(this).attr("src","/media/images/clients/public.jpg");
	});
	$("#marketing img").hover(function(){
		$(this).attr("src","/media/images/clients/marketing-over.jpg");
			}, function() {
		$(this).attr("src","/media/images/clients/marketing.jpg");
	});


	
});


function updateIndexes(el, cls) {
    var href = $(el).attr('href');
    var date = new Date();
    var curDate = null;
    $(cls).slideUp ('slow', function (){
       $.post('/ajax',
    {
        'act': 'getpage', 'href': href
    }, 
    function(data){
       
        if(data.error) {
            alert(data.error);
            return;
        }
       	
        if (cls == '.client')
		{
		$(cls).html ('<img class="client-logo" src=' + data.result.logo + ' />' + data.result.content);
		} else {
		$(cls).html ('<h2>' + data.result.label + '</h2>' + data.result.content);
		}
        
        $(cls).slideDown ('slow', 'swing');
    },'json');  
    });      
      
    var complete = true;
    return false;
};
