(function($) { 
	$.fn.animBg = function(command,options) { 

		if(command && typeof command ==='string'){
			clearInterval($(this).data('anim'));
			return this;
		}
		var $this = $(this),
		o = {'interval':100},
		options = (typeof command === 'object' && typeof options === 'undefined')?command:options,
		o = jQuery.extend({}, o, options), anim;
		if(!o.step && !o.steps){return this;}
		anim = setInterval(function() { 
			if ($this.css('background-position') == undefined) {
				var bgpos = parseInt( $this.css('background-position-y'));
				$this.css('background-position-y',(-(o.step*o.steps)>=(bgpos-o.step)?0:bgpos-o.step)+'px');
			} else {
				var bgpos = parseInt( $this.css('background-position').split(" ")[1] );
				$this.css('background-position','0 '+(-(o.step*o.steps)>=(bgpos-o.step)?0:bgpos-o.step)+'px');
			}
		}, o.interval);
		$this.data('anim',anim);
		return this; 
	}
})(jQuery); 

jQuery.fn.addLightsLink = function(displayelement, linktext) {
	var $this = $(this);
	var $disp = $(displayelement);
	var $text = $(displayelement+' .lightstext');
	var $timer;
	$this.bind('mouseenter', function() {
		$disp.css('background','url(images/rainbow.png) 0 0 no-repeat').animBg({'step':116,'steps':15,'interval':100});
		$timer = setTimeout(function(){
			$disp.animBg('stop');
			$text.html(linktext);
			$disp.css('background','url(images/lights.png) 0 0 no-repeat').animBg({'step':116,'steps':15,'interval':100});
		},1500);
	});
	$this.bind('mouseleave', function() {
		clearTimeout($timer);
		$disp.animBg('stop');
		$disp.css('background', 'transparent');
		$text.html('+');
	});
}

var birds_are_flying = false;

function showBirds() {
//	alert("SHOW BIRDS " + (birds_are_flying?"BUT THEY'RE STILL IN THE AIR!":"AS THEY RETURNED!"));
	if (!birds_are_flying){
		birds_are_flying = true;
		document.getElementById('birds').src='images/sky_birds.gif';
		setTimeout(function(){
			birds_are_flying = false;
		},12000);
	}
}

