function doSearch (mode)
{
    var ok = doFormSearch (mode);
    
    if (ok)
    {
        var form = EL ('searchForm');

        form.submit();
    }
    
    return false;
}


function doPartnerSearch()
{
    var width    = EL('width');
    var ratio    = EL('ratio');
    var diameter = EL('diameter');
    var speed    = EL('speed');
    var isError  = (width.value == '' || ratio.value == '' || diameter.value == '' || speed.value == '');

    if (isError)
    {
        alert (error);
    }
    else
    {
        var form = EL ('searchForm');
        
        form.submit();
    }
    
    return false;
}

function doPartnerSearchVehicle()
{
    var carMaker      = EL('carMaker');
    var carModel      = EL('carModel');
    var carMotorPower = EL('carMotorPower');
    var carYear       = EL('carYear');
    var carDimension  = EL('carDimension');

    var isError  = (carMaker.value == '' || carModel.value == '' || carMotorPower.value == '' || carYear.value == '' || carDimension.value == '');

    if (isError)
    {
        alert (error);
    }
    else
    {
        var form = EL ('searchForm');

        form.submit();
    }

    return false;
}

/**
 *      check form and display errors
 **/
function doFormSearch (mode)
{
    //TODO : ne pas oublier de mettre la valeur dans l'appel de doSearch
    //var form = EL('searchForm');
    
    //var manufacturer;
    var width;
    var ratio;
    var diameter;
    var speed;
    var carMaker;
    var carModel;
    var carMotorPower;
    var carYear;
    var carDimension;
    var shifted;
    
    var isError = false;

    var nbErrorLeftColumn = 0;
    var nbErrorRightColumn = 0;
    var leftColumn = false;

    var labelError = "";
    var colorError = EL('color-error').value;

    //CallCenter search
    var callCenterDimension = EL('callCenterDimension');
    if (callCenterDimension != null)
    {
        var value = callCenterDimension.value;

        value = Valraiso.util.trim (value);

        if (value != "")
        {
            return true;
        }
    }        
    //END : CallCenter search
   
    //Size search
    if (mode == '' || mode == 'size' || mode == 'brand')
    {
        shifted  = EL('shifted');
        width    = EL('width');
        ratio    = EL('ratio');
        diameter = EL('diameter');
        speed    = EL('speed');
        
        if (width.value == '')
        {
            EL('label-width').style.color       = colorError;
            EL('label-width').style.fontWeight  = "bold";

            var labelWidth = EL('label-width').firstChild.nodeValue;

            labelError += labelWidth;
            isError     = true;
            leftColumn  = true;

            nbErrorLeftColumn++;

            //EL('warning-width').style.display = 'block';
            //EL('error-width').innerHTML = "- "+labelWidth.substring(0,labelWidth.length-2);
            //EL('error-width').style.display = "block";
        }
        else
        {
            EL('label-width').style.color       = "white";
            EL('label-width').style.fontWeight  = "normal";

            //EL('warning-width').style.display = 'none';
            //EL('error-width').innerHTML = "";
            //EL('error-width').style.display = "none";
        }

        if (ratio.value == '')
        {
            EL('label-ratio').style.color       = colorError;
            EL('label-ratio').style.fontWeight  = "bold";

            var labelRatio = EL('label-ratio').firstChild.nodeValue;

            if (isError)
            {
                labelError += ", ";
            }

            labelError += labelRatio;
            isError     = true;
            leftColumn  = true;

            nbErrorLeftColumn++;

            //EL('warning-ratio').style.display = 'block';
            //EL('error-ratio').innerHTML = "- "+labelRatio.substring(0,labelRatio.length-2);
            //EL('error-ratio').style.display = "block";
            
        }
        else
        {
            EL('label-ratio').style.color       = "white";
            EL('label-ratio').style.fontWeight  = "normal";

            //EL('warning-ratio').style.display = 'none';
            //EL('error-ratio').innerHTML = "";
            //EL('error-ratio').style.display = "none";
        }

        if (diameter.value == '')
        {
            EL('label-diameter').style.color       = colorError;
            EL('label-diameter').style.fontWeight  = "bold";

            var labelDiameter = EL('label-diameter').firstChild.nodeValue;

            if (isError)
            {
                labelError += ", ";
            }

            labelError += labelDiameter;
            isError     = true;
            leftColumn  = true;

            nbErrorLeftColumn++;

            //EL('warning-diameter').style.display = 'block';
            //EL('error-diameter').innerHTML = "- "+labelDiameter.substring(0,labelDiameter.length-2);
            //EL('error-diameter').style.display = "block";
        }
        else
        {
            EL('label-diameter').style.color       = "white";
            EL('label-diameter').style.fontWeight  = "normal";

            //EL('warning-diameter').style.display = 'none';
            //EL('error-diameter').innerHTML = "";
            //EL('error-diameter').style.display = "none";
        }

        if (speed.value == '')
        {
            EL('label-speed').style.color       = colorError;
            EL('label-speed').style.fontWeight  = "bold";

            var labelSpeed = EL('label-speed').firstChild.nodeValue;

            if (isError)
            {
                labelError += ", ";
            }

            labelError += labelSpeed;
            isError     = true;

            nbErrorRightColumn++;

            //EL('warning-speed').style.display = 'block';
            //EL('error-speed').innerHTML = "- "+labelSpeed.substring(0,labelSpeed.length-2);
            //EL('error-speed').style.display = "block";
        }
        else
        {
            EL('label-speed').style.color       = "white";
            EL('label-speed').style.fontWeight  = "normal";

            //EL('warning-speed').style.display = 'none';
            //EL('error-speed').innerHTML = "";
            //EL('error-speed').style.display = "none";
        }

        var shiftedChecked = false;
        
        if (shifted != null) 
        {
            shiftedChecked = shifted.checked;
        }

        if (!isError && shiftedChecked)
        {
            startDecrease(0);
            //EL('warning-message').style.display = 'none';
            callAjax();
            return false;
        }
    }
    //Manufacturer search (now is the same than tyre search)
    /*else if (mode == 'brand')
    {
        createManufacturers();
        
        manufacturer = EL('manufacturer');
        
        EL('error-manufacturer').style.display = 'none';
        EL('error-informations').style.display = 'none';
        
        if (manufacturer.value == '')
        {
            EL('error-manufacturer').style.display = 'block';
            isError = true;
        }
        
        if (!isError)
        {
            shifted  = EL('shifted');
            width    = EL('width');
            ratio    = EL('ratio');
            diameter = EL('diameter');

            if (width.value == '')
            {
                EL('warning-width').style.display = 'block';
                isError = true;
            }
            if (ratio.value == '')
            {
                EL('warning-ratio').style.display = 'block';
                isError = true;
            }
            if (diameter.value == '')
            {
                EL('warning-diameter').style.display = 'block';
                isError = true;
            }
            if (isError)
            {
                EL('error-informations').style.display = 'block';
            }
            else if (shifted.checked)
            {
                callAjax ();
                return false;
            }
        }
    }*/
    //Vehicle search
    else if (mode == 'vehicle')
    {
        carMaker      = EL('carMaker');
        carModel      = EL('carModel');
        carMotorPower = EL('carMotorPower');
        carYear       = EL('carYear');
        carDimension  = EL('carDimension');

        if (carMaker.value == '')
        {
            EL('label-carMaker').style.color       = colorError;
            EL('label-carMaker').style.fontWeight  = "bold";
            
            var labelCarMaker = EL('label-carMaker').firstChild.nodeValue;

            labelError += labelCarMaker;
            isError     = true;
            leftColumn  = true;

            nbErrorLeftColumn++;

            //EL('warning-carMaker').style.display = 'block';
            //EL('error-carMaker').innerHTML = "- "+labelCarMaker.substring(0,labelCarMaker.length-2);
            //EL('error-carMaker').style.display = "block";
        }
        else
        {
            EL('label-carMaker').style.color       = "white";
            EL('label-carMaker').style.fontWeight  = "normal";
            //EL('warning-carMaker').style.display = 'none';
            //EL('error-carMaker').innerHTML = "";
            //EL('error-carMaker').style.display = "none";
        }
        if (carModel.value == '')
        {
            EL('label-carModel').style.color       = colorError;
            EL('label-carModel').style.fontWeight  = "bold";

            var labelCarModel = EL('label-carModel').firstChild.nodeValue;

            if (isError)
            {
                labelError += ", ";
            }

            labelError += labelCarModel;
            isError     = true;
            leftColumn  = true;

            nbErrorLeftColumn++;

            //EL('warning-carModel').style.display = 'block';
            //EL('error-carModel').innerHTML = "- "+labelCarModel.substring(0,labelCarModel.length-2);
            //EL('error-carModel').style.display = "block";
        }
        else
        {
            EL('label-carModel').style.color       = "white";
            EL('label-carModel').style.fontWeight  = "normal";
            //EL('warning-carModel').style.display = 'none';
            //EL('error-carModel').innerHTML = "";
            //EL('error-carModel').style.display = "none";
        }
        if (carMotorPower.value == '')
        {
            EL('label-carMotorPower').style.color       = colorError;
            EL('label-carMotorPower').style.fontWeight  = "bold";

            var labelCarMotorPower = EL('label-carMotorPower').firstChild.nodeValue;

            if (isError)
            {
                labelError += ", ";
            }

            labelError += labelCarMotorPower;
            isError     = true;
            leftColumn  = true;

            nbErrorLeftColumn++;

            //EL('warning-carMotorPower').style.display = 'block';
            //EL('error-carMotorPower').innerHTML = "- "+labelCarMotorPower.substring(0,labelCarMotorPower.length-2);
            //EL('error-carMotorPower').style.display = "block";
        }
        else
        {
            EL('label-carMotorPower').style.color       = "white";
            EL('label-carMotorPower').style.fontWeight  = "normal";
            //EL('warning-carMotorPower').style.display = 'none';
            //EL('error-carMotorPower').innerHTML = "";
            //EL('error-carMotorPower').style.display = "none";
        }
        if (carYear.value == '')
        {
            EL('label-carYear').style.color       = colorError;
            EL('label-carYear').style.fontWeight  = "bold";

            var labelCarYear = EL('label-carYear').firstChild.nodeValue;

            if (isError)
            {
                labelError += ", ";
            }

            labelError += labelCarYear;
            isError     = true;

            nbErrorRightColumn++;

            //EL('warning-carYear').style.display = 'block';
            //EL('error-carYear').innerHTML = "- "+labelCarYear.substring(0,labelCarYear.length-2);
            //EL('error-carYear').style.display = "block";
        }
        else
        {
            EL('label-carYear').style.color       = "white";
            EL('label-carYear').style.fontWeight  = "normal";
            //EL('warning-carYear').style.display = 'none';
            //EL('error-carYear').innerHTML = "";
            //EL('error-carYear').style.display = "none";
        }
        if (carDimension.value == '')
        {
            EL('label-carDimension').style.color       = colorError;
            EL('label-carDimension').style.fontWeight  = "bold";

            var labelCarDimension = EL('label-carDimension').firstChild.nodeValue;

            if (isError)
            {
                labelError += ", ";
            }

            labelError += labelCarDimension;
            isError     = true;

            nbErrorRightColumn++;

            //EL('warning-carDimension').style.display = 'block';
            //EL('error-carDimension').innerHTML = "- "+labelCarDimension.substring(0,labelCarDimension.length-2);
            //EL('error-carDimension').style.display = "block";
        }
        else
        {
            EL('label-carDimension').style.color       = "white";
            EL('label-carDimension').style.fontWeight  = "normal";
            //EL('warning-carDimension').style.display = 'none';
            //EL('error-carDimension').innerHTML = "";
            //EL('error-carDimension').style.display = "none";
        }
    }
    if (isError)
    {
        EL('warning-message').style.display = 'block';

        var heightError = 96;

        EL('label-error').firstChild.nodeValue = labelError;

//            heightError = (18 * nbErrorLeftColumn) + 48;
//
//            if (nbErrorRightColumn > nbErrorLeftColumn)
//            {
//                heightError = (18 * nbErrorRightColumn) + 48;
//                EL('warning-message-right').style.marginTop ="0px";
//            }
//
//            EL('warning-message-right').style.marginTop ="-"+(18 * nbErrorLeftColumn)+"px";

        startDecrease(heightError);
        //startOpen();
    }
    else
    {
        return true;
    }
    
    return false;
}


function callAjax()
{
    var url;
    var load     = EL ('load');
    var speed    = EL ('speed');
    var width    = EL('width');
    var ratio    = EL('ratio');
    var diameter = EL('diameter');

    url  = '/shifteddimensionajax?width=';
    url += width.value;
    url += '&ratio=';
    url += ratio.value;
    url += '&diameter=';
    url += diameter.value;

    if (load != null)
    {
        url += '&load=';
        url += load.value;
    }
    if (speed != null)
    {
        url += '&speed=';
        url += speed.value;
    }
    
    loadShiftedPopUp (url, true);
}

/**
 *  Submit url request in ajax
*/
function loadPopup (url, type, extension)
{
    var query = Bw.IO.Query.create();
    
    query.setNoCache();
    query.get (url, function () { gotPopup (query, type, extension); } );
}

function loadMultiPopup (url, type, extension)
{
    var query = Bw.IO.Query.create();

    query.setNoCache();
    query.get (url, function () { gotMultiPopup (query, type, extension); } );
}

/**
 *      Got ajax response and replace div with id equals type + Container
**/
function gotPopup (query, type, extension)
{
    var pop = query.getText();

    if (extension != null)
    {
        type += extension;
    }

    var div = EL(type + "Container");
    if (div == null)
        return;
        
    div.innerHTML = pop;
}

function gotMultiPopup (query, type, extension)
{
    var pop = query.getText();

    var firstType = type;

    var selectBeginPosition = pop.indexOf("<select");
    var selectEndPosition   = pop.indexOf("</select>");

    while (selectBeginPosition != -1 && selectEndPosition != -1)
    {
        if (selectBeginPosition != -1 && selectEndPosition != -1)
        {
            var selectContent = pop.substring(selectBeginPosition,selectEndPosition + 9);

            pop = pop.substring(selectEndPosition + 9,pop.length - 1);

            var idBeginPosition = selectContent.indexOf("id=");
            var idEndPosition   = selectContent.indexOf("class=");

            type = selectContent.substring(idBeginPosition + 4,idEndPosition - 2);

            var div = EL(type + "Container");

            if (div != null)
            {
                div.innerHTML = selectContent;
            }

            selectBeginPosition = pop.indexOf("<select");
            selectEndPosition   = pop.indexOf("</select>");
        }
    }
    
    displaySelectFocus();

    saveMultiFindDimension(firstType);
}

function loadArticlePromoImage (url)
{
    var query = Bw.IO.Query.create();
    
    query.setNoCache();
    query.get (url, function () { gotPopup (query, type); } );
}

/**
 *      Filling of the drop-down menu in ajax. Clean menu's childs. Option extension for duplicate id in monthTyres (ex: Pirreli)
 */
function popupChanged (pop, uri, extension)
{
    var id     = pop.id;
    var url    = "?type=";
    var params = "";
    var type   = "";

    var widthName           = "width";
    var ratioName           = "ratio";
    var diameterName        = "diameter";
    var loadName            = "load";
    var speedName           = "speed";

    if (extension != null)
    {
        widthName          += extension;
        ratioName          += extension;
        diameterName       += extension;
        loadName           += extension;
        speedName          += extension;
    }

         if (id == widthName)         invalidateDimension (speedName, loadName, diameterName, ratioName);
    else if (id == ratioName)         invalidateDimension (speedName, loadName, diameterName);
    else if (id == "carMaker")      invalidateVehicle   ("carDimension", "carYear", "carMotorPower", "carModel");
    else if (id == "carModel")      invalidateVehicle   ("carDimension", "carYear", "carMotorPower");
    else if (id == "carMotorPower") invalidateVehicle   ("carDimension", "carYear");
    else if (id == "carYear")       invalidateVehicle   ("carDimension");
    else if (id == diameterName)
    {
        invalidateDimension (speedName, loadName);
    }
    
    // We have a Width and we need Ratios 
    var el    = EL(widthName);
    var value = Valraiso.form.getFieldValue (el);
    
    if (value != null)
    {
        params += "&width=" + value ;
        type   = "ratio";
    }
    
    // We have a Ratio and we need Diameters 
    el = EL(ratioName);
    value = Valraiso.form.getFieldValue (el);

    if (value != null)
    {
        params += "&ratio=" + value;
        type = "diameter";
    }
    
    // We have a carMaker and we need carModel 
    el = EL("carMaker");
    value = Valraiso.form.getFieldValue (el);

    if (value != null)
    {
        params += "&carMaker=" + value;
        type = "carModel";
    }
    
    // We have a carModel and we need carMotorPower
    el = EL("carModel");
    value = Valraiso.form.getFieldValue (el);

    if (value != null)
    {
        params += "&carModel=" + value;
        type = "carMotorPower";
    }
    
    // We have a carMotorPower and we need carYear
    el = EL("carMotorPower");
    value = Valraiso.form.getFieldValue (el);

    if (value != null)
    {
        params += "&carMotorPower=" + value;
        type = "carYear";
    }
    
    // We have a carYear and we need a carDimension
    el = EL("carYear");
    value = Valraiso.form.getFieldValue (el);

    if (value != null)
    {
        params += "&carYear=" + value;
        type = "carDimension";
    }

    // We have a Diameter and we need LoadIndex and Speeds
    el = EL(diameterName);
    value = Valraiso.form.getFieldValue (el);

    if (value != null)
    {
        params += "&diameter=" + value;
        
        // load LoadIndex before
        type = "load";
        url += type + params;

        if (extension != null)
        {
            url += "&manufacturerSearch="+ extension;
        }

        loadMultiPopup (uri + url, type, extension);
        
        // init for load Speeds
        type = "speed";
        url  = "?type="; 
    }

    if (type == "")
        return;
    
    url += type + params;

    if (extension != null)
    {
        url += "&manufacturerSearch="+extension;
    }

    loadMultiPopup (uri + url, type, extension);
}

/**
 *      select menus to clean
 */
function invalidateDimension (speed, load, diameter, ratio)
{
    var pop;

    if (ratio != null)
    {
        pop = EL (ratio);
        if (pop != null)
        {
            Valraiso.form.select.setSelectedValue (pop, "");
            cleanPopUp ("", ratio);
        }
    }
    if (diameter != null)
    {
        pop = EL (diameter);
        
        if (pop != null)
        {
            Valraiso.form.select.setSelectedValue (pop, "");
            cleanPopUp ("", diameter);
        }
    }
    if (load != null)
    {
        pop = EL (load);

        if (pop != null)
        {
            Valraiso.form.select.setSelectedValue (pop, "");
            cleanPopUp ("", load);
        }
    }
    if (speed != null)
    {
        pop = EL (speed);
        if (pop != null)
        {
            Valraiso.form.select.setSelectedValue (pop, "");
            cleanPopUp ("", speed);
        }
    }
}

/**
 *   to clean the menu with default value and default label
 */
function cleanPopUp (value, type)
{
    var html;
    var container = EL (type + 'Container');
    
    html  = "<select name=\"";
    html += type;
    html += "\" id=\"";
    html += type;
    html += "\">";
    html += "   <option value=\"";
    html += value;

    if (type == 'load')
    {
        var loadLabel       = EL('loadLabel');
        var loadLabelValue  = "...";

        if (loadLabel != null)
        {
            loadLabelValue = loadLabel.value;
        }

        html += "\">" + loadLabelValue + "</option>";
    }
    else
    {
        html += "\">...</option>";
    }


    html += "</select>";
    
    container.innerHTML = html;
}


function invalidateVehicle (carDimension, carYear, carMotorPower, carModel)
{
    var pop;
    
    if (carModel != null)
    {
        pop = EL (carModel);
        
        if (pop != null)
        {
            Valraiso.form.select.setSelectedValue (pop, "");
            cleanPopUp ("", "carModel");
        }
    }
    if (carMotorPower != null)
    {
        pop = EL (carMotorPower);
        
        if (pop != null)
        {
            Valraiso.form.select.setSelectedValue (pop, "");
            cleanPopUp ("", "carMotorPower");
        }
    }
    if (carYear != null)
    {
        pop = EL (carYear);
        
        if (pop != null)
        {
            Valraiso.form.select.setSelectedValue (pop, "");
            cleanPopUp ("", "carYear");
        }
    }
    if (carDimension != null)
    {
        pop = EL (carDimension);
        
        if (pop != null)
        {
            Valraiso.form.select.setSelectedValue (pop, "");
            cleanPopUp ("", "carDimension");
        }
    }
}


function createManufacturers()
{
    var manufacturer = EL('manufacturer');
    var elements     = document.getElementsByName ('chkManufacturer');
    var length       = elements.length;
    
    manufacturer.value = '';
    
    for (i = 0; i < length; i++)
    {
        if (elements[i].checked)
        {
            manufacturer.value += elements[i].value;
            manufacturer.value += ',';
        }
    }
    
    length = manufacturer.value.length;
    
    if (manufacturer.value.charAt (length - 1) == ',')
    {
        manufacturer.value = manufacturer.value.substring (0, length - 1);
    }
}


function getPriceByArticle (idArticle, url, idContainer)
{
    url += '?idArticle=' + idArticle;
    
    loadPopup (url, idContainer);
}


function getPriceByArticleAndQte (Sqte, idContainer)
{
    var Sarticle = document.getElementById('Article');
        
    var url;
    url  = "/searchPriceAjax";
    url += '?idArticle=' + Sarticle.options[Sarticle.selectedIndex].value;
    url += '&qte=' + Sqte.options[Sqte.selectedIndex].value;
    
    loadPopup (url, idContainer);
}


function getAnnee (carModel, carMotor, container)
{
    // http://localhost:8084/searchAjax?type=carYear&carMaker=250&carModel=8524&carMotorPower=1.7

    var url;
    
    url  = "/refCarSearchAjax?type=carYear";
    url += '&carModel='      + carModel;
    url += '&carMotorPower=' + carMotor;
    
    loadPopup (url, container);
}


function getDimensions (carModel, carMotor, carYear, container)
{
    // http://localhost:8084/searchAjax?type=carYear&carMaker=250&carModel=8524&carMotorPower=1.7
    
    if (carYear == null || carYear == '')
    {
        getAnnee   (carModel, carMotor, 'annee');
        cleanPopUp ('', container);
        return;
    }

    var url;
    
    url  = "/refCarSearchAjax?type=width";
    url += '&carModel='      + carModel;
    url += '&carMotorPower=' + carMotor;
    url += '&carYear='       + carYear;
    
    loadPopup (url, container);
}


function doSearchRef (carMaker, carModel, carMotor)
{
    var SelectAnnee      = EL('sAnnee');
    var SelectDimensions = EL('sDimmension');
    var buyButtonLink    = EL('buyButtonLink');
    var url;

    url  = '/find?mode=vehicle';
    url += '&carMaker=' + carMaker;
    url += '&carModel=' + carModel;
    url += '&carMotorPower=' + carMotor;
    url += '&carYear=' + SelectAnnee.options[SelectAnnee.selectedIndex].value;
    url += '&carDimension=' + SelectDimensions.options[SelectDimensions.selectedIndex].value;
    url += '&manufacturer=';
    url += '&season=toutes';

    buyButtonLink.href = url;
}


function showBuyButton()
{
    var el               = EL('buyButton');
    var SelectDimensions = EL('sDimmension');

    if (SelectDimensions.options[SelectDimensions.selectedIndex].value != '')
    {
        el.style.display = '';
    }
    else
    {
        el.style.display = 'none';
    }
}

function saveFindDimension(pop)
{
    var id    = pop.id;
    var el    = EL(id);
    var value = Valraiso.form.getFieldValue (el);

    if (value == null)
    {
        value = "";
    }

    if (id == 'season1' || id == 'season2')
    {
        id = "season";
    }

    var url   = "/saveFindDimension?" + id + "=" + value;
    var query = Bw.IO.Query.create();

    query.setNoCache();
    query.get (url, function () { var result = query.getText(); } );
}

function saveMultiFindDimension(firstType)
{
    var params = "";

    // Page vehicule
    var el = EL("carMaker");
    var value = Valraiso.form.getFieldValue (el);

    if (value != null)
    {
        params += "carMaker=" + value;
    }

    if (firstType == 'carMaker' && value == null)
    {
        params += "carMaker=";
    }

    el = EL("carModel");
    value = Valraiso.form.getFieldValue (el);

    if (value != null)
    {
        params += "&carModel=" + value;
    }

    el = EL("carMotorPower");
    value = Valraiso.form.getFieldValue (el);

    if (value != null)
    {
        params += "&carMotorPower=" + value;
    }

    el = EL("carYear");
    value = Valraiso.form.getFieldValue (el);

    if (value != null)
    {
        params += "&carYear=" + value;
    }

    el = EL("carDimension");
    value = Valraiso.form.getFieldValue (el);

    if (value != null)
    {
        params += "&carDimension=" + value;
    }


    //Page Taille
    el = EL("width");
    value = Valraiso.form.getFieldValue (el);

    if (value != null)
    {
        params += "width=" + value;
    }

    if (firstType == 'width' && value == null)
    {
        params += "width=";
    }

    el = EL("ratio");
    value = Valraiso.form.getFieldValue (el);

    if (value != null)
    {
        params += "&ratio=" + value;
    }

    el = EL("diameter");
    value = Valraiso.form.getFieldValue (el);

    if (value != null)
    {
        params += "&diameter=" + value;
    }

    el = EL("load");
    value = Valraiso.form.getFieldValue (el);

    if (value != null)
    {
        params += "&load=" + value;
    }

    el = EL("speed");
    value = Valraiso.form.getFieldValue (el);

    if (value != null)
    {
        params += "&speed=" + value;
    }

    var url   = "/saveFindDimension?" + params;

    var query = Bw.IO.Query.create();

    query.setNoCache();
    query.get (url, function () { var result = query.getText(); } );
}

function displaySelectFocus()
{
    var width       = EL('width');
    var ratio       = EL('ratio');
    var diameter    = EL('diameter');
    var load        = EL('load');
    var speed       = EL('speed');
    var loadLabel   = EL('loadLabel');

    var carMaker      = EL('carMaker');
    var carModel      = EL('carModel');
    var carMotorPower = EL('carMotorPower');
    var carYear       = EL('carYear');
    var carDimension  = EL('carDimension');

    if (width != null)
    {
        //alert("width = " + width.options[width.selectedIndex].value);

        if (width.options[width.selectedIndex].value != '')
        {
            //width.style.border = "";
            EL('direction-width').style.display = "none";

            if (ratio != null)
            {
                //alert("ratio = " + ratio.options[ratio.selectedIndex].value);

                if (ratio.options[ratio.selectedIndex].value != '')
                {
                    //ratio.style.border = "";
                    EL('direction-ratio').style.display = "none";

                    if (diameter != null)
                    {
                        //alert("diameter = " + diameter.options[diameter.selectedIndex].value);

                        if (diameter.options[diameter.selectedIndex].value != '')
                        {
                            //diameter.style.border = "";
                            EL('direction-diameter').style.display = "none";

                            if (load != null)
                            {
                                //alert("load = " + load.options[load.selectedIndex].text);

                                if (load.options[load.selectedIndex].value != '' || load.options[load.selectedIndex].text == loadLabel.value)
                                {
                                    //load.style.border = "";
                                    EL('direction-load').style.display = "none";
                                }
                                else
                                {
                                    //load.style.border = "3px solid black";
                                    EL('direction-load').style.display  = "block";
                                }
                            }

                            if (speed != null)
                            {
                                //alert("speed = " + speed.options[speed.selectedIndex].value);

                                if (speed.options[speed.selectedIndex].value != '')
                                {
                                    //speed.style.border = "";
                                    EL('direction-speed').style.display = "none";
                                }
                                else
                                {
                                    //speed.style.border = "3px solid black";
                                    EL('direction-speed').style.display = "block";
                                }
                            }
                        }
                        else
                        {
                            //diameter.style.border = "3px solid black";
                            EL('direction-diameter').style.display  = "block";
                            EL('direction-load').style.display      = "none";
                            EL('direction-speed').style.display     = "none";
                        }
                    }
                }
                else
                {
                    //ratio.style.border = "3px solid black";
                    EL('direction-ratio').style.display     = "block";
                    EL('direction-diameter').style.display  = "none";
                    EL('direction-load').style.display      = "none";
                    EL('direction-speed').style.display     = "none";
                }
            }
        }
        else
        {
            //width.style.border = "3px solid black";
            EL('direction-width').style.display     = "block";
            EL('direction-ratio').style.display     = "none";
            EL('direction-diameter').style.display  = "none";
            EL('direction-load').style.display      = "none";
            EL('direction-speed').style.display     = "none";
        }
    }
    else if(carMaker != null)
    {
        if (carMaker.options[carMaker.selectedIndex].value != '')
        {
            EL('direction-carMaker').style.display = "none";

            if (carModel.options[carModel.selectedIndex].value != '')
            {
                EL('direction-carModel').style.display = "none";

                if (carMotorPower.options[carMotorPower.selectedIndex].value != '')
                {
                    EL('direction-carMotorPower').style.display = "none";

                    if (carYear.options[carYear.selectedIndex].value != '')
                    {
                        EL('direction-carYear').style.display = "none";

                        if (carDimension.options[carDimension.selectedIndex].value != '')
                        {
                            EL('direction-carDimension').style.display = "none";
                        }
                        else
                        {
                            EL('direction-carDimension').style.display = "block";
                        }
                    }
                    else
                    {
                        EL('direction-carYear').style.display       = "block";
                        EL('direction-carDimension').style.display  = "none";
                    }
                }
                else
                {
                    EL('direction-carMotorPower').style.display = "block";
                    EL('direction-carYear').style.display       = "none";
                    EL('direction-carDimension').style.display  = "none";
                }
            }
            else
            {
                EL('direction-carModel').style.display      = "block";
                EL('direction-carMotorPower').style.display = "none";
                EL('direction-carYear').style.display       = "none";
                EL('direction-carDimension').style.display  = "none";
            }
        }
        else
        {
            EL('direction-carMaker').style.display      = "block";
            EL('direction-carModel').style.display      = "none";
            EL('direction-carMotorPower').style.display = "none";
            EL('direction-carYear').style.display       = "none";
            EL('direction-carDimension').style.display  = "none";
        }
    }
}