jQuery(function () {
	var $ = jQuery;
	// Обработка хеша
	var match = window.location.hash.match(/^#[0-9]+/)
	if (match) {
		var hash = match[0];
		$('.small_photo a').each(function () {
			var link = $(this);
			var href = $(this).attr('href');
			if (href.indexOf(hash) >= 0) {
				link.click();
			}
			
		});
	}
});

function open_slaider(id, hdr) {

    var slaider = document.getElementById('shrouded');
// test	
	var block_rolik = document.getElementById('block_rolik');
    var block_shrouded = document.getElementById('block_shrouded');
	var block_rolik_header = document.getElementById('block_rolik_header');
    
    var topheight = Math.round(document.documentElement.clientHeight*0.15) + document.documentElement.scrollTop;
    var divheight = document.documentElement.scrollHeight;

	block_rolik.innerHTML = '<object width="640" height="390"><param name="movie" value="http://www.youtube.com/v/' +id+ '?fs=1&amp;hl=ru_RU&amp;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+id+'?fs=1&amp;hl=ru_RU&amp;rel=0" type="application/x-shockwave-flash" width="640" height="390" allowscriptaccess="always" allowfullscreen="true"></embed></object>';
	block_rolik_header.innerText = hdr;
	
    slaider.style.height = divheight + "px";
    block_shrouded.style.marginTop = (topheight-60) + "px";
    slaider.style.display = 'inline';
	
}
function close_slaider() {
    var slaider = document.getElementById('shrouded');
    slaider.style.display = 'none';
}

function rotate_bg() {
   var bg = document.getElementById('index_body');
   var i = Math.round(Math.random() * (5 - 1) + 1);
   i = i + '';
   bg.style.backgroundImage = 'url(/images/bg-'+i+'.jpg)';
}
function rotate_logo() {
   var logo = document.getElementById('logo');
   var colors = ['#dddd01', '#8050e4', '#ff245f'];
   var i = 0;
   var prev_color = 0;
   
   do {
		i = Math.round(Math.random() * (colors.length-1));
		prev_color = logo.style.backgroundColor;
   } while (colors[i] == prev_color);
   
   logo.style.backgroundColor = colors[i];
}

