$.fn.reverse = [].reverse; 

//////////////////////////////////////////////////////////////////////////////////////////////////
// FUNKCE
//////////////////////////////////////////////////////////////////////////////////////////////////
function languageSwitch(){
	$('#languages a').click(function(){
		var href = window.location.href;
		window.location.href = href.replace(/(\/+)[a-zA-Z]{2}(\/+)/, $(this).attr('href'));
		return false;
	})
}

//Ochrana e/mailu
function obfsctml(){
	$('a.em').each(function(){
		e = this.rel.replace('/','@');
		this.href = 'mailto:' + e;
		$(this).text(e);
	});
}

$.address.change(function(c){
	// TODO využít fci die
	// if(historyControll == 1){
		if($('a[name_='+c.value+']')) $('a[name=_'+c.value+']').trigger('click');
	// }
});
function replaceText(){
	Cufon.replace('#menu, h2', { 
		fontFamily: 'Saraevents',
		hover:true
	})
}
function hoverDetail(){
	$('#reference .ref').hover(function(){
		$(this).addClass('hovered').find('img.ref_img').hide();
		$(this).find('img.ref_detail').show();
		
	},function(){
		$(this).removeClass('hovered').find('img.ref_img').show();
		$(this).find('img.ref_detail').hide();
	})
	
	$('#employees .employee').hover(function(){
		$(this).find('a.em').addClass('visible');
	},function(){
		$(this).find('a.em').removeClass('visible');
	})
}
function readMoreLess(){
	$('a.read_more').click(function(){
		service = $(this).parent().parent();
		service.find('.perex').hide();
		service.find('.full').show();
	})
	$('a.read_less').click(function(){
		service = $(this).parent().parent();
		service.find('.full').hide();
		service.find('.perex').show();
	})
}
function setup(){
	replaceText();
	obfsctml();
	languageSwitch();
	hoverDetail();
	readMoreLess()
}

$(document).ready(function() {
		
	setup();
	$('.gallery a').lightBox(); // Select all links with lightbox class

});

