




$(document).ready(function(){


	// FancyBox
	$('.content').find('a[href$=".jpg"], a[href$=".JPG"], a[href$=".png"], a[href$=".PNG"], a[href$=".gif"], a[href$=".GIF"]').each(function() {
		$(this).addClass('slideshow').attr('rel', 'fancybox');
	});


	$(".content a[href*='youtube.com/watch']").click(function() {
		$.fancybox({
				'padding'		: 0,
				'autoScale'		: false,
				'transitionIn'	: 'none',
				'transitionOut'	: 'none',
				'title'			: this.title,
				'width'			: 480,
				'height'		: 385,
				'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
				'type'			: 'swf',
				'swf'			: {
					'wmode'				: 'transparent',
					'allowfullscreen'	: 'true'
				}
			});

		return false;
	});

	$('a.slideshow').fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	500,
		'speedOut'		:	200,
		'overlayShow'	:	true,
		'autoScale'		:	true,
		'titlePosition'	:	'over',
		'showNavArrows'	:	true,
		'padding'		:	1,
		'overlayOpacity':	.3,
		'overlayColor'	:	'#000000',
		'easingIn'		:	'easeOutBack',
		'easingOut'		:	'easeInBack',
		'onComplete'	:	function() {
			$("#fancybox-wrap").hover(function() {
				$("#fancybox-title").show();
			}, function() {
				$("#fancybox-title").hide();
			});
		}


	});


	$("#myCarousel").jcarousel({
		scroll			: 1,
		easing			: 'easeOutCirc',
		animation		: 600
	});



});






/**
 * Эта ф-ция запускается только если можно показывать флеш
 * Ф-ция проверяет URI и:
 * 1. если 'carlo.ru/en/events/#/shops/' - убирает из пути /events/
 * 2. если 'carlo.ru/en/events/', то делает 'carlo.ru/en/#/events/'
 * 
 * // http://dev.web-fusion.ru/carlo-pazolini.ru/ru/shops/#/events/
 */
function removeRequestUri()
{
	
	if (requestUri == '/') {
		requestUri = '';
	}
	
	var lHash = window.location.hash.toString().replace('\#', '');
	
	if (requestUri != '' && lHash != '') {
		window.location.href = baseHref + '#' + lHash;
		window.wfStop = true;
	} else if (requestUri != '' && lHash == '') {
		window.location.href = baseHref + '#/' + requestUri;
		window.wfStop = true;
	}
	
}

/**
 * Ф-ция запускается только если не возможно показать флеш.
 * При этом, если юзер зашёл по адресу carlo.ru/en/shops/#/events/
 * То переправляет юзера по адресу carlo.ru/en/#/events/
 * 
 */
function removeLocationHash()
{
	
	var lHash = window.location.hash.toString().replace('\#', '');
	
	
	if (lHash != '') {
		window.location.href = baseHref + lHash.substr(1);
		window.wfStop = true;
	}
	
}


/**
 * Специальная ф-ция для печати.
 * 
 */
function flashPrint()
{
	
	var lHash = window.location.hash.toString().replace('\#', '');
	
	var iFrame = document.createElement('iframe');
	var tmp = baseHref + lHash + '?print=Y';
	iFrame.setAttribute('src',	tmp);
	document.getElementsByTagName('body')[0].appendChild(iFrame);
	
	
}














