jQuery(function($) {

	$(".post-notification-email").focus(function (e) {
		if ($(this).val() === 'Enter your email here >>') {
			$(this).val('').removeClass('label');
		}
	}).blur(function (e) {
		if ($(this).val() === '') {
			$(this).val('Enter your email here >>').addClass('label');
		}
		if ($(this).val() === 'Enter your email here >>') {
			$(this).addClass('label');
		}
	}).blur();
	
	/*$(".post_notification_widget").prepend('<div id="flash-dad-wrapper"><div id="flash-dad"></div></div>');
	
	swfobject.embedSWF("/wp/wp-content/themes/main/images/flash.swf", "flash-dad", 
		"329", "233", "9.0.0", null, null, {'wmode' : 'transparent', 'scale' : 'noorder'});*/

	var newsBox = $("#sidebar .text-first .textwidget");
	if (newsBox.length) {
		var that = newsBox;
		if (that.height() > 70)
		{
			that.css({'height' : '70px', 'overflow' : 'hidden'}).wrapInner('<div class="newsWrap"></div>');
			that.append(that.find(".newsWrap").clone(true));
			
			var newsTicker = null;
			function startNewsTicker() {
				newsTicker = setInterval(function() {
					var scrollTop = that.get(0).scrollTop;
					if (scrollTop >= that.find(".newsWrap").height())
					{
						that.get(0).scrollTop = 0;
					}
					that.get(0).scrollTop += 1;
				}, 100);
			}
			
			function stopNewsTicker() {
				if (newsTicker) {
					clearInterval(newsTicker);
				}
				newsTicker = null;
			}
			
			startNewsTicker();
			
			that.hover(function (e) {
				stopNewsTicker();
			}, function (e) {
				startNewsTicker();
			});
		}	
	};
	
	$("#bookmark").click(function(e) {
		try {
			window.external.AddFavorite('/', 'Casino Dad - Online Casino Guide');
			return false;
		} catch (e) {
		}
	});
		
	
	if ($("#offers").length)
	{
		var offers = $("#offers");
		var offersList = offers.find("ul");
		var offersCount = offersList.find("li").length;
		var currentOffer = 0;
		offersList.append(offers.find("li:first").clone(true));
		
		if (typeof DD_belatedPNG !== "undefined")
		{
			var lastItem = offers.find("li:last a");
			if (lastItem.hasClass('has-image'))
			{
				DD_belatedPNG.fixPng(lastItem.get(0));
			}
		}
		
		var offersAnimation = null;
		function startOffersAnimation() {
			offersAnimation = setInterval(function() {
				if (currentOffer == offersCount) {
					offersList.css({'top' : 0});
					currentOffer = 0;
				}
				offersList.animate({top:"-=70px"}, 700, "easeInOutBack");
				currentOffer++;
			}, 3000);
		}
		
		function stopOffersAnimation() {
			if (offersAnimation) {
				clearInterval(offersAnimation);
			}
			offersAnimation = null;
		}
		
		startOffersAnimation();
		
		offers.hover(function (e) {
			stopOffersAnimation();
		}, function (e) {
			startOffersAnimation();
		});
	}	
});