jQuery.noConflict();

cfct = {}

cfct.loading = function() {
	return '<div class="loading"><span>Chargement ...</span></div>';
}

cfct.ajax_post_content = function() {
	jQuery('ol.archive h3 a').unbind().click(function() {
		var post_id = jQuery(this).attr('rev').replace('post-', '');
		jQuery('#post-' + post_id).hide();
		jQuery('#post-content-' + post_id + '-target').html(cfct.loading()).load(CFCT_URL + '/index.php?cfct_action=post_content&id=' + post_id, cfct.ajax_post_comments);
		return false;
	});
}

cfct.ajax_post_comments = function() {
	if (typeof AFCT_AJAX_LOAD_COMMENTS == 'undefined' || !AFCT_AJAX_LOAD_COMMENTS)
		return false;

	jQuery('span.meta-comments a').unbind().click(function() {
		var rev = jQuery(this).attr('rev');
		if (rev == '') rev = jQuery(this).prev().attr('rev');
		var post_id = rev.replace('post-', '');
		jQuery(this).parent().hide();
		jQuery('#post-comments-' + post_id + '-target').html(cfct.loading()).load(CFCT_URL + '/index.php?cfct_action=post_comments&id=' + post_id);
//		jQuery('#post-comments-' + post_id + '-target').html('<iframe frameborder="0" src="' + CFCT_URL + '/index.php?cfct_action=post_comments_iframe&id=' + post_id + '" allowtransparency="true" vspace="0" hspace="0" marginheight="0" marginwidth="0" name="dsqus-content-frame" id="dsqus-add-iframe-' + post_id + '"/>');
		return false;
	});
}

cfct.ajax_search = function() {
	jQuery('#search').unbind().keyup(function() {
		var s = jQuery(this).val();
		if (s != "" && s != "Rechercher")
		{
			var div = jQuery(this).siblings('div');
			if (div.length == 0)
			{
				jQuery(this).after("<div class='bla'>test</div>");
				div = jQuery(this).siblings('div');
			}
			div.load(CFCT_URL + '/index.php?preview_theme=asbin08&cfct_action=search&s=' + s);
		}
		else if (s == "")
		{
			jQuery(this).siblings('div').remove();
		}
	});
}

jQuery(document).ready(function($) {
	// suckerfish dropdown fixes for IE
	$('#nav li, #top-nav li').mouseover(function() {
		$(this).addClass('hover');
	});
	$('#nav li, #top-nav li').mouseout(function() {
		$(this).removeClass('hover');
	});
	// :first-child fix for IE
	$('#nav li:first-child, #top-nav li:first-child').addClass('first');
	// :hover fix for full articles in IE
	$('.box-left').mouseover(function() {
		$(this).addClass('hover');
	});
	$('.box-left').mouseout(function() {
		$(this).removeClass('hover');
	});
	if (!$.browser.msie || $.browser.version.substr(0,1) != '6') {
		if (typeof AFCT_AJAX_LOAD_POSTS != 'undefined' && AFCT_AJAX_LOAD_POSTS) {
			cfct.ajax_post_content();
		}
		if (typeof AFCT_AJAX_LOAD_COMMENTS != 'undefined' && AFCT_AJAX_LOAD_COMMENTS) {
			cfct.ajax_post_comments();
		}

		//cfct.ajax_search();
	}
	$('#nav li a, #top-nav li a').removeAttr('title');
});




jQuery(document).ready(function($) {
	$('#search').focus(function() {
		if ($(this).val() == "Rechercher")
			$(this).val("");
	});

	$('#search').blur(function() {
		if ($(this).val() == "")
			$(this).val("Rechercher");
	});
});
