


function auto_load_divs() {
	$('div[data-load]').live("resize",function () {

		auto_load_div($(this));
		
			
	});
	
	
	
}

function auto_load_div(div_to_load) {
	
	
	    url = div_to_load.attr("data-url");
		
	   
		load_block = div_to_load.children(".loading") ;
		div_to_load.children(".ajax_load_content").hide();
		load_block.activity({segments: 8, steps: 5, opacity: 0.5, width: 5, space: 0, length: 5, color: '#212222', speed: 1.5});
		load_block.show();
		
		
		div_to_load.children(".ajax_load_content").load(url, function() {div_to_load.children(".loading").hide();$(this).show();block_js_initialize();})
		
	
}

function update_auto_load_div(url, div_to_load)
{
	
	div = $("#"+div_to_load);
	
	div.attr("data-url", url);
	auto_load_div(div);

	
}

function when_admin_load() {

	$('.closeable').hide().fadeIn().delay(2000).fadeOut();



	
	
	auto_load_divs();

	
	
	$(".update_auto_load_div").live("click",function() {
		

		update_auto_load_div($(this).attr("href"), $(this).attr("data_div_id"));
		
		$(this).parent().children("a").removeClass("selected");
		$(this).addClass("selected");
	
		return false;
	});

	
}


function flash_notice(text) {
	$('#flash').html('');
	$('#flash').html('<div id="flash_notice" class="notice message closeable" style="display:none;">'+text+'</div>');
	
	$('#flash_notice').fadeIn();
	$('#flash_notice').delay(2000).fadeOut();
	
	
	
}


function flash_alert(text) {
	$('#flash').html('');
	$('#flash').html('<div id="flash_alert" class="alert message closeable" style="display:none;">'+text+'</div>');
	
	$('#flash_alert').fadeIn();
	$('#flash_alert').delay(4000).fadeOut();
	
	
	
}


function set_busy(){
	$('body').append('<div id="busy"></div>');
	$('#busy').activity({segments: 8, steps: 5, opacity: 0.5, width: 10, space: 0, length: 10, color: '#212222', speed: 1.5});
}


function unset_busy(){
	$('#busy').remove();
	
}


$(document).ready(function () {
	when_admin_load();
});
