<?php
	$offset=5*356*24*60*60;
	header("Content-type:text/javascript");
	header("Expires:" . gmdate("D,d M Y H:i:s",time()+$offset) . " GMT");
	header('Cache-Control:max-age=' . $offset);
	ob_start("ob_gzhandler");
?>
/*
	DOCUMENT READY
*/
jQuery.noConflict();
jQuery(function(){
	HOST = 'http://intensecycles.pl'; 
	/*
		MAIN ANI
	*/
	if (jQuery('#main-ani').size()) {
		jQuery('#main-ani').css('visibility', 'visible');
		swfobject.embedSWF(HOST	+ '/assets/templates/01/flash/intense_home.swf', 'main-ani-content', '980', '469', '8.0.0', '', {}, {wmode: 'transparent', menu: 'false'});
	}
	/*
		CONTACT form ajax submit
	*/
	jQuery('#article form').submit(function(){
		$this = jQuery(this);
		$this.find('.warning').removeClass('warning');
		if (jQuery.trim(jQuery('#f_name').val()) == ''){
			jQuery('label[for="f_name"]').parent('div').addClass('warning');
		}
		if (jQuery.trim(jQuery('#f_mail').val()) == ''){
			jQuery('label[for="f_mail"]').parent('div').addClass('warning');
		}
		if (jQuery.trim(jQuery('#f_msg').val()) == ''){
			jQuery('label[for="f_msg"]').parent('div').addClass('warning');
		}
		if (jQuery('.warning').size()) {
			alert('Wypełnij poprawnie wszystkie obowiązkowe pola formularza.');
			jQuery('.warning:first label').next().focus();
			return false;
		}
		$this.addClass('processing');
		jQuery.post(HOST + '/engage.form-submit.php', $this.find('input, textarea').serialize(), function(){
			$this.removeClass('processing').html('<p><strong>Formularz kontaktowy został wysłany, dziękujemy.</strong></p>');
		});
		return false;
	});

	/*
		GALLERY lightbox
	*/
	lightBoxParams = {imageLoading: HOST + '/assets/templates/01/images/lightbox-ico-loading.gif', imageBtnPrev: HOST + '/assets/templates/01/images/lightbox-btn-prev.png', imageBtnNext: HOST + '/assets/templates/01/images/lightbox-btn-next.png', imageBtnClose: HOST + '/assets/templates/01/images/lightbox-btn-close.png', imageBlank: HOST + '/assets/templates/01/images/lightbox-blank.gif'};
	if (jQuery('#bike-thumb a').size()){
		jQuery('#bike-thumb a:not(.zoom-in)').lightBox(lightBoxParams);
		jQuery('#bike-thumb a.zoom-in').lightBox(lightBoxParams);
	}
	if (jQuery('.gallery li a').size()){
		jQuery('.gallery li a').lightBox(lightBoxParams);
	}
	jQuery('img').hide().fadeIn();
	itemsCount = jQuery("#carousel li").size();
	jQuery("#carousel")
		.prepend('<a href="#prev" class="prev">poprzednie</a><a href="#prev" class="prev-icon"></a>')
		.append('<a href="#next" class="next">następne</a><a href="#next" class="next-icon"></a>')
		.find('.prev, .next').css({opacity: '0.5'}).end()
		.find('.prev, .prev-icon')
			.hover(function(){
					jQuery('.prev').animate({width: '100px'}, { queue:false, duration:100 });
					jQuery('.prev-icon').addClass('active').animate({left: '50px'}, {queue:false, duration:100});
				},
				function(){
					jQuery('.prev').animate({width: '50px'}, { queue:false, duration:100 });
					jQuery('.prev-icon').removeClass('active').animate({left: '15px'}, {queue:false, duration:100});
				}).end()
		.find('.next, .next-icon')
			.hover(function(){
					jQuery('.next').animate({width: '100px'}, { queue:false, duration:100 });
					jQuery('.next-icon').addClass('active').animate({'width': '50px'}, {queue:false, duration:100});
				},
				function(){
					jQuery('.next').animate({width: '50px'}, {queue:false, duration:100});
					jQuery('.next-icon').removeClass('active').animate({'width': '27px'}, {queue:false, duration:100});
				}).end()
		.jCarouselLite({
			btnNext: '.next, .next-icon',
			btnPrev: '.prev, .prev-icon',
			visible: itemsCount,
			scroll: 1
		});
	jQuery('#bike-thumb a').hover(function(){
		jQuery('#bike-thumb a.zoom-in').css({'background-position': '0 100%'});
	},function(){
		jQuery('#bike-thumb a.zoom-in').css({'background-position': '0 0'});
	});
	
	jQuery('#bike-properties > ul > li')
		.find('h3').css('cursor', 'pointer').click(function(){
			jQuery(this).addClass('active').parent('li').siblings('li').find('h3').removeClass('active');
			jQuery('.ajax-content').html(jQuery(this).siblings('.content').html());
		}).hover(function(){
			jQuery(this).addClass('hover');
		},function(){
			jQuery(this).removeClass('hover');
		}).end()
		.filter(':not(:first)').addClass('merged').end()
		.filter(':first').find('.content').hide().after('<div class="ajax-content"></div>').end().find('h3').trigger('click');
	
});
