
/******* Anchor Slider by Cedric Dugas *******/
/******* Http://www.position-absolute.com *******/

$(document).ready(function () {
    $("a.anchorLink").anchorAnimate()
});

jQuery.fn.anchorAnimate = function (settings) {

    settings = jQuery.extend({
        speed: 1500
    }, settings);

    return this.each(function () {
        var caller = this
        $(caller).click(function (event) {
            event.preventDefault()
            var locationHref = window.location.href
            var elementClick = $(caller).attr("href")

            var destination = $(elementClick).offset().top;
            $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination }, settings.speed, function () {
                window.location.hash = elementClick
            });
            return false;
        })
    })
}





/*
* jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
*
* Uses the built in easing capabilities added In jQuery 1.1
* to offer multiple easing options
*
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend(jQuery.easing,
{
    def: 'easeOutQuad',
    swing: function(x, t, b, c, d) {
        //alert(jQuery.easing.default);
        return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
    },
    easeInQuad: function(x, t, b, c, d) {
        return c * (t /= d) * t + b;
    },
    easeOutQuad: function(x, t, b, c, d) {
        return -c * (t /= d) * (t - 2) + b;
    },
    easeInOutQuad: function(x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t + b;
        return -c / 2 * ((--t) * (t - 2) - 1) + b;
    },
    easeInCubic: function(x, t, b, c, d) {
        return c * (t /= d) * t * t + b;
    },
    easeOutCubic: function(x, t, b, c, d) {
        return c * ((t = t / d - 1) * t * t + 1) + b;
    },
    easeInOutCubic: function(x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
        return c / 2 * ((t -= 2) * t * t + 2) + b;
    },
    easeInQuart: function(x, t, b, c, d) {
        return c * (t /= d) * t * t * t + b;
    },
    easeOutQuart: function(x, t, b, c, d) {
        return -c * ((t = t / d - 1) * t * t * t - 1) + b;
    },
    easeInOutQuart: function(x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b;
        return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
    },
    easeInQuint: function(x, t, b, c, d) {
        return c * (t /= d) * t * t * t * t + b;
    },
    easeOutQuint: function(x, t, b, c, d) {
        return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
    },
    easeInOutQuint: function(x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
        return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
    },
    easeInSine: function(x, t, b, c, d) {
        return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
    },
    easeOutSine: function(x, t, b, c, d) {
        return c * Math.sin(t / d * (Math.PI / 2)) + b;
    },
    easeInOutSine: function(x, t, b, c, d) {
        return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
    },
    easeInExpo: function(x, t, b, c, d) {
        return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
    },
    easeOutExpo: function(x, t, b, c, d) {
        return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
    },
    easeInOutExpo: function(x, t, b, c, d) {
        if (t == 0) return b;
        if (t == d) return b + c;
        if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
        return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
    },
    easeInCirc: function(x, t, b, c, d) {
        return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
    },
    easeOutCirc: function(x, t, b, c, d) {
        return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
    },
    easeInOutCirc: function(x, t, b, c, d) {
        if ((t /= d / 2) < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
        return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
    },
    easeInElastic: function(x, t, b, c, d) {
        var s = 1.70158; var p = 0; var a = c;
        if (t == 0) return b; if ((t /= d) == 1) return b + c; if (!p) p = d * .3;
        if (a < Math.abs(c)) { a = c; var s = p / 4; }
        else var s = p / (2 * Math.PI) * Math.asin(c / a);
        return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
    },
    easeOutElastic: function(x, t, b, c, d) {
        var s = 1.70158; var p = 0; var a = c;
        if (t == 0) return b; if ((t /= d) == 1) return b + c; if (!p) p = d * .3;
        if (a < Math.abs(c)) { a = c; var s = p / 4; }
        else var s = p / (2 * Math.PI) * Math.asin(c / a);
        return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
    },
    easeInOutElastic: function(x, t, b, c, d) {
        var s = 1.70158; var p = 0; var a = c;
        if (t == 0) return b; if ((t /= d / 2) == 2) return b + c; if (!p) p = d * (.3 * 1.5);
        if (a < Math.abs(c)) { a = c; var s = p / 4; }
        else var s = p / (2 * Math.PI) * Math.asin(c / a);
        if (t < 1) return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
        return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
    },
    easeInBack: function(x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        return c * (t /= d) * t * ((s + 1) * t - s) + b;
    },
    easeOutBack: function(x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
    },
    easeInOutBack: function(x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
        return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
    },
    easeInBounce: function(x, t, b, c, d) {
        return c - jQuery.easing.easeOutBounce(x, d - t, 0, c, d) + b;
    },
    easeOutBounce: function(x, t, b, c, d) {
        if ((t /= d) < (1 / 2.75)) {
            return c * (7.5625 * t * t) + b;
        } else if (t < (2 / 2.75)) {
            return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
        } else if (t < (2.5 / 2.75)) {
            return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
        } else {
            return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
        }
    },
    easeInOutBounce: function(x, t, b, c, d) {
        if (t < d / 2) return jQuery.easing.easeInBounce(x, t * 2, 0, c, d) * .5 + b;
        return jQuery.easing.easeOutBounce(x, t * 2 - d, 0, c, d) * .5 + c * .5 + b;
    }
});





/* =========================================================

// jquery.innerfade.js

// ========================================================= */


(function($) {

    $.fn.innerfade = function(options) {
        return this.each(function() {
            $.innerfade(this, options);
        });
    };

    $.innerfade = function(container, options) {
        var settings = {
            'animationtype': 'fade',
            'speed': 'normal',
            'type': 'sequence',
            'timeout': 2000,
            'containerheight': 'auto',
            'runningclass': 'innerfade',
            'children': null
        };
        if (options)
            $.extend(settings, options);
        if (settings.children === null)
            var elements = $(container).children();
        else
            var elements = $(container).children(settings.children);
        if (elements.length > 1) {
            $(container).css('position', 'relative').css('height', settings.containerheight).addClass(settings.runningclass);
            for (var i = 0; i < elements.length; i++) {
                $(elements[i]).css('z-index', String(elements.length - i)).css('position', 'absolute').hide();
            };
            if (settings.type == "sequence") {
                setTimeout(function() {
                    $.innerfade.next(elements, settings, 1, 0);
                }, settings.timeout);
                $(elements[0]).show();
            } else if (settings.type == "random") {
                var last = Math.floor(Math.random() * (elements.length));
                setTimeout(function() {
                    do {
                        current = Math.floor(Math.random() * (elements.length));
                    } while (last == current);
                    $.innerfade.next(elements, settings, current, last);
                }, settings.timeout);
                $(elements[last]).show();
            } else if (settings.type == 'random_start') {
                settings.type = 'sequence';
                var current = Math.floor(Math.random() * (elements.length));
                setTimeout(function() {
                    $.innerfade.next(elements, settings, (current + 1) % elements.length, current);
                }, settings.timeout);
                $(elements[current]).show();
            } else {
                alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
            }
        }
    };

    $.innerfade.next = function(elements, settings, current, last) {
        if (settings.animationtype == 'slide') {
            $(elements[last]).slideUp(settings.speed);
            $(elements[current]).slideDown(settings.speed);
        } else if (settings.animationtype == 'fade') {
            $(elements[last]).fadeOut(settings.speed);
            $(elements[current]).fadeIn(settings.speed, function() {
                removeFilter($(this)[0]);
            });
        } else
            alert('Innerfade-animationtype must either be \'slide\' or \'fade\'');
        if (settings.type == "sequence") {
            if ((current + 1) < elements.length) {
                current = current + 1;
                last = current - 1;
            } else {
                current = 0;
                last = elements.length - 1;
            }
        } else if (settings.type == "random") {
            last = current;
            while (current == last)
                current = Math.floor(Math.random() * elements.length);
        } else
            alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
        setTimeout((function() {
            $.innerfade.next(elements, settings, current, last);
        }), settings.timeout);
    };

})(jQuery);

// **** remove Opacity-Filter in ie ****
function removeFilter(element) {
    if (element.style.removeAttribute) {
        element.style.removeAttribute('filter');
    }
}


/* =========================================================

// jquery.slideviewer.1.1.js

// ========================================================= */

jQuery(function() {
    jQuery("div.svw").prepend("<span class='ldrgif'>loading...</span>");
});
var j = 0;
var quantofamo = 0;
jQuery.fn.slideView = function(settings) {
    settings = jQuery.extend({
        easeFunc: "easeInOutExpo",
        easeTime: 750,
        toolTip: false
    }, settings);
    return this.each(function() {
        var container = jQuery(this);
        container.find(".ldrgif").remove(); // removes the preloader gif
        container.removeClass("svw").addClass("stripViewer");
        var pictWidth = container.find("img").width();
        var pictHeight = container.find("img").height();
        var pictEls = container.find("li").size();
        var stripViewerWidth = pictWidth * pictEls;
        container.find("ul").css("width", stripViewerWidth); //assegnamo la larghezza alla lista UL	
        container.css("width", pictWidth);
        container.css("height", pictHeight);
        container.each(function(i) {
            jQuery(this).after("<div class='stripTransmitter' id='stripTransmitter" + (j) + "'><\p>Browse Images:<\/p><ul><\/ul><\/div>");
            jQuery(this).find("li").each(function(n) {
                jQuery("div#stripTransmitter" + j + " ul").append("<li><a title='" + jQuery(this).find("img").attr("alt") + "' href='#'>" + (n + 1) + "<\/a><\/li>");
            });
            jQuery("div#stripTransmitter" + j + " a").each(function(z) {
                jQuery(this).bind("click", function() {

                    jQuery(this).addClass("current").parent().parent().find("a").not(jQuery(this)).removeClass("current"); // wow!
                    var cnt = -(pictWidth * z);
                    container.find("ul").animate({ left: cnt }, settings.easeTime, settings.easeFunc);
                    return false;
                });
            });


            // next image via image click	14/01/2009
            jQuery("div#stripTransmitter" + j + " a").parent().parent().parent().prev().find("img").each(function(z) {
                jQuery(this).bind("click", function() {
                    var ui = jQuery(this).parent().parent().parent().next().find("a");
                    if (z + 1 < pictEls) {
                        ui.eq(z + 1).trigger("click");
                    }
                    else ui.eq(0).trigger("click");
                });
            });


            jQuery("div#stripTransmitter" + j).css("width", pictWidth);
            jQuery("div#stripTransmitter" + j + " a:first").addClass("current");
            if (settings.toolTip) {
                container.next(".stripTransmitter ul").find("a").Tooltip({
                    track: true,
                    delay: 0,
                    showURL: false,
                    showBody: false
                });
            }
        });
        j++;
    });
};



/**
* jCarouselLite - jQuery plugin to navigate images/any content in a carousel style widget.
* @requires jQuery v1.2 or above
*
* http://gmarwaha.com/jquery/jcarousellite/
*
* Copyright (c) 2007 Ganeshji Marwaha (gmarwaha.com)
*
* Version: 1.0.1
*/

/**
* Creates a carousel-style navigation widget for images/any-content from a simple HTML markup.
* @author Ganeshji Marwaha/ganeshread@gmail.com
*/

(function($) {                                          // Compliant with jquery.noConflict()
    $.fn.jCarouselLite = function(o) {
        o = $.extend({
            btnPrev: null,
            btnNext: null,
            btnGo: null,
            mouseWheel: false,
            auto: null,

            speed: 200,
            easing: null,

            vertical: false,
            circular: true,
            visible: 3,
            start: 0,
            scroll: 1,

            beforeStart: null,
            afterEnd: null
        }, o || {});

        return this.each(function() {                           // Returns the element collection. Chainable.

            var running = false, animCss = o.vertical ? "top" : "left", sizeCss = o.vertical ? "height" : "width";
            var div = $(this), ul = $("ul", div), tLi = $("li", ul), tl = tLi.size(), v = o.visible;

            if (o.circular) {
                ul.prepend(tLi.slice(tl - v - 1 + 1).clone())
              .append(tLi.slice(0, v).clone());
                o.start += v;
            }

            var li = $("li", ul), itemLength = li.size(), curr = o.start;
            div.css("visibility", "visible");

            li.css({ overflow: "hidden", float: o.vertical ? "none" : "left" });
            ul.css({ margin: "0", padding: "0", position: "relative", "list-style-type": "none", "z-index": "1" });
            div.css({ overflow: "hidden", position: "relative", "z-index": "2", left: "0px" });

            var liSize = o.vertical ? height(li) : width(li);   // Full li size(incl margin)-Used for animation
            var ulSize = liSize * itemLength;                   // size of full ul(total length, not just for the visible items)
            var divSize = liSize * v;                           // size of entire div(total length for just the visible items)

            li.css({ width: li.width(), height: li.height() });
            ul.css(sizeCss, ulSize + "px").css(animCss, -(curr * liSize));

            div.css(sizeCss, divSize + "px");                     // Width of the DIV. length of visible images

            if (o.btnPrev)
                $(o.btnPrev).click(function() {
                    return go(curr - o.scroll);
                });

            if (o.btnNext)
                $(o.btnNext).click(function() {
                    return go(curr + o.scroll);
                });

            if (o.btnGo)
                $.each(o.btnGo, function(i, val) {
                    $(val).click(function() {
                        return go(o.circular ? o.visible + i : i);
                    });
                });

            if (o.mouseWheel && div.mousewheel)
                div.mousewheel(function(e, d) {
                    return d > 0 ? go(curr - o.scroll) : go(curr + o.scroll);
                });

            if (o.auto)
                setInterval(function() {
                    go(curr + o.scroll);
                }, o.auto + o.speed);

            function vis() {
                return li.slice(curr).slice(0, v);
            };

            function go(to) {
                if (!running) {

                    if (o.beforeStart)
                        o.beforeStart.call(this, vis());

                    if (o.circular) {            // If circular we are in first or last, then goto the other end
                        if (to <= o.start - v - 1) {           // If first, then goto last
                            ul.css(animCss, -((itemLength - (v * 2)) * liSize) + "px");
                            // If "scroll" > 1, then the "to" might not be equal to the condition; it can be lesser depending on the number of elements.
                            curr = to == o.start - v - 1 ? itemLength - (v * 2) - 1 : itemLength - (v * 2) - o.scroll;
                        } else if (to >= itemLength - v + 1) { // If last, then goto first
                            ul.css(animCss, -((v) * liSize) + "px");
                            // If "scroll" > 1, then the "to" might not be equal to the condition; it can be greater depending on the number of elements.
                            curr = to == itemLength - v + 1 ? v + 1 : v + o.scroll;
                        } else curr = to;
                    } else {                    // If non-circular and to points to first or last, we just return.
                        if (to < 0 || to > itemLength - v) return;
                        else curr = to;
                    }                           // If neither overrides it, the curr will still be "to" and we can proceed.

                    running = true;

                    ul.animate(
                    animCss == "left" ? { left: -(curr * liSize)} : { top: -(curr * liSize) }, o.speed, o.easing,
                    function() {
                        if (o.afterEnd)
                            o.afterEnd.call(this, vis());
                        running = false;
                    }
                );
                    // Disable buttons when the carousel reaches the last/first, and enable when not
                    if (!o.circular) {
                        $(o.btnPrev + "," + o.btnNext).removeClass("disabled");
                        $((curr - o.scroll < 0 && o.btnPrev)
                        ||
                       (curr + o.scroll > itemLength - v && o.btnNext)
                        ||
                       []
                     ).addClass("disabled");
                    }

                }
                return false;
            };
        });
    };

    function css(el, prop) {
        return parseInt($.css(el[0], prop)) || 0;
    };
    function width(el) {
        return el[0].offsetWidth + css(el, 'marginLeft') + css(el, 'marginRight');
    };
    function height(el) {
        return el[0].offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom');
    };

})(jQuery);



/*
* Facebox (for jQuery)
* version: 1.2 (05/05/2008)
* @requires jQuery v1.2 or later
*
* Examples at http://famspam.com/facebox/
*
* Licensed under the MIT:
*   http://www.opensource.org/licenses/mit-license.php
*
* Copyright 2007, 2008 Chris Wanstrath [ chris@ozmm.org ]
*
* Usage:
*  
*  jQuery(document).ready(function() {
*    jQuery('a[rel*=facebox]').facebox() 
*  })
*
*  <a href="#terms" rel="facebox">Terms</a>
*    Loads the #terms div in the box
*
*  <a href="terms.html" rel="facebox">Terms</a>
*    Loads the terms.html page in the box
*
*  <a href="terms.png" rel="facebox">Terms</a>
*    Loads the terms.png image in the box
*
*
*  You can also use it programmatically:
* 
*    jQuery.facebox('some html')
*    jQuery.facebox('some html', 'my-groovy-style')
*
*  The above will open a facebox with "some html" as the content.
*    
*    jQuery.facebox(function($) { 
*      $.get('blah.html', function(data) { $.facebox(data) })
*    })
*
*  The above will show a loading screen before the passed function is called,
*  allowing for a better ajaxy experience.
*
*  The facebox function can also display an ajax page, an image, or the contents of a div:
*  
*    jQuery.facebox({ ajax: 'remote.html' })
*    jQuery.facebox({ ajax: 'remote.html' }, 'my-groovy-style')
*    jQuery.facebox({ image: 'stairs.jpg' })
*    jQuery.facebox({ image: 'stairs.jpg' }, 'my-groovy-style')
*    jQuery.facebox({ div: '#box' })
*    jQuery.facebox({ div: '#box' }, 'my-groovy-style')
*
*  Want to close the facebox?  Trigger the 'close.facebox' document event:
*
*    jQuery(document).trigger('close.facebox')
*
*  Facebox also has a bunch of other hooks:
*
*    loading.facebox
*    beforeReveal.facebox
*    reveal.facebox (aliased as 'afterReveal.facebox')
*    init.facebox
*
*  Simply bind a function to any of these hooks:
*
*   $(document).bind('reveal.facebox', function() { ...stuff to do after the facebox and contents are revealed... })
*
*/
(function($) {
    $.facebox = function(data, klass) {
        $.facebox.loading()

        if (data.ajax) fillFaceboxFromAjax(data.ajax, klass)
        else if (data.image) fillFaceboxFromImage(data.image, klass)
        else if (data.div) fillFaceboxFromHref(data.div, klass)
        else if ($.isFunction(data)) data.call($)
        else $.facebox.reveal(data, klass)
    }

    /*
    * Public, $.facebox methods
    */

    $.extend($.facebox, {
        settings: {
            opacity: 0,
            overlay: true,
            loadingImage: '/images/loading.gif',
            closeImage: '/images/closelabel.gif',
            imageTypes: ['png', 'jpg', 'jpeg', 'gif'],
            faceboxHtml: '\
    <div id="facebox" style="display:none;"> \
      <div class="popup"> \
        <table> \
          <tbody> \
            <tr> \
              <td class="tl"/><td class="b"/><td class="tr"/> \
            </tr> \
            <tr> \
              <td class="b"/> \
              <td class="body"> \
                <div class="fb-content"> \
                </div> \
                <div class="fb-footer"> \
                  <a href="#" class="close"> \
                     \
                  </a> \
                </div> \
              </td> \
              <td class="b"/> \
            </tr> \
            <tr> \
              <td class="bl"/><td class="b"/><td class="br"/> \
            </tr> \
          </tbody> \
        </table> \
      </div> \
    </div>'
        },

        loading: function() {
            init()
            if ($('#facebox .loading').length == 1) return true
            showOverlay()

            $('#facebox .fb-content').empty()
            $('#facebox .body').children().hide().end().
        append('<div class="loading"><img src="' + $.facebox.settings.loadingImage + '"/></div>')

            $('#facebox').css({
                top: getPageScroll()[1] + (getPageHeight() / 10),
                left: $(window).width() / 2 - 205
            }).show()

            $(document).bind('keydown.facebox', function(e) {
                if (e.keyCode == 27) $.facebox.close()
                return true
            })
            $(document).trigger('loading.facebox')
        },

        reveal: function(data, klass) {
            $(document).trigger('beforeReveal.facebox')
            if (klass) $('#facebox .fb-content').addClass(klass)
            $('#facebox .fb-content').append(data)
            $('#facebox .loading').remove()
            $('#facebox .body').children().fadeIn('normal')
            $('#facebox').css('left', $(window).width() / 2 - ($('#facebox table').width() / 2))
            $(document).trigger('reveal.facebox').trigger('afterReveal.facebox')
        },

        close: function() {
            $(document).trigger('close.facebox')
            return false
        }
    })

    /*
    * Public, $.fn methods
    */

    $.fn.facebox = function(settings) {
        init(settings)

        function clickHandler() {
            $.facebox.loading(true)

            // support for rel="facebox.inline_popup" syntax, to add a class
            // also supports deprecated "facebox[.inline_popup]" syntax
            var klass = this.rel.match(/facebox\[?\.(\w+)\]?/)
            if (klass) klass = klass[1]

            fillFaceboxFromHref(this.href, klass)
            return false
        }

        return this.bind('click.facebox', clickHandler)
    }

    /*
    * Private methods
    */

    // called one time to setup facebox on this page
    function init(settings) {
        if ($.facebox.settings.inited) return true
        else $.facebox.settings.inited = true

        $(document).trigger('init.facebox')
        makeCompatible()

        var imageTypes = $.facebox.settings.imageTypes.join('|')
        $.facebox.settings.imageTypesRegexp = new RegExp('\.(' + imageTypes + ')$', 'i')

        if (settings) $.extend($.facebox.settings, settings)
        $('body').append($.facebox.settings.faceboxHtml)

        var preload = [new Image(), new Image()]
        preload[0].src = $.facebox.settings.closeImage
        preload[1].src = $.facebox.settings.loadingImage

        $('#facebox').find('.b:first, .bl, .br, .tl, .tr').each(function() {
            preload.push(new Image())
            preload.slice(-1).src = $(this).css('background-image').replace(/url\((.+)\)/, '$1')
        })

        $('#facebox .close').click($.facebox.close)
        $('#facebox .close_image').attr('src', $.facebox.settings.closeImage)
    }

    // getPageScroll() by quirksmode.com
    function getPageScroll() {
        var xScroll, yScroll;
        if (self.pageYOffset) {
            yScroll = self.pageYOffset;
            xScroll = self.pageXOffset;
        } else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
            yScroll = document.documentElement.scrollTop;
            xScroll = document.documentElement.scrollLeft;
        } else if (document.body) {// all other Explorers
            yScroll = document.body.scrollTop;
            xScroll = document.body.scrollLeft;
        }
        return new Array(xScroll, yScroll)
    }

    // Adapted from getPageSize() by quirksmode.com
    function getPageHeight() {
        var windowHeight
        if (self.innerHeight) {	// all except Explorer
            windowHeight = self.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
            windowHeight = document.documentElement.clientHeight;
        } else if (document.body) { // other Explorers
            windowHeight = document.body.clientHeight;
        }
        return windowHeight
    }

    // Backwards compatibility
    function makeCompatible() {
        var $s = $.facebox.settings

        $s.loadingImage = $s.loading_image || $s.loadingImage
        $s.closeImage = $s.close_image || $s.closeImage
        $s.imageTypes = $s.image_types || $s.imageTypes
        $s.faceboxHtml = $s.facebox_html || $s.faceboxHtml
    }

    // Figures out what you want to display and displays it
    // formats are:
    //     div: #id
    //   image: blah.extension
    //    ajax: anything else
    function fillFaceboxFromHref(href, klass) {
        // div
        if (href.match(/#/)) {
            var url = window.location.href.split('#')[0]
            var target = href.replace(url, '')
            $.facebox.reveal($(target).show().replaceWith("<div id='facebox_moved'></div>"), klass)

            // image
        } else if (href.match($.facebox.settings.imageTypesRegexp)) {
            fillFaceboxFromImage(href, klass)
            // ajax
        } else {
            fillFaceboxFromAjax(href, klass)
        }
    }

    function fillFaceboxFromImage(href, klass) {
        var image = new Image()
        image.onload = function() {
            $.facebox.reveal('<div class="image"><img src="' + image.src + '" /></div>', klass)
        }
        image.src = href
    }

    function fillFaceboxFromAjax(href, klass) {
        $.get(href, function(data) { $.facebox.reveal(data, klass) })
    }

    function skipOverlay() {
        return $.facebox.settings.overlay == false || $.facebox.settings.opacity === null
    }

    function showOverlay() {
        if (skipOverlay()) return

        if ($('#facebox_overlay').length == 0)
            $("body").append('<div id="facebox_overlay" class="facebox_hide"></div>')

        $('#facebox_overlay').hide().addClass("facebox_overlayBG")
      .css('opacity', $.facebox.settings.opacity)
      .click(function() { $(document).trigger('close.facebox') })
      .fadeIn(200)
        return false
    }

    function hideOverlay() {
        if (skipOverlay()) return

        $('#facebox_overlay').fadeOut(200, function() {
            $("#facebox_overlay").removeClass("facebox_overlayBG")
            $("#facebox_overlay").addClass("facebox_hide")
            $("#facebox_overlay").remove()
        })

        return false
    }

    /*
    * Bindings
    */

    $(document).bind('close.facebox', function() {
        $(document).unbind('keydown.facebox')
        $('#facebox').fadeOut(function() {
            if ($('#facebox_moved').length == 0) $('#facebox .fb-content').removeClass().addClass('fb-content')
            else $('#facebox_moved').replaceWith($('#facebox .fb-content').children().hide())
            hideOverlay()
            $('#facebox .loading').remove()
        })
    })

})(jQuery);


/*--------------------------------------------------------------------------
Toggle Field Input
--------------------------------------------------------------------------*/
jQuery.fn.toggleVal = function(focusClass) {
this.each(function() {
	$(this).focus(function() {
		if($(this).val() == this.defaultValue) { $(this).val(""); }
		if(focusClass) { $(this).addClass(focusClass); }
	}).blur(function() {
		if($(this).val() == "") { $(this).val(this.defaultValue); }
		if(focusClass) { $(this).removeClass(focusClass); }
	});
  });
}

/*Execute my function*/
$(document).ready(function() {
  
  //Customer Details
  $("#cdEmail, #cdPhoneDay, #cdPhoneEvening, #cdConfirmEmail, #cdMobile").toggleVal("active");  
  
  //Billing Address
  $("#baTitle, #baFirstname, #baSurname, #baAddress1, #baAddress2, #baTownCity, #baPostcode, #baCountry").toggleVal("active");
  
  //Delivery Address
  $("#daTitle, #daFirstname, #daSurname, #daAddress1, #daAddress2, #daTownCity, #daPostcode, #daCountry").toggleVal("active");
  
  //Promotional Code / Comments
  $("#frmPromotionCode, #daComments").toggleVal("active");

  //Make a Payment
  $("#pdCardIssuer, #pdCardHolder, #pdCardNumber, #pdCardIssue, #pdStartDate, #pdStartYear, #pdEndDate, #pdEndYear, #pdSecurityNumber").toggleVal("active");
  
});

/*--------------------------------------------------------------------------
Hover Anything
--------------------------------------------------------------------------*/
$(document).ready(function() {

 $('submit').hover(function() {
    $(this).addClass('jsHover');
  }, function() {
    $(this).removeClass('jsHover');
 }); 
 
});

/*--------------------------------------------------------------------------
Hide / Show Element
--------------------------------------------------------------------------*/
$(document).ready(function() {
						   
   $('#creditcard').hide();   
   $('#aQuestion').click(function(){
     $('#creditcard').toggle();
   });
   
 });
 
 function disableButton(el)
 {
    el.disabled=true;
}

/*-------------------------------------------------------
Google Yellow text box fix
--------------------------------------------------------*/

if (window.attachEvent)
    window.attachEvent("onload", setListeners);

function setListeners() {
    inputList = document.getElementsByTagName("INPUT");
    for (i = 0; i < inputList.length; i++) {
        inputList[i].attachEvent("onpropertychange", restoreStyles);
        inputList[i].style.backgroundColor = "";
    }
    selectList = document.getElementsByTagName("SELECT");
    for (i = 0; i < selectList.length; i++) {
        selectList[i].attachEvent("onpropertychange", restoreStyles);
        selectList[i].style.backgroundColor = "";
    }
}

function restoreStyles() {
    if (event.srcElement.style.backgroundColor != "" && event.srcElement.style.backgroundColor != "#a0d0ff") {
        event.srcElement.style.backgroundColor = "#fff"; /* color of choice for AutoFill */
        //document.all['googleblurb'].style.display = "block";
    }
}
  
/*--------------------------------------------------------------------------
Flash Embedding [SWF Object]
--------------------------------------------------------------------------*/

if (typeof deconcept == "undefined") var deconcept = new Object();
if (typeof deconcept.util == "undefined") deconcept.util = new Object();
if (typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
deconcept.SWFObject = function(swf, id, w, h, ver, c, quality, xiRedirectUrl, redirectUrl, detectKey) {
    if (!document.getElementById) { return; }
    this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
    this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
    this.params = new Object();
    this.variables = new Object();
    this.attributes = new Array();
    if (swf) { this.setAttribute('swf', swf); }
    if (id) { this.setAttribute('id', id); }
    if (w) { this.setAttribute('width', w); }
    if (h) { this.setAttribute('height', h); }
    if (ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
    this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
    if (!window.opera && document.all && this.installedVer.major > 7) {
        // only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE
        deconcept.SWFObject.doPrepUnload = true;
    }
    if (c) { this.addParam('bgcolor', c); }
    var q = quality ? quality : 'high';
    this.addParam('quality', q);
    this.setAttribute('useExpressInstall', false);
    this.setAttribute('doExpressInstall', false);
    var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
    this.setAttribute('xiRedirectUrl', xir);
    this.setAttribute('redirectUrl', '');
    if (redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
}
deconcept.SWFObject.prototype = {
    useExpressInstall: function(path) {
        this.xiSWFPath = !path ? "expressinstall.swf" : path;
        this.setAttribute('useExpressInstall', true);
    },
    setAttribute: function(name, value) {
        this.attributes[name] = value;
    },
    getAttribute: function(name) {
        return this.attributes[name];
    },
    addParam: function(name, value) {
        this.params[name] = value;
    },
    getParams: function() {
        return this.params;
    },
    addVariable: function(name, value) {
        this.variables[name] = value;
    },
    getVariable: function(name) {
        return this.variables[name];
    },
    getVariables: function() {
        return this.variables;
    },
    getVariablePairs: function() {
        var variablePairs = new Array();
        var key;
        var variables = this.getVariables();
        for (key in variables) {
            variablePairs[variablePairs.length] = key + "=" + variables[key];
        }
        return variablePairs;
    },
    getSWFHTML: function() {
        var swfNode = "";
        if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
            if (this.getAttribute("doExpressInstall")) {
                this.addVariable("MMplayerType", "PlugIn");
                this.setAttribute('swf', this.xiSWFPath);
            }
            swfNode = '<embed type="application/x-shockwave-flash" src="' + this.getAttribute('swf') + '" width="' + this.getAttribute('width') + '" height="' + this.getAttribute('height') + '" style="' + this.getAttribute('style') + '"';
            swfNode += ' id="' + this.getAttribute('id') + '" name="' + this.getAttribute('id') + '" ';
            var params = this.getParams();
            for (var key in params) { swfNode += [key] + '="' + params[key] + '" '; }
            var pairs = this.getVariablePairs().join("&");
            if (pairs.length > 0) { swfNode += 'flashvars="' + pairs + '"'; }
            swfNode += '/>';
        } else { // PC IE
            if (this.getAttribute("doExpressInstall")) {
                this.addVariable("MMplayerType", "ActiveX");
                this.setAttribute('swf', this.xiSWFPath);
            }
            swfNode = '<object id="' + this.getAttribute('id') + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + this.getAttribute('width') + '" height="' + this.getAttribute('height') + '" style="' + this.getAttribute('style') + '">';
            swfNode += '<param name="movie" value="' + this.getAttribute('swf') + '" />';
            var params = this.getParams();
            for (var key in params) {
                swfNode += '<param name="' + key + '" value="' + params[key] + '" />';
            }
            var pairs = this.getVariablePairs().join("&");
            if (pairs.length > 0) { swfNode += '<param name="flashvars" value="' + pairs + '" />'; }
            swfNode += "</object>";
        }
        return swfNode;
    },
    write: function(elementId) {
        if (this.getAttribute('useExpressInstall')) {
            // check to see if we need to do an express install
            var expressInstallReqVer = new deconcept.PlayerVersion([6, 0, 65]);
            if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
                this.setAttribute('doExpressInstall', true);
                this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
                document.title = document.title.slice(0, 47) + " - Flash Player Installation";
                this.addVariable("MMdoctitle", document.title);
            }
        }
        if (this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))) {
            var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
            n.innerHTML = this.getSWFHTML();
            return true;
        } else {
            if (this.getAttribute('redirectUrl') != "") {
                document.location.replace(this.getAttribute('redirectUrl'));
            }
        }
        return false;
    }
}

/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function() {
    var PlayerVersion = new deconcept.PlayerVersion([0, 0, 0]);
    if (navigator.plugins && navigator.mimeTypes.length) {
        var x = navigator.plugins["Shockwave Flash"];
        if (x && x.description) {
            PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
        }
    } else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0) { // if Windows CE
        var axo = 1;
        var counter = 3;
        while (axo) {
            try {
                counter++;
                axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + counter);
                //				document.write("player v: "+ counter);
                PlayerVersion = new deconcept.PlayerVersion([counter, 0, 0]);
            } catch (e) {
                axo = null;
            }
        }
    } else { // Win IE (non mobile)
        // do minor version lookup in IE, but avoid fp6 crashing issues
        // see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
        try {
            var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
        } catch (e) {
            try {
                var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
                PlayerVersion = new deconcept.PlayerVersion([6, 0, 21]);
                axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
            } catch (e) {
                if (PlayerVersion.major == 6) {
                    return PlayerVersion;
                }
            }
            try {
                axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            } catch (e) { }
        }
        if (axo != null) {
            PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
        }
    }
    return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion) {
    this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
    this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
    this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(fv) {
    if (this.major < fv.major) return false;
    if (this.major > fv.major) return true;
    if (this.minor < fv.minor) return false;
    if (this.minor > fv.minor) return true;
    if (this.rev < fv.rev) return false;
    return true;
}
/* ---- get value of query string param ---- */
deconcept.util = {
    getRequestParameter: function(param) {
        var q = document.location.search || document.location.hash;
        if (param == null) { return q; }
        if (q) {
            var pairs = q.substring(1).split("&");
            for (var i = 0; i < pairs.length; i++) {
                if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
                    return pairs[i].substring((pairs[i].indexOf("=") + 1));
                }
            }
        }
        return "";
    }
}
/* fix for video streaming bug */
deconcept.SWFObjectUtil.cleanupSWFs = function() {
    var objects = document.getElementsByTagName("OBJECT");
    for (var i = objects.length - 1; i >= 0; i--) {
        objects[i].style.display = 'none';
        for (var x in objects[i]) {
            if (typeof objects[i][x] == 'function') {
                objects[i][x] = function() { };
            }
        }
    }
}
// fixes bug in some fp9 versions see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
if (deconcept.SWFObject.doPrepUnload) {
    if (!deconcept.unloadSet) {
        deconcept.SWFObjectUtil.prepUnload = function() {
            __flash_unloadHandler = function() { };
            __flash_savedUnloadHandler = function() { };
            window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs);
        }
        window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload);
        deconcept.unloadSet = true;
    }
}
/* add document.getElementById if needed (mobile IE < 5) */
if (!document.getElementById && document.all) { document.getElementById = function(id) { return document.all[id]; } }

/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;

/*--------------------------------------------------------------------------
Homepage / Slider
--------------------------------------------------------------------------*/
/*
* jQuery Nivo Slider v2.0
* http://nivo.dev7studios.com
*
* Copyright 2010, Gilbert Pellegrom
* Free to use and abuse under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
* 
* May 2010 - Pick random effect from specified set of effects by toronegro
* May 2010 - controlNavThumbsFromRel option added by nerd-sh
* May 2010 - Do not start nivoRun timer if there is only 1 slide by msielski
* April 2010 - controlNavThumbs option added by Jamie Thompson (http://jamiethompson.co.uk)
* March 2010 - manualAdvance option added by HelloPablo (http://hellopablo.co.uk)
*/

(function($) {

    $.fn.nivoSlider = function(options) {

        //Defaults are below
        var settings = $.extend({}, $.fn.nivoSlider.defaults, options);

        return this.each(function() {
            //Useful variables. Play carefully.
            var vars = {
                currentSlide: 0,
                currentImage: '',
                totalSlides: 0,
                randAnim: '',
                running: false,
                paused: false,
                stop: false
            };

            //Get this slider
            var slider = $(this);
            slider.data('nivo:vars', vars);
            slider.css('position', 'relative');
            slider.addClass('nivoSlider');

            //Find our slider children
            var kids = slider.children();
            kids.each(function() {
                var child = $(this);
                var link = '';
                if (!child.is('img')) {
                    if (child.is('a')) {
                        child.addClass('nivo-imageLink');
                        link = child;
                    }
                    child = child.find('img:first');
                }
                //Get img width & height
                var childWidth = child.width();
                if (childWidth == 0) childWidth = child.attr('width');
                var childHeight = child.height();
                if (childHeight == 0) childHeight = child.attr('height');
                //Resize the slider
                if (childWidth > slider.width()) {
                    slider.width(childWidth);
                }
                if (childHeight > slider.height()) {
                    slider.height(childHeight);
                }
                if (link != '') {
                    link.css('display', 'none');
                }
                child.css('display', 'none');
                vars.totalSlides++;
            });

            //Set startSlide
            if (settings.startSlide > 0) {
                if (settings.startSlide >= vars.totalSlides) settings.startSlide = vars.totalSlides - 1;
                vars.currentSlide = settings.startSlide;
            }

            //Get initial image
            if ($(kids[vars.currentSlide]).is('img')) {
                vars.currentImage = $(kids[vars.currentSlide]);
            } else {
                vars.currentImage = $(kids[vars.currentSlide]).find('img:first');
            }

            //Show initial link
            if ($(kids[vars.currentSlide]).is('a')) {
                $(kids[vars.currentSlide]).css('display', 'block');
            }

            //Set first background
            slider.css('background', 'url(' + vars.currentImage.attr('src') + ') no-repeat');

            //Add initial slices
            for (var i = 0; i < settings.slices; i++) {
                var sliceWidth = Math.round(slider.width() / settings.slices);
                if (i == settings.slices - 1) {
                    slider.append(
						$('<div class="nivo-slice"></div>').css({ left: (sliceWidth * i) + 'px', width: (slider.width() - (sliceWidth * i)) + 'px' })
					);
                } else {
                    slider.append(
						$('<div class="nivo-slice"></div>').css({ left: (sliceWidth * i) + 'px', width: sliceWidth + 'px' })
					);
                }
            }

            //Create caption
            slider.append(
				$('<div class="nivo-caption"><p></p></div>').css({ display: 'none', opacity: settings.captionOpacity })
			);
            //Process initial  caption
            if (vars.currentImage.attr('title') != '') {
                $('.nivo-caption p', slider).html(vars.currentImage.attr('title'));
                $('.nivo-caption', slider).fadeIn(settings.animSpeed);
            }

            //In the words of Super Mario "let's a go!"
            var timer = 0;
            if (!settings.manualAdvance && kids.length > 1) {
                timer = setInterval(function() { nivoRun(slider, kids, settings, false); }, settings.pauseTime);
            }

            //Add Direction nav
            if (settings.directionNav) {
                slider.append('<div class="nivo-directionNav"><a class="nivo-prevNav">Prev</a><a class="nivo-nextNav">Next</a></div>');

                //Hide Direction nav
                if (settings.directionNavHide) {
                    $('.nivo-directionNav', slider).hide();
                    slider.hover(function() {
                        $('.nivo-directionNav', slider).show();
                    }, function() {
                        $('.nivo-directionNav', slider).hide();
                    });
                }

                $('a.nivo-prevNav', slider).live('click', function() {
                    if (vars.running) return false;
                    clearInterval(timer);
                    timer = '';
                    vars.currentSlide -= 2;
                    nivoRun(slider, kids, settings, 'prev');
                });

                $('a.nivo-nextNav', slider).live('click', function() {
                    if (vars.running) return false;
                    clearInterval(timer);
                    timer = '';
                    nivoRun(slider, kids, settings, 'next');
                });
            }

            //Add Control nav
            if (settings.controlNav) {
                var nivoControl = $('<div class="nivo-controlNav"></div>');
                slider.append(nivoControl);
                for (var i = 0; i < kids.length; i++) {
                    if (settings.controlNavThumbs) {
                        var child = kids.eq(i);
                        if (!child.is('img')) {
                            child = child.find('img:first');
                        }
                        if (settings.controlNavThumbsFromRel) {
                            nivoControl.append('<a class="nivo-control" rel="' + i + '"><img src="' + child.attr('rel') + '" alt="" /></a>');
                        } else {
                            nivoControl.append('<a class="nivo-control" rel="' + i + '"><img src="' + child.attr('src').replace(settings.controlNavThumbsSearch, settings.controlNavThumbsReplace) + '" alt="" /></a>');
                        }
                    } else {
                        nivoControl.append('<a class="nivo-control" rel="' + i + '">' + i + '</a>');
                    }

                }
                //Set initial active link
                $('.nivo-controlNav a:eq(' + vars.currentSlide + ')', slider).addClass('active');

                $('.nivo-controlNav a', slider).live('click', function() {
                    if (vars.running) return false;
                    if ($(this).hasClass('active')) return false;
                    clearInterval(timer);
                    timer = '';
                    slider.css('background', 'url(' + vars.currentImage.attr('src') + ') no-repeat');
                    vars.currentSlide = $(this).attr('rel') - 1;
                    nivoRun(slider, kids, settings, 'control');
                });
            }

            //Keyboard Navigation
            if (settings.keyboardNav) {
                $(window).keypress(function(event) {
                    //Left
                    if (event.keyCode == '37') {
                        if (vars.running) return false;
                        clearInterval(timer);
                        timer = '';
                        vars.currentSlide -= 2;
                        nivoRun(slider, kids, settings, 'prev');
                    }
                    //Right
                    if (event.keyCode == '39') {
                        if (vars.running) return false;
                        clearInterval(timer);
                        timer = '';
                        nivoRun(slider, kids, settings, 'next');
                    }
                });
            }

            //For pauseOnHover setting
            if (settings.pauseOnHover) {
                slider.hover(function() {
                    vars.paused = true;
                    clearInterval(timer);
                    timer = '';
                }, function() {
                    vars.paused = false;
                    //Restart the timer
                    if (timer == '' && !settings.manualAdvance) {
                        timer = setInterval(function() { nivoRun(slider, kids, settings, false); }, settings.pauseTime);
                    }
                });
            }

            //Event when Animation finishes
            slider.bind('nivo:animFinished', function() {
                vars.running = false;
                //Hide child links
                $(kids).each(function() {
                    if ($(this).is('a')) {
                        $(this).css('display', 'none');
                    }
                });
                //Show current link
                if ($(kids[vars.currentSlide]).is('a')) {
                    $(kids[vars.currentSlide]).css('display', 'block');
                }
                //Restart the timer
                if (timer == '' && !vars.paused && !settings.manualAdvance) {
                    timer = setInterval(function() { nivoRun(slider, kids, settings, false); }, settings.pauseTime);
                }
                //Trigger the afterChange callback
                settings.afterChange.call(this);
            });
        });

        function nivoRun(slider, kids, settings, nudge) {
            //Get our vars
            var vars = slider.data('nivo:vars');
            if ((!vars || vars.stop) && !nudge) return false;

            //Trigger the beforeChange callback
            settings.beforeChange.call(this);

            //Set current background before change
            if (!nudge) {
                slider.css('background', 'url(' + vars.currentImage.attr('src') + ') no-repeat');
            } else {
                if (nudge == 'prev') {
                    slider.css('background', 'url(' + vars.currentImage.attr('src') + ') no-repeat');
                }
                if (nudge == 'next') {
                    slider.css('background', 'url(' + vars.currentImage.attr('src') + ') no-repeat');
                }
            }
            vars.currentSlide++;
            if (vars.currentSlide == vars.totalSlides) {
                vars.currentSlide = 0;
                //Trigger the slideshowEnd callback
                settings.slideshowEnd.call(this);
            }
            if (vars.currentSlide < 0) vars.currentSlide = (vars.totalSlides - 1);
            //Set vars.currentImage
            if ($(kids[vars.currentSlide]).is('img')) {
                vars.currentImage = $(kids[vars.currentSlide]);
            } else {
                vars.currentImage = $(kids[vars.currentSlide]).find('img:first');
            }

            //Set acitve links
            if (settings.controlNav) {
                $('.nivo-controlNav a', slider).removeClass('active');
                $('.nivo-controlNav a:eq(' + vars.currentSlide + ')', slider).addClass('active');
            }

            //Process caption
            if (vars.currentImage.attr('title') != '') {
                if ($('.nivo-caption', slider).css('display') == 'block') {
                    $('.nivo-caption p', slider).fadeOut(settings.animSpeed, function() {
                        $(this).html(vars.currentImage.attr('title'));
                        $(this).fadeIn(settings.animSpeed);
                    });
                } else {
                    $('.nivo-caption p', slider).html(vars.currentImage.attr('title'));
                }
                $('.nivo-caption', slider).fadeIn(settings.animSpeed);
            } else {
                $('.nivo-caption', slider).fadeOut(settings.animSpeed);
            }

            //Set new slice backgrounds
            var i = 0;
            $('.nivo-slice', slider).each(function() {
                var sliceWidth = Math.round(slider.width() / settings.slices);
                $(this).css({ height: '0px', opacity: '0',
                    background: 'url(' + vars.currentImage.attr('src') + ') no-repeat -' + ((sliceWidth + (i * sliceWidth)) - sliceWidth) + 'px 0%'
                });
                i++;
            });

            if (settings.effect == 'random') {
                var anims = new Array("sliceDownRight", "sliceDownLeft", "sliceUpRight", "sliceUpLeft", "sliceUpDown", "sliceUpDownLeft", "fold", "fade");
                vars.randAnim = anims[Math.floor(Math.random() * (anims.length + 1))];
                if (vars.randAnim == undefined) vars.randAnim = 'fade';
            }

            //Run random effect from specified set (eg: effect:'fold,fade')
            if (settings.effect.indexOf(',') != -1) {
                var anims = settings.effect.split(',');
                vars.randAnim = $.trim(anims[Math.floor(Math.random() * anims.length)]);
            }

            //Run effects
            vars.running = true;
            if (settings.effect == 'sliceDown' || settings.effect == 'sliceDownRight' || vars.randAnim == 'sliceDownRight' ||
				settings.effect == 'sliceDownLeft' || vars.randAnim == 'sliceDownLeft') {
                var timeBuff = 0;
                var i = 0;
                var slices = $('.nivo-slice', slider);
                if (settings.effect == 'sliceDownLeft' || vars.randAnim == 'sliceDownLeft') slices = $('.nivo-slice', slider).reverse();
                slices.each(function() {
                    var slice = $(this);
                    slice.css('top', '0px');
                    if (i == settings.slices - 1) {
                        setTimeout(function() {
                            slice.animate({ height: '100%', opacity: '1.0' }, settings.animSpeed, '', function() { slider.trigger('nivo:animFinished'); });
                        }, (100 + timeBuff));
                    } else {
                        setTimeout(function() {
                            slice.animate({ height: '100%', opacity: '1.0' }, settings.animSpeed);
                        }, (100 + timeBuff));
                    }
                    timeBuff += 50;
                    i++;
                });
            }
            else if (settings.effect == 'sliceUp' || settings.effect == 'sliceUpRight' || vars.randAnim == 'sliceUpRight' ||
					settings.effect == 'sliceUpLeft' || vars.randAnim == 'sliceUpLeft') {
                var timeBuff = 0;
                var i = 0;
                var slices = $('.nivo-slice', slider);
                if (settings.effect == 'sliceUpLeft' || vars.randAnim == 'sliceUpLeft') slices = $('.nivo-slice', slider).reverse();
                slices.each(function() {
                    var slice = $(this);
                    slice.css('bottom', '0px');
                    if (i == settings.slices - 1) {
                        setTimeout(function() {
                            slice.animate({ height: '100%', opacity: '1.0' }, settings.animSpeed, '', function() { slider.trigger('nivo:animFinished'); });
                        }, (100 + timeBuff));
                    } else {
                        setTimeout(function() {
                            slice.animate({ height: '100%', opacity: '1.0' }, settings.animSpeed);
                        }, (100 + timeBuff));
                    }
                    timeBuff += 50;
                    i++;
                });
            }
            else if (settings.effect == 'sliceUpDown' || settings.effect == 'sliceUpDownRight' || vars.randAnim == 'sliceUpDown' ||
					settings.effect == 'sliceUpDownLeft' || vars.randAnim == 'sliceUpDownLeft') {
                var timeBuff = 0;
                var i = 0;
                var v = 0;
                var slices = $('.nivo-slice', slider);
                if (settings.effect == 'sliceUpDownLeft' || vars.randAnim == 'sliceUpDownLeft') slices = $('.nivo-slice', slider).reverse();
                slices.each(function() {
                    var slice = $(this);
                    if (i == 0) {
                        slice.css('top', '0px');
                        i++;
                    } else {
                        slice.css('bottom', '0px');
                        i = 0;
                    }

                    if (v == settings.slices - 1) {
                        setTimeout(function() {
                            slice.animate({ height: '100%', opacity: '1.0' }, settings.animSpeed, '', function() { slider.trigger('nivo:animFinished'); });
                        }, (100 + timeBuff));
                    } else {
                        setTimeout(function() {
                            slice.animate({ height: '100%', opacity: '1.0' }, settings.animSpeed);
                        }, (100 + timeBuff));
                    }
                    timeBuff += 50;
                    v++;
                });
            }
            else if (settings.effect == 'fold' || vars.randAnim == 'fold') {
                var timeBuff = 0;
                var i = 0;
                $('.nivo-slice', slider).each(function() {
                    var slice = $(this);
                    var origWidth = slice.width();
                    slice.css({ top: '0px', height: '100%', width: '0px' });
                    if (i == settings.slices - 1) {
                        setTimeout(function() {
                            slice.animate({ width: origWidth, opacity: '1.0' }, settings.animSpeed, '', function() { slider.trigger('nivo:animFinished'); });
                        }, (100 + timeBuff));
                    } else {
                        setTimeout(function() {
                            slice.animate({ width: origWidth, opacity: '1.0' }, settings.animSpeed);
                        }, (100 + timeBuff));
                    }
                    timeBuff += 50;
                    i++;
                });
            }
            else if (settings.effect == 'fade' || vars.randAnim == 'fade') {
                var i = 0;
                $('.nivo-slice', slider).each(function() {
                    $(this).css('height', '100%');
                    if (i == settings.slices - 1) {
                        $(this).animate({ opacity: '1.0' }, (settings.animSpeed * 2), '', function() { slider.trigger('nivo:animFinished'); });
                    } else {
                        $(this).animate({ opacity: '1.0' }, (settings.animSpeed * 2));
                    }
                    i++;
                });
            }
        }
    };

    //Default settings
    $.fn.nivoSlider.defaults = {
        effect: 'random',
        slices: 20,
        animSpeed: 400,
        pauseTime: 10000,
        startSlide: 0,
        directionNav: false,
        directionNavHide: true,
        controlNav: true,
        controlNavThumbs: false,
        controlNavThumbsFromRel: false,
        controlNavThumbsSearch: '.jpg',
        controlNavThumbsReplace: '_thumb.jpg',
        keyboardNav: true,
        pauseOnHover: true,
        manualAdvance: false,
        captionOpacity: 1,
        beforeChange: function() { },
        afterChange: function() { },
        slideshowEnd: function() { }
    };

    $.fn.reverse = [].reverse;

})(jQuery);

/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/

var offsetfrommouse = [15, 15]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration = 0; //duration in seconds image should remain visible. 0 for always.
var currentimageheight = 270; // maximum image size.

if (document.getElementById || document.all) {
    document.write('<div id="trailimageid">');
    document.write('</div>');
}

function gettrailobj() {
    if (document.getElementById)
        return document.getElementById("trailimageid").style
    else if (document.all)
        return document.all.trailimagid.style
}

function gettrailobjnostyle() {
    if (document.getElementById)
        return document.getElementById("trailimageid")
    else if (document.all)
        return document.all.trailimagid
}


function truebody() {
    return (!window.opera && document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body
}

function showtrail(imagename, title, description, showthumb, height) {

    if (height > 0) {
        currentimageheight = height;
    }

    document.onmousemove = followmouse;

    newHTML = '<div style="padding: 0; background: transparent; border: none;">';

    if (showthumb > 0) {
        newHTML = newHTML + '<div align="center" style="padding: 15px 20px;">';
        newHTML = newHTML + '<img src="' + imagename + '" border="0"></div>';
        // newHTML = newHTML + '<h2>' + title + '</h2>';
    }

    gettrailobjnostyle().innerHTML = newHTML;
    gettrailobj().visibility = "visible";

}

function hidetrail() {
    gettrailobj().visibility = "hidden"
    document.onmousemove = ""
    gettrailobj().left = "-500px"

}

function followmouse(e) {

    var xcoord = offsetfrommouse[0]
    var ycoord = offsetfrommouse[1]

    var docwidth = document.all ? truebody().scrollLeft + truebody().clientWidth : pageXOffset + window.innerWidth - 15
    var docheight = document.all ? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

    if (typeof e != "undefined") {
        if (docwidth - e.pageX < 380) {
            xcoord = e.pageX - xcoord - 400; // Move to the left side of the cursor
        } else {
            xcoord += e.pageX;
        }
        if (docheight - e.pageY < (currentimageheight + 110)) {
            ycoord += e.pageY - Math.max(0, (110 + currentimageheight + e.pageY - docheight - truebody().scrollTop));
        } else {
            ycoord += e.pageY;
        }

    } else if (typeof window.event != "undefined") {
        if (docwidth - event.clientX < 380) {
            xcoord = event.clientX + truebody().scrollLeft - xcoord - 400; // Move to the left side of the cursor
        } else {
            xcoord += truebody().scrollLeft + event.clientX
        }
        if (docheight - event.clientY < (currentimageheight + 110)) {
            ycoord += event.clientY + truebody().scrollTop - Math.max(0, (110 + currentimageheight + event.clientY - docheight));
        } else {
            ycoord += truebody().scrollTop + event.clientY;
        }
    }

    var docwidth = document.all ? truebody().scrollLeft + truebody().clientWidth : pageXOffset + window.innerWidth - 15
    var docheight = document.all ? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
    if (ycoord < 0) { ycoord = ycoord * -1; }
    gettrailobj().left = xcoord + "px"
    gettrailobj().top = ycoord + "px"

}

 /*--------------------------------------------------------------------------
                         MultiLine Text Box Limiter
--------------------------------------------------------------------------*/
/*Function to check if max chars/rows is reached*/
var pasted = false;

function detectPaste()
{
    pasted = false;
    //alert(pasted);
}

function limitTextarea(textarea,maxLines,maxChar,label)
{ 
    var newLabel = document.getElementById(label);
    
    if(pasted)
    {
        var full = textarea.value;
        var one = full.substring(0, maxChar);
        
        var three = '';
        var four = '';
      
        one = one.substring(0, one.lastIndexOf(' ')).trim();
        var two = full.substring(one.length).trim();
        
        if(maxLines > 2)
        {
            two = full.substring(one.length, one.length + maxChar).trim();
            three = full.substring(one.length + maxChar, one.length + maxChar + maxChar).trim();
            four = full.substring(one.length + maxChar + maxChar, one.length + maxChar + maxChar + maxChar).trim();
            
            textarea.value = one + '\n' + two + '\n' + three + '\n' + four;
        }
        else
        {
            textarea.value = one + '\n' + two;
        }

        pasted = '';
    }
    
    var lines=textarea.value.replace(/\r/g,'').split('\n'),
    lines_removed,
    char_removed,
    i;

    if(maxLines&&lines.length>maxLines)
    {
        lines=lines.slice(0,maxLines);
        lines_removed=1
    }
    
    if(maxChar)
    {
        i=lines.length;
        while(i-->0)if(lines[i].length>maxChar)
        {
            lines[i]=lines[i].slice(0,maxChar);
            char_removed=1
        }
        if(char_removed||lines_removed)
        {
            textarea.value=lines.join('\n')
        }

        function watchTextarea()
        {
            document.getElementById('resticted').onkeyup()
        }
    }
    
    var fullLength = textarea.value.replace(/\r/g,'').replace(/\n/g,'').length;
    
    if(fullLength > 0)
        newLabel.innerHTML = '(' + (maxLines - lines.length) + ' lines, '
    else
        newLabel.innerHTML = '(' + maxLines + ' lines, '
    
    newLabel.innerHTML += (maxChar * maxLines) - fullLength + ' chars left)';
}

/*--------------------------------------------------------------------------
                         SingleLine Text Box Counter
--------------------------------------------------------------------------*/
/*Function to display charachter counter.*/

function limitTextbox(textbox,maxChar,label)
{
    var newLabel = document.getElementById(label);
    
    var lines=textbox.value.replace(/\r/g,'').split('\n'),
    lines_removed,
    char_removed,
    i;
    
    if(maxChar)
    {
        i=lines.length;
        while(i-->0)if(lines[i].length>maxChar)
        {
	        lines[i]=lines[i].slice(0,maxChar);
	        char_removed=1
        }
        if(char_removed||lines_removed)
        {
	        textbox.value=lines.join('\n')
        }

        function watchTextarea()
        {
	        document.getElementById('resticted').onkeyup()
        }
    }
    
    var fullLength = textbox.value.replace(/\r/g,'').replace(/\n/g,'').length;
    
    newLabel.innerHTML = '(' + (maxChar - fullLength) + ' chars left)';
}

/////////////////   PRINT FUNCTION  /////////////////
function doPrint() {
    window.print();
    return false;
}

