	// interval for jquery animations
	jQuery.fx.interval = 50;

function onYouTubePlayerReady(playerId) {
	ytplayer = document.getElementById('yt-player' + playerId);
	videoID = $('#yt-player' + playerId).parent().data('videoID');
	ytplayer.cueVideoById(videoID);
	//console.log(videoID);
}

function playYT(playerId){
	ytplayer = document.getElementById("yt-player" + playerId);
	ytplayer.playVideo();
}

function pauseYT(playerId){
	ytplayer = document.getElementById("yt-player" + playerId);
	ytplayer.pauseVideo();
}


$(document).ready(function () {

    //facebook ie hack, this seems pointless but the like buttons are fucking up the fonts.
    if ($.browser.msie) {
        $('.facebook').each(function () {
            $(this).parent().find('li:first-child').after('<li class="facebook fltRight"><iframe src="http://www.facebook.com/plugins/like.php?href=' + escape(window.location) + '&amp;layout=button_count&amp;show_faces=false&amp;width=120&amp;action=like&amp;font&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:120px; height:21px;" allowTransparency="true"></iframe></li>')
            $(this).remove();
        });
    }


    // make all external links open in a new window
    $('a[href^="http://"]').attr("target", "_blank");


    //main menu script
    var $megaMenu = $('#megaMenu');
    $('#NavContainer').hoverIntent(function () {
        $megaMenu.slideDown(200);

    }, function () {
        $megaMenu.slideUp(200, function () {
            $('.navSelected').removeClass('navSelected');
        });

    });

    $('#Nav a').hoverIntent(function () {
        $('.navSelected').removeClass('navSelected');
        $(this).addClass('navSelected');
        var whichNav = '#' + $(this).attr('rel') + 'Nav';
        if (!($(whichNav).is(':visible'))) {
            $('.megaNav').hide();
            $(whichNav).fadeIn();
        }
    }, function () {

    });

    //footer menu scripts
    var megaFooterVisible = false;
    $('#siteMapLink').click(function () {

        if (megaFooterVisible === false) {
            //alert(megaFooterVisible);
            $('#megaFooter').slideDown();
            megaFooterVisible = true;
        } else {
            //alert(megaFooterVisible);
            $('#megaFooter').slideUp();
            megaFooterVisible = false;
        }

        $('#sendToFriend').slideUp();
        sendToFriendVisible = false;

        $('#newsletters').slideUp();
        newsletterVisible = false;

        return false;
    });

    //$('#megaFooter').hoverIntent(function() {
    //
    //}, function() {
    //    $(this).slideUp();
    //    megaFooterVisible = false;
    //});

    // popUp send to friend
    var sendToFriendVisible = false;
    $('#emailLink').click(function () {
        $('.shareLinks').fadeToggle();
        if (sendToFriendVisible === false) {
            //alert(megaFooterVisible);
            $('#sendToFriend').slideDown();
            sendToFriendVisible = true;
        } else {
            //alert(megaFooterVisible);
            $('#sendToFriend').slideUp();
            sendToFriendVisible = false;
        }


        $('#megaFooter').slideUp();
        megaFooterVisible = false;

        $('#newsletters').slideUp();
        newsletterVisible = false;
        return false;
    });

    //$('#sendToFriend').hoverIntent(function() {
    //
    //}, function() {
    //    $(this).slideUp();
    //    sendToFriendVisible = false;
    //});

    $('#shareLink').click(function () {
        $(this).find('.shareLinks').fadeToggle();

        $('#megaFooter').slideUp();
        megaFooterVisible = false;
        $('#newsletters').slideUp();
        newsletterVisible = false;
        $('#sendToFriend').slideUp();
        sendToFriendVisible = false;
        //return false;
    });

    // popUp send to friend
    var newsletterVisible = false;
    $('#newsletterLink').click(function () {
        if (newsletterVisible === false) {
            //alert(megaFooterVisible);
            $('#newsletters').slideDown();
            newsletterVisible = true;
        } else {
            //alert(megaFooterVisible);
            $('#newsletters').slideUp();
            newsletterVisible = false;
        }
        $('#megaFooter').slideUp();
        megaFooterVisible = false;
        $('#sendToFriend').slideUp();
        sendToFriendVisible = false;
        return false;
    });

    //$('#newsletters').hoverIntent(function() {
    //
    //}, function() {
    //    $(this).slideUp();
    //    newsletterVisible = false;
    //});

    // ajax load and popup the faq
    $('.faqLauncher').click(function () {
        var $faq = '<div id="faqsContainer"></div>';
        $('body').append($faq);
        $('#faqsContainer').load('/help/faq.aspx #faqsPanel', function () {
            $('html,body').animate({ scrollTop: 0 }, 300, function () {
                $('body').append('<div id="popUpOverlay"></div>');
                $('#popUpOverlay').show();
                $('#faqsContainer').fadeIn();
            });

        });
        return false;
    });

    $('.clubFaqLauncher').click(function () {
        var $faq = '<div id="faqsContainer"></div>';
        $('body').append($faq);
        $('#faqsContainer').load('/help/faq.aspx #faqsPanel', function (response, status, xhr) {
            //alert(status);

            $('html,body').animate({ scrollTop: 0 }, 300, function () {
                $('body').append('<div id="popUpOverlay"></div>');
                $('#faqsContainer .tabNav li').eq(1).find('a').click();
                $('#popUpOverlay').show();
                $('#faqsContainer').fadeIn();
            });

        });
        return false;
    });

    $('.xmasDeliveryLauncher').click(function () {
        var $faq = '<div id="faqsContainer"></div>';
        $('body').append($faq);
        $('#faqsContainer').load('/help/ChristmasDeliveryInfo.htm', function (response, status, xhr) {
            //alert(status);
            //$('#faqsContainer').load('/help/faq.aspx #faqsPanel', function (response, status, xhr) {

            $('html,body').animate({ scrollTop: 0 }, 300, function () {
                $('body').append('<div id="popUpOverlay"></div>');
                //$('#faqsContainer .tabNav li').eq(1).find('a').click();
                $('#popUpOverlay').show();
                $('#faqsContainer').fadeIn();
            });

        });
        return false;
    });

    $('#xmasPanel .close a').live('click', function () {
        $('#faqsContainer').remove();
        $('#paymentFaqsContainer').hide();
        $('#popUpOverlay').remove();
        return false;
    });


    $('.privateHireVenueLauncher').click(function () {
        var $faq = '<div id="privateHireContainer"></div>';
        $('body').append($faq);
        $('#privateHireContainer').load('/PrivateHire/VenueDetails.aspx?id=' + $(this).data('venueid'), function () {
            $('html,body').animate({ scrollTop: 0 }, 300, function () {
                $('body').append('<div id="popUpOverlay"></div>');
                $('#popUpOverlay').show();
                $('#privateHireContainer').fadeIn();
            });

        });
        return false;
    });

    $('#privateHireVenueDetail .close a').live('click', function () {
        $('#privateHireContainer').remove();
        $('#paymentFaqsContainer').hide();
        $('#popUpOverlay').remove();
        return false;
    });

      $('.privateHireDetailHireLauncher').click(function () {
          var $faq = '<div id="privateHireContainer"></div>';
        $('body').append($faq);
        $('#privateHireContainer').load('/PrivateHire/HireDetails.aspx?id=' + $(this).data('venueid'), function () {
            $('html,body').animate({ scrollTop: 0 }, 300, function () {
                $('body').append('<div id="popUpOverlay"></div>');
                $('#popUpOverlay').show();
                $('#privateHireContainer').fadeIn();
            });

        });
        return false;
    });

    $('#privateHireDetailHire .close a').live('click', function () {
        $('#privateHireContainer').remove();
        $('#paymentFaqsContainer').hide();
        $('#popUpOverlay').remove();
        return false;
    });



    //load the payment faq
    $('.paymentFaqLauncher').live('click', function () {
        $('body').append('<div id="popUpOverlay"></div>');
        $('#popUpOverlay').show();
        $('#paymentFaqsContainer').fadeIn();
        return false;
    });

    // load the radio contact form
    $('.radioContact').live('click', function () {
        var $element = $(this);
        $('#contactForm').css({
            left: '50%',
            marginLeft: -255,
            top: 120,
            position: 'fixed',
            zIndex: 999
        });
        $('body').append('<div id="popUpOverlay"></div>');
        $('#radioContact input').eq(0).val($element.data('email'));
        $('#radioContact .formHeader span').text($element.data('show'))
        $('#popUpOverlay').show();
        $('#contactForm').fadeIn();
        return false;
    });

    $(".question").live('click', function () {
        $(this).next(".answer").slideToggle(100);
    });

    $('#faqsPanel .close a').live('click', function () {
        $('#faqsContainer').remove();
        $('#paymentFaqsContainer').hide();
        $('#popUpOverlay').remove();
        return false;
    });

    //back to top
    $('#backToTop a').click(function () {
        $('html,body').animate({ scrollTop: 0 }, 300);
        return false;
    });

    //shopTabs
    $('.tabPages>div').data('currentPage', 0);
    $('.tabPages>div').data('maxPage', 0);


    $('.tabPages>div').each(function () {
        if ($(this).data('totalPages') < 2) {
            $(this).find('.nextArrow').addClass('disable').removeClass('active');
        }
    });

    $('.tabPages .nextArrow').click(function () {
        var $slider = $(this).parent().find('.productSlider');
        var $container = $slider.parent().parent();
        var totalPages = $(this).parents('.tabPages>div').data('totalPages');

        var newPos = parseInt($slider.css('marginLeft')) - 760;

        if (!($(this).hasClass('disable'))) {
            $(this).parent().find('.prevArrow').removeClass('disable');
            $(this).parent().find('.prevArrow').addClass('active');
            if ($container.data('currentPage') === $container.data('maxPage')) {
                $slider.width($slider.width() + 760);
                $container.data('maxPage', $container.data('maxPage') + 1);
                addScript('/tubbyvortex.ashx?methodName=getProducts&jsonp=onProductCategoryLoaded&model=0&type=63&tabid=' + $slider.parent().parent().attr('id') + '&page=' + $container.data('maxPage') + '&pagesize=4');
            }
            $slider.stop(false, true).animate({
                marginLeft: newPos
            }, function () {
                $slider.css({ marginLeft: newPos });
            });
            $container.data('currentPage', $container.data('currentPage') + 1);
            if ($container.data('currentPage') === totalPages - 1) {
                $(this).addClass('disable');
                $(this).removeClass('active');
            }
            return false;
        } else {
            return false;
        }
    });

    $('.tabPages .prevArrow').click(function () {
        var $slider = $(this).parent().find('.productSlider');
        var $container = $slider.parent().parent();
        var newPos = parseInt($slider.css('marginLeft')) + 760;
        if (!($(this).hasClass('disable'))) {
            $(this).parent().find('.nextArrow').removeClass('disable');
            $(this).parent().find('.nextArrow').addClass('active');
            $container.data('currentPage', $container.data('currentPage') - 1);
            $slider.stop(false, true).animate({
                marginLeft: newPos
            });
            if ($container.data('currentPage') === 0) {
                $(this).addClass('disable');
                $(this).removeClass('active');
            }
            return false;
        } else {
            return false;
        }
    });

    $('.tabPages .nextArrowTwo').click(function () {
        var $slider = $(this).parent().find('.productSlider');
        var $container = $slider.parent().parent();
        var totalPages = $(this).parents('.tabPages>div').data('totalPages');

        var newPos = parseInt($slider.css('marginLeft')) - 480;

        if (!($(this).hasClass('disable'))) {
            $(this).parent().find('.prevArrowTwo').removeClass('disable');
            $(this).parent().find('.prevArrowTwo').addClass('active');
            if ($container.data('currentPage') === $container.data('maxPage')) {
                $slider.width($slider.width() + 480);
                $container.data('maxPage', $container.data('maxPage') + 1);
                addScript('/tubbyvortex.ashx?methodName=getProducts&jsonp=onProductCategoryLoaded&model=0&type=63&tabid=' + $slider.parent().parent().attr('id') + '&page=' + $container.data('maxPage') + '&pagesize=2');
            }
            $slider.stop(false, true).animate({
                marginLeft: newPos
            }, function () {
                $slider.css({ marginLeft: newPos });
            });
            $container.data('currentPage', $container.data('currentPage') + 1);
            if ($container.data('currentPage') === totalPages - 1) {
                $(this).addClass('disable');
                $(this).removeClass('active');
            }
            return false;
        } else {
            return false;
        }
    });

    $('.tabPages .prevArrowTwo').click(function () {
        var $slider = $(this).parent().find('.productSlider');
        var $container = $slider.parent().parent();
        var newPos = parseInt($slider.css('marginLeft')) + 480;
        if (!($(this).hasClass('disable'))) {
            $(this).parent().find('.nextArrowTwo').removeClass('disable');
            $(this).parent().find('.nextArrowTwo').addClass('active');
            $container.data('currentPage', $container.data('currentPage') - 1);
            $slider.stop(false, true).animate({
                marginLeft: newPos
            });
            if ($container.data('currentPage') === 0) {
                $(this).addClass('disable');
                $(this).removeClass('active');
            }
            return false;
        } else {
            return false;
        }
    });

    // preorder tooltips

    $('.preorder').live({
        mouseenter: function () {
            $(this).append('<span class="preorderTooltip corners">released: ' + $(this).data('releasedate') + '</span>');
            var centerLeft = ($(this).width() / 2) - ($(this).find('.preorderTooltip').width() / 2);
            $(this).find('.preorderTooltip').css({ left: centerLeft });
            $(this).find('.preorderTooltip').animate({
                opacity: '1',
                top: 30
            });
        },
        mouseleave: function () {
            $(this).find('.preorderTooltip').animate({
                opacity: '0',
                top: 60
            }, function () {
                $(this).remove();
            });
        }
    }
    );

    // setup add to basket buttons on the club homepage
    $('.buyClubTicket').each(function () {
        var $button = $(this).find('.addToBasket');
        var productID = $(this).find('select.ticketType option:selected').val();
        var quantity = $(this).find('select.ticketQuantity option:selected').val();
        //console.log(productID + ', ' + quantity);
        $button.data('productID', productID);
        $button.data('quantity', quantity);
    });




    //call to addto basket
    $('.addToBasket').live('click', function () {
        if (!($(this).hasClass('outofstock'))) {
            //$('.checkoutLink').show();

            var $quantity;
            if ($(this).data('quantity') === undefined) {
                $quantity = 1;
            } else {
                $quantity = $(this).data('quantity');
            }
            if ($(this).data('bundlestockid') === undefined) {
                AddtoBasket($(this).data('productID'), $quantity);
            } else {
                AddtoBasketBundle($(this).data('bundlestockid'), $(this).data('productID'), $quantity);
            }
            //console.log("quantity: " + $quantity);
            //alert('added:' + $(this).data('productID'))
            var popup = '<div id="addToBasketPopUp"><div class="padding10"></div></div>';
            var popupoverlay = '<div id="popUpOverlay">&nbsp;</div>';
            var initialPositionX = ($(window).width() / 2) - 100;
            var initialPositionY = ($(window).height() / 2) - 50;
            var newPositionX = ($(window).width() / 2) - 200;
            var title = $(this).data('title');
            var image = $(this).data('thumbnail');
            var imagepos = 'music';
            if ($(this).data('imagepos') != undefined) {
                imagepos = $(this).data('imagepos');
            }
            var productID = $(this).data('productID');
            var quantity_text = ' x ' + $quantity;
            var isTicket = $(this).data('isticket');
            var eticketMessage = '';

            if (isTicket == 'True') {
                eticketMessage = '<p class="eTik_Alert_PU">Please note: All tickets are E-tickets &amp; non-refundable</p>';
            }

            $('body').append(popupoverlay);
            $('body').append(popup);
            $('#addToBasketPopUp').css({
                top: initialPositionY,
                left: initialPositionX,
                position: 'fixed'
            });
            $('#popUpOverlay').show();
            $('#addToBasketPopUp').show();
            $('#addToBasketPopUp').animate({
                width: 400,
                left: newPositionX
            }, function () {
                $('#addToBasketPopUp .padding10').append('<h3 class="gothamBold addToBasketPopUpHeader">Item Added to Basket</h3>' + '<div class="addToBasketPopUpImage fltLeft"><img src="/uploads/products/' + imagepos + '/' + image + '" /></div><h2 class="gothamBold addToBasketPopUpTitle">' + title + quantity_text + '</h2>' + eticketMessage + '<br class="clear" />');
                $('#addToBasketPopUp .padding10').append('<div class="addToBasketPopUpButtons"><a href="/Profile/OrderSummary.aspx" class="checkoutBtn fltRight">Checkout</a><a href="#" class="addToBasketPopUpClose fltRight formBtn">Continue Shopping</a></div>');
            });
        }
        return false;
    });

    $('.addToBasketPopUpClose').live('click', function () {
        $('#popUpOverlay').remove();
        $('#addToBasketPopUp').remove();
        return false;
    });

    //all tabs
    $('.tabNav a').live('click', function () {
        var $parent = $(this).parents('.tabContainer');
        $parent.find('.tabNav li').removeClass('active');
        $(this).parent().addClass('active');
        $parent.find('.tabPages>div').hide();
        $parent.find($(this).attr('href')).fadeIn();
        return false;
    });

    $('.tabNav a').eq(0).click();

    //CD tabs
    $('.cdTabPages div:first-child').show();
    $('.cdTabNav a').click(function () {
        var $parent = $(this).parents('.cdTabContainer');
        $parent.find('.cdTabNav li a').removeClass('active');
        $(this).addClass('active');
        $parent.find('.cdTabPages>div').hide();
        $parent.find($(this).attr('href')).fadeIn();
        return false;
    });



    $('.trackList li:last-child').addClass('last');
    $('.discNumber li:first-child a').addClass('active').parent().addClass('first');
    $('.discNumber li').eq(2).addClass('last');


    //view Changer on blog
    $('.article-viewChanger').live('click', function () {
        var $thisPost = $(this).parent();
        if ($(this).data('color') === 'black') {
            //alert('this is black')
            $(this).data('color', 'white');
            $thisPost.addClass('whitePost');
            $thisPost.animate({
                color: '#000000'
            }).css({
                backgroundColor: '#ffffff',
                backgroundImage: 'url(/images/blog-fadeWhite.png)'
            });
            $(this).css('background-image', 'url(/images/viewChanger-black.png)');
        } else {
            //alert('this is white');
            $(this).data('color', 'black');
            $thisPost.removeClass('whitePost');
            $thisPost.animate({
                color: '#ffffff'
            }).css({
                backgroundColor: 'transparent',
                backgroundImage: 'url(/images/blog-fadeBlack.png)'
            });

            $(this).css('background-image', 'url(/images/viewChanger-white.png)');
        }
        return false;
    });


    // Latest Gallery Slider
    $('.galleryLandingThumbContainer .nextArrow').click(function () {
        if ($(this).hasClass('active')) {
            $(this).parent().find('.galleryLatestSlider').animate({
                marginLeft: -580
            });
            $(this).removeClass('active').addClass('disable');
            $(this).siblings('.prevArrow').removeClass('disable').addClass('active');
        }

        return false;
    });

    $('.galleryLandingThumbContainer .prevArrow').click(function () {
        if ($(this).hasClass('active')) {
            $(this).parent().find('.galleryLatestSlider').animate({
                marginLeft: 0
            });
            $(this).removeClass('active').addClass('disable');
            $(this).siblings('.nextArrow').removeClass('disable').addClass('active');
        }

        return false;
    });

    // Homepage Modules

    var thisSlide = 0;
    var nextSlide = 1;
    var $slides = $('#homepageSlides .image');
    var $titles = $('#sliderTitles li');
    var homepagePaused = false;
    var slideShow = function () { slideBaby(nextSlide); };

    // This is because jQuery can't animate to 'auto' so we have to find the max width of each one
    $titles.each(function () {
        $(this).css({ width: 'auto' });
        $TitleWidth = $(this).width();
        if ($TitleWidth < 16) { $TitleWidth = 11; }
        $(this).data('max-width', $TitleWidth);
        $(this).css({ width: '11px' });
    });
    //alert($titles.eq(0).width());
    if ($titles.eq(0).data('max-width') > 15) {
        $titles.eq(0).css({ width: 'auto' });
    }
    $titles.eq(0).find('.sliderDot').css('background-image', 'url(/images/sliderDot-active.png)');

    // sliding function depends on which item to go to.
    function slideBaby(which) {
        clearTimeout(slideTimer);
        nextSlide = which;
        $titles.eq(thisSlide).siblings().css({ width: '11px' });
        $titles.eq(thisSlide).animate({ width: '11px' }, function () {
            var toWidth = $titles.eq(nextSlide).data('max-width');
            $(this).find('.sliderDot').css('background-image', 'url(/images/sliderDot.png)');
            $titles.eq(nextSlide).find('.sliderDot').css('background-image', 'url(/images/sliderDot-active.png)');
            $titles.eq(nextSlide).animate({ width: toWidth });
        });
        $slides.eq(thisSlide).animate({ top: -296 }, function () { $(this).css({ top: 296 }); });
        $slides.eq(nextSlide).animate({ top: 0 }, function () {
            thisSlide = $slides.index(this);
            nextSlide = thisSlide + 1;
            if (nextSlide > $slides.length - 1) { nextSlide = 0; }
        });
        if (!(homepagePaused)) { slideTimer = setTimeout(slideShow, 5000); }
    }

    // set up the timer for auto scrolling, and make it pause on hover
    var slideTimer = setTimeout(slideShow, 5000);
    $('#homepageSlider').hover(function () {
        homepagePaused = true;
        clearTimeout(slideTimer);
    }, function () {
        homepagePaused = false;
        slideTimer = setTimeout(slideShow, 5000);
    });

    // make the dots clickable
    $('.sliderDot').click(function () {
        slideBaby($('.sliderDot').index(this));
        return false;
    });


    //Club Student sliders
    var thisSlideStudents = 0;
    var nextSlideStudents = 1;
    var $slidesStudents = $('#clubStudentSlides .image');
    var $titlesStudents = $('#sliderStudentTitles li');
    var $titlesStudentsText = $('#sliderStudentTitlesText li');
    var studentPagePaused = false;
    var slideShowStudents = function () { slideBabyStudents(nextSlideStudents); };

    // This is because jQuery can't animate to 'auto' so we have to find the max width of each one
    $titlesStudents.each(function () {
        // alert("stude");
        $(this).css({ width: 'auto' });
        $TitleWidth = $(this).width();
        if ($TitleWidth < 16) { $TitleWidth = 11; }
        $(this).data('max-width', $TitleWidth);
        $(this).css({ width: '11px' });
    });
    //alert($titles.eq(0).width());
    if ($titlesStudents.eq(0).data('max-width') > 15) {
        $titlesStudents.eq(0).css({ width: 'auto' });
    }
    $titlesStudents.eq(0).find('.sliderStudentDot').css('background-image', 'url(/images/sliderDot-active.png)');

    // sliding function depends on which item to go to.
    function slideBabyStudents(which) {
        clearTimeout(slideTimer);
        nextSlideStudents = which;
        //alert("hello slider" + which);
        $titlesStudents.eq(thisSlideStudents).siblings().css({ width: '11px' });
        $titlesStudents.eq(thisSlideStudents).animate({ width: '11px' }, function () {
            var toWidth = $titlesStudents.eq(nextSlideStudents).data('max-width');
            $(this).find('.sliderStudentDot').css('background-image', 'url(/images/sliderDot.png)');
            $titlesStudents.eq(nextSlideStudents).find('.sliderStudentDot').css('background-image', 'url(/images/sliderDot-active.png)');
            $titlesStudents.eq(nextSlideStudents).animate({ width: toWidth });
        });
        $slidesStudents.eq(thisSlideStudents).animate({ top: -335 }, function () { $(this).css({ top: 335 }); });
        $slidesStudents.eq(nextSlideStudents).animate({ top: 0 }, function () {
            thisSlideStudents = $slidesStudents.index(this);
            nextSlideStudents = thisSlideStudents + 1;
            if (nextSlideStudents > $slidesStudents.length - 1) { nextSlideStudents = 0; }
        });

        //text titles
        $titlesStudentsText.eq(thisSlideStudents).hide();
        $titlesStudentsText.eq(nextSlideStudents).show();

        if (!(studentPagePaused)) { slideTimer = setTimeout(slideShowStudents, 2500); }
    }

    // set up the timer for auto scrolling, and make it pause on hover
    var slideTimer = setTimeout(slideShowStudents, 2500);
    $('#studentpageSlider').hover(function () {
        studentPagePaused = true;
        clearTimeout(slideTimer);
    }, function () {
        studentPagePaused = false;
        slideTimer = setTimeout(slideShowStudents, 2500);
    });

    // make the dots clickable
    $('.sliderStudentDot').click(function () {
        slideBabyStudents($('.sliderStudentDot').index(this));
        return false;
    });

    //End of Club Student sliders



    //Private Hire Home sliders

    var thisSlidePhHome = 0;
    var nextSlidePhHome = 1;
    var $slidesPhHome = $('#privateHireHomeSlides .image');
    var $titlesPhHome = $('#privateHireHomeTitles li');
    var $titlesPhHomeText = $('#privateHireHomeTitlesText li');
    var phHomePagePaused = false;
    var slideShowPhHome = function () { slideBabyPhHome(nextSlidePhHome); };

    // This is because jQuery can't animate to 'auto' so we have to find the max width of each one
    $titlesPhHome.each(function () {
        //alert("stude");
        $(this).css({ width: 'auto' });
        $TitleWidth = $(this).width();
        if ($TitleWidth < 16) { $TitleWidth = 11; }
        $(this).data('max-width', $TitleWidth);
        $(this).css({ width: '11px' });
    });
    //alert($titlesPhHome.eq(0).width());
    if ($titlesPhHome.eq(0).data('max-width') > 15) {
        $titlesPhHome.eq(0).css({ width: 'auto' });
    }
    $titlesPhHome.eq(0).find('.sliderPrivateHireHomeDot').css('background-image', 'url(/images/private_hire/sliderDot-active.png)');

    // sliding function depends on which item to go to.
    function slideBabyPhHome(which) {
        clearTimeout(slideTimer);
        nextSlidePhHome = which;
        //alert("hello slider" + which);
        $titlesPhHome.eq(thisSlidePhHome).siblings().css({ width: '11px' });
        $titlesPhHome.eq(thisSlidePhHome).animate({ width: '11px' }, function () {
            var toWidth = $titlesPhHome.eq(nextSlidePhHome).data('max-width');
            $(this).find('.sliderPrivateHireHomeDot').css('background-image', 'url(/images/private_hire/sliderDot.png)');
            $titlesPhHome.eq(nextSlidePhHome).find('.sliderPrivateHireHomeDot').css('background-image', 'url(/images/private_hire/sliderDot-active.png)');
            $titlesPhHome.eq(nextSlidePhHome).animate({ width: toWidth });
        });
        $slidesPhHome.eq(thisSlidePhHome).animate({ left: -540 }, function () { $(this).css({ left: 540 }); });
        $slidesPhHome.eq(nextSlidePhHome).animate({ left: 0 }, function () {
            thisSlidePhHome = $slidesPhHome.index(this);
            nextSlidePhHome = thisSlidePhHome + 1;
            if (nextSlidePhHome > $slidesPhHome.length - 1) { nextSlidePhHome = 0; }
        });

        //text titles
        $titlesPhHomeText.eq(thisSlidePhHome).hide();
        $titlesPhHomeText.eq(nextSlidePhHome).show();

        if (!(phHomePagePaused)) { slideTimer = setTimeout(slideShowPhHome, 2500); }
    }

    // set up the timer for auto scrolling, and make it pause on hover
    var slideTimer = setTimeout(slideShowPhHome, 2500);
    $('#privateHireHomeSlider').hover(function () {
        phHomePagePaused = true;
        clearTimeout(slideTimer);
    }, function () {
        phHomePagePaused = false;
        slideTimer = setTimeout(slideShowPhHome, 2500);
    });

    // make the dots clickable
    $('.sliderPrivateHireHomeDot').click(function () {
        slideBabyPhHome($('.sliderPrivateHireHomeDot').index(this));
        return false;
    });

    //End of Private Hire Home sliders





    // This is for the sound slot

    $("#jplayer_holder").jPlayer({
        swfPath: "/script",
        volume: 50,
        ready: function () { this.element.jPlayer(); }
    });

    $('.homepageMusic').hover(function () {
        var file = $(this).data('sound');
        $("#jplayer_holder").jPlayer("setFile", file);
        $("#jplayer_holder").jPlayer('play').jPlayer("onSoundComplete", function () { this.element.jPlayer("play"); });
    }, function () {
        $("#jplayer_holder").jPlayer('stop');
    });


    // Flash embed stuff for the small videos
    $('.homepageVideo').each(function () {
        $youtube = $(this).data('videoID');
        $id = 'yt-player' + $(this).parent().index();
        $(this).find('.youtube-player').flash({
            swf: 'http://www.youtube.com/apiplayer?version=3&enablejsapi=1&playerapiid=' + $(this).parent().index(),
            width: 261,
            height: 149,
            id: $id,
            allowScriptAccess: 'always'
        });

    });

    $('.homepageVideo').hover(function () {
        $(this).find('.overlayImage').fadeOut();
        playYT($(this).parent().index());
    }, function () {
        $(this).find('.overlayImage').fadeIn();
        pauseYT($(this).parent().index());
    });






    // Now Playing slimline radio scroller

    var $nowPlayer = $('.nowPlayingScroll');
    function slideRadio() {
        var trackWidth = ($('.playingScroll').width() + 10) * -1;
        $nowPlayer.css({ textIndent: '0' });
        $nowPlayer.animate({
            textIndent: trackWidth
        }, 15000, 'linear', function () {
            //ReloadNowPlaying();
            $('.playingScroll').eq(0).remove();
            $nowPlayer.append('<span href="javascript:openRadioPlayer();" class="playingScroll"><span class="nowPlaying gothamBlack">Now Playing On Ministry of Sound Radio</span> <i>' + $('.updatedRadio').text() + '</i>...</span>');
            slideRadio();
        });
    }
    var trackName = $('.updatedRadio').text();
    $nowPlayer.append('<span href="javascript:openRadioPlayer();" class="playingScroll"><span class="nowPlaying gothamBlack">Now Playing On Ministry of Sound Radio</span> <i>' + trackName + '</i>...</span>');
    $nowPlayer.append('<span href="javascript:openRadioPlayer();" class="playingScroll"><span class="nowPlaying gothamBlack">Now Playing On Ministry of Sound Radio</span> <i>' + trackName + '</i>...</span>');
    slideRadio();


    //Login show/hide password panel

    $('.loginVert').height($('#accountRegisterForm').height() - 20);

    $('.accountRadio input:radio').click(function () {
        if ($(this).val() === 'yes') {
            $('.signInPassword').show();
            $('.formBtn').text('Login');
        } else {
            $('.signInPassword').hide();
            $('.formBtn').text('Register');
        }
    });

    if ($('.accountRadio input:radio:checked').val() === 'no') {
        $('.signInPassword').hide();
        $('.formBtn').text('Register');
    }

    // For left and right hand nav menus
    $("#standard li.menuHeader").click(function () {
        if ($(this).next().hasClass('menuList')) {
            $(this).css({ background: "none" }).next("li.menuList").slideToggle(300).siblings("li.menuList").slideUp("slow");
            $(this).siblings().css({ backgroundImage: "none)" });
            return false;
        }
    });


    // Listing page view switcher
    $('#switchView a').click(function () {
        if (!($(this).hasClass('active'))) {
            $('#switchView a').removeClass('active');
            $(this).addClass('active');
            $('.productListing').hide();
            $($(this).attr('href')).fadeIn();
        }
        return false;
    });

    //Listing description
    $('.readOn').live('click', function () {
        $(this).siblings('.shortDesc').hide();
        $(this).hide();
        $(this).siblings('.longDesc').fadeIn();
        $(this).siblings('.readLess').show();
        return false;
    });

    $('.readLess').live('click', function () {
        $(this).siblings('.longDesc').hide();
        $(this).siblings('.shortDesc').fadeIn();
        $(this).hide();
        $(this).siblings('.readOn').show();
        return false;
    });

    $('.articleClose').live('click', function () {
        $(this).parent().siblings('.articleGroup').slideToggle();
        $(this).removeClass('articleClose').addClass('articleExpand');
        return false;
    });

    $('.articleExpand').live('click', function () {
        $(this).parent().siblings('.articleGroup').slideToggle();
        $(this).removeClass('articleExpand').addClass('articleClose');
        return false;
    });

    // sorting
    $('.orderBy .selectList li').click(function () {
        $('.product').remove();
        var parentSelect = $(this).parents('.selectListContainer').data('selectID');
        var getVal = $('#' + parentSelect + ' option').eq($(this).index()).val();
        var getType = $('#' + parentSelect).data('type');
        if (!($(this).parents('#productList').data('isClothing') === undefined)) {
            getType += '&isclothing=';
            getType += $(this).parents('#productList').data('isClothing').toLowerCase();
        }
        addScript("/tubbyvortex.ashx?methodName=getProducts&jsonp=onListingLoaded&listing=" + getType + "&pagesize=25&tag=shop&orderby=" + getVal + "&p=0");
    });

    //mydownload list link
    $('.downloadListLink').click(function () {
        $thisLink = $(this);
        $(this).parents('tr').next().fadeToggle(function () {
            if ($(this).is(':visible')) {
                $thisLink.css('background-image', 'url(/images/Close_Small.png)');
            } else {
                $thisLink.css('background-image', 'url(../images/DownArrowLink.gif)');
            }
        });

        return false;
    });

    // popup basket link
    $('.basketLink').live('click', function () {
        $('.popupBasket').slideToggle();
        return false;
    });

    // checkout panel switch
    $('.shippingDetails .checkoutBtn').live('click', function () {
        $('.shippingDetails').hide();
        $('.paymentDetails').fadeIn();
        $('#checkoutNavShipping').removeClass('active');
        $('#ctl00_mainContent_checkoutNavPayment').addClass('active');
        billingPopulate();

        return false;
    });

    $('.checkoutNav').live('click', function () {

        if ($($(this).attr('href')).is(':visible')) {
            return false;
        } else {
            $('.shippingDetails').hide();
            $('.paymentDetails').hide();
            $($(this).attr('href')).fadeIn();
            $('.checkoutNav').removeClass('active');
            $(this).addClass('active');
            billingPopulate();
            return false;
        }
    });

    //$('#deliveryAddress .selectList li').live('click', function(){
    //	setTimeout('__doPostBack(\'ctl00$mainContent$ddlDelivery\',\'\')', 0);
    //});

    //checkout populate billing address
    function billingPopulate() {
        //console.log($('#deliveryAddress li').eq(8).find('.delAddress').text());
        $('#billingAddress li').eq(0).find('input').val($('#deliveryAddress>li').eq(3).find('.delAddress').text());
        $('#billingAddress li').eq(1).find('input').val($('#deliveryAddress>li').eq(4).find('.delAddress').text());
        $('#billingAddress li').eq(2).find('input').val($('#deliveryAddress>li').eq(5).find('.delAddress').text());
        $('#billingAddress li').eq(3).find('input').val($('#deliveryAddress>li').eq(6).find('.delAddress').text());
        $('#billingAddress li').eq(4).find('input').val($('#deliveryAddress>li').eq(8).find('.delAddress').text());
        //$('#billingAddress li').eq(5).find('select').val($('#deliveryAddress li').eq(8).find('.delAddress').text());
        //console.log($('#billingAddress li').eq(5).find('select').val());
        //$('#billingAddress li').eq(5).find('input').val($('#deliveryAddress li').eq(4).find('.delAddress').text());
    }

    //commentsLink
    $('.article-CommentLink a').live('click', function () {
        if (!($(this).parent().siblings('.article-commentContainer').is(':visible'))) {
            $(this).parent().siblings('.article-commentContainer').find('.article-comment').remove();
            GetComments($(this).data('postID'));
        }
        $(this).parent().siblings('.article-commentContainer').slideToggle();
        return false;
    });


    // shop mini feature links
    var $shopMiniSlide = 0;
    var $nextMiniSlide;

    $('.shopMiniNext').click(function () {
        miniSlide($(this).parent(), true, $(this).parent().find('li').length - 1);
        return false;
    });
    $('.shopMiniPrev').click(function () {
        miniSlide($(this).parent(), false, $(this).parent().find('li').length - 1);
        return false;
    });

    function miniSlide(container, forward, maxSlides) {
        if (forward) {
            if ($shopMiniSlide === maxSlides) {
                $nextMiniSlide = 0;
            } else {
                $nextMiniSlide = $shopMiniSlide + 1;
            }
        } else {
            if ($shopMiniSlide === 0) {
                $nextMiniSlide = maxSlides;
            } else {
                $nextMiniSlide = $shopMiniSlide - 1;
            }
        }
        container.find('li').eq($shopMiniSlide).fadeOut();
        container.find('li').eq($nextMiniSlide).fadeIn();
        $shopMiniSlide = $nextMiniSlide;
    }

    function isValidEmailAddress(emailAddress) {
        var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
        return pattern.test(emailAddress);
    }


    // blog comment Form submit
    $('.article-comment-form a').live('click', function () {
        var $name = $(this).parents('.article-comment-form').find('input[name$="name"]').val();
        var $email = $(this).parents('.article-comment-form').find('input[name$="email"]').val();
        var $comment = $(this).parents('.article-comment-form').find('textarea[name$="comment"]').val();
        var $postID = $(this).parents('.post').find('.article-CommentLink a').data('postID');
        var $this = $(this);

        var validEmail = false;
        var validName = false;
        var validComment = false;

        $('.commentError').hide();

        if ($name === '') {
            $(this).parents('.article-comment-form').find('li').eq(0).find('.commentError').fadeIn();
            validName = false;
        } else {
            validName = true;
        }

        if ($comment === '') {
            $(this).parents('.article-comment-form').find('li').eq(3).find('.commentError').fadeIn();
            validComment = false;
        } else {
            validComment = true;
        }

        if ($email === '' && isValidEmailAddress($email)) {
            $(this).parents('.article-comment-form').find('li').eq(1).find('.commentError').fadeIn();
            validEmail = false;
        } else {
            validEmail = true;
        }

        if (validName && validComment && validEmail) {

            $.post("/tubbyvortex.ashx", {
                methodName: "addComment",
                jsonp: "onCommentAdded",
                model: "0",
                postid: $postID,
                name: $name,
                email: $email,
                comment: $comment
            }, function () {
                var $newHTML = '';
                $newHTML += '<div class="article-comment newComment">';
                $newHTML += '<span class="article-commentName gothamBold yellow">';
                $newHTML += $name;
                $newHTML += '</span>';
                $newHTML += '<span class="article-commentDate"><strong>';
                var newDate = Date();
                $newHTML += dateFormat(newDate, "dd mmm yyyy");
                $newHTML += '</strong> ';
                $newHTML += dateFormat(newDate, "h:MM:sstt");
                $newHTML += '</span>';
                $newHTML += '<div class="article-commentText"><p>';
                $newHTML += $comment;
                $newHTML += '</p></div>';
                $newHTML += '</div>';

                $this.parents('.article-addComment').siblings('.article-comments').append($newHTML);
                $('.newComment').slideDown('fast', function () {
                    $(this).removeClass('newComment');
                });
                $this.parents('.article-comment-form').find('input').val('');
                $this.parents('.article-comment-form').find('textarea').val('');
            });
        } else {
            //alert('something invalid')
        }
        return false;
    });

    //show youtube on hover in product details
    //$('#productImg').hover(function(){
    //	var $youtube = $(this).data('videoID');
    //	if($youtube !== ""){
    //console.log($youtube);
    //	$(this).append('<iframe width="250" height="250" frameborder="0" src="http://www.youtube.com/embed/' + $youtube + '?rel=0&amp;autoplay=1&amp;loop=1&amp;&amp;hd=1" type="text/html" class="youtube-player" id="youtube-player" title="YouTube video player"></iframe>');
    //	$(this).find('a').fadeOut();
    //	}
    //}, function(){
    //	$(this).find('a').fadeIn('fast', function(){
    //		$(this).parent().find('.youtube-player').remove();
    //	});
    //	
    //});



    $('#productImg').each(function () {
        $youtube = $(this).data('videoID');
        if ($youtube !== "") {
            $(this).hover(function () {
                $(this).find('a').fadeOut();
                playYT(0);
            }, function () {
                $(this).find('a').fadeIn();
                pauseYT(0);
            });

            $('.youtube-player').flash({
                swf: 'http://www.youtube.com/apiplayer?version=3&enablejsapi=1&playerapiid=0',
                width: 250,
                height: 250,
                id: 'yt-player0',
                allowScriptAccess: 'always'
            });
        }
    });



    //play minimix
    $('.minimixPlay').live('click', function () {
        $("#jplayer_holder").jPlayer('stop');
        $('.jPlayActive').addClass('jPlay');
        $('.jPlayActive').removeClass('jPlayActive');

        var file = $(this).data('sound');
        $("#jplayer_holder").jPlayer("setFile", file);
        $("#jplayer_holder").jPlayer('play').jPlayer("onSoundComplete", function () { this.element.jPlayer("play"); });
        $(this).removeClass('minimixPlay');
        $(this).addClass('minimixPlaying');
    });
    $('.minimixPlaying').live('click', function () {
        $("#jplayer_holder").jPlayer('stop');
        $(this).removeClass('minimixPlaying');
        $(this).addClass('minimixPlay');
    });

    //play samples
    $('.jPlay').each(function () {

        if ($(this).data('sound') !== "") {
            $(this).css('display', 'block');
        }
    });

    $('.jPlay').live('click', function () {
        $("#jplayer_holder").jPlayer('stop');
        $('.jPlayActive').addClass('jPlay');
        $('.jPlayActive').removeClass('jPlayActive');
        $('.minimixPlaying').addClass('minimixPlay');
        $('.minimixPlaying').removeClass('minimixPlaying');

        var file = $(this).data('sound');
        $("#jplayer_holder").jPlayer("setFile", file);
        $("#jplayer_holder").jPlayer('play').jPlayer("onSoundComplete", function () { this.element.jPlayer("play"); });
        $(this).removeClass('jPlay');
        $(this).addClass('jPlayActive');
    });

    $('.jPlayActive').live('click', function () {
        $("#jplayer_holder").jPlayer('stop');
        $(this).removeClass('jPlayActive');
        $(this).addClass('jPlay');
    });

    // change views on the clothing zoomer

    $('#otherViews a').click(function () {
        var $thumbSRC = $(this).find('img').attr('src').replace("_thumb", "_Standard");
        var $zoomSRC = $(this).find('img').attr('src').replace("_thumb", "___Selected");
        var $normal = $(this).parent().parent().find('.artworkzoom');
        var $zoomer = $(this).parent().parent().find('.zoomImage');

        $normal.fadeOut('fast', function () {
            $normal.attr('src', $thumbSRC);
            $zoomer.attr('src', $zoomSRC);
            $normal.fadeIn();
        });

        return false;
    });

    // news ticker
    var newsItem = 0;
    var tickerPaused = false;

    function newsTicker() {
        clearTimeout(tickerTimer);
        $('#newsTicker li').eq(newsItem).animate({ top: -28 }, function () { $(this).css('top', 28); });
        newsItem++;
        if (newsItem === $('#newsTicker li').length) { newsItem = 0; }
        $('#newsTicker li').eq(newsItem).animate({ top: 0 });
        if (!(tickerPaused)) { tickerTimer = setTimeout(newsTicker, 7000); }
    }

    var tickerTimer = setTimeout(newsTicker, 7000);

    $('#newsTicker').hover(function () {
        tickerPaused = true;
        clearTimeout(tickerTimer);
    }, function () {
        tickerPaused = false;
        tickerTimer = setTimeout(newsTicker, 7000);
    });

    // Private hire news ticker
    var phNewsItem = 0;
    var phTickerPaused = false;

    function privateHireNewsTicker() {
        clearTimeout(phTickerTimer);
        $('#phNewsTicker li').eq(phNewsItem).animate({ left: -790 }, function () { $(this).css('left', 790); });
        phNewsItem++;
        if (phNewsItem === $('#phNewsTicker li').length) { phNewsItem = 0; }
        $('#phNewsTicker li').eq(phNewsItem).animate({ left: 0 });
        if (!(phTickerPaused)) { phTickerTimer = setTimeout(privateHireNewsTicker, 6000); }
    }

    var phTickerTimer = setTimeout(privateHireNewsTicker, 6000);

    $('#phNewsTicker').hover(function () {
        phTickerPaused = true;
        clearTimeout(phTickerTimer);
    }, function () {
        phTickerPaused = false;
        phTickerTimer = setTimeout(privateHireNewsTicker, 6000);
    });

    // Private hire testimonials ticker
    var phTestimonialsItem = 0;
    var phTestimonialTickerPaused = false;

    function privateHireTestimonialsTicker() {
        clearTimeout(phTestimonialsTickerTimer);
        $('#phTestimonialsTicker li').eq(phTestimonialsItem).animate({ left: -790 }, function () { $(this).css('left', 790); });
        phTestimonialsItem++;
        if (phTestimonialsItem === $('#phTestimonialsTicker li').length) { phTestimonialsItem = 0; }
        $('#phTestimonialsTicker li').eq(phTestimonialsItem).animate({ left: 0 });
        if (!(phTestimonialTickerPaused)) { phTestimonialsTickerTimer = setTimeout(privateHireTestimonialsTicker, 7000); }
    }

    var phTestimonialsTickerTimer = setTimeout(privateHireTestimonialsTicker, 7000);

    $('#phTestimonialsTicker').hover(function () {
        phTestimonialTickerPaused = true;
        clearTimeout(phTestimonialsTickerTimer);
    }, function () {
        phTestimonialTickerPaused = false;
        phTestimonialsTickerTimer = setTimeout(privateHireTestimonialsTicker, 7000);
    });


    // Events expand in club
    $('.viewMore a').live('click', function () {
        if ($(this).parent().data('imageDriver')) {
            return true;
        } else {
            $(this).parent().parent().next().slideDown();
            $(this).text('hide info').parent().removeClass('viewMore').addClass('viewLess');
            return false;
        }
    });
    $('.viewLess a').live('click', function () {
        $(this).parent().parent().next().slideUp();
        $(this).text('view more info').parent().removeClass('viewLess').addClass('viewMore');
        return false;
    });

    // course list expand in dj academy
    $('.courseExpander').live('click', function () {
        $(this).parents('.courseList').find('.courseExpand').slideDown();
        $(this).text('hide info').addClass('courseContractor').removeClass('courseExpander');
        return false;
    });

    $('.courseContractor').live('click', function () {
        $(this).parents('.courseList').find('.courseExpand').slideUp();
        $(this).text('view more info').addClass('courseExpander').removeClass('courseContractor');
        return false;
    });


    // student success biography list expand in dj academy
    $('.studentSuccessExpander').live('click', function () {
        $(this).parents('.courseList').find('.courseExpand').slideDown();
        $(this).text('hide biography').addClass('studentSuccessContractor').removeClass('studentSuccessExpander');
        return false;
    });

    $('.studentSuccessContractor').live('click', function () {
        $(this).parents('.courseList').find('.courseExpand').slideUp();
        $(this).text('view biography').addClass('studentSuccessExpander').removeClass('studentSuccessContractor');
        return false;
    });

    // vip contact form
    var $vipContactHeight = $('#contactForm').height();
    $('#contactForm').css({
        display: 'none',
        position: 'fixed',
        top: ($(window).height() / 2) - ($vipContactHeight / 2),
        left: ($(window).width() / 2) - ($('#contactForm').width() / 2),
        zIndex: 900
    });

    $('.academyQuestion').click(function () {

        $('#contactForm').fadeIn();
        $('body').append('<div id="popUpOverlay" style="display:block">&nbsp;</div>');
        return false;
    });

    $('.contactEvents').click(function () {
        $('#contactForm').fadeIn();
        $('body').append('<div id="popUpOverlay" style="display:block">&nbsp;</div>');
        return false;
    });

    $('.contactUniTrash').click(function () {

        $('#contactForm').fadeIn();
        $('body').append('<div id="popUpOverlay" style="display:block">&nbsp;</div>');
        return false;
    });

    $('.contactAAA').click(function () {

        $('#contactForm').fadeIn();
        $('body').append('<div id="popUpOverlay" style="display:block">&nbsp;</div>');
        return false;
    });

    $('.makeVIPLink').click(function () {

        $('#contactForm').fadeIn();
        $('.selectListContainer').remove();
        $('select').selectBaby();
        $('body').append('<div id="popUpOverlay" style="display:block">&nbsp;</div>');
        return false;
    });

    $('#contactForm .close').click(function () {
        $('#contactForm').fadeOut();
        $('#popUpOverlay').remove();
        return false;
    });


    // search box and button
    $('#searchBox').live('focus', function () {
        if ($(this).val() == 'Search Ministry of Sound') {
            $(this).val('');
        }
    });

    $('#searchBox').live('blur', function () {
        if ($(this).val() == '') {
            $(this).val('Search Ministry of Sound');
        }
    });

    $('#searchBox').live('keydown', function (event) {
        if (event.keyCode == '13') {
            event.preventDefault();
            //alert('hi');
            $('#searchBoxBtn').click();
        }
    });

    $('#searchBoxBtn').live('click', function () {
        window.location = '/searchfolder/searchresult.aspx?q=' + $('#searchBox').val();

    });

    $('#shopSearchInput').live('focus', function () {
        if ($(this).val() == 'Search for products') {
            $(this).val('');
        }
    });

    $('#shopSearchInput').live('blur', function () {
        if ($(this).val() == '') {
            $(this).val('Search for products');
        }
    });

    $('#shopSearchInput').live('keydown', function (event) {
        if (event.keyCode == '13') {
            event.preventDefault();
            //alert('hi');
            $('#shopSearchButton').click();
        }
    });

    $('#shopSearchButton').live('click', function () {
        window.location = '/searchfolder/shopsearchresult.aspx?q=' + $('#shopSearchInput').val() + '&producttype=' + $('#shopSearchType').val();

    });


    // IPAD FIXES

    if (navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod') {
        $("#footer").css("position", "static");
    }

    /*if (navigator.platform == 'iPhone' || navigator.platform == 'iPod') {
    if ($.cookie("appPop") === null) {
    $('body').append('<div id="appPop" class="appPop"><div class="padding15"><h3 class="gothamBlack formHeader fltLeft">Ministry of Sound <span style="text-transform:lowercase;">i</span>Phone App</h3><div class="close"><a href="#">close</a></div><br class="clear" /><span class="fluoroBorder_840 clear" style="margin:auto">Enquiries</span><div class="fltLeft gothamBold" style="width:300px;"><h3>GET OUR <span style="text-transform:lowercase;">i</span>Phone APP FOR FREE</h3></div><div class="fltLeft gothamBold" style="width:300px;"><a href="http://clk.tradedoubler.com/click?p=23708&a=1782332&EPI=WEBAPP&url=http%3A%2F%2Fitunes.apple.com%2Fgb%2Fapp%2Fultimate-ministry-of-sound%2Fid399590349%3Fmt%3D8%26uo%3D4%26partnerId%3D2003"><img src="/images/mobile/appstore.png" class="appButton" /></a></div><img src="/images/mobile/popUpPhone.png" class="fltRight" /><br class="clear" /></div></div>');
    $.cookie('appPop', 'true', { expires: 3, path: '/' });
    $('#appPop .close a').click(function () {
    $('#appPop').remove();
    });
    }
    }
    if (navigator.userAgent.indexOf('WP7') > -1) {
    $("#footer").css("position", "static");
    }
	
    if (navigator.userAgent.indexOf('WP7') > -1) {
    if ($.cookie("appPop2") === null) {
    $('body').append('<div id="appPop2" class="appPop"><div class="padding15"><h3 class="gothamBlack formHeader fltLeft">Ministry of Sound WP7 App</h3><div class="close"><a href="#">close</a></div><br class="clear" /><span class="fluoroBorder_840 clear" style="margin:auto">Enquiries</span><div class="fltLeft gothamBold" style="width:300px;"><h3>GET OUR WP7 APP</h3></div><div class="fltLeft gothamBold" style="width:300px;"><a href="http://social.zune.net/redirect/preferences/askclient?ReturnUrl=http%3a%2f%2fsocial.zune.net%2fredirect%3ftype%3dphoneApp%26id%3dc968b96e-2dda-df11-a844-00237de2db9e"><img src="/images/Magazine/mobile/2011/buy_wp7.png" class="appButton" /></a></div><img src="/images/mobile/popUpWP7Phone.png" class="fltRight" /><br class="clear" /></div></div>');
    $.cookie('appPop2', 'true', { expires: 3, path: '/' });
    $('#appPop2 .close a').click(function () {
    $('#appPop2').remove();
    });
    }
    }*/


    // DIRTY HACK FOR OBJECT EMBEDS SORT THIS OUT
    //$('object').each(function(){
    //	console.log($(this));
    //	var newObject = $('<object></object>');
    //	newObject.attr({
    //		classid: 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000',
    //		width: $(this).attr('width'),
    //		height: $(this).attr('height')
    //	});
    //	newObject.html('<param value="http://player.soundcloud.com/player.swf?url=http://api.soundcloud.com/tracks/8324508" name="data"><param value="always" name="allowscriptaccess"><param value="http://player.soundcloud.com/player.swf?url=http://api.soundcloud.com/tracks/8324508" name="src">');
    //	$(this).replaceWith(newObject);
    //});

    // dj academy testimonials
    var testimonial = $('#testimonials blockquote p').text();
    if (testimonial.length > 120) {
        testimonial = testimonial.substr(0, 120);
        $('#testimonials blockquote p').text(testimonial);
    }

    //clothing size guide stuff
    $('.sizeTable td').hover(function () {
        $('.sizeHeading td').eq($(this).index()).stop().animate({ 'color': '#000000' });
    }, function () {
        $('.sizeHeading td').eq($(this).index()).stop().animate({ 'color': '#666666' });
    });

    $('.sizeGuideLink a').live('click', function () {
        $('#sizePopUp').show();
        $('body').append('<div id="popUpOverlay" style="display: block;">&nbsp;</div>');
        $('#sizePopUp').animate({
            'height': 440,
            'width': 700,
            'top': 220,
            'margin-left': -350,
            'margin-top': 0
        }, function () {
            $(this).find('.padding15').fadeIn();
        });
        return false;
    });

    $('.closeSize').live('click', function () {
        $('#popUpOverlay').remove();
        $('#sizePopUp .padding15').hide();
        $('#sizePopUp').css({
            'display': 'none',
            'width': 200,
            'height': 200,
            'margin-left': -100,
            'margin-top': -100,
            'top': '50%'
        });
        return false;
    });

    //Change views on product detail page
    $('.changeProductView').live('click', function () {
        var $img = $(this).find('img');
        var $currentImg = $('.artworkzoom')
        //console.log($img.attr('src') + ', ' + $currentImg.attr('src'));

        //get and store the new src's
        var newViewSrc = $currentImg.attr('src').replace('__Selected.jpg', '120.jpg');
        var newMainSrc = $img.attr('src').replace('120.jpg', '__Selected.jpg');

        $img.attr('src', newViewSrc);
        $currentImg.attr('src', newMainSrc);
        $('.zoomImage').attr('src', newMainSrc);

        return false;
    });

    // Equal Column Heights on electronics details page
    $('.electronicColumnHolder').each(function () {
        $(this).find('.electronicColumn').height($(this).innerHeight());
    });

    $('#paypalRadio').live('click', function () {
        $(this).parent().find('.loginForm').slideUp();
        $('.cardForm').slideUp();
        $('.cardBtn').hide();
        $('.paypalBtn').show();
        $('.confirmOrder span').html($('.confirmOrder span').html().replace('Confirm Order', 'Pay with PayPal'));
    });

    $('#cardRadio').live('click', function () {
        $(this).parent().find('.loginForm').slideDown();
        $('.cardForm').slideDown();
        $('.cardBtn').show();
        $('.paypalBtn').hide();
        $('.confirmOrder span').html($('.confirmOrder span').html().replace('Pay with PayPal', 'Confirm Order'));
    });

    //On facebook private hire page this shows the 'other' box for where did you hear about us
    $('#ctl00_mainContent_drpPrivateHireFacebookWhereHear').live('change', function () {
        $('#privateHireFacebookWhereHearOtherBox').css('display', ($(this).val() == 'Other') ? 'block' : 'none');
    });

});

function pageLoad(){
	if(!($.browser.msie && parseInt(jQuery.browser.version) < 8)){
		$('.selectListContainer').remove();
		$('select').selectBaby();
	}
	$(".zoomBabyArtwork").zoomBaby(440, 440);
	$('.zoomBabyClothing').zoomBaby(370, 370);
	$('.zoomBabyElectronic').zoomBaby(430, 430);
	$('body').live('click', function(){
		$('.popupBasket').slideUp();
	});
}


