﻿

window.addEvent('domready', function () {



    if ($('CallbackRequestForm')) {
        Callback();
    }
    if ($('BrochureRequestForm')) {
        BrochureRequest()
    }

    $$('.footerLinks').getLast().setStyle('background', 'none');
    $('HomeLink').addEvents({ 'mouseenter': function () {


        $('HomeLink').getFirst().addClass('TopGenericMenuOn');
        $('HolidayHomeOwnership').getFirst().removeClass('TopGenericMenuOn');
        $('BookYourHoliday').getFirst().removeClass('TopGenericMenuOn');
        $('ParkLocations').getFirst().removeClass('TopGenericMenuOn');
        //        $('HolidayHomeFirstlevel').morph({ 'top': '-350px' });
        //        $('BookHolidayFirstlevel').morph({ 'top': '-350px' });
        //        $('ViewPrakLocations').morph({ 'top': '-350px' });
    }
    });


    $$('.TopGenericMenuSecondlevelSplit,.TopGenericMenuSecondlevelSplit2').set('morph', { duration: '200', transition: 'expo:out' });

    $('HolidayHomeOwnership').addEvents({ 'mouseenter': function () {
        $('HolidayHomeFirstlevel').set('morph', { duration: '400', transition: 'expo:out' });
        $('HolidayHomeFirstlevel').morph({ 'top': '0px' });
        $('HomeLink').getFirst().removeClass('TopGenericMenuOn');
        $('HolidayHomeOwnership').getFirst().addClass('TopGenericMenuOn');
        $('BookYourHoliday').getFirst().removeClass('TopGenericMenuOn');
        $('ParkLocations').getFirst().removeClass('TopGenericMenuOn');
        $('BookHolidayFirstlevel').morph({ 'top': '-200px' });
        $('ViewbyTypeBook').morph({ 'top': '-350px' });
        $('ViewbyParkBook').morph({ 'top': '-350px' });
        $('ViewPrakLocations').morph({ 'top': '-350px' });
    }
    });

    $('byPark').addEvents({ 'mouseenter': function () {

        $('ViewbyType').morph({ 'top': '-350px' });
        $('ViewbyPark').set('morph', { duration: '400', transition: 'expo:out' });
        $('ViewbyPark').morph({ 'top': '72px' });
        $('byPark').morph({ 'color': '#D7EA4B' });
        $('byType').morph({ 'color': '#26472B' });
        $('SpecialOffers').getFirst().morph({ 'color': '#26472B' });
        $$('.TopGenericMenuSecondlevelSplit,.TopGenericMenuSecondlevelSplit2').morph({ 'height': '140px' });
    }
    });
    $('byType').addEvents({ 'mouseenter': function () {

        $('ViewbyPark').morph({ 'top': '-350px' });
        $('ViewbyType').set('morph', { duration: '400', transition: 'expo:out' });
        $('ViewbyType').morph({ 'top': '72px' });
        $('byType').morph({ 'color': '#D7EA4B' });
        $('byPark').morph({ 'color': '#26472B' });
        $('SpecialOffers').getFirst().morph({ 'color': '#26472B' });
        $$('.TopGenericMenuSecondlevelSplit,.TopGenericMenuSecondlevelSplit2').morph({ 'height': '59px' });
    }
    });
    $('SpecialOffers').addEvents({ 'mouseenter': function () {

        $('ViewbyType').morph({ 'top': '-350px' });
        $('ViewbyPark').morph({ 'top': '-350px' });
        $('SpecialOffers').getFirst().morph({ 'color': '#D7EA4B' });
        $('byPark').morph({ 'color': '#26472B' });
        $('byType').morph({ 'color': '#26472B' });
    }
    });


    // book your holidays


    $('BookYourHoliday').addEvents({ 'mouseenter': function () {

        $('BookHolidayFirstlevel').set('morph', { duration: '400', transition: 'expo:out' });
        $('BookHolidayFirstlevel').morph({ 'top': '0px' });
        $('HomeLink').getFirst().removeClass('TopGenericMenuOn');
        $('HolidayHomeOwnership').getFirst().removeClass('TopGenericMenuOn');
        $('BookYourHoliday').getFirst().addClass('TopGenericMenuOn');
        $('ParkLocations').getFirst().removeClass('TopGenericMenuOn');

        $('HolidayHomeFirstlevel').morph({ 'top': '-350px' });
        $('ViewbyType').morph({ 'top': '-350px' });
        $('ViewbyPark').morph({ 'top': '-350px' });
        $('ViewPrakLocations').morph({ 'top': '-350px' });
    }
    });


    $('byParkBook').addEvents({ 'mouseenter': function () {

        $('ViewbyTypeBook').morph({ 'top': '-200px' });
        $('ViewbyParkBook').set('morph', { duration: '400', transition: 'expo:out' });
        $('ViewbyParkBook').morph({ 'top': '72px' });
        $('byParkBook').morph({ 'color': '#D7EA4B' });
        $('byTypeBook').morph({ 'color': '#26472B' });
        $('SpecialOffersBook').morph({ 'color': '#26472B' });
        $$('.TopGenericMenuSecondlevelSplit,.TopGenericMenuSecondlevelSplit2').morph({ 'height': '140px' });
    }
    });


    $('byTypeBook').addEvents({ 'mouseenter': function () {

        $('ViewbyParkBook').morph({ 'top': '-350px' });
        $('ViewbyTypeBook').set('morph', { duration: '400', transition: 'expo:out' });
        $('ViewbyTypeBook').morph({ 'top': '72px' });
        $('byTypeBook').morph({ 'color': '#D7EA4B' });
        $('byParkBook').morph({ 'color': '#26472B' });
        $('SpecialOffers').morph({ 'color': '#26472B' });
        $$('.TopGenericMenuSecondlevelSplit,.TopGenericMenuSecondlevelSplit2').morph({ 'height': '102px' });
    }
    });


    $('SpecialOffersBook').addEvents({ 'mouseenter': function () {

        $('ViewbyTypeBook').morph({ 'top': '-350px' });
        $('ViewbyParkBook').morph({ 'top': '-350px' });
        $('SpecialOffersBook').morph({ 'color': '#D7EA4B' });
        $('byParkBook').morph({ 'color': '#26472B' });
        $('byTypeBook').morph({ 'color': '#26472B' });

    }
    });

    $('HolidayHomeFirstlevel').addEvents({ 'mouseenter': function () {

        MegaMouseOut = false;
    },
        'mouseleave': function () {
            MegaMouseOut = true;
            MegaDropUp.delay(1000);
        }
    });
    var MegaDropUp = function () {
        if (MegaMouseOut == true) {
            $('HolidayHomeFirstlevel').set('morph', { duration: '800', transition: 'back:InOut' });
            $('HolidayHomeFirstlevel').morph({ 'top': '-350px' });

        }
    }

    $('BookHolidayFirstlevel').addEvents({ 'mouseenter': function () {

        MegaMouseOutBook = false;
    },
        'mouseleave': function () {
            MegaMouseOutBook = true;
            MegaDropUpBook.delay(1000);
        }
    });
    var MegaDropUpBook = function () {
        if (MegaMouseOutBook == true) {
            $('BookHolidayFirstlevel').set('morph', { duration: '800', transition: 'back:InOut' });
            $('BookHolidayFirstlevel').morph({ 'top': '-350px' });

        }
    }

    // view park locations

    $('ParkLocations').addEvents({ 'mouseenter': function () {

        $('ViewPrakLocations').set('morph', { duration: '400', transition: 'expo:out' });
        $('ViewPrakLocations').morph({ 'top': '0px' });
        $('HomeLink').getFirst().removeClass('TopGenericMenuOn');
        $('HolidayHomeOwnership').getFirst().removeClass('TopGenericMenuOn');
        $('BookYourHoliday').getFirst().removeClass('TopGenericMenuOn');
        $('ParkLocations').getFirst().addClass('TopGenericMenuOn');
        $('HolidayHomeFirstlevel').morph({ 'top': '-350px' });
        $('BookHolidayFirstlevel').morph({ 'top': '-350px' });
        $$('.TopGenericMenuSecondlevelSplit,.TopGenericMenuSecondlevelSplit2').morph({ 'height': '144px' });
    }
    });


    $('ViewPrakLocations').addEvents({ 'mouseenter': function () {

        MegaMouseOutPrakLocations = false;
    },
        'mouseleave': function () {
            MegaMouseOutPrakLocations = true;
            MegaDropUpPrakLocations.delay(1000);
        }
    });
    var MegaDropUpPrakLocations = function () {
        if (MegaMouseOutPrakLocations == true) {
            $('ViewPrakLocations').set('morph', { duration: '800', transition: 'back:InOut' });
            $('ViewPrakLocations').morph({ 'top': '-350px' });

        }
    }

});


function Callback() {

    $$('.CallBackTextInput').each(function (e, i, a) {

        e.addEvent('focus', function () {
            e.getParent().getFirst().set('morph', { duration: '400', transition: 'back:out' });
            e.getParent().getFirst().morph({ 'left': '-63px' });

        });
    });


    var val1 = new Form.Validator($("CallbackRequestForm"), {
        stopOnFailure: true,
        onElementPass: function (e, arr) {
            if (e.hasClass("overtext") == true) {

                e.getParent().getFirst(".overtext").setStyle("background", "#ffffff");
            }
        },
        onElementFail: function (e, arr) {
            if (e.hasClass("overtext") == true) {

                e.getParent().getFirst(".overtext").setStyle("background", "#ff2d2d");
            }
        },
        onFormValidate: function (passed, form, event) {
            if (passed == true) {
                return true;
            }

            return false;
        }
    });
}

function BrochureRequest() {

    
    $$('.Brochuretextfield').each(function (e, i, a) {
        e.addEvent('click', function () {
            e.getParent().getFirst().set('morph', { duration: '400', transition: 'back:out' });
            e.getParent().getFirst().morph({ 'left': '-84px' });
        });
    });

    Form.Validator.add('atleast-one-checkbox-checked',
            {
                test: function (element) {

                    var shouldBeChecked = $('atleast-one-checkbox-checked-parent').getElements('input:checked');

                    if (shouldBeChecked.length < 1) {

                        $("atleast-one-checkbox-checked-parent").setStyle("background", "#ff2d2d");
                        return false;
                    }
                    $("atleast-one-checkbox-checked-parent").setStyle("background", "none");
                    return true;
                }
            });

    var val3 = new Form.Validator($("BrochureRequestForm"), {
        stopOnFailure: true,
        onElementPass: function (e, arr) {
            if (e.hasClass("overtext") == true) {

                e.getParent().getFirst(".overtext").setStyle("background", "#ffffff");
            }
        },
        onElementFail: function (e, arr) {
            if (e.hasClass("overtext") == true) {

                e.getParent().getFirst(".overtext").setStyle("background", "#ff2d2d");
            }
        },       

        onFormValidate: function (passed, form, event) {
            if (passed == true) {
                return true;
            }
            return false;
        }
    });

}



