/* -------------------------------------------------- *
 * Project scripts
 * -------------------------------------------------- *
 * Author: Morozov Igor
 * URL: http://www.morozoff.info/
 * Copyright: 2011 Morozov Igor
** -------------------------------------------------- */

$(function(){
	if($('.visual-area').length) {
		prodscroller();
	};
	
	$('.b-navigation .pi .nav__a').bind('mouseenter', function(){
		$(this).parent().addClass('active-nav')
	});
	$('.b-navigation .pi').bind('mouseleave', function(){
		$(this).removeClass('active-nav')
	});
	
	if($('.b-feedback').length>0){
		$('.b-feedback').message();
	}
	
	if($('.g-maps-i').length>0){
		$('.g-maps-i').gMap({
			markers: [{
					latitude: 53.9622,
					longitude: 27.630183,
					html: "<h3>ИП АтлантКонсалт</h3><p>223053, Минская область, Минский р-н, д. Боровая, офис №402.</p>",
					icon: {
						image: "/webroot/delivery/img/pointer.png",
						iconsize: [55,38],
						iconanchor: [27,19],
						infowindowanchor: [27,3]
					}
			}],
			zoom: 14
		});
	}
});

function prodscroller() {
	var $obj = $('.visual-area'),
		$obj__parent = $obj.parent();
		
	$obj.scrollable({
		circular:true,
		speed:800,
		prev:'.ar-l',
		next:'.ar-r',
		onSeek:function(event){
			var idx = this.getIndex()+1,
				cnt = $('.visual__li',$obj).eq(idx);
			$('.visual-txt-i',$obj__parent).html($('.visual-sinfo',cnt).html());
			$('.visual-tip',$obj__parent).html($('.visual-stip',cnt).html());
			/* $('.panes',$blcont).hide();
			$navi
				.removeClass('active')
				.eq(idx).addClass('active');
			$('#prodcard-id-'+idx,$blcont).show(); */
		}
	}).navigator({
		navi:'.visual-navi .navi',
		indexed:true
	}).autoscroll({ interval: 5000, autopause:false });
	var $api = $obj.data('scrollable');
	
	$('.ar-l, .ar-r',$obj__parent).click(function(){
		$api.stop();
		return false;
	});
	
	$('.visual-navi .navi a').click(function(){
		$api.stop();
	});

	cnt = $('.visual__li',$obj).eq(1);
	$('.visual-txt-i',$obj__parent).html($('.visual-sinfo',cnt).html());
	$('.visual-tip',$obj__parent).html($('.visual-stip',cnt).html());
};
