jQuery.root = jQuery(document);
jQuery.root.ready(function(){
	var cache = [];
	var $liveTip = $('<div id="snapshot"></div>').hide().appendTo('body');
	$('#contentWrapper, .snapShotContent').delegate('a.snapshot','mouseover',function(event){
		var $link = $(this);
		var $sleep = $link.hasClass('sleep');
		var $time = 0;
		if($sleep == true){
			$time = 1000;
		}
		$link.data('evento',true);
		$link.removeAttr("title");
		setTimeout(function(){if($link.data('evento') == true){
		
		if($link.hasClass('type1')){
			$type= 1;
		}else{
			$type= 0;
		}
			
			
			if(!cache[$link.attr('href')]){
				
				$.ajax({
					url: $link.attr('href'),
					method: 'post',
					data: 'type=' + $type,
					success:function(data){
					    cache[$link.attr('href')] = data;
						$liveTip.html(data);
					}
				});
				$liveTip.css( {
					top : event.pageY + 0,
					left : event.pageX + 12
				}).html('<div><img src="/images/loading.gif" width="30"/></div>').show();
			}else{
				$liveTip.html(cache[$link.attr('href')]).show();
			}
			
			
			
		}},$time);
		
		
	}).delegate('a.snapshot','mouseout click',function(event){
		var $link = $(this);
		$link.data('evento',false);
		$liveTip.hide();
	}).delegate('a.snapshot','mousemove',function(event){
		$liveTip.css( {
			top : event.pageY + 0,
			left : event.pageX + 12
		})
	});
})