﻿function submitform() {
    // Get all raw_ text inputs
    var allTextAreas = document.getElementsByTagName('textarea');
    for (i = 0; i < allTextAreas.length; i++) {
        var aDiv = allTextAreas[i];
        var sID = aDiv.id;
        if (sID.indexOf('raw_') == 0) {
            // Set textbox content to the related editable div content (id without leading raw_)

            document.getElementById(sID).value = document.getElementById(sID.substring(4)).innerHTML;
        }
    }

    document.getElementById("pageContent").submit();
}


$(function() {
    $(".datepicker").datepicker({ dateFormat: 'dd/mm/yy' });

    $('#nuclear-map').click(function() {
        $('#interactive-map').stop().removeClass().addClass('nuclear');
        $('#map-sectors li').removeClass();
        $(this).addClass('selected-map');
        return false;
    });
});

function getDefaultContent(textArea, content) {
    var container = document.getElementById(textArea);
    if (CKEDITOR.instances[textArea] == null) {
        container.innerHTML = content;
    }
    else if (CKEDITOR.instances[textArea] != null) {
        CKEDITOR.instances[textArea].setData(content);
    }
}

$(document).ready(function() {

        //$('.slidepic').css('clear', 'both');
        //$('.pics').css('width', '200px');
        //$('#img-slideshow').css('height', 'auto');
        //$('#img-slideshow').css('overflow', 'hidden');
        $('#homeFlash').cycle({
            fx: 'fade',
            pause: 10,
            speed: 5000,
            random: 1,
            prev: '.prev',
            next: '.next'
        });



        //Calendar Functions

        $('#closeBookingForm').click(function() {
            $('#bookingForm').hide()
            $('#blackoutGrid').hide();
        });

        jQuery.fn.fadeToggle = function(speed, easing, callback) {
            return this.animate({ opacity: 'toggle' }, speed, easing, callback);
        };

//        $(function() {
//            var tabContainers = $('div#bookingInfo > div');
//            tabContainers.hide();
//            $('.open a').click(function() {
//                tabContainers.hide().filter(this.hash).show();
//                var thisId = $(this).attr('id');
//                var showId = thisId.replace('Id', '');
//                var left = $(this).position().left + 169;
//                var top = $(this).position().top;
//                $('#' + showId).css({ top: top, left: left });
//                $('#' + showId).show();
//                return false;
//            });
//        });

    });

function book(day, month, year) {
    $('#bookingForm').css({ position: "absolute", top: "+70px", left: "+30px" });
    $('.date').hide()
    $('#bookingForm').fadeIn(1400);
    $('#blackoutGrid').show();
    $('#dateChosen').show();
    $('#dateChosentd').html(day + "/" + month + "/" + year);
    $('#Day').val(day);
    $('#Month').val(month);
    $('#Year').val(year);
}

function stayForValidation(day, month, year) {
    $('#bookingForm').css({ position: "absolute", top: "+70px", left: "+30px" });
    $('.date').hide()
    $('#bookingForm').show()
    $('#dateChosen').show()
    $('#blackoutGrid').show();
    $('#dateChosentd').html(day + "/" + month + "/" + year);
    $('#Day').val(day);
    $('#Month').val(month);
    $('#Year').val(year);
}

function hideDetails(id) {
    $('#' + id).hide()
}

