$(document).ready(function(){
    Whl.Site.initPortalPage();
    var sort = Whl.getCookie('tour-sort');
    if (sort != null && sort != '') {
        $('#tour-sort').val(sort);
    }
    
    $('#tour-sort, #tour-category').change(function(){
        arguments[0].preventDefault();
        $('#tour-sort-frm').submit();
    });  
    
    Whl.getMore();
	//cfd tooltip
	$('.cfd').tooltip({title: Message.titlecfd, positionLeft: true, actionDefault: true});
	//cft tooltip
	$('.cft').tooltip({title: Message.titlecfd, positionLeft: true, actionDefault: true});
    //Internet facility tooltip
    $('.internet-facility').tooltip({title: Message.internetFacility, positionLeft: true});
    //Load thumbnails
    Whl.Image.loadImages(tourIds, tourThumnails, pathURI, 'tour-');
    
    //Tour Search
    var category = Whl.getCookie('tour-category');
    if (category != null && category != '') {
        $('#tour-category').val(category);
    }
    $('#prev_week').click(function(){
        arguments[0].preventDefault();
        var strDate = $('#tour-date-from').val();
        var date = $.datepicker.parseDate('dd M yy', strDate);
        date.setDate( date.getDate()-6 );
        $('#tour-date-to').val(strDate);
        $('#tour-date-from').val($.datepicker.formatDate('dd M yy', date));
        $('#frmTourSearch2').submit();
    });
    $('#next_week').click(function(){
        arguments[0].preventDefault();
        var strDate = $('#tour-date-to').val();
        var date = $.datepicker.parseDate('dd M yy', strDate);
        date.setDate( date.getDate()+6 );
        $('#tour-date-from').val(strDate);
        $('#tour-date-to').val($.datepicker.formatDate('dd M yy', date));
        $('#frmTourSearch2').submit();
    });
    
    //Check available alloment            
    Whl.Site.checkInstant('tour_normal', arrCheckAvl);
});
