

// ----------------------------------------------------------------------------------
// Divers
// ----------------------------------------------------------------------------------



$(document).ready(function() {

	$(".connection").click(function() {
		$(this).css("background-position","-165px 0");
		$(this).find(".connect").slideDown("fast");
		$(this).hover(function(){
			$(this).find(".connect").hide();
			$(this).css("background-position","0 0");
		});
	})
	
	


}) 
						



// ----------------------------------------------------------------------------------
// Boites de connection
// ----------------------------------------------------------------------------------




// ----------------------------------------------------------------------------------
// Validate
// ----------------------------------------------------------------------------------


jQuery.extend(jQuery.validator.messages, {
required: "Ce champ est requis.",
email: "Veuillez entrer une adresse email valide.",
maxlength: "Veuillez ne pas entrer plus de {0} caractères.",
minlength: "Veuillez entrer au moins {0} caractères.",
digits: "Veuillez entrer des chiffres uniquements.",
equalTo: "Veuillez saisir la même valeur que le champs précédent."
});

$.validator.addMethod(
"nospecialchar",
function(value, element) {
return value.match(/^[a-z0-9-]*$/);
},
"Entrez uniquement des chiffres ou des lettres, sans espace"
);





// ----------------------------------------------------------------------------------
// Waiting
// ----------------------------------------------------------------------------------



function startWaiting() { $("#waiting").data("overlay").load() ;  }
function stopWaiting() { $("#waiting").data("overlay").close() ; }


// ----------------------------------------------------------------------------------
// EditProfile
// ----------------------------------------------------------------------------------


function AvocatProfilChange() { 

	$("#submitprofil").removeAttr("disabled");

}

function AvocatUrlProfilChange() { 

	$("#submiturl").removeAttr("disabled");

}


function saveAvocatProfilSuccess() { 

	$("#submitprofil").attr("disabled","true");
	stopWaiting();
}

function saveURLProfilSuccess(responseXML) { 

	var alreadyexist = $('alreadyexist', responseXML).text();
    	
    	 
	if (alreadyexist == "") {
		$("#submiturl").attr("disabled","true");
		$("#profildejautilise").hide();
	} else {
		$("#profildejautilise").show();
	}
	
	stopWaiting();
}



function savePhotoSuccess(responseXML) { 

	var photo = $('photo', responseXML).text();
	var d = new Date();
    	
	if (photo == "") {
		$("#profilphoto").hide();
		$("#profilnophoto").show();

	} else {
		$("#profilphoto").show();
		$("#profilnophoto").hide();
		$("#photopreview").attr("src",photo+"?foo="+d.getTime());
	}
	
	stopWaiting();
}


function DelArticle(id) {

	var buttons = $("#confirmdelarticlemodal button").click(function(e) {
		
		var yes = buttons.index(this) === 0;
	
		if(yes) { window.location.href = "?section=articles&cm=delarticle&delid="+id ; };

		});

	$("#confirmdelarticlemodal").data("overlay").load() ;

}


function addDomaine() {
$('#adddomaineform').ajaxSubmit({beforeSubmit: startWaiting,success: refreshDomaineTable});
return false;
}

function refreshDomaineTable() { 

	$("#domaineTable").load("/custom/refreshDomaineTable.xml", refreshAddDomaineForm);
	$("#newdomaine").val("");
	$("#selectdomaine").val("");
}

function refreshAddDomaineForm() { 

	if($("#domaineTable tbody tr").length >= 11)  $("#adddomaineformdiv").hide();
	else  $("#adddomaineformdiv").show();
	stopWaiting() ;
}


function delDomaine(dom) {

	$("#"+dom).remove();
	addDomaine();
	return false;

}
















