$(function() {
	$('#gallery a').lightBox({fixedNavigation:true});
});

//$(document).ready(function() {
$(window).load(function() {
	var $imageSum = $(".small_imgs img").size();
//	alert($imageSum);
	for($z=0;$z<$imageSum;$z++) {
//		alert(".img_"+$z);
//		alert($(".small_imgs .img_"+$z).width());
		$width = $(".small_imgs .img_"+$z).width();
		$height = $(".small_imgs .img_"+$z).height();
//		alert($width+'|'+$height);
		if($width > $height) {
			$height = Math.round(((75*$height)/$width))+'px';
			$width = '75px';
//			alert($width+'|'+$height);
			$('.small_imgs .img_'+$z).css('width',$width);
			$('.small_imgs .img_'+$z).css('height',$height);
		} else {
			$width = Math.round(((75*$width)/$height))+'px';
			$height = '75px';
//			alert($width+'|'+$height);
			$('.small_imgs .img_'+$z).css('width',$width);
			$('.small_imgs .img_'+$z).css('height',$height);
		}
		$('.small_imgs .img_'+$z).css('display', 'inline');
	}
	$(".small_imgs img").click(function() {
	var $imgclass = $(this).attr('class');
//	alert($imgclass);
	for($i = 0;$i<$imageSum;$i++) {
		$('.big_imgs .img_'+$i).css('display', 'none');
		$('.big_imgs .'+$imgclass).css('display', 'block');
	}
	});
})

$(window).load(function() {
	for($z=0;$z<3;$z++) {
//		alert(".img_"+$z);
//		alert($(".small_imgs .img_"+$z).width());
		$width = $(".recent_products .img_"+$z).width();
		$height = $(".recent_products .img_"+$z).height();
//		alert($width+'|'+$height);
		if($width > $height) {
			$height = Math.round(((221*$height)/$width))+'px';
			$width = '221px';
//			alert($width+'|'+$height);
			$('.recent_products .img_'+$z).css('width',$width);
			$('.recent_products .img_'+$z).css('height',$height);
		} else {
			$width = Math.round(((73*$width)/$height))+'px';
			$height = '73px';
//			alert($width+'|'+$height);
			$('.recent_products .img_'+$z).css('width',$width);
			$('.recent_products .img_'+$z).css('height',$height);
		}
		$('.recent_products .img_'+$z).css('display', 'inline');
	}
})

$(window).load(function() {
	for($z=0;$z<3;$z++) {
//		alert(".img_"+$z);
//		alert($(".small_imgs .img_"+$z).width());
		$width = $(".goods .img_"+$z+' img').width();
		$height = $(".goods .img_"+$z+' img').height();
//		alert($width+'|'+$height);
		if($width > $height) {
			$height = Math.round(((100*$height)/$width))+'px';
			$width = '100px';
//			alert($width+'|'+$height);
			$('.goods .img_'+$z+' img').css('width',$width);
			$('.goods .img_'+$z+' img').css('height',$height);
		} else {
			$width = Math.round(((60*$width)/$height))+'px';
			$height = '60px';
//			alert($width+'|'+$height);
			$('.goods .img_'+$z+' img').css('width',$width);
			$('.goods .img_'+$z+' img').css('height',$height);
		}
		$('.goods .img_'+$z+' img').css('display', 'inline');
	}
})

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        // Configuration goes here
		auto: 5,
		wrap: 'last',
        initCallback: mycarousel_initCallback
    });
});

    YMaps.jQuery(window).load(function () {
        var map = new YMaps.Map(YMaps.jQuery("#YMapsID-5235")[0]);
        map.setCenter(new YMaps.GeoPoint(27.652607,53.865743), 15, YMaps.MapType.MAP);
        map.addControl(new YMaps.Zoom());
        map.addControl(new YMaps.ToolBar());
        YMaps.MapType.PMAP.getName = function () { return "Народная"; };
        map.addControl(new YMaps.TypeControl([
            YMaps.MapType.MAP,
            YMaps.MapType.SATELLITE,
            YMaps.MapType.HYBRID,
            YMaps.MapType.PMAP
        ], [0, 1, 2, 3]));

        YMaps.Styles.add("constructor#pmlbmPlacemark", {
            iconStyle : {
                href : "http://api-maps.yandex.ru/i/0.3/placemarks/pmlbm.png",
                size : new YMaps.Point(28,29),
                offset: new YMaps.Point(-8,-27)
            }
        });

       map.addOverlay(createObject("Placemark", new YMaps.GeoPoint(27.65707,53.863816), "constructor#pmlbmPlacemark", "ТП ООО \"ТЕХАВТО\""));
        
        function createObject (type, point, style, description) {
            var allowObjects = ["Placemark", "Polyline", "Polygon"],
                index = YMaps.jQuery.inArray( type, allowObjects),
                constructor = allowObjects[(index == -1) ? 0 : index];
                description = description || "";
            
            var object = new YMaps[constructor](point, {style: style, hasBalloon : !!description});
            object.description = description;
            
            return object;
        }
    });
