/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
function display_pinfos()
{
    $('produit_tech_data').hide();
    $('produit_description_data').show();

    $('a_switch_2').setStyle({
      backgroundColor: '#b7aea5'
    });
    $('a_switch_1').setStyle({
      backgroundColor: '#6f5e4a'
    });
}

function display_ptech()
{
    $('produit_tech_data').show();
    $('produit_description_data').hide();

    $('a_switch_1').setStyle({
      backgroundColor: '#b7aea5'
    });
    $('a_switch_2').setStyle({
      backgroundColor: '#6f5e4a'
    });
}


function ajaxReq(div,params,actionPage) {
    var url = actionPage;
    var ajax = new Ajax.Updater
    (
        {success: div},
        url,{method: 'post', parameters: params}
    );
}

function ajaxReq_2(actionPage,div,params)
{
    var loaderDiv = "wait_im_loading";
    var url = actionPage;

    var ajax = new Ajax.Updater
    (
        {success: div},
        url,{
            onLoading: function(transport) {
            $(loaderDiv).className="loading_visible";
            },

            onComplete: function(transport) {
            $(loaderDiv).className="loading_invisible";
            },

            method: 'post',
            parameters: params
        }
    );
}

function updateTheDivs(id,idCat)
{
    if($("addCraftAsItem").checked)
    {
        ajaxReq('itemCats','id='+id,'/home/ajax/craft2itemCats');

        if(id > 0)
        {
            ajaxReq('itemsSubCats','cat='+id+'&id='+idCat,'/home/ajax/craft2itemSubCats');
        }
    }
    else
    {
        ajaxReq('itemCats','halt=1','/home/ajax/craft2itemCats');
        ajaxReq('itemsSubCats','halt=1','/home/ajax/craft2itemSubCats');
    }
}

function changeView(id)
{
    $(id).toggle();
}

function ashow(id)
{
    document.getElementById(id).style.display='block'
}

function ahide(id) {
    document.getElementById(id).style.display='none'
}

function turnOn(id)
{
    $(id).setStyle({'background': '#dedede'});
}

function turnOff(id)
{
    $(id).setStyle({'background': 'none'});
}

function select_text(form_name, field_name)
{
    var content=eval("document."+form_name+"."+field_name);
    content.focus();
    content.select();
}


function checkform ( form )
{
  if (form.marqueid.value == "") {
    alert( "Merci de renseigner la marque de votre vélo." );
    form.marqueid.focus();
    return false ;
  }

  return true ;
}
