var hash = '#/'; var path="./"; var title=Array(); var part=Array();

$(document).ready(function() {
	if(location.hash.substr(1,1)=='!') hashchange();
	$('.obsah .galery a').colorbox();
});

$('a[rel]:not(a[rel*=imagebox])').live('click',function() {
	$(this).attr('onclick'); 
	loadIt($(this).attr('href'),$(this).attr('rel')); 
	return false;
});

//	$.colorbox({ maxWidth:$(window).width()-20, maxHeight:$(window).height()-20, scrolling:false, scalePhotos:true,	title: function() { return $(this).children().attr('alt'); }, current: "{current}/{total}",	next: 'další', previous: 'předchozí', slideshow: true, slideshowAuto: false, slideshowStart: 'přehrát', slideshowStop: 'zastavit'	});
	//$.colorbox({ maxWidth:200, maxHeight:200,current:"{current}x" });


function hashchange() { 
 	if(location.hash!=hash) { loadIt(location.hash.replace('#!',''),''); }
}
$(window).bind('hashchange', hashchange);

//$(window).height()-40;
//$(window).width()-50, maxHeight:$(window).height()-50;
var scw=$(window).width();
var sch=$(window).height();
//maxWidth:scw, maxHeight:sch, 



function loadIt(url,trg) {
	url='^'+url; url=url.replace('^/','').replace('^','');
	url=url+'$'; url=url.replace('.html$','').replace('$','');
	
	if(trg==''){	trg = part[url]; }
	
	$('.menu li.selected').removeClass('selected');
	$('.menu li a[href="/'+url+'.html"]').parent().addClass('selected');
	
	if(url=='' || url=='home' || url=='podhursky' || url=='underhill'){
		$('#all').animate({width:'100%',marginLeft:'0%'},500);	url = 'home';
	}else if(trg=='underhill'){
		$('#all').animate({width:'200%',marginLeft:'0%'},500);
	}else if(trg=='podhursky'){
		$('#all').animate({width:'200%',marginLeft:'-100%'},500);	
	}
	
	if(url=='home'){
		$('#home').animate({ marginLeft: '-75' },500);
		$('#podhursky .menu').animate({ marginLeft: '70' },500);
		$('#underhill .menu').animate({ marginLeft: '-70' },500);
		$('.obsah').animate({ marginLeft: '-80%',marginRight: '-80%'	},500, function(){
			$('#podhursky .obsah').load(path+'null/podhursky',function (data) { 
				$(this).html(data);
				$('#podhursky .obsah').animate({ marginLeft: '0',marginRight: '0'	},500);
			});
			$('#underhill .obsah').load(path+'null/underhill',function (data) { 
				$(this).html(data);
				$('#underhill .obsah').animate({ marginLeft: '0',marginRight: '0'	},500);
			});
		});	
	}else{
		$('#podhursky .menu').animate({ marginLeft: '145' },500);
		$('#underhill .menu').animate({ marginLeft: '-145' },500);
		if(trg=='podhursky'){
			$('#home').animate({ marginLeft: '-0' },500);
		}else{
			$('#home').animate({ marginLeft: '-150' },500);
		}

		$('#'+trg+' .obsah').animate({ marginLeft: '-80%',marginRight: '-80%'	},500, function(){
			$('#'+trg+' .obsah').load(path+'null/'+url+'',function (data) { 
				$(this).html(data);
				$('#'+trg+' .obsah').animate({ marginLeft: '0',marginRight: '0'	},500);
					$('.obsah .galery a').colorbox({ maxWidth:$(window).width()-60, maxHeight:$(window).height()-60, scrolling:false, scalePhotos:true,	title: function() { return $(this).parent().find("h4").html(); }, current: "{current}/{total}",	next: 'další', previous: 'předchozí', slideshow: false });
			});
		});
	}

	
	tmpurl=url.split("&"); url=tmpurl[0];
	hash='#!'+url;
	document.title = title[url];
	location.href=path+'#!'+url; 
}


function loadFlash(id,mp){
	$('#'+id).html('');
	$('#'+id).flash({
			src: './swf/mp3_small.swf?target=./mp3/'+mp+'.mp3',
			width: 20,	height: 20,
			wmode: 'transparent',
			id: id+'_swf',	
			name: id+'mp_swf'
	});
}








