﻿addEvent('domready', function () {
    var accordion = new Accordion($$('.PackThumbHeader'), $$('.AccordElement'), {
        display: -1,
        opacity: 0,
        alwaysHide: false
    });

    FAQPage();

    /*$("PackDetails").addEvent("mouseenter", function () {
        this.morph({ "background-color": ["#000000", "#812E8A"] });
    });
    $("PackDetails").addEvent("mouseleave", function () {
        this.morph({ "background-color": ["#812E8A", "#000000"] });
    });*/

    $$('.PackThumbHeader').addEvent('mouseenter', function () { this.fireEvent('click'); });
    $$(".NavPackagesBg").morph({ "opacity": "0.1" });
    var glosseryMorpher = new Fx.Morph($('GlosseryMover'), { duration: 300, transition: Fx.Transitions.Expo.easeInOut });
    var ContentHeight = 910;
    var GlosseryArray = $$('#glosseryMenuWrapper li a');
    GlosseryArray.each(function (el, i, a) {
        if (i == 0) {
            $("GlosseryContainer").morph({ "height": $('GlosseryMover').getChildren()[i].getSize().y });
            // alert("setting continer height to " + $('ServicesMover').getChildren()[i].getSize().y);
        }
        el.addEvents({ mouseenter: function () {
            $("GlosseryContainer").morph({ "height": $('GlosseryMover').getChildren()[i].getSize().y });
            glosseryMorpher.cancel().start({ 'left': -ContentHeight * i });
            containerHeight = $('GlosseryMover').getChildren()[i].getSize().y;

            GlosseryArray.each(function (el2, i2, a2) {
                el2.setStyle("background-color", "");
            });

            el.setStyle("background-color", "#000000");
        }
        });
    });
    TopNav();
    var array = $$('.HomeBuyIcon img');
    array.each(function (el, i, a) {
        el.addEvents({ 'mouseenter': function () {
            el.set('morph', { duration: '600', transition: 'elastic:out' });
            el.morph({ "width": "88px", "height": "86px", "left": "-10px", "top": "-10px" });
        },
            'mouseleave': function () {
                el.morph({ "width": "58px", "height": "56px", "left": "15px", "top": "0px" });
            }
        });
    });
    var array = $$('.BasketBuyIcon img');
    array.each(function (el, i, a) {
        el.addEvents({ 'mouseenter': function () {
            el.set('morph', { duration: '600', transition: 'elastic:out' });
            el.morph({ "width": "88px", "height": "86px", "left": "0px", "top": "-10px" });
        },
            'mouseleave': function () {
                el.morph({ "width": "68px", "height": "66px", "left": "15px", "top": "0px" });
            }
        });
    });
    var array = $$('#PackageBuyNow img');
    array.each(function (el, i, a) {

        el.addEvents({ 'mouseenter': function () {
            el.set('morph', { duration: '600', transition: 'elastic:out' });
            el.morph({ "width": "88px", "height": "86px", "left": "5px", "top": "-5px" });
        },
            'mouseleave': function () {
                el.morph({ "width": "78px", "height": "76px", "left": "15px", "top": "0px" });
            }
        });
    });
//    var ServiceMenuMorpher = new Fx.Morph($('ServicesMover'), { duration: 400, transition: Fx.Transitions.Expo.easeInOut });
//    var ContentWidth = 910;
//    var containerHeight = $('ServicesMover').getChildren()[0].getSize().y;
//    var ServicesMenuArray = $$('#ServicesMenu li');
//    ServicesMenuArray.each(function (el, i, a) {
//        if (i == 0) {
//            $("ServiceLinksWrapper").morph({ "height": $('ServicesMover').getChildren()[i].getSize().y });
//            // alert("setting continer height to " + $('ServicesMover').getChildren()[i].getSize().y);
//        }
//        el.addEvents({
//            mouseenter: function () {
//                $("ServiceLinksWrapper").morph({ "height": $('ServicesMover').getChildren()[i].getSize().y });
//                ServiceMenuMorpher.cancel().start({ 'left': -ContentWidth * i });
//                containerHeight = $('ServicesMover').getChildren()[i].getSize().y;

//                ServicesMenuArray.each(function (el2, i2, a2) {
//                    el2.setStyle("background-color", "");
//                });

//                el.setStyle("background-color", "#000000");
//            }
//        });
//    });
    var array = $$('.BuyNowIcon img');
    array.each(function (el, i, a) {
        el.addEvents({ 'mouseenter': function () {
            el.set('morph', { duration: '600', transition: 'elastic:out' });
            el.morph({ "width": "110px", "height": "111px", "left": "-10px", "top": "-15px" });
        },
            'mouseleave': function () {
                el.morph({ "width": "80px", "height": "81px", "left": "5px", "top": "0px" });
            }
        });
    });
    var array = $$('.NavPackages');
    array.each(function (el, i, a) {
        el.addEvents({ 'mouseenter': function () {

            el.getFirst(".NavPackagesBg").morph({ "opacity": "1" });
        },
            'mouseleave': function () {
                el.getFirst(".NavPackagesBg").morph({ "opacity": "0.1" });
            }
        });
    });
});

function TopNav() {

    /*$('HomeSearchNav').set('morph', { duration: '400', transition: 'expo:out' });
    $('PackageComparrisonDiv').set('morph', { duration: '400', transition: 'expo:out' });
   // $('ServiceNavWrapper').set('morph', { duration: '400', transition: 'expo:out' });
    $("shoppingbasket").addEvent("mouseenter", function (el) {
        $('HomeSearchNav').morph({ top: "-175px" });
        $('basketTextLink').setStyle("background", "#000000");
        $('HomeSearchDiv').removeClass("MenuBg");
        $("shoppingbasketImg").setStyle("background-position", "0px 56px");
    });

    $("shoppingbasket").addEvent("mouseenter", function () {
        $('shoppingbasket').addClass("MenuBg");
        $("shoppingbasketImg").setStyle("background-position", "0px 56px");
    });

    $("shoppingbasket").addEvent("mouseleave", function () {
        $('shoppingbasket').removeClass("MenuBg");
        $("shoppingbasketImg").setStyle("background-position", "0px 0px");
        $('basketTextLink').setStyle("background", "");
    });

    $("HomeSearchDiv").addEvent("mouseenter", function () {

        $('PackageComparrisonDiv').morph({ top: "-330px" });
        //$('ServiceNavWrapper').morph({ top: "-420px" });
        //$('glosseryMenuWrapper').morph({ top: "-150px" });

        $('HomeSearchNav').morph({ top: "30px" });
        $('HomeSearchDiv').addClass("MenuBg");
        $('HomeDrop').removeClass("MenuBg");
        $('PackageDrop').removeClass("MenuBg");
        $('ServiceDrop').removeClass("MenuBg");
        $('GlosseryDrop').removeClass("MenuBg");
    });*/

    /*$("basketTextLink").addEvent("mouseenter", function () {

        $("shoppingbasketImg").setStyle("background-position", "0px 56px");
        $('basketTextLink').setStyle("background", "#000000");
    });
    $("basketTextLink").addEvent("mouseleave", function () {

        $("shoppingbasketImg").setStyle("background-position", "0px 0px");
        $('basketTextLink').setStyle("background", "");
    });*/


    //    $("HomeSearchNav").addEvent("mouseleave", function () {
    //        $('HomeSearchNav').morph({ top: "-175px" });
    //        $('HomeSearchDiv').removeClass("MenuBg");
    //    });


    /*$$('#HomeSearchNav').addEvents({ 'mouseenter': function () {

        SearchMouseOut = false;
    },
        'mouseleave': function () {

            SearchMouseOut = true;
            SearchDropUp.delay(500);
        }
    });

    var SearchDropUp = function () {
        if (SearchMouseOut == true) {

            $('HomeSearchNav').morph({ top: "-175px" });
            $('HomeSearchDiv').removeClass("MenuBg");
            //$("BasketCurrent").setStyle("display", "");
        }
    } */

    /*$("HomeSearchDivImg").addEvent("mouseenter", function () {
        $('HomeSearchNav').morph({ top: "45px" });
        $('HomeSearchDiv').addClass("MenuBg");
    });
    //    $("HomeSearchNav").addEvent("mouseleave", function () {
    //        //Reset values
    //        $('HomeSearchNav').morph({ top: "-175px" });
    //        $('HomeSearchDiv').removeClass("MenuBg");
    //    });
    $("HomeDrop").addEvent("mouseenter", function () {
        $('PackageComparrisonDiv').morph({ top: "-330px" });
        //$('ServiceNavWrapper').morph({ top: "-420px" });
        //$('glosseryMenuWrapper').morph({ top: "-150px" });
        $('HomeSearchNav').morph({ top: "-175px" });

        $('HomeDrop').addClass("MenuBg");
        $('PackageDrop').removeClass("MenuBg");
        $('ServiceDrop').removeClass("MenuBg");
        $('GlosseryDrop').removeClass("MenuBg");
        $('HomeSearchDiv').removeClass("MenuBg");



    });
    $("HomeDrop").addEvent("mouseleave", function () {
        $('HomeDrop').removeClass("MenuBg");
        $("shoppingbasketImg").setStyle("display", "");
        if ($('BasketCurrent')) {
            $("BasketCurrent").setStyle("display", "");
        }
    });
    //Package Dropdown
    $("PackageDrop").addEvent("mouseenter", function () {
        //$('ServiceNavWrapper').morph({ top: "-420px" });
        //$('glosseryMenuWrapper').morph({ top: "-150px" });
        $('HomeSearchNav').morph({ top: "-175px" });
        //$('PackageComparrisonDiv').morph({ top: "45px" });

        $('HomeDrop').removeClass("MenuBg");
        $('PackageDrop').addClass("MenuBg");
        $('ServiceDrop').removeClass("MenuBg");
        $('GlosseryDrop').removeClass("MenuBg");
        $('HomeSearchDiv').removeClass("MenuBg");
        if ($('BasketCurrent')) {
            $("BasketCurrent").setStyle("display", "none");
        }
    });   

$("PackageDrop").addEvent("mouseleave", function () {
        $('PackageDrop').removeClass("MenuBg")
    });


    $("PackageComparrisonDiv").addEvent("mouseleave", function () {
        $('PackageComparrisonDiv').morph({ top: "-330px" });
        $('PackageDrop').removeClass("MenuBg");
        if ($('BasketCurrent')) {
            $("BasketCurrent").setStyle("display", "");
        }
    });
 
    //Services Dropdown
    $("ServiceDrop").addEvent("mouseenter", function () {
        //Reset values
        $('HomeSearchNav').morph({ top: "-175px" });
        $('PackageComparrisonDiv').morph({ top: "-330px" });
        //$('ServiceNavWrapper').morph({ top: "45px" });
        //$('glosseryMenuWrapper').morph({ top: "-150px" });
        $('ServiceDrop').addClass("MenuBg");
        $('HomeDrop').removeClass("MenuBg");
        $('PackageDrop').removeClass("MenuBg");
        $('GlosseryDrop').removeClass("MenuBg");
        $('HomeSearchDiv').removeClass("MenuBg");
        if ($('BasketCurrent')) {
            $("BasketCurrent").setStyle("display", "none");
        }
    });

    $("ServiceDrop").addEvent("mouseleave", function () {
        $('ServiceDrop').removeClass("MenuBg")
    });

//    $("ServiceNavWrapper").addEvent("mouseleave", function () {
//        $('ServiceNavWrapper').morph({ top: "-420px" });
       // $('ServiceDrop').removeClass("MenuBg");
//        if ($('BasketCurrent')) {
//            $("BasketCurrent").setStyle("display", "");
//        }
//    });
    //Glossery Dropdown
    $("GlosseryDrop").addEvent("mouseenter", function () {
        $('PackageComparrisonDiv').morph({ top: "-330px" });
        //$('ServiceNavWrapper').morph({ top: "-420px" });
        $('HomeSearchNav').morph({ top: "-175px" });
        //$('glosseryMenuWrapper').morph({ top: "45px" });
        $('HomeDrop').removeClass("MenuBg");
        $('PackageDrop').removeClass("MenuBg");
        $('ServiceDrop').removeClass("MenuBg");
        $('GlosseryDrop').addClass("MenuBg");
        $('HomeSearchDiv').removeClass("MenuBg");
        if ($('BasketCurrent')) {
            $("BasketCurrent").setStyle("display", "none");
        }
    });

	$("GlosseryDrop").addEvent("mouseleave", function () {
        $('GlosseryDrop').removeClass("MenuBg")
    });

    $("glosseryMenuWrapper").addEvent("mouseleave", function () {
        $('glosseryMenuWrapper').morph({ top: "-150px" });
        $('GlosseryDrop').removeClass("MenuBg");
        if ($('BasketCurrent')) {
            $("BasketCurrent").setStyle("display", "");
        }
    });*/
}
/*
$('navmenu').getChildren().each(function(e, i, a) {

if (e.getChildren('ul').length > 0) {
e.getFirst('ul').setStyle('z-index', '50');
}

e.addEvent('mouseenter', function() {
if (e.getChildren().length > 1) {

e.getFirst('ul').setStyle('display', 'block');
}
});

e.addEvent('mouseleave', function() {
if (e.getChildren().length > 1) {
e.getFirst('ul').setStyle('display', 'none');
}
});
});   
*/

function FAQPage() {

    var accordion = new Fx.Accordion($$('.faqtitle'), $$('.faqItems'), {
        opacity: 0,
        display: -1,
        alwaysHide: true

    });



}
