$(document).ready(function(){
	$('.callback div:last').css({'border':'none'});
	$('.thumbContainer .more').hide();
	$('.show_less').hide();
	$('.show_more').click(function(){
		$(this).parent('.thumbContainer').find('.more').show();
		$(this).hide();
		$(this).next('.show_less').show();
		return false;
	});
	$('.show_less').click(function(){
		$(this).parent('.thumbContainer').find('.more').hide();
		$(this).hide();
		$(this).prev('.show_more').show();
		return false;
	});
	$('#gallery .galleryImage').click(function(){
		stop_image();
		$('#image_1').hide();
		url = $(this).css('background-image').replace(/\"/g,'').replace('40\/','').slice(4).slice(0,-1);
		$('#image_0').attr('src',url);
		$('#image_0').show();
		$('#image_0').attr('style','');
	});
	$('#clients .galleryImage, #clients .client_thumb').click(function(){
		id = basename($(this).css('background-image'));
		id = id.replace('.jpg)','');
		id = id.replace('.jpg")','');	//IE compatability problem
		page = $('#pagination a.active').html();
		if( !page ) {
			url = window.location.toString();
			page = url.substr( 5 + url.search('page=') );
		}
		window.location.replace('item.php?id='+id+'&page='+page);
	});
	$('.errorBox').fadeIn('slow');
	$('.upload').click(function(){
		$('#left_column').css('background','url("/_images/loading.gif") center center no-repeat');
	});
});

function basename (path, suffix) {
    // Returns the filename component of the path  
    // 
    // version: 1103.1210
    // discuss at: http://phpjs.org/functions/basename    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Ash Searle (http://hexmen.com/blog/)
    // +   improved by: Lincoln Ramsay
    // +   improved by: djmix
    // *     example 1: basename('/www/site/home.htm', '.htm');    // *     returns 1: 'home'
    // *     example 2: basename('ecra.php?p=1');
    // *     returns 2: 'ecra.php?p=1'
    var b = path.replace(/^.*[\/\\]/g, '');
     if (typeof(suffix) == 'string' && b.substr(b.length - suffix.length) == suffix) {
        b = b.substr(0, b.length - suffix.length);
    }
 
    return b;
} 

