﻿loadScripts = function () {
    var href = $(location).attr('href').split('/');
    loadheader();
    loadCurrencies();
    loadResorts();
    loadWaterMarks();
    loadDatePickers();
    //loadCalendar(true);
    $('#NavigationMenu ul').append('<li role="menuitem" class="static" style="cursor:pointer;position: relative; float: left;"><a onclick="openCheckAvailability();" class="level1 static" tabindex="-1">Check Availability</a></li>');
    //$('#NavigationMenu ul').append('<li role="menuitem" class="static" style="position: relative; float: left;"><a onclick="openCalendar();" class="level1 static" tabindex="-1">Popup Calendar</a></li>');
    var pg = href[href.length - 1].split('.')[0];
    if (pg != 'Calendar') {
        loadCalendar(true);
        $('#NavigationMenu ul').append('<li role="menuitem" class="static" style="cursor:pointer;position: relative; float: left;"><a onclick="openCalendar();" class="level1 static" tabindex="-1">Popup Calendar</a></li>');
    }
    if (pg == 'GuestOption') {
        loadGuestEnquiry();
    }
    if (pg == 'Quoter') {
        $('input.firstname').change(function () {
            $(QMail).html($('.ajax__html_editor_extender_texteditor').html());
            $(QMail).find('firstname').html($(this).val());
            $('.ajax__html_editor_extender_texteditor').html($(QMail).html());
        });
        //        $('#MainContent_tbAccomArrive0').change(function () {
        //            $(QMail).html($('.ajax__html_editor_extender_texteditor').html());
        //            $(QMail).find('startdate').html($('#MainContent_tbAccomArrive0').val());
        //            $('.ajax__html_editor_extender_texteditor').html($(QMail).html());
        //        });
        //        $('#MainContent_tbAccomDepart0').change(function () {
        //            $(QMail).html($('.ajax__html_editor_extender_texteditor').html());
        //            $(QMail).find('enddate').html($('#MainContent_tbAccomDepart0').val());
        //            $('.ajax__html_editor_extender_texteditor').html($(QMail).html());
        //        });
        //loadResort();


        $('.salespeople').bind('change', function () {
            var data = $(this).find(':selected').data('salesperson');
            if (data == null) {
                alert('Select a salesperson from the list.');
                return false;
            }

            $(QMail).html($('.ajax__html_editor_extender_texteditor').html());

            $(QMail).find('spname').html(data['fullname']);

            if (data['emailaddress'] == null) $(QMail).find('spemail').html('');
            $(QMail).find('spemail').html(data['emailaddress'] + '<br/>');

            if (data['title'] == null) $(QMail).find('sptitle').html('');
            else $(QMail).find('sptitle').html(data['title'] + '<br/>');

            if (data['office'] == null) $(QMail).find('spoffice').html('');
            else $(QMail).find('spoffice').html('Office Tel: ' + data['office'] + '<br/>');

            if (data['mobile'] == null) $(QMail).find('spmobile').html('');
            else $(QMail).find('spmobile').html('Mobile Tel: ' + data['mobile'] + '<br/>');

            if (data['skype'] == null) $(QMail).find('spskype').html('');
            else $(QMail).find('spskype').html('Skype: ' + data['skype'] + '<br/>');

            $('.ajax__html_editor_extender_texteditor').html($(QMail).html());
        });
    }
    if (pg == "Calendar") {
        loadCalendar(false);
    }
}













