//<![CDATA[



/* convert all links to ajax links */
/* this is an ajax get request */
function ajaxLinks(class, container, before_cb, after_cb){
	$('a.' + class).click(function(){	
		/* perform confirmation */
		if($(this).attr('onClick')){
			eval($(this).attr('onClick'));
			if(c != 'undefined' && !confirm(c))return false;
		}
		
		var url = $(this).attr('href');
		
		/* call callback */
		if($.isFunction(before_cb)){
			$.facebox.cb = function(){										
				/* load content */
				$(container + '_ac').load(url + '&ajax=true' + ' ' + container, null, after_cb);   
			};
			before_cb.call( );		
		}else{
			/* load content */
			$(container + '_ac').load(url + '&ajax=true' + ' ' + container, null, after_cb);
		}
				
		
		return false;
	});
}

		   
function ajaxForm(id, submit_name, url_str, a, b){
	
	// form bining
	$(id).submit(function(){		
		var str = $(id).serialize() + '&' + submit_name + '=1&silent=true';
		
		$.ajax({
			type: "POST",
			url: url_str,
			data: str,
			success: b,
			beforeSend: a,					
		});
		
		
		
		return false;
	});		
	
	// blur
	$(id + ' tr td input, ' + id + ' tr td textarea').blur(function(){				
		$(this).parent().parent().css('opacity', '1.0');
		$(this).parent().parent().css('background', 'none');
	});
	
	
	// focus
	$(id + ' tr td input, ' + id + ' tr td textarea').focus(function(){								
		$(this).parent().parent().parent().children().css('opacity', '0.4');
		$(this).parent().parent().css('opacity', '1.0');
		$(this).parent().parent().css('background', '#FF9900');
		
		// button wieder alpha = 1
		$(id + ' tr td button').parent().parent().css('opacity', '1.0');
	});
}

function initAjaxLoader(){		
	/* inject loader */
	$("#ajax_loading").append("<center><img src=\"images/ajax_loading.gif\" alt=\"\" title=\"\" /><br /><br /><small>Loading ... please wait</small></center>");				
}

function lockContainer(){
	$('#container').css('opacity', '0.2');
	$.facebox($('#ajax_loading').html());
	if($.isFunction($.facebox.cb))$.facebox.cb.call();
}

function unlockContainer(callback){
	$('#container').animate({
		opacity: '1.0'
	}, 200, 'linear', function(){
		$.facebox.close();			
		if($.isFunction(callback))callback.call();	
	});			
}

//]]>