
	

$(document).ready(function() {
	
	//$('#cadreclair').cornerz({corners:"tr bl"});
	//$('#menu').cornerz({corners:"tl tr", background:"#434343"});
	

	$("#ssIndexListe div:gt(0)").each(function(){
		$(this).hide();
	});

	$("#password").blur(function(){
		$("#ajaxLoad2").html('');
		if($("#password").val().length < 6 && $("#password").val().length > 32 ){
			$("#ajaxLoad2").html('<img src="images/cross.png" alt="" />La longueur de votre mot de passe doit être comprise entre 6 et 32 caractères.');
		}
		if($("#password").val() == ""){
			$("#ajaxLoad2").html('<img src="images/cross.png" alt="" />le mot de passe ne peut être vide.');
		}
	});

	$("#password2").blur(function(){
		if($("#password2").val() != ""){
			$("#ajaxLoad3").html('');
			if($("#password2").val() == $("#password").val()){
				$("#ajaxLoad3").html('<img src="images/accept.png" alt="" />');
			}else{
				$("#ajaxLoad3").html('<img src="images/cross.png" alt="" />Reconfirmez votre mot de passe');
			}
		}
		
	});

	$("#checkedUrl").blur(function(){
		$("#ajaxLoad4").html('<img src="images/loader.gif" alt="" />');
		$("#checkedUrl").val($("#checkedUrl").val().replace("http://", ""));
		$("#checkedUrl").val($("#checkedUrl").val().replace("https://", ""));
		
		var posslash=$("#checkedUrl").val().indexOf ("/", 0);
		if (posslash !=-1) 
			$("#checkedUrl").val($("#checkedUrl").val().substring(0, posslash));
		
		$.ajax({
			type:"GET",
			url:"librairies/test_url.php",
			data:"url="+$("#checkedUrl").val()+"&lng="+$("#langue").val(),
			success: function(data){
				if(data == 1){
					$("#ajaxLoad4").html('<img src="images/accept.png" alt="" />');
				}else if(data == 2){
						$("#ajaxLoad4").html('');
				}else{
					$("#ajaxLoad4").html('<img src="images/cross.png" alt="" />'+ data);
				}
			}
		});
	});
	$("#checkedEmail").blur(function(){
		$("#ajaxLoad1").html('<img src="images/loader.gif" alt="" />');
		$.ajax({
			type:"GET",
			url:"librairies/test_mail.php",
			data:"email="+$("#checkedEmail").val(),
			success: function(data){
				if(data==1){
					$("#ajaxLoad1").html('<img src="images/accept.png" alt="" />');
				}else if(data==2){
					if($("#langue").val() == "fr"){
						$("#ajaxLoad1").html('<img src="images/cross.png" alt="" /> L\'adresse renseignée est déjà enregistrée.');
					}else{
						$("#ajaxLoad1").html('<img src="images/cross.png" alt="" /> A customer has already subscribed with the same email address.');
					}
				}else{
					if($("#langue").val() == "fr"){
						$("#ajaxLoad1").html('<img src="images/cross.png" alt="" /> L\'adresse renseignée est incorrecte.');
					}else{
						$("#ajaxLoad1").html('<img src="images/cross.png" alt="" /> The email address is incorrect.');
					}
				}
			}
		});
	});
	$("#inscriptionDemo").submit(function(){
		var readyToSend = true;
		$("#checkedTel").blur();
		
		if($("#ajaxLoad1").text() != '' || $("#checkedEmail").val() == ""){
			readyToSend = false;
			$("#checkedEmail").focus();
		}else if($("#ajaxLoad2").text() != '' || $("#password").val() == ""){
			readyToSend = false;
			$("#password").focus();
		}else if($("#ajaxLoad3").text() != '' || $("#password2").val() == ""){
			readyToSend = false;
			$("#password2").focus();
		}else if($("#ajaxLoad4").text() != '' || $("#checkedUrl").val() == ""){
			readyToSend = false;
			$("#checkedUrl").focus();
		}else if($("#nom").val() == ""){
			readyToSend = false;
			$("#nom").focus();
		}
		
		if(readyToSend == false){
			if($("#langue").val() == "fr"){
				alert('Tous les champs obligatoires n\'ont pas été renseignés correctement.');
			}else{
				alert('All mandatory fields must be correctly fulfilled.');
			}
		}
		return readyToSend;
	});	
});

function onglet(numOnglet){
	$("#indexListe li").each(function (){
		$(this).removeClass('fond');
	});
	$("#ssIndexListe div").each(function(){
		$(this).hide();
	});
	$("#indexListe li:eq("+numOnglet+")").addClass('fond');
	$("#ssIndexListe div:eq("+numOnglet+")").show();
}