function showMiseEnAvant(HtmlId, bErase) {

	HtmlId = '#'+HtmlId+'_error';
	var htmlcurrent = $(HtmlId).html();

	if ( htmlcurrent == '' ) {
		$(HtmlId).html('&nbsp;<b>/!\\</b>');
		$(HtmlId).css('color', 'red');
	} else if ( bErase ) {
		$(HtmlId).html(' ');
	}
}


function check_sub(objet) {

	if (arguments.length > 1) {
		comparison_value = arguments[1].value;
		//$("#error_message").load(vCheminPhp + 'check_field.php?name=' + objet.name + '&value=' + objet.value + '&comparison_value=' + comparison_value);
		$.get(vCheminPhp + 'check_field.php?name=' + objet.name + '&value=' + objet.value + '&comparison_value=' + comparison_value, function(retour){
			if(retour!="") {
				$("#error_message").html(retour);
				showMiseEnAvant(objet.name, false);
			} else {
				showMiseEnAvant(objet.name, true);
			}
		});
	} else {
		if(objet.name == "fsubs_chk_confirm") {
			//$("#error_message").load(vCheminPhp + 'check_field.php?name=' + objet.name + '&value=' + objet.checked);
			$.get(vCheminPhp + 'check_field.php?name=' + objet.name + '&value=' + objet.checked, function(retour){
				if(retour!="") {
					$("#error_message").html(retour);
					showMiseEnAvant(objet.name, false);
				} else {
					showMiseEnAvant(objet.name, true);
				}
			});
		} else {
			//$("#error_message").load(vCheminPhp + 'check_field.php?name=' + objet.name + '&value=' + objet.value);
			$.get(vCheminPhp + 'check_field.php?name=' + objet.name + '&value=' + objet.value, function(retour){
				if(retour!="") {
					$("#error_message").html(retour);
					showMiseEnAvant(objet.name, false);
				} else {
					showMiseEnAvant(objet.name, true);
				}
			});
		}
	}
}


function check_sub_device(objet) {

	if(objet.value == 1) {
		$("#p_fsubs_txt_model").css({display : "block"});
	} else {
		$("#error_message").load(vCheminPhp + 'check_field.php?name=' + objet.name + '&value=' + objet.value);
	}
}

function check_all() {

	param = "";

	param += "&fsubs_txt_email=" + $("#fsubs_txt_email").val();
	param += "&fsubs_txt_pseudo=" + $("#fsubs_txt_pseudo").val();
	param += "&fsubs_txt_pass=" + $("#fsubs_txt_pass").val();
	param += "&fsubs_txt_pass_confirm=" + $("#fsubs_txt_pass_confirm").val();
	param += "&fsubs_sel_device=" + $("#fsubs_sel_device").val();
	param += "&fsubs_sel_model=" + $("#fsubs_sel_model").val();
	param += "&fsubs_txt_model=" + $("#fsubs_txt_model").val();
	param += "&fsubs_txt_captcha=" + $("#fsubs_txt_captcha").val();
	param += "&fsubs_chk_promo=" + $("#fsubs_chk_promo").get(0).checked;
	param += "&fsubs_chk_confirm=" + $("#fsubs_chk_confirm").get(0).checked;

	$.get(vCheminPhp + 'check_field.php?type=all' + param, function(retour) {

		if(retour != "ok") {

			$("#error_message").html(retour);
			/*$("#fsubs_txt_email_error").load(vCheminPhp + 'check_field.php?type=alone_small&name=fsubs_txt_email&value=' + $("#fsubs_txt_email").val());
			$("#fsubs_txt_email2_error").load(vCheminPhp + 'check_field.php?type=alone_small&name=fsubs_txt_email2&value=' + $("#fsubs_txt_email2").val() + '&comparison_value=' + $("#fsubs_txt_email").val());
			$("#fsubs_txt_pseudo_error").load(vCheminPhp + 'check_field.php?type=alone_small&name=fsubs_txt_pseudo&value=' + $("#fsubs_txt_pseudo").val());
			$("#fsubs_txt_pass1_error").load(vCheminPhp + 'check_field.php?type=alone_small&name=fsubs_txt_pass1&value=' + $("#fsubs_txt_pass1").val());
			$("#fsubs_txt_pass2_error").load(vCheminPhp + 'check_field.php?type=alone_small&name=fsubs_txt_pass2&value=' + $("#fsubs_txt_pass2").val() + '&comparison_value=' + $("#fsubs_txt_pass1").val());
			$("#fsubs_txt_country_error").load(vCheminPhp + 'check_field.php?type=alone_small&name=fsubs_txt_country&value=' + $("#fsubs_txt_country").val());
			$("#fsubs_txt_lang_error").load(vCheminPhp + 'check_field.php?type=alone_small&name=fsubs_txt_lang&value=' + $("#fsubs_txt_lang").val());
			$("#fsubs_sel_device_error").load(vCheminPhp + 'check_field.php?type=alone_small&name=fsubs_sel_device&value=' + $("#fsubs_sel_device").val());
			$("#fsubs_txt_captcha_error").load(vCheminPhp + 'check_field.php?type=alone_small&name=fsubs_txt_captcha&value=' + $("#fsubs_txt_captcha").val());
			$("#fsubs_chk_confirm_error").load(vCheminPhp + 'check_field.php?type=alone_small&name=fsubs_chk_confirm&value=' + $("#fsubs_chk_confirm").get(0).checked);

			$("#error_sub_all").css({display : "block"});
			$("#error_sub_all").html(retour);*/
		} else {
			document.forms["form_subscribe"].submit();
		}

	});
}

$(document).ready(function() {
	$('#fsubs_sel_device').change(function () {

		if ( $(this).val() == '1' ) {

			$('#p_fsubs_sel_model').css('display', 'none');
			$('#p_fsubs_txt_model').css('display', 'block');

		} else if( $(this).val() == 'none' ) {

			$('#p_fsubs_sel_model').css('display', 'none');
			$('#p_fsubs_txt_model').css('display', 'none');

		} else {

			$.get("/phplib/ajax_scripts/share_information_by_query.php?type=GetModelFromBrand&brand="+$(this).val(), function(retour) {
				$('#p_fsubs_txt_model').css('display', 'none');
				$('#p_fsubs_sel_model').css('display', 'block');
				$('#fsubs_sel_model').html(retour);
			});
		}
	}).change();

	$('#fsubs_sel_model').change(function () {
		if ( $(this).val() == '1' ) {
			$('#p_fsubs_txt_model').css('display', 'block');
		} else if ( $(this).val() == 'none' ) {

		} else {
			$('#p_fsubs_txt_model').css('display', 'none');
		}
	}).change();
});
