var cls,current;
var output;
jQuery(function($){
	var t;
	showPreview = function(obj){
		//console.log(obj);
		$("." + obj + " > div.photo").append('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="205" height="162"><param name="movie" value="assets/swf/thumbn.swf"><param name="quality" value="high"><param value="'+$("." + obj + " > input").val()+ '" name="flashvars"><param value="transparent" name="wmode"><embed  wmode="transparent"  src="assets/swf/thumbn.swf" flashvars="'+$("." + obj + " > input").val()+ '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"  width="205" height="162"></embed></object>');
		$("." + obj + " > div.photo > a").hide();
	}
	
	hidePreview = function (obj){
		$("." + obj + " > div.photo > object").remove();
		$("." + obj + " > div.photo > a").show();
		cls = undefined;
	}
	
	thumbClosed = function(){
		hidePreview(cls);
	};
	
	$('.preview > div.photo').hover(
		function(){
			
			current =  String($(this).parent().attr('class').split(' ').slice(-1));
			if(current == cls){
				return false;
			} 						
			if(t){
				clearTimeout(t);
				hidePreview(current);
			}			
			cls = current;
			t = setTimeout("showPreview(cls)",300);
		},
		function(){
			if(t){
				clearTimeout(t);
			}
			
			if(cls){
				hidePreview(cls);
			}
		}
			
	);
});