﻿(function($) {
    $.fn.contentSlider = $.fn.contentslider = function(delay, childQuery) {
        delay = delay || 5000;
        initTicker = function(el, cQ) {
            stopTicker(el);
            el.items = $(cQ, el);
            el.items.not(":eq(0)").hide().end();
            el.currentitem = 0;
            startTicker(el);
        };
        startTicker = function(el) {
            el.tickfn = setInterval(function() { doTick(el) }, delay)
        };
        stopTicker = function(el) {
            clearInterval(el.tickfn);
        };
        pauseTicker = function(el) {
            el.pause = true;
        };
        resumeTicker = function(el) {
            el.pause = false;
        };
        doTick = function(el) {
            if (el.pause) return;
            el.pause = true;
            $(el.items[el.currentitem]).fadeOut("slow",
			function() {
            $(this).fadeOut("slow");
                el.currentitem = ++el.currentitem % (el.items.size());
                $(el.items[el.currentitem]).fadeIn("slow",
					function() {
                    el.pause = false;
                }
				);
            }
		);
        };
        this.each(
		function() {
            initTicker(this, childQuery);
        }
	)
	.addClass("newsticker")
	.hover(
		function() {
            pauseTicker(this);
        },
		function() {
            resumeTicker(this);
        }
	);
        return this;
    };

})(jQuery);

$(document).ready(function() {
    $("ul.contact-inner li").eq(0).show();
    $("ul.partner-inner li").eq(0).show();
    $("ul.contact-inner").contentSlider(10000, "li");
    $("ul.partner-inner").contentSlider(10000, "li");
});
