$(document).ready(function(){
	$('#randomPhoto img').show();
	$("img.mi").mouseover(function()
	{
		$(this).attr("src","/i/a"+$(this).attr('src').substring(3));
		$(this).unbind();
	});
});
var speech=setInterval(function() {
	$.get(window.location+'',{tname:'blocks/speech.tpl',x:Math.ceil(Math.random()*1000000)},
		 function(data){
		 	$('#speech div').fadeOut("slow",function(){
				$(this).html(data);
				$(this).fadeIn("slow");
			});
		}
	);
	$.get(window.location+'',{tname:'blocks/randomPhoto.tpl',x:Math.ceil(Math.random()*1000000)},
		 function(data){
			$('#bgBlock').html($('#randomPhoto').html());
//			alert('test');
var a=setTimeout(function(){		
			$('#bgBlock').show();
			$('#randomPhoto').replaceWith(data);
			$('#randomPhoto img').load(function(){
				$('#bgBlock').fadeOut("slow", function(){
					$('#bgBlock').hide();
				});
			});
//			$('#randomPhoto img').fadeOut("slow",function(){
//				$('#randomPhoto').replaceWith(data);
//				$('#randomPhoto img').fadeIn("slow");
//			});
}, 500);
		}
	);
}, 8000);
//var rp=setInterval(function() {
//	$.get(window.location+'',{tname:'blocks/randomPhoto.tpl',x:Math.ceil(Math.random()*1000000)},
//		 function(data){
//			$('#randomPhoto').replaceWith(data);
//		}
//	);}, 7000);