$(document).ready(function(){
    // dialog box ask if you realy want remove content
    $(".alert").live("click", function(event){
	event.preventDefault();
	var link = this.href;
	var text = $(this).data('hexpDialog');
	jDialogDelete(link, text);
    });

        
    // more for gallery
    $('#gallery-body').hide();
    $('#gallery .more').click(function()
    {
	$('#gallery .more').slideToggle(100);
	$('#gallery-body').slideToggle(300);
    })
    
    
    // hacks for tinymce
    // select all relative adress and add basePath
    $('.tinymce-content a').each(function(i){
	var href = $(this).attr('href');
	if(href.substr(0,4) != 'http')
	{
	    $(this).attr('href', BASE_PATH + '/' + href);
	}
    });
    // same for images
    $('.tinymce-content img').each(function(i){
	var src = $(this).attr('src');
	if(src.substr(0,4) != 'http')
	{
	    $(this).attr('src', BASE_PATH + '/' + src);
	}
    });
    
    // lightbox tinymce
    $('.tinymce-content a img').each(function(i){
	$(this).parent().addClass('lightbox');
    });
    
    $('#other a img').each(function(i){
	$(this).parent().addClass('lightbox');
    });
    
    // this must be last !!!
    $('a.lightbox').lightBox();
});
