var cs_prive=window.location.pathname.match(/\/ecrire\/$/)!=null;
jQuery.fn.cs_todo=function(){return this.not('.cs_done').addClass('cs_done');};
var cs_verif_email = 1;
var cs_verif_nom = 1;
var cs_verif_deux = 0;
function soft_scroller_init() { if(typeof jQuery.localScroll=="function") jQuery.localScroll({hash: true}); }
// compatibilite Ajax : ajouter "this" a "jQuery" pour mieux localiser les actions 
// et tagger avec cs_done pour eviter de binder plrs fois le meme bloc
function cs_auteur_forum() {
	// selecteur du bloc de previsualisation
	var sel = jQuery('fieldset.previsu', this);
	if(!sel.length) return;
//	alert('previsu OK');
	var form = sel.parents('form').eq(0);
	if(!form.length) return;
	// SPIP 2.0 remplace 'auteur' par 'session_nom'
	var auteur = jQuery('#session_nom', this);
	if(!auteur.length) auteur = jQuery('#auteur', this);
	// SPIP 2.0 remplace 'email_auteur' par 'session_email'
	var email = jQuery('#session_email', this);
	if(!email.length) email = jQuery('#email_auteur', this);
	if(auteur.length || email.length)
	// eviter les forums anonymes
	form.cs_todo().bind('submit', function(event){
		var alert_nom = auteur.length && !auteur.val().length;
		var alert_email = email.length && !email.val().length;
		var alert_deux = cs_verif_deux && alert_nom && alert_email;
		if(!cs_verif_deux) {
			alert_nom = alert_nom && cs_verif_nom;
			alert_email = alert_email && cs_verif_email;
		} else if(!alert_deux)
			alert_nom = alert_email = false;
		auteur.css('background-color','').css('border','');
		email.css('background-color','').css('border','');
		if(alert_email) {
			email.focus();
			email.css('background-color','#FCC').css('border','solid #C30');
		}
		if(alert_nom) {
			auteur.focus();
			auteur.css('background-color','#FCC').css('border','solid #C30');
		}
		if(alert_deux) {
			alert("Merci de spécifier votre nom ou votre email !");
			return false;
		}
		if(alert_nom) {
			alert("Merci de spécifier votre nom !");
			return false;
		}
		if(alert_email) {
			alert("Merci de spécifier votre email !");
			return false;
		}
		return true;
	});
}

if (window.jQuery) jQuery.fn.jc_ajouter_parent = function(color, padding, margin) {
	color = ((typeof color=='undefined') || (color==''))?'':(' background-color:'+color+';');
	if ((typeof padding=='undefined') || (padding=='')) padding = '4px';
	if ((typeof margin=='undefined') || (margin=='')) margin = '4px 0';
	return this.wrap('<div class="jc_parent" style="padding:'+padding+';'+color+' margin:'+margin+';"><\/div>');
};
var cs_init = function() {
	cs_auteur_forum.apply(this);
	/* optimisation : 'IF(1)' */ if(!cs_prive) jQuery("a.spip_out,a.spip_url,a.spip_glossaire",this).attr("target", "_blank"); 
	soft_scroller_init.apply(this);
	if(typeof jcorner_init=="function") jcorner_init.apply(this);
}
if(typeof onAjaxLoad=='function') onAjaxLoad(cs_init);
if(window.jQuery) {
var cs_sel_jQuery=typeof jQuery(document).selector=='undefined'?'@':'';
var cs_CookiePlugin="prive/javascript/jquery.cookie.js";
jQuery(document).ready(function(){
	cs_init.apply(document);
});
}
