// Put all your lovely jQuery / Javascript goodies right down here.

function entity_type_has_changed()
{
   if($('#entity_type').val() == 'individual')
   {
	   $('#company_name').val('');
       $('#company_name').attr('disabled', 'disabled');
       $('#siren').val('');
       $('#siren').attr('disabled', 'disabled');
       $('#tva_intracom').val('');
       $('#tva_intracom').attr('disabled', 'disabled');
       
       $('#birthdate').removeAttr('disabled');
       $('#country_of_birth').removeAttr('disabled');
       $('#city_of_birth').removeAttr('disabled');
       $('#state_of_birth').removeAttr('disabled');
   }
   else
   {
	   $('#birthdate').val('');
       $('#birthdate').attr('disabled', 'disabled');
       $('#country_of_birth').val('');
       $('#country_of_birth').attr('disabled', 'disabled');
       $('#city_of_birth').val('');
       $('#city_of_birth').attr('disabled', 'disabled');
       $('#state_of_birth').val('');
       $('#state_of_birth').attr('disabled', 'disabled');
       $('#company_name').removeAttr('disabled');
       $('#siren').removeAttr('disabled');
       $('#tva_intracom').removeAttr('disabled');
   }
}

function country_of_birth_has_changed()
{
   if($('#country_of_birth').val() == 'FR')
   {
	   $('#state_of_birth').removeAttr('disabled');
	   $('#city_of_birth').removeAttr('disabled');
   }
   else
   {
       $('#state_of_birth').attr('disabled', 'disabled');
       $('#city_of_birth').attr('disabled', 'disabled');
   }
}

function record_type_has_changed()
{
   if($('#type').val() == 'MX')
	   $('#opt').removeAttr('disabled');
   else
       $('#opt').attr('disabled', 'disabled');
   
   if($('#type').val() == 'TXT')
	   $('#host').attr('disabled', 'disabled');
   else
	   $('#host').removeAttr('disabled');
}

function confirm_delete()
{
	return confirm('Etes-vous sûr de vouloir supprimer cet élément ?');
}

function hide(id)
{
    $('#'+id).hide();
    $('#link_hide_'+id).hide();
    $('#link_show_'+id).show();
}

function show(id)
{
    $('#'+id).show();
    $('#link_show_'+id).hide();
    $('#link_hide_'+id).show();
}

//hide optional forms
$("[id^=optional]").each(function() {
        $(this).hide();
    }
);

//hide link that hide optional forms
$("[id^=link_hide]").each(function() {
        $(this).hide();
    }
);

var login = $('#login').val();
var login_placeholder = "E-mail";
if(login == '' || login == login_placeholder)
{
	$("#login").placeHolder({
        "text"           : login_placeholder,
        "active"         : "#000",
        "placeholder"    : "#aaa"
	});
}

var password = $('#password').val();
var password_placeholder = "Mot de passe";
if(password == '' || password == password_placeholder)
{
	$("#password").placeHolder({
        "text"           : password_placeholder,
        "active"         : "#000",
        "placeholder"    : "#aaa"
	});
}



