$(window).load(function() {
	$('#frame').width($('#main-img').width());
	$('#slider').nivoSlider({
		effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
		slices:1,
		animSpeed:500, //Slide transition speed
		pauseTime:10000,
		startSlide:0, //Set starting Slide (0 index)
		directionNav:false, //Next & Prev
		directionNavHide:true, //Only show on hover
		controlNav:false, //1,2,3...
		controlNavThumbs:false, //Use thumbnails for Control Nav
		controlNavThumbsFromRel:false, //Use image rel for thumbs
		controlNavThumbsSearch: '.jpg', //Replace this with...
		controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
		keyboardNav:false, //Use left & right arrows
		pauseOnHover:false, //Stop animation while hovering
		manualAdvance:false, //Force manual transitions
		captionOpacity:0.8, //Universal caption opacity
		beforeChange: function(){},
		afterChange: function(){},
		slideshowEnd: function(){}, //Triggers after all slides have been shown
		lastSlide: function(){}, //Triggers when last slide is shown
		afterLoad: function(){} //Triggers when slider has loaded
	});

	if( $(window).width()  <= 1024) {
		$("body.main-page").css('paddingLeft','0');
		$("body.main-page").css('paddingRight','0');
	} else {
		$("body.main-page").css('paddingRight','5%');
		$("body.main-page").css('paddingRight','5%');
	}
});

$(document).ready(function() {			

	$(window).resize(function() {
		$('#frame').width($('#main-img').width());
	});

	function formatTitle(title, currentArray, currentIndex, currentOpts) {
		return (title && title.length ? '<b>' + title + '</b>' : '' ) + 'Изображение ' + (currentIndex + 1) + ' из ' + currentArray.length;
	}

	$("a[rel^=gallery]").fancybox({
			'titlePosition' 	: 'inside',
			'titleFormat'	: formatTitle
	});

	$('div.calculator-block h3').click(function() {
		$(this).parent().toggleClass('active-block');
	});

	/*разукрасим таблицу*/
	$('div.calculator-block tr:nth-child(even)').addClass('grey');
	//alert($("body.main-page").width());
});

var getWidth = function() {
	if(typeof(window.innerWidth) == 'number' ) {
		width = window.innerWidth;
	} else if(document.documentElement && (document.documentElement.clientWidth)) {
		width = document.documentElement.clientWidth;
	}
	return width;
}
/*
window.onload = function() {
	var body = document.getElementsByTagName('body')[0];
	alert (getWidth() + 'getWidth' );
	if(getWidth() <= 1024) {
		$("body.main-page").css('paddingLeft','0');
		$("body.main-page").css('paddingRight','0');
	} else {
		$("body.main-page").css('paddingRight','5%');
		$("body.main-page").css('paddingRight','5%');
	}
}*/
