jQuery(document).ready(function(){

	var path = "/wp-content/themes/artishok",
		lbSettings = {
			imageLoading: path + '/js/images/lightbox-ico-loading.gif',
			imageBtnPrev: path + '/js/images/lightbox-btn-prev.gif',
			imageBtnNext: path + '/js/images/lightbox-btn-next.gif',
			imageBtnClose: path + '/js/images/lightbox-btn-close.gif',
			imageBlank: path + '/js/images/lightbox-blank.gif'
		},
		allTechImgs = jQuery(".tech-type .items img"),
		techImgsNum = allTechImgs.length,
		techImgsLoadedNum = 0,

		createTechCarousels = function() {
			jQuery("#tech-type-1").jCarouselLite({
				btnNext: "#tech-type-1-right",
				btnPrev: "#tech-type-1-left",
				visible: 5
			});

			jQuery("#tech-type-2").jCarouselLite({
				btnNext: "#tech-type-2-right",
				btnPrev: "#tech-type-2-left",
				visible: 5
			});

			jQuery("#tech-type-3").jCarouselLite({
				btnNext: "#tech-type-3-right",
				btnPrev: "#tech-type-3-left",
				visible: 5
			});

			jQuery('#tech-type-1 a').lightBox(lbSettings);
			jQuery('#tech-type-2 a').lightBox(lbSettings);
			jQuery('#tech-type-3 a').lightBox(lbSettings);
		},
		
		increaseImgsNum = function() {
			techImgsLoadedNum++;
			if (techImgsLoadedNum == techImgsNum) {
				createTechCarousels();
			}
		};

	allTechImgs.each(function(){
		if (this.complete) {
			increaseImgsNum();
			return;
		}

		this.onload = increaseImgsNum;
	});
});
