// /BelambraResources/views/SearchDevisForm.ascx :

function checkMandatoryFieldDevis()
{
    if(document.forms[0].elements['DevisRegionClub'].value=="" ||document.forms[0].elements['DevisStartDateDay'].value==''
    || document.forms[0].elements['DevisStartDateMonth'].value=='' || document.forms[0].elements['DevisStartDateYear'].value=='')
        return(false);
    else
        return(true);
}

function getFieldSearchForDevis()
{
    var tabSelect=new Array('DevisDuration','DevisAdults','DevisChildren','DevisBabies');
    var tabText=new Array('DevisRegionClub','DevisStartDateDay','DevisStartDateMonth','DevisStartDateYear','typeAction');
    var param=new String();    
    param+=getFieldText(tabText,'','');    
    param+=getFieldSelect(tabSelect,'','');

    return(param);
}

// \BelambraResources\views\ListClub.ascx 

function devisClub(idParam)
{
    document.forms[0].idClubDevis.value=idParam;
    document.forms[0].action="http://www.belambra.de/belambra/Recherche/tabid/77/Default.aspx";
    submitTypeAction('DevisClub');
}



function CalculPrice(idContentPrice)
{
    var param=new String();
    param='codeAccom='+document.getElementById('CodeAccom'+idContentPrice).getAttribute('value')+'&';
    param+='date='+document.getElementById('Date'+idContentPrice).getAttribute('value')+'&';
    param+='during='+document.getElementById('During'+idContentPrice).getAttribute('value')+'&';
    param+='nbAdults='+document.getElementById('NbAdults'+idContentPrice).getAttribute('value')+'&';
    param+='nbChildren='+document.getElementById('NbChildren'+idContentPrice).getAttribute('value')+'&';
    param+='nbBabies='+document.getElementById('NbBabies'+idContentPrice).getAttribute('value')+'&';
    param+='typeClub='+document.getElementById('TypeClub'+idContentPrice).getAttribute('value')+'&';
    param+='idClubOffer='+document.getElementById('IdClubOffer'+idContentPrice).getAttribute('value')+'&';    
   //param+='isOfferWanted=0&';    
    callAjax('http://www.belambra.de/belambra/BelambraResources/views/CalculPrice.aspx',param,'POST','contentPrice'+idContentPrice,null);
}

function filterCountry(idCountry)
{
    document.forms[0].MultiIdCountry.value=idCountry;
    if(document.forms[0].IsSearchForMulti.value=='true')
        callAjax('http://www.belambra.de/belambra/BelambraResources/views/ListClub.aspx',getFieldSearchForMulti(),'POST','content',enableFields);
    else
    {
        var param='typeAction=SearchAll&';
        param+='MultiIdCountry='+document.forms[0].MultiIdCountry.value+'&';
        callAjax('http://www.belambra.de/belambra/BelambraResources/views/ListClub.aspx',param,'POST','content',enableFields);      
    }
}

function searchAll()
{
    if(document.getElementById('MultiIdCountry'))
        document.forms[0].MultiIdCountry.value='';
    submitTypeAction('SearchAll');
}

function getServerMessage(messageId)
{
    var param = 'messageId=' + messageId + '&';
    callAjax('http://www.belambra.de/belambra/BelambraResources/views/GetMessage.aspx',param,'POST','checkMessageContainer',null);
}



//  BelambraResources\views\SearchMultiForm.ascx

function getFieldSearchForMulti()
{
    var tabRadio=new Array('MultiDestination','MultiActivities','MultiServices','MultiFormule');
    var tabText=new Array('typeAction');
    var param=new String();    
    param+=getFieldRadio(tabRadio,'','');
    param+=getFieldText(tabText,'','');
    
    return(param);
}

function enableFields()
{
    VVF.enableFields(VVF.cacheMaskMultiSearchTool);
}

function searchForMulti()
{
    if(document.forms[0].IsSearchForMulti.value=='false')
    {
        document.forms[0].action="http://www.belambra.de/belambra/Recherche/tabid/77/Default.aspx";
        if(document.getElementById('MultiIdCountry'))
            document.forms[0].MultiIdCountry.value='';
        submitTypeAction('SearchForMulti');
    }
    else
        searchForMultiAuto();
}

function searchForMultiAuto()
{
    if(document.forms[0].IsSearchForMulti.value=='true')
    {
        document.forms[0].MultiIdCountry.value='';
        callAjax('http://www.belambra.de/belambra/BelambraResources/views/ListClub.aspx',getFieldSearchForMulti(),'POST','content',CallBackSearchForMulti);
    }
}


function CallBackSearchForMulti()
{
    enableFields();
    
    
    if(document.getElementById('GoogleTag'))
        setGoogleAnalytics(document.getElementById('GoogleTag').getAttribute("value"));
    
    else if (document.getElementById('LocalGoogleCallBackTag'))
        setGoogleAnalytics(document.getElementById('LocalGoogleCallBackTag').innerHTML, true);
}





// BelambraResources\templates\BottomTemplate.ascx

function submitTypeAction(nameAction)
{
    document.forms[0].elements.typeAction.value=nameAction;
    document.forms[0].submit();
}

function showInfo(infos)
{
    /*var html=getHtmlTopInfos(infos.name, infos.cap, infos.resort, infos.id, infos.target);
    document.getElementById('clubFocus').innerHTML=html;
    VVF.ie6PNG();*/
}


function getFieldConnection(prefix)
{
    var tabText=new Array('LoginNickName','LoginPassword');
    var param=new String();    
    param+=getFieldText(tabText,'',prefix);
    
    //alert(param);
    return(param);
}


function callbackConnectionPopin(paramNextAction)
{    
    if(document.getElementById('idCustomer'))
        VVF.openPopin('http://www.belambra.de/belambra/BelambraResources/popin/popin_message.aspx'+paramNextAction,false);
    else
        document.getElementById('errorPopin').innerHTML="<h3>"+document.forms[0].elements['errorAuthentication'].value+"</h3>";
}


function connectionPopin(paramNextAction)
{
    var param=getFieldConnection('Popin');
    param+='typeAction=Connection&';
    //alert(param);    
    callAjax('http://www.belambra.de/belambra/BelambraResources/views/Connection.aspx',param,'POST','myVVF',function() {callbackConnectionPopin(paramNextAction)});
}

function connection(isWantConnect)
{
    var param='';
    if(isWantConnect)
    {
        param+=getFieldConnection('');
        param+='typeAction=Connection&';
    }
    else
        param='typeAction=Deconnection&';
    
    if (typeof document.body.style.maxHeight != "undefined")
        callAjax('http://www.belambra.de/belambra/BelambraResources/views/Connection.aspx',param,'POST','myVVF',function() {VVF.inputText();});
    else
        callAjax('http://www.belambra.de/belambra/BelambraResources/views/Connection.aspx',param,'POST','myVVF',function() {VVF.inputText(); VVF.ie6PNG();});
}

function displayMessage(messageContainerId, mes){
    var messageContainer = document.getElementById(messageContainerId);
    if (messageContainer){
        messageContainer.innerHTML = "<h3>" + mes + "</h3><br/>";
    } else {
        alert(mes);
    }
}

function forgotPassword()
{
    var param=new String();
    param='ForgotNickName='+document.forms[0].elements["ForgotNickName"].value+'&';
    callAjax('http://www.belambra.de/belambra/BelambraResources/views/ForgotPassword.aspx',param,'POST','msgForgotPassword',function() { setGoogleAnalytics('customer_account/forgotten_password/confirmation') });
}

function changeLanguage(codeLanguage)
{
    document.forms[0].elements['dnn$TopTemplate$dnnLANGUAGE$selectCulture'].value=codeLanguage;
    __doPostBack('dnn$TopTemplate$dnnLANGUAGE$selectCulture', '');
}

function checkReservation(codeAccom,codeCatalog,callback)
{
    var date=new String();
    date=document.getElementById('fStartDateYearPopin').value+'-'+document.getElementById('fStartDateMonthPopin').value+'-'+document.getElementById('fStartDateDayPopin').value;
    var duration=document.getElementById('fLengthPopin').value;
    var nbAdults=document.getElementById('fAdultsPopin').value;
    var nbChildren=document.getElementById('fChildrenPopin').value;
    var nbBabies=document.getElementById('fBabiesPopin').value;
    var codePromo=document.getElementById('codePromoPopin').value;
    
    if(date.length > 4)
    {   
        if(callback && typeof callback == 'function') 
        {
            callback();
            VVF.closePopin();            
        }
        else
            reservation(codeAccom,date,duration,codeCatalog,codePromo,nbAdults,nbChildren,nbBabies);
    }
}
/*
function reservation(codeAccom,date,duration,codeCatalog,codePromo,nbAdults,nbChildren,nbBabies)
{
    setReservationValues(codeAccom,date,duration,codeCatalog,codePromo,nbAdults,nbChildren,nbBabies);
    document.forms[0].action="/belambra/HomeBelambra/Reservation/tabid/115/Default.aspx";
    submitTypeAction('Reservation');
}
*/
function OpenZapette(idClubDevis,promoId,callback)
{
    var param = 'idClubDevis='+idClubDevis;
    if (promoId && promoId != '')
        param += '&promoId=' + promoId;
    if (callback && callback != '')
        param += '&callback=' + callback;
                
    VVF.openPopin('http://www.belambra.de/belambra/BelambraResources/popin/popin_zapette.aspx?cachePopin=0&' + param, true);
}

function setReservationValues(codeAccom,date,duration,codeCatalog,codePromo,nbAdults,nbChildren,nbBabies)
{
    document.forms[0].reservationCodeAccom.value=codeAccom;
    document.forms[0].reservationDate.value=date;
    document.forms[0].reservationDuration.value=duration;
    document.forms[0].reservationCodeCatalog.value=codeCatalog;
    document.forms[0].reservationCodePromo.value=codePromo;
    document.forms[0].reservationNbAdults.value=nbAdults;    
    document.forms[0].reservationNbChildren.value=nbChildren;  
    document.forms[0].reservationNbBabies.value=nbBabies;  
}

jQuery(document).ready(function() {
    if(document.getElementById('IsSearchForMulti') && document.forms[0].elements['IsSearchForMulti'].value=='true')
    {
        //VVF.supportSH.close(jQuery('#bookingTool'));
        VVF.supportSH.close(jQuery('#mapTool'));
        //VVF.multiSearchSH.open(jQuery('#multiSearchToolMore'), jQuery('#showMultiSearchToolMore').get(0));
    }
});


if(document.getElementById('DefaultCodeSaison'))
{
    var isChecked=false;
    
    if (document.forms[0].elements['MultiSaison'])
    {
        for (var i=0; i<document.forms[0].elements['MultiSaison'].length;i++) 
        {
             if (document.forms[0].elements['MultiSaison'][i].checked) 
                isChecked=true
        }
          
        if(isChecked==false)
        {
            for (var i=0; i<document.forms[0].elements['MultiSaison'].length;i++) 
            {
                 if (document.forms[0].elements['MultiSaison'][i].value==document.getElementById('DefaultCodeSaison').value)
                     document.forms[0].elements['MultiSaison'][i].checked=true; 
            }    
        }
    }
}

