﻿
$(document).ready(function () {

//    if ($('#fsSearch input:text') != null) {
//        if ($('#fsSearch input:text').val() == "Recherche simple" || $('#fsSearch input:text').val() == "" || $('#fsSearch input:text').val().trim().length == 0) {
//            $('#simpleValidSearch').attr('disabled', 'disabled');
//            $('#simpleValidSearch').css('cursor', 'default');
//        }
//    }

    $('#fsSearch input:text').focus(function () {
        //alert($(document.getElementById("a$t0")).val());
        ClearSimpleSearch();
        ReEnabled();
        valideSurEntree('simpleValidSearch');
    });
    $('#fsSearch input:text').change(function () {
        $(document.getElementById("a$t0")).focus();
    });

    $('#fsSearch input:text').keypress(function () {
        $(document.getElementById("a$t0")).focus();
    });
    $('#fsSearch input:text').mousedown(function () {
        $(document.getElementById("a$t0")).focus();
    });

    $('#simpleValidSearch').click(function () {
        searchWaiting();
    });

    $('#fsSearch input:text').each(function () {
        $(this).attr('maxlength', '100');
    });


});

function ResetSearch(url) {
    document.location.href = url;
}
/* RECHERCHE SIMPLE */
function ClearSimpleSearch() {
    if ($('#fsSearch input:text').val() == "Recherche simple") {
        $('#fsSearch input:text').val("");
    }
}
function ReEnabled() {
    if ($(document.getElementById("a$t0")).val().length > 1) {        
        $('#simpleValidSearch').removeAttr('disabled');
        $('#simpleValidSearch').css('cursor', 'pointer');        
    } else {    
        $('#simpleValidSearch').attr('disabled', 'disabled');
        $('#simpleValidSearch').css('cursor', 'default');        
    }
}

