
jQuery(document).ready(function() {
	var _video_first = true;
	jQuery('.videosList').each(function(){
		
		var events = {
			onmouseover: function(li, e){
				if ( jQuery(li).is(".videosList_hover") ) return;
				if ( jQuery(li).is(".videosList_playing") ) return;
				jQuery('>li', this).not(".videosList_playing").removeClass("videosList_hover");
				jQuery(li).addClass("videosList_hover");
			},
			onmouseout: function(li, e){
				if ( jQuery(li).is(".videosList_playing") ) return;
				jQuery(li).removeClass("videosList_hover");
			},
			onclick: function(li, e) {
				if ( jQuery(li).is(".videosList_playing") ) return;
				jQuery('>li', this).filter(".videosList_playing").removeClass("videosList_playing");
				jQuery(li).addClass("videosList_playing");
			}
		};
		
		var elem = this;
		
		jQuery('>li', this).bind("mouseover mouseout", function(e){
			if (e && e.type) {
				if (events['on'+e.type] && typeof events['on'+e.type] == "function") {
					events['on'+e.type].apply(elem, [this, e]);
				}
			}
		});
		
		jQuery('.videosList_desc_title a', this).each(function(){
			var li = jQuery(this).parents("li");
			var h = jQuery(li).innerHeight();
			var w = jQuery(li).innerWidth();
			
			var a = jQuery(this).clone(true);
			jQuery(a).html("").addClass("videosList_boxLink").css({
				width:w+"px",
				height:h+"px"
			})
			.append( jQuery("<img />").attr("src", "/images/lactaid/swf/videos/x.gif").css({
				width:w+"px",
				height:h+"px",
				border:0,
				margin:0,
				padding:0
			}))
			.appendTo(li).bind("click", function(e){
				this.blur();
				events['onclick'].apply(elem, [li,e]);
			});
		});
	});
	
	jQuery(".flash_holder").bind("click", function(){
		if (jQuery('.videosList > li.videosList_playing').length < 1) {
			jQuery('.videosList > li:eq(0)').addClass("videosList_playing");
		}
	});
});