/******************************/
/*  START - GOOGLE ANALYTICS  */
/******************************/

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2755470-1']);
_gaq.push(['_trackPageview']);

(function () {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

/******************************/
/*  START - GOOGLE ANALYTICS  */
/******************************/




var addThisHoverTimeout;
var stringDefault = "I am looking for...";

function enterAddThis() {
    if (addThisHoverTimeout) clearTimeout(addThisHoverTimeout);
}

function exitAddThis() {
    //Set Time delay to hide dropdown and hover state
    addThisHoverTimeout = setTimeout(function() {
        $('.addthis_toolbox').stop().fadeTo("fast", 0.0);
    }, 150);
}

var intervalId;
function changeTarget() {
    intervalId = setInterval(forceTarget, 1000);
}

function forceTarget() {
    var target;
    $.each($('.addthis_toolbox a'), function() {
        target = $(this).attr('target');
        if (target == '_self') {
            stopInterval();
        }
        else {
            $(this).attr('target', '_self');
        }
    });
}

function stopInterval() {
    clearInterval(intervalId);
}

jQuery.fn.exists = function() { return jQuery(this).length > 0; }

$(document).ready(function() {

    //Share this button
    //=====================//   
    changeTarget();

    $('.addthis_toolbox').css({ opacity: 0 });

    $('a.shareThis').hover(function() {
        //Panel Position
        $('.addthis_toolbox').css({ display: 'block' }).css('left', '87px').css('top', '-180px').stop().fadeTo("fast", 1.0);
        enterAddThis();

    }, function() {
        exitAddThis();
    });

    $('.addthis_toolbox').hover(function() {
        enterAddThis();
    }, function() {
        exitAddThis();
    })


    // Main Menu arrow
    var $menuWidth = $('ul.mainMenu li.active').width();
    var $pos = ($menuWidth - 12) / 2;
    $('ul.mainMenu li a').live('mouseover mouseout', function(event) {
        if (event.type == 'mouseover') {
            $('ul.mainMenu li a').removeClass('menuHover');
            $(this).addClass('menuHover');
        } else {
            $('ul.mainMenu li a').removeClass('menuHover');
        }
    });
    $('ul.mainMenu li.active a span').append('<span class="mainMenuArrows" style="left:' + $pos + 'px"></span>');
    $("ul.mainMenu li:first").children().addClass("first");


    // auto hide and show intro text from field

    /*
    $('input[type="text"].searchInputField, input[type="text"].textField').focus(function() {
    $(".searchValidationMessage").fadeOut("slow"); //only when error message appears
    $(this).addClass("focusField");
    if (this.value == this.defaultValue) { this.value = ''; }
    if (this.value != this.defaultValue) { this.select(); }
    });
    $('input[type="text"].searchInputField, input[type="text"].textField').blur(function() {
    $(this).removeClass("focusField");
    if (this.value == '') { this.value = (this.defaultValue ? this.defaultValue : this.defaultValue); }
    });

	*/
    $('input[type="text"].searchInputField').focus(function() {
        $(".searchValidationMessage").fadeOut("slow"); //only when error message appears
        $(this).addClass("focusField");
        if (this.value == stringDefault) { this.value = ''; }
        if (this.value != this.defaultValue) { this.select(); }
    });
    $('input[type="text"].searchInputField').blur(function() {
        $(this).removeClass("focusField");
    });



    // BULLSEYE table style
    $('.wysiwygContent').find('table.bullseye').each(function() {
        var col = $(this).find('tr:first').children().size();
        var chLastSpc = $(this).find('tr:last').children('td').html();
        if ((chLastSpc != '&nbsp;')) {
            $(this).append('<tr><td></td></tr>');
        }

        $(this).find('tr th:first').addClass('first');
        $(this).find('tr th:last').addClass('last');

        $(this).find('tr').find('td:first').addClass("first");
        $(this).find('tr').find('td:last').addClass("last");

        $(this).find('tr:first').addClass('first');
        $(this).find('tr:last').addClass('last');
        $(this).find('tr').eq(-2).addClass("lastContent");


        $(this).find('tr.last').children('td:not(:first)').remove();
        $(this).find('tr.last td').attr('colspan', col);

    });

    //  BM Table Style
    $('table.jst').each(function() {
        var $jst = $(this);
        $jst.find(':last-child').addClass('jlc')
        $jst.find('tr:last-child td').addClass('jlr')

        $jst.find('tr:first-child th:first-child').addClass('jtl');
        $jst.find('tr:first-child th:last-child').addClass('jtr');

        $jst.find('tbody tr td:first-child').addClass('jl').addClass('jb')
        $jst.find('tbody tr td:last-child').addClass('jr').addClass('jb')

        $jst.find('tr:last-child td').addClass('jb')
        $jst.find('tr:last-child td:first-child').addClass('jbl').removeClass('jl')
        $jst.find('tr:last-child td:last-child').addClass('jbr').removeClass('jr')
    });



    // Reset Font Size
    var originalFontSize = $('.wysiwygContent, .snapshotRight p, .newsAndArticlesItem').css('font-size');
    var count = 0;
    $(".resetFont").click(function() {
        $('html').css('font-size', originalFontSize);
    });
    // Increase Font Size
    $(".toolResizeLarge").click(function() {
        if (count == 0 || count < 2) {
            var currentFontSize = $('.wysiwygContent, .snapshotRight p, .newsAndArticlesItem').css('font-size');
            var currentFontSizeNum = parseFloat(currentFontSize, 10);
            var newFontSize = currentFontSizeNum * 1.2;
            $('.wysiwygContent, .snapshotRight p, .newsAndArticlesItem').css('font-size', newFontSize);

            count++;
        }
        return false;
    });
    // Decrease Font Size
    $(".toolResizeSmall").click(function() {
        if (count > 0) {
            if (count == 1) {
                var newFontSize = originalFontSize;
            } else {
                var currentFontSize = $('.wysiwygContent, .snapshotRight p, .newsAndArticlesItem').css('font-size');
                var currentFontSizeNum = parseFloat(currentFontSize, 10);
                var newFontSize = currentFontSizeNum * 0.8;
            }
            $('.wysiwygContent, .snapshotRight p, .newsAndArticlesItem').css('font-size', newFontSize);

            count--;
        }
        return false;
    });


    // mega menu
    function megaHoverOver() {
        if ($(this).children('.megaMenuWrapper') != null) {
            var submenu = $(this).children('.megaMenuWrapper');
            $(submenu).css({ 'display': 'block', 'left': ($(this).position().left * -1) - 4 });
        }
    }

    function megaHoverOut() {
        $('.megaMenuWrapper').css({ 'display': 'none' });
    }

    var config = {
        sensitivity: 2,
        interval: 0,
        over: megaHoverOver,
        timeout: 0,
        out: megaHoverOut
    };

    $('.mainMenu li.parent').hoverIntent(config);

    // event calendar
    jQuery.fn.exists = function() { return jQuery(this).length > 0; }
    if ($("input.startDate").exists()) {
        $('div#eventCalendar').datepicker({
            dayNamesMin: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
            firstDay: 1,
            dateFormat: 'dd/mm/yy',
            altField: '.startDate, .endDate',
            onSelect: function(dateText, inst) {
                //alert(dateText);
                $('input.startDate').val(dateText);
                $('input.endDate').val(dateText);
                __doPostBack('centercolumn_0$lnkSearch', ''); // fire search button
            },
            beforeShowDay: function(date) {
                var currentDate = new Date(date);
                currentDate.setHours(0, 0, 0, 0);

                var startDateTemp = $('input.startDate').val().split('/');
                var startDate = new Date();
                startDate.setFullYear(startDateTemp[2], startDateTemp[1] - 1, startDateTemp[0]);
                startDate.setHours(0, 0, 0, 0);

                var endDateTemp = $('input.endDate').val().split('/');
                var endDate = new Date();
                endDate.setFullYear(endDateTemp[2], endDateTemp[1] - 1, endDateTemp[0]);
                endDate.setHours(0, 0, 0, 0);

                if (currentDate >= startDate && currentDate <= endDate) {
                    return [true, 'ui-datepicker-days-cell-over', $.datepicker.formatDate('dd/mm/yy', currentDate)];
                }
                else {
                    return [true, '', $.datepicker.formatDate('dd/mm/yy', currentDate)];
                }
            }
        });
    }

});



/************************************************************************************************
Jquery UI
*************************************************************************************************/

$(function() {

    //select box
    $('.selectField').selectbox();

    // Tabs
    $('.highlightTabs').tabs({ show: function() { initAllHoverCarousels(); } });
    $('.eventsAndNewsTabComp').tabs();

    // Dialog Link
    $('#dialog_link').click(function() { $('#dialog').dialog('open'); return false; });

    // Datepicker
    $(function() {
        $('.startDate, .endDate').datepicker({
            showOn: 'button',
            buttonText: 'cal',
            dateFormat: 'dd/mm/yy',
            onSelect: function(dateText, inst) {
                $('div#eventCalendar').datepicker("refresh");
            }
        });
    });

});


/************************************************************************************************
Selectbox
*************************************************************************************************/
jQuery.fn.extend({
    selectbox: function(options) {
        return this.each(function() {
            new jQuery.SelectBox(this, options);
        });
    }
});

jQuery.SelectBox = function(selectobj, options) {

    var opt = options || {};
    opt.inputClass = opt.inputClass || "selectbox";
    opt.containerClass = opt.containerClass || "selectbox-wrapper";
    opt.hoverClass = opt.hoverClass || "selected";
    opt.debug = opt.debug || false;

    var elm_id = selectobj.id;
    var active = -1;
    var inFocus = false;
    var hasfocus = 0;
    var $select = $(selectobj);
    var $container = setupContainer(opt);
    var $input = setupInput(opt);
    // hide select and append newly created elements
    $select.hide().before($input).before($container);

    init();

    $input
	.click(function() {
	    if (!inFocus) {
	        $container.toggle();
	    }
	})
	.focus(function() {
	    if ($container.not(':visible')) {
	        inFocus = true;
	        $container.show();
	    }
	})
	.keydown(function(event) {
	    switch (event.keyCode) {
	        case 38: // up
	            event.preventDefault();
	            moveSelect(-1);
	            break;
	        case 40: // down
	            event.preventDefault();
	            moveSelect(1);
	            break;
	        //case 9:  // tab     
	        case 13: // return
	            event.preventDefault(); // seems not working in mac !
	            setCurrent();
	            hideMe();
	            break;
	    }
	})
	.blur(function() {
	    if ($container.is(':visible') && hasfocus > 0) {
	        if (opt.debug) console.log('container visible and has focus')
	    } else {
	        hideMe();
	    }
	});


    function hideMe() {
        hasfocus = 0;
        $container.hide();
    }

    function init() {
        $container.append(getSelectOptions()).hide();
        var width = $input.width()
        $container.width(width);
    }

    function setupContainer(options) {
        var container = document.createElement("div");
        $container = $(container);
        $container.attr('id', elm_id + '_container');
        $container.addClass(options.containerClass);

        return $container;
    }

    function setupInput(options) {
        var input = document.createElement("input");
        var $input = $(input);
        $input.attr("id", elm_id + "_input");
        $input.attr("type", "text");
        $input.addClass(options.inputClass);
        $input.attr("autocomplete", "off");
        $input.attr("readonly", "readonly");
        $input.attr("tabIndex", $select.attr("tabindex")); // "I" capital is important for ie

        return $input;
    }

    function moveSelect(step) {
        var lis = $("li", $container);
        if (!lis) return;

        active += step;

        if (active < 0) {
            active = 0;
        } else if (active >= lis.size()) {
            active = lis.size() - 1;
        }

        lis.removeClass(opt.hoverClass);

        $(lis[active]).addClass(opt.hoverClass);
    }

    function setCurrent() {
        var li = $("li." + opt.hoverClass, $container).get(0);
        var el = li.id
        $select.val(el);
        //  JNO 23/6/2011 - Fix for HTML encoded &.
        $input.val($(li).html().replace('&amp;', '&'));

        //  JNO 09/6/2011 - Trigger the change event of the SELECT.
        $select.trigger('change');
        return true;
    }

    // select value
    function getCurrentSelected() {
        return $select.val();
    }

    // input value
    function getCurrentValue() {
        return $input.val();
    }

    function getSelectOptions() {
        var select_options = new Array();
        var ul = document.createElement('ul');
        $select.children('option').each(function() {
            var li = document.createElement('li');
            li.setAttribute('id', $(this).val());
            li.innerHTML = $(this).html().replace('&amp;', '&');  //  JNO 23/6/2011 - Fix for HTML encoded &.
            if ($(this).is(':selected')) {
                $input.val($(this).html().replace('&amp;', '&'));  //  JNO 23/6/2011 - Fix for HTML encoded &.
                $(li).addClass(opt.hoverClass);
            }
            ul.appendChild(li);
            $(li)
			.mouseover(function(event) {
			    hasfocus = 1;
			    if (opt.debug) console.log('out on : ' + this.id);
			    jQuery(event.target, $container).addClass(opt.hoverClass);
			})
			.mouseout(function(event) {
			    hasfocus = -1;
			    if (opt.debug) console.log('out on : ' + this.id);
			    jQuery(event.target, $container).removeClass(opt.hoverClass);
			})
			.click(function(event) {
			    if (opt.debug) console.log('click on :' + this.id);
			    $(this).addClass(opt.hoverClass);
			    setCurrent();
			    hideMe();
			});
        });
        return ul;
    }

};



/************************************************************************************************
Testimonials Rotator
*************************************************************************************************/
$(document).ready(function() {
    var $curr = $(".frameRotator  ul.rotatorList li:first.rotatorItem").fadeIn();
    var $totSlide = $('.frameRotator  ul.rotatorList li.rotatorItem').size();

    function setNavButtons() {
        if ($curr.index() > 0 && $curr.index() < ($totSlide - 1)) {
            $(".testiNavigation span.prev").show();
            $(".testiNavigation span.next").show();
        }
        else if ($curr.index() == 0) {
            $(".testiNavigation span.prev").hide();
            $(".testiNavigation span.next").show();
        }
        else if ($curr.index() == ($totSlide - 1)) {
            $(".testiNavigation span.prev").show();
            $(".testiNavigation span.next").hide();
        }
    }
    $('.testiRotator .testiNavigation')
		  	.prepend('<span class="pngFix prev" title="Prev">Prev</span>')
    		.append('<span class="pngFix next" title="Next">Next</span>');

    $(".testiNavigation span.prev").click(function() {
        $curr = $curr.prev();
        if ($curr.index() == -1) return false;

        $(".frameRotator  ul.rotatorList li.rotatorItem").fadeOut("slow").removeClass("active");
        $curr.fadeIn("slow").addClass("active");

        setNavButtons();
    });
    $(".testiNavigation span.next").click(function() {
        $curr = $curr.next();
        $(".frameRotator  ul.rotatorList li.rotatorItem").fadeOut("slow").removeClass("active");
        $curr.fadeIn("slow").addClass("active");
        setNavButtons();
    });

    if ($totSlide > 1) {
        $(".testiNavigation span.next").show();
    } else {
        $(".testiNavigation span.next").hide();
    }

    if ($curr.index() == 0) {
        $(".testiNavigation span.prev").hide();
    }

});

/************************************************************************************************
Slider Banner
*************************************************************************************************/
$(document).ready(function() {
    // create slider function
    jQuery.fn.fadeSlideShow = function(options) {
        return this.each(function() {
            settings = jQuery.extend({
                width: 960,
                height: 303,
                speed: 3000,
                interval: 7500,
                navWrap: 'navBanner',
                PlayPauseElement: 'bnrPlayPause',
                PlayText: 'Play',
                PauseText: 'Pause',
                NextElement: 'bnrNext',
                NextElementText: 'Next',
                PrevElement: 'bnrPrev',
                PrevElementText: 'Prev',
                addListToId: false,
                autoplay: true
            }, options);

            // writeNavigationWrapper
            jQuery(this).before('<div class="' + settings.navWrap + '"></div>');

            // set style for wrapper element
            jQuery(this).css({
                width: settings.width,
                height: settings.height,
                position: 'relative',
                overflow: 'hidden'
            });

            // set styles for child element
            jQuery('> *', this).css({
                position: 'absolute',
                width: settings.width,
                height: settings.height
            });

            // count number of slides
            Slides = jQuery('> *', this).length;
            Slides = Slides - 1;
            ActSlide = 0;
            // Set jQuery Slide short var
            jQslide = jQuery('> *', this);
            // save this
            fssThis = this;

            //set first fadein
            jQslide.eq(ActSlide).fadeIn(settings.speed);

            //start auto play
            autoplay = function() {
                intval = setInterval(function() {
                    jQslide.fadeOut(settings.speed);
                    if (ActSlide < Slides) {

                        ActSlide = ActSlide + 1;

                    } else {
                        ActSlide = 0;
                        //jQslide.eq(ActSlide).fadeIn(settings.speed);
                    }
                    //show slide base interval
                    jQslide.eq(ActSlide).fadeIn(settings.speed);

                }, settings.interval);

                if (settings.PlayPauseElement) {
                    jQuery('#' + settings.PlayPauseElement).html(settings.PauseText).removeClass('play').addClass('pause');
                }
            }

            stopAutoplay = function() {
                clearInterval(intval);
                intval = false;
                if (settings.PlayPauseElement) {
                    jQuery('#' + settings.PlayPauseElement).html(settings.PlayText).removeClass('pause').addClass('play');
                }
            }

            jumpTo = function(newIndex) {
                if (newIndex < 0) { newIndex = Slides; }
                else if (newIndex > Slides) { newIndex = 0; }
                if (newIndex >= ActSlide) {
                    jQuery('> *:lt(' + (newIndex + 1) + ')', fssThis).fadeIn("fast"); //.fadeIn(settings.speed);
                } else if (newIndex <= ActSlide) {
                    jQuery('> *:gt(' + newIndex + ')', fssThis).fadeOut("fast"); //.fadeOut(settings.speed)
                }

                // set the active slide
                ActSlide = newIndex;
            }

            if (settings.PlayPauseElement) {
                if (!jQuery('#' + settings.PlayPauseElement).css('display')) {
                    //jQuery(this).after('<a href="#" id="'+settings.PlayPauseElement+'"><\/a>');
                    jQuery('.' + settings.navWrap).append('<a href="#" id="' + settings.PlayPauseElement + '"><\/a>');
                }

                if (settings.autoplay) {
                    jQuery('#' + settings.PlayPauseElement).html(settings.PauseText).removeClass('play').addClass('pause');
                } else {
                    jQuery('#' + settings.PlayPauseElement).html(settings.PlayText).removeClass('pause').addClass('play');
                }

                jQuery('#' + settings.PlayPauseElement).bind('click', function() {
                    if (intval) {
                        stopAutoplay();
                    } else {
                        autoplay();
                    }
                    return false;
                });
            }

            if (settings.NextElement) {
                if (!jQuery('#' + settings.NextElement).css('display')) {
                    //jQuery(this).after('<a href="#" id="'+settings.NextElement+'">'+settings.NextElementText+'<\/a>');
                    jQuery('.' + settings.navWrap).append('<a href="#" id="' + settings.NextElement + '">' + settings.NextElementText + '<\/a>');
                }

                jQuery('#' + settings.NextElement).bind('click', function() {
                    nextSlide = ActSlide + 1;
                    stopAutoplay();
                    jumpTo(nextSlide);
                    return false;
                });
            }

            if (settings.PrevElement) {
                if (!jQuery('#' + settings.PrevElement).css('display')) {
                    //jQuery(this).after('<a href="#" id="'+settings.PrevElement+'">'+settings.PrevElementText+'<\/a>');
                    jQuery('.' + settings.navWrap).append('<a href="#" id="' + settings.PrevElement + '">' + settings.PrevElementText + '<\/a>');
                }

                jQuery('#' + settings.PrevElement).bind('click', function() {
                    prevSlide = ActSlide - 1;
                    stopAutoplay();
                    jumpTo(prevSlide);
                    return false;
                });
            }


            // start autoplay or set it to false
            if (settings.autoplay) { autoplay(); } else { intval = false; }
        });
    };

    // call slider function ready
    jQuery('.bannerSliderContent').fadeSlideShow();

});


/************************************************************************************************
Accordion
*************************************************************************************************/
//ddaccordion.init({ headerclass: "leftMenuItemHeader", contentclass: "leftMenuItemContent", revealtype: "click", mouseoverdelay: 200, collapseprev: true, defaultexpanded: [], onemustopen: false, animatedefault: false, persiststate: false, toggleclass: ["left-menu-disable", "left-menu-active"], togglehtml: ["prefix", "", ""], animatespeed: "slow", oninit: function(expandedindices) { }, onopenclose: function(header, index, state, isuseractivated) { } })
//ddaccordion.init({ headerclass: "leftMenuItemHeader", contentclass: "leftMenuItemContent", revealtype: "click", mouseoverdelay: 200, collapseprev: true, defaultexpanded: [], onemustopen: false, animatedefault: false, persiststate: false, togglehtml: ["prefix", "", ""], animatespeed: "slow", oninit: function(expandedindices) { }, onopenclose: function(header, index, state, isuseractivated) { } })
ddaccordion.init({ headerclass: "compAccordHeader", contentclass: "compAccordContent", revealtype: "click", mouseoverdelay: 200, collapseprev: true, defaultexpanded: [], onemustopen: false, animatedefault: false, persiststate: false, toggleclass: ["comp-accordion-disable", "comp-accordion-active"], togglehtml: ["prefix", "", ""], animatespeed: "slow", oninit: function(expandedindices) { }, onopenclose: function(header, index, state, isuseractivated) { } })

/************************************************************************************************
homeCarousel
*************************************************************************************************/

$(document).ready(function() {
    jQuery.fn.exists = function() { return jQuery(this).length > 0; }

    if ($("#businessCarousel").exists()) {


        $("#businessCarousel").featureCarousel({
            autoPlay: 0,
            trackerIndividual: false,
            trackerSummation: false,
            smallFeatureHeight: 0.8,
            smallFeatureWidth: 0.8,
            smallFeatureOffset: 16,
            largeFeatureWidth: 244,
            largeFeatureHeight: 158,
            topPadding: 0,
            carouselSpeed: 700,
            movedToCenter: function(feature) {

                var temp = $('.businessCarouselContentHide', feature).html();
                $('.businessCarouselCaption').html(temp);
                $('.businessCarouselCaption').fadeTo('fast', 1.0);

            },
            leavingCenter: function() {
                $('.businessCarouselCaption').fadeTo('fast', 0.0);
            }
        });

    }

});



/* Common positioning functions */
function getAbsoluteLeft(focusObject) {
    // Get an object left position from the upper left viewport corner
    o = $(focusObject)[0];
    oLeft = o.offsetLeft;
    while (o.offsetParent != null) {
        oParent = o.offsetParent;
        oLeft += oParent.offsetLeft;
        o = oParent;
    }
    return oLeft;
}




/*===============================
Promo Carousel
===============================*/
$(window).load(function() {
    if ($('#promoSlider,#slideShow').exists()) {
        $('#promoSlider,#slideShow').nivoSlider({
            effect: 'fold',
            controlNav: true,
            directionNav: false,
            animSpeed: 1000,
            pauseTime: 5000,
            slices: 1,
            captionOpacity:1.0
        });

        // centered nav
        var controlNavWidth = $('#compPromotionalBanner .nivo-controlNav').width();
        var controlNum = $('#compPromotionalBanner .nivo-controlNav a').size();
        var controlWidth = $('#compPromotionalBanner .nivo-controlNav a').width();
        var marginRight = 14;
        var paddingLeft = (controlNavWidth / 2) - ((controlNum * ((controlWidth + marginRight)) - marginRight) / 2);

        $('#compPromotionalBanner .nivo-controlNav').css({ 'padding-left': paddingLeft, 'width': controlNavWidth - paddingLeft });
    }
});



/*===============================
News & highlights
===============================*/
var highlightCarousel;
var newsCarousel;

$(document).ready(function() {

    // Tab Highlight
    initAllHoverCarousels();

});

function initAllHoverCarousels() {

    if ($('#Carousel').length > 0) {

        /* Highlights carousel init */
        highlightCarousel = $('#Carousel')[0];
        newsCarousel = $('#CarouselNews')[0];

        initHoverCarousel(highlightCarousel, "highlightCarousel");
        initHoverCarousel(newsCarousel, "newsCarousel");

    }

}

/* Init Hover Carousel*/
function initHoverCarousel(hoverCarousel, carouselId) {
    var temp;
    var propertiesObj = [];

    propertiesObj.id = carouselId;                                          // String ID for interval
    propertiesObj.currentLeft = 0; 											// Current pos
    propertiesObj.numChildren = $('li', hoverCarousel).length; 				// Carousel item count
    propertiesObj.minLeft = 0 - (propertiesObj.numChildren * 201) + 602; // Min position
    propertiesObj.maxLeft = 0; 												// Starting pos
    propertiesObj.carouselContainerLeft = getAbsoluteLeft(hoverCarousel); // Left to page
    propertiesObj.carouselWidth = 602; 										// Visible width
    propertiesObj.slideInterval = null; 									// Interval timer
    propertiesObj.totalTime = 800 * propertiesObj.numChildren; 			// Total milliseconds
    propertiesObj.slideSpeed = 8; 										// Max Speed value
    propertiesObj.activeArea = 200; 										// Active area width
    propertiesObj.leftActiveLimit = 200; 								// Left active hover area end
    propertiesObj.rightActiveLimit = 402; 								// Right active hover area start
    propertiesObj.isOverCarousel = false; 								// Hover state
    propertiesObj.relativeLeft = 0; 										// Mouse position relative to container

    temp = (propertiesObj.numChildren * 201);

    $(hoverCarousel).css({ width: temp + 'px' });
    $('ul', hoverCarousel).css({ width: temp + 'px', left: '0px' });



    if (propertiesObj.numChildren <= 3) {
        // NOT ENOUGH TO SCROLL
        $('.btnPrev', hoverCarousel).hide();
        $('.btnNext', hoverCarousel).hide();


    } else {
        // ENOUGH TO SCROLL

        // Save data to element
        jQuery.data(hoverCarousel, 'propertiesObj', propertiesObj);


        // Carousel hover
        $(hoverCarousel).hover(function(e) {

            var properties = jQuery.data(this, 'propertiesObj');
            properties.isOverCarousel = true;
            properties.relativeLeft = e.pageX - properties.carouselContainerLeft;
            jQuery.data(this, 'propertiesObj', properties);

            setHoverCarouselScrollAnimation(this);

        }, function() {

            // Mouse out
            var properties = jQuery.data(this, 'propertiesObj');

            properties.isOverCarousel = false;

            if (properties.slideInterval != null) clearInterval(properties.slideInterval);

            jQuery.data(this, 'propertiesObj', properties);

        });


        $(hoverCarousel).mousemove(function(e) {

            var properties = jQuery.data(this, 'propertiesObj');

            properties.isOverCarousel = true;
            properties.relativeLeft = e.pageX - properties.carouselContainerLeft;

            jQuery.data(this, 'propertiesObj', properties);

        });

    }

}

function setHoverCarouselScrollAnimation(hoverCarousel) {

    var properties = jQuery.data(hoverCarousel, 'propertiesObj');


    // Mouse over
    if (properties.slideInterval != null) clearInterval(properties.slideInterval);

    jQuery.data(hoverCarousel, 'propertiesObj', properties);


    properties.slideInterval = setInterval("updateHoverCarouselAnimation('" + properties.id + "')", 30);

    // Save properties
    jQuery.data(hoverCarousel, 'propertiesObj', properties);

}


function updateHoverCarouselAnimation(hoverCarouselId) {

    var hoverCarousel;

    // Work out which carousel
    if (hoverCarouselId == "highlightCarousel") hoverCarousel = highlightCarousel;
    else if (hoverCarouselId == "newsCarousel") hoverCarousel = newsCarousel;

    // Get properties
    var properties = jQuery.data(hoverCarousel, 'propertiesObj');

    // Update
    var posScale = 1;


    if (properties.relativeLeft < properties.leftActiveLimit && properties.relativeLeft > 0) {

        // LEFT SIDE
        posScale = (1 - (properties.relativeLeft / properties.activeArea));

        if (properties.currentLeft + (properties.slideSpeed * posScale) < properties.maxLeft) properties.currentLeft += properties.slideSpeed * posScale;
        else properties.currentLeft = properties.maxLeft;

        $('ul', hoverCarousel).css('left', properties.currentLeft + "px");

    } else if (properties.relativeLeft > properties.rightActiveLimit && properties.relativeLeft < properties.carouselWidth) {

        // RIGHT SIDE
        posScale = ((properties.relativeLeft - properties.rightActiveLimit) / properties.activeArea);

        if (properties.currentLeft - (properties.slideSpeed * posScale) > properties.minLeft) properties.currentLeft -= properties.slideSpeed * posScale;
        else properties.currentLeft = properties.minLeft;

        $('ul', hoverCarousel).css('left', properties.currentLeft + "px");

    } else {

        // MIDDLE OR OUT
        //leave still

    }

    // Save properties
    jQuery.data(hoverCarousel, 'propertiesObj', properties);

}
