function dump(obj) {
    var out = "";
    if(obj && typeof(obj) == "object"){
        for (var i in obj) {
            out += i + ": " + obj[i] + "\n";
        }
    } else {
        out = obj;
    }
    alert(out);
}

function random( rand, min, max)
{
	new_rand = parseInt( Math.random() * (max - min) + min );
	if ( new_rand == rand )
	{
	 	return random( rand, min, max );
	} 
	return new_rand;
}

$(document).ready(function(){

	var refresh = 
	$('#refresh').mouseenter(function() {
	$('#next img').attr('src', 'images/next2.png');
	window.refresh = setInterval(
		function() {
				$('#next').animate({rotate: '+=10deg'}, 0);	
			},
			20
		);
	return refresh
	});

	$('#refresh').mouseleave(function() {
	    $('#next img').attr('src','images/next.png');
		$('#next').animate({rotate: '0deg'}, 0);	
		clearInterval(window.refresh);
	});

	$("#logo").hover(function() {
		$(this).fadeOut('fast', function() {
			$(this).css('width', '192px');
			$(this).css('background', ' url(../images/designspace.png) bottom no-repeat');
			$(this).fadeIn('fast');
		});
	});

	$("#logo").mouseout(function() {
		$(this).fadeOut('fast', function() {
			$(this).css('width', '38px');
			$(this).css('background', ' url(../images/logo.png) no-repeat');
			$(this).fadeIn('fast');
		});
	});

	var content = new Array(
		{
			'alt' : 'Мы просто делаем сайты.',
			'title' : 'Мы просто делаем сайты.',
			'src' : '../content/My_prosto_delaem_sajty.png'
		},
		
		{
			'alt' : 'У нас нет портфолио.',
			'title' : 'У нас нет портфолио.',
			'src' : '../content/U_nas_net_portfolio.png'
		},
		
		{
			'alt' : 'У нас есть отличная CMS.',
			'title' : 'У нас есть отличная CMS.',
			'src' : '../content/U_nas_est_otlichnaja_CMS.png'
		},
		
		{
			'alt' : 'Мы собираемся захватить мир!',
			'title' : 'Мы собираемся захватить мир!',
			'src' : '../content/Quatator.png'
		}
		
	);

	$('#refresh').click(function() {
		var next = parseInt($('#quote').attr('rel'));
		get_quote( next, content );	
	});
	
	$('#lab').fold();

	$("body").queryLoader2({
        	barColor: "#FFF",
        	backgroundColor: "#000",
        	percentage: false,
        	barHeight: 30,
        	completeAnimation: "grow"
    	});


	// $('body').fadeIn(5000, function() {
		// $(this).slideDown();
		// $(this).css('background', 'url(../images/bg.jpg) 50% 50%  no-repeat');
	// });

	get_quote( random(-1, 0, content.length), content );
});	

function get_quote( next, content )
{
		var img = $('#quote');
		next = random( next, 0, content.length );
		$('title').text(content[next].title);
		img.attr( 'rel', next );
		img.fadeOut('slow', function() { 
			img.css( 'background', '' );
			img.css( 'background', 'url(' + content[next].src + ') no-repeat bottom' );
		});
		img.fadeIn('slow');
}

