

function showCurrent() {

    $('#col-products ul li').each(function() {

            if ($(this).hasClass('current')) {
                var current_mask = $(this).children('.mask');
                current_mask.addClass('survol');
            }
            else {
                $(this).children('.mask').show();
            }

    });
}

function hideAllNoCurrent() {

    $('#col-products ul li').each(function() {

            if ($(this).hasClass('current')) {

            }
            else {

                $(this).children('.mask').show();
            }


	});

}




var is_valid_anchor = false;
var anchor;

function get_anchor() {

	var anchor = window.location.hash;
        anhor = anchor.substring(1, anchor.length);

	if (anchor == "") anchor = "contact";

	return anchor;

}


function show(anchor) {

	switch (anchor) {

		case 'documentation':

			$('.formdocumentation').closest('div.form-row').show();

		; break;

		case 'invitation':

			$('.forminvitation').closest('div.form-row').show();

		; break;

	}

}


function hide(anchor) {

	switch (anchor) {

		case 'documentation':

			$('.formdocumentation').closest('div.form-row').hide();

		; break;

		case 'invitation':

			$('.forminvitation').closest('div.form-row').hide();

		; break;

	}

}

function hideAll() {
	$('.forminvitation').closest('div.form-row').hide();
	$('.formdocumentation').closest('div.form-row').hide();
}


$().ready(function() {

        $('#menu ul li:last-child').addClass('devis');
        //$('#menu ul li:last-child').prev('li').addClass('bold');
        //$('#menu ul li').length;

//        $('#col-products ul li').each(function() {
//            var _h = $(this).children("div").children("a").height() + $(this).children("div").children("span").height() + 10;
//
//            $(this).css({"height" : _h});
//            $(this).children("div.mask").css({"height" : _h});
//        });
		
//	var _h_content = $("#col-content").height();
//
//	if(_h_content > $("#col-products").height())
//        $("#col-products").css({"height" : _h_content});

        $(document).pngFix();

        showCurrent();

	$('#col-products ul li').each(function() {


		$(this).mouseenter( function() {
                
			var current_mask = $(this).children('.mask');
                        current_mask.addClass('survol');
                        $(this).children('.mask').hide();
                        if (!$(this).hasClass('survol')) {

                        }
                     else {
                         $(this).children('.mask').show();
                         }

		});


		$(this).mouseleave( function() {

			var current_mask = $(this).children('.mask');
                        current_mask.removeClass('survol');

                        hideAllNoCurrent();

		});

	});



        anchor = get_anchor();
	hide('documentation');
	hide('invitation');
	show(anchor);

	$('form#contact ul li').bind('mouseenter', function() {

		$(this).children('.layer').show();

		$(this).children('.layer').click(function() {
     
			anchor = $(this).parent().find("input:radio").val();

			if (anchor == "demandedevis") document.location.href = '/couverture/fr/demande-de-devis';

			$(this).parent().parent().find("input:radio").attr('checked',false);
			$(this).parent().find("input:radio").attr('checked',true);
			hideAll();
			show(anchor);

		});

	});

	$('form#contact ul li').bind('mouseleave', function() {
		$(this).children('.layer').hide();
	});
	
	
	
	
	$("#devis").formwizard({ 
		 	formPluginEnabled: true,
		 	validationEnabled: true,
		 	focusFirstInput : false,
		 	formOptions :{
				beforeSubmit: function(){ $("#devis").hide(); $("#sending").show(); $('html, body').animate({ scrollTop: 0}, 'slow'); },
				success: function(){ $("#sending").fadeOut(); $("#form_sent").delay(400).fadeIn(); },
				resetForm: true
		 	}	
		 }
	);
	$("#catalog").formwizard({ 
		 	formPluginEnabled: true,
		 	validationEnabled: true,
		 	focusFirstInput : false,
		 	formOptions :{
				beforeSubmit: function(){ $("#catalog").hide(); $("#sending").show(); $('html, body').animate({ scrollTop: 0}, 'slow'); },
				success: function(){ $("#sending").fadeOut(); $("#form_sent").delay(400).fadeIn(); },
				resetForm: true
		 	}	
		 }
	);
	
	
	if($("#devis_wherecountryid_val").val() == 1){
		$("#devis_weherecp_val").parent().parent().show();
	}
	else{
		$("#devis_weherecp_val").parent().parent().hide();
			$("#devis_weherecp_val").val(0);
	}
	
	$("#devis_wherecountryid_val").change(function(){
		if($("#devis_wherecountryid_val").val() == 1){
			$("#devis_weherecp_val").parent().parent().show();
		}
		else{
			$("#devis_weherecp_val").parent().parent().hide();
			$("#devis_weherecp_val").val(0);
		}
	});
	
	
	
	if($("#catalog_wherecountryid_val").val() == 1){
		$("#catalog_weherecp_val").parent().parent().show();
	}
	else{
		$("#catalog_weherecp_val").parent().parent().hide();
			$("#catalog_weherecp_val").val(0);
	}
	
	$("#catalog_wherecountryid_val").change(function(){
		if($("#catalog_wherecountryid_val").val() == 1){
			$("#catalog_weherecp_val").parent().parent().show();
		}
		else{
			$("#catalog_weherecp_val").parent().parent().hide();
			$("#catalog_weherecp_val").val(0);
		}
	});
	
	
	

});

