

$(document).ready(function() {
	$(".arbo").click(function () {
    	$(this).children().show("slow");       	
  });		
  
  $(".listecomplete").click(function () {  	
    	$(".arbo").show();       	
    	$(".zonnageVille").show();  
  });		
  
  $(".listecompleteReplier").click(function () {  	
    	$(".zonnageRegion").hide();       	
    	$(".zonnageVille").hide();  
  });	
    
	$(".standOutHover").hover(
			function() { $(this).expose({opacity: 0.4, api: true, loadSpeed: 500, closeSpeed: 500}).load(); },
	    function() {	$(this).expose().close();	}
 		); /* standOutHover */
   		
   $("#nomPrenom").click(function(){   
			$("#nomPrenom").css("background-color", "white");
   }); /* nomPrenom */
   
   $("#cp").click(function(){   
			$("#cp").css("background-color", "white");
   }); /* cp */
   
   $("#tel").click(function(){   
			$("#tel").css("background-color", "white");
   }); /* tel */
   
   $("#email").click(function(){   
			$("#email").css("background-color", "white");
   }); /* tel */
   
   $("#nomPrenom60").click(function(){   
			$("#nomPrenom60").css("background-color", "white");
   }); /* nomPrenom60 */
   
   $("#cp60").click(function(){   
			$("#cp60").css("background-color", "white");
   }); /* cp60 */
   
   $("#tel60").click(function(){   
			$("#tel60").css("background-color", "white");
   }); /* tel60 */
   
   $("#email60").click(function(){   
			$("#email60").css("background-color", "white");
   }); /* email */
   
   $("#ir").click(function(){   
			$("#ir").css("background-color", "white");
   }); /* ir */
   
   $("#email").click(function(){   
			$("#email").css("background-color", "white");
   }); /* email */
   
   $("#nbPart").click(function(){   
			$("#nbPart").css("background-color", "white");
   }); /* nbPart */
   
   $("#salaireMme").click(function(){   
			$("#salaireMme").css("background-color", "white");
   }); /* salaireMme */
   
   $("#salaireMr").click(function(){   
			$("#salaireMr").css("background-color", "white");
   }); /* salaireMr */
   
   $("#ageMmeSimu").click(function(){   
			$("#ageMmeSimu").css("background-color", "white");
   }); /* ageMmeSimu */
   
   $("#ageMrSimu").click(function(){   
			$("#ageMrSimu").css("background-color", "white");
   }); /* ageMrSimu */
   
   $("#capaEpargne").click(function(){   
			$("#capaEpargne").css("background-color", "white");
   }); /* capaEpargne */
   
}); /* fin ready */


function nbNum(field) {
	var valid = "0123456789";
	var numCount = 0;
	
	for (var i=0; i < field.length; i++) {
		temp = "" + field.substring(i, i+1);
		if (valid.indexOf(temp) != "-1") numCount++;
	}
	
	return numCount;
}

/* check if field contain only char from pattern */
function matchPattern(field, pattern) {
	var valid = pattern;
	var numCount = 0;
	
	for (var i=0; i < field.length; i++) {
		temp = "" + field.substring(i, i+1);
		if (valid.indexOf(temp) != "-1") numCount++;
	}
	
	return (field.length == numCount);
}

/* check if field contain only numeric chars */
function isNumeric(field) {
	return matchPattern(field, "0123456789");
}

/* check if field contain only numeric or "," char */
function isDecimal(field) {
	return matchPattern(field, "0123456789,");
}

function verifBait() {
	$(".ttnomprenom").css("display", "none");
	$("#nomPrenom").css("background-color", "white");
	$(".ttcp").css("display", "none");
	$("#cp").css("background-color", "white");
	$(".tttel").css("display", "none");
	$("#tel").css("background-color", "white");
	$(".ttmail").css("display", "none");
	$("#email").css("background-color", "white");
   		
	if(($("#nomPrenom").val().length < 6) || ($("#nomPrenom").val().indexOf(' ', 0) == -1))
	{
		$(".ttnomprenom").fadeIn("slow");
		$("#nomPrenom").css("background-color", "#EF5D47");
		return false;
	}
	
	if(($("#cp").val().length >=5) && (nbNum($("#cp").val()) == 5) && ($("#cp").val().length <=6))
	{
	}
	else
	{		
		$(".ttcp").fadeIn("slow");
		$("#cp").css("background-color", "#EF5D47");
		return false;
	}
	
	if(($("#tel").val().length >=10) && (nbNum($("#tel").val()) == 10) && ($("#tel").val().length <=14))
	{
	}
	else
	{
		$(".tttel").fadeIn("slow");
		$("#tel").css("background-color", "#EF5D47");
		return false;
	}
	
	if($("#email").val().indexOf("@") != "-1" && 
			$("#email").val().indexOf(".") != "-1" && 
			$("#email").val() != "")
	{
	}
	else
	{
		$(".ttmail").fadeIn("slow");
		$("#email").css("background-color", "#EF5D47");
		return false;
	}
	
	return true;	
}



function verifBait60villes() {
	$(".ttnomprenom60").css("display", "none");
	$("#nomPrenom60").css("background-color", "white");
	$(".ttcp60").css("display", "none");
	$("#cp60").css("background-color", "white");
	$(".tttel60").css("display", "none");
	$("#tel60").css("background-color", "white");
	$(".ttemail60").css("display", "none");
	$("#email60").css("background-color", "white");
	
	if(($("#nomPrenom60").val().length < 6) || ($("#nomPrenom60").val().indexOf(' ', 0) == -1))
	{
		$(".ttnomprenom60").fadeIn("slow");
		$("#nomPrenom60").css("background-color", "#EF5D47");
		return false;
	}
	
	if(($("#cp60").val().length >=5) && (nbNum($("#cp60").val()) == 5) && ($("#cp60").val().length <=6))
	{
	}
	else
	{
		$(".ttcp60").fadeIn("slow");
		$("#cp60").css("background-color", "#EF5D47");
		return false;
	}
	
	if(($("#tel60").val().length >=10) && (nbNum($("#tel60").val()) == 10) && ($("#tel60").val().length <=14))
	{
	}
	else
	{
		$(".tttel60").fadeIn("slow");
		$("#tel60").css("background-color", "#EF5D47");
		return false;
	}
	
	if($("#email60").val().indexOf("@") != "-1" && 
			$("#email60").val().indexOf(".") != "-1" && 
			$("#email60").val() != "")
	{
	}
	else
	{
		$(".ttemail60").fadeIn("slow");
		$("#email60").css("background-color", "#EF5D47");
		return false;
	}
	
	return true;
	
}

function verifBaitSimu() {
	$("#nomPrenomSimu").css("background-color", "white");
	$("#cpSimu").css("background-color", "white");
	$("#tel").css("background-color", "white");
	$("#ir").css("background-color", "white");
  $("#email").css("background-color", "white");
  $("#nbPart").css("background-color", "white");
  $("#salaireMme").css("background-color", "white");
  $("#salaireMr").css("background-color", "white");
  $("#ageMmeSimu").css("background-color", "white");
  $("#ageMrSimu").css("background-color", "white");
  $("#capaEpargne").css("background-color", "white");
  
  $(".ttnomprenomSimu").css("display", "none");
  $(".ttcpSimu").css("display", "none");
  $(".tttelSimu").css("display", "none");
  $(".ttimpotSimu").css("display", "none");
  $(".ttemailSimu").css("display", "none");
  $(".ttnbPartSimu").css("display", "none");
  $(".ttsalaireMmeSimu").css("display", "none");
  $(".ttsalaireMrSimu").css("display", "none");
  $(".ttageMmeSimu").css("display", "none");
  $(".ttageMrSimu").css("display", "none");
  $(".ttcapaEpargneSimu").css("display", "none");
  
   		
	if(($("#nomPrenomSimu").val().length < 6) || ($("#nomPrenomSimu").val().indexOf(' ', 0) == -1))
	{
		$(".ttnomprenomSimu").fadeIn("slow");
		$("#nomPrenomSimu").css("background-color", "#EF5D47");
		return false;
	}
	
	if(($("#cpSimu").val().length >=5) && (nbNum($("#cpSimu").val()) == 5) && ($("#cpSimu").val().length <=6))
	{
	}
	else
	{
		$(".ttcpSimu").fadeIn("slow");
		$("#cpSimu").css("background-color", "#EF5D47");
		return false;
	}
	
	if(($("#tel").val().length >=10) && (nbNum($("#tel").val()) == 10) && ($("#tel").val().length <=14))
	{
	}
	else
	{
		$(".tttelSimu").fadeIn("slow");
		$("#tel").css("background-color", "#EF5D47");
		return false;
	}
	
	return true;
	
}