(function($) {
/*
 * A basic news ticker.
 *
 * @name     newsticker (or newsTicker)
 * @param    delay      Delay (in milliseconds) between iterations. Default 4 seconds (4000ms)
 * @author   Sam Collett (http://www.texotela.co.uk)
 * @example  $("#news").newsticker(); // or $("#news").newsTicker(5000);
 *
 */
$.fn.newsTicker = $.fn.newsticker = function(delay)
{
	delay = delay || 4000;
	count = 0;
	var text = ['Become a paid member today to contact members. <a href="upgrade1.php"><strong>Upgrade now</strong></a>',
    'Checkout our membership plans and choose the one that suits you. <a href="upgrade2.php"><strong>Choose now</strong></a>',
    'Did you know you can find out the compatibility scores between you and other members?',
    'Live alerts popup in secondshaadi website when other members view your profile',
    'Secondshaadi allows you to generate FREE Horoscope now!',
    'It is possible to match horoscopes online now for a very nominal fee',
    'As a Gold member, you can receive SMS alerts and view unlimited contact details!',
    'You can define and store your search criteria once and save time.',
    'You can quickly bookmark the members you like while you are searching.',
    'Checkout our exclusive portal on Cars. <a href="http://www.gaadi.com" target="_blank">www.gaadi.com</a>. Think Cars! Think Gaadi!'
    ];
	initTicker = function(el)
	{
		stopTicker(el);
		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)
	{
		// don't run if paused
		if(el.pause) return;
		// pause until animation has finished
		el.pause = true;
		// hide current item

		$('#news').fadeOut("slow",
			function()
			{
				$(this).hide();
				// move to next item and show
				$(el).html(text[count]).slideToggle("slow",
					function()
					{
						el.pause = false;
						count++;
						if(count >= text.length)
							count = 0;
					}
				);
			}
		);
	};
	this.each(
		function()
		{
			if(this.nodeName.toLowerCase()!= "div") return;
			initTicker(this);
		}
	)
	.addClass("newsticker")
	.hover(
		function()
		{
			// pause if hovered over
			pauseTicker(this);
		},
		function()
		{
			// resume when not hovered over
			resumeTicker(this);
		}
	);
	return this;
};

})(jQuery);