﻿$(document).ready(function() {
	if(getObj('body')) getObj('body').style.backgroundColor = '#333333';
	
	if (getObj("banner-pics")) { // pouze na úvodce
		pic_bg = new Image();
		pic_bg.src = '/images/gr/banner-bg.png';
		
		banner_fade("banner-pics", 1000, 5000);
		
		$("#banner-text1").animate({
				marginLeft: '-=50'
			}, 1000);
		$("#banner-text2").animate({
				marginLeft: '+=50'
			}, 1000);
		
	}
	
	if (getObj("tabs-uvod")) { // pouze na úvodce
		$(".tab_content").hide(); //Hide all content
		$("ul.tabs li:first a").addClass("active").show(); //Activate first tab
		$(".tab_content:first").show(); //Show first tab content
		
		//On Click Event
		$("ul.tabs li").click(function() {
		
			$("ul.tabs li a").removeClass("active"); //Remove any "active" class
			$(this).find('a').addClass("active"); //Add "active" class to selected tab
			$(".tab_content").hide(); //Hide all tab content
		
			var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
			$(activeTab).fadeIn(); //Fade in the active ID content
			return false;
		});
	}
	
	initBuyNowQtip();
});

function initBuyNowQtip() {
	$('input[id^="kup-ted-button-"]').qtip({
		content: {
			attr: 'title'
		},
		position: {
			my: 'bottom right',
			at: 'top right'
		},
		style: {
			classes: 'ui-tooltip-dark'
		}
	});
}

function banner_fade(obj, fade_speed, change_speed) {
	var i = 0;
	var i_next = 0;
	var max = 3; // počet obrázku mínus jedna
	var $banner_pics = $('#'+obj+' > div');
	
	pic = [];
	$banner_pics.find('img').each(function(index) { // preloader obrázků
		picsrc = $(this).attr("src");
		pic[index] = new Image();
		pic[index].src = picsrc;
	});
	
	$banner_pics.hide();
	$banner_pics.eq(i).fadeIn(2000, function() { // načtení úvodního obrázku
			setInterval(function() {
					i_next = i + 1;
					if (i_next > max) i_next = 0;
					$banner_pics.eq(i).fadeOut(fade_speed);
					$banner_pics.eq(i_next).fadeIn(fade_speed);
					i = i_next;
				}, change_speed);
		});
}

hs.graphicsDir = '/lib-js/img-nahled/graphics/';
hs.align = 'center';
hs.transitions = ['expand', 'crossfade'];
hs.outlineType = 'rounded-white';
hs.wrapperClassName = 'controls-in-heading';
hs.fadeInOut = true;
hs.dimmingOpacity = 0.7;
// Add the controlbar
if (hs.addSlideshow) hs.addSlideshow({
	//slideshowGroup: 'group1',
	interval: 5000,
	repeat: false,
	useControls: true,
	fixedControls: true,
	overlayOptions: {
		opacity: 1,
		position: 'top right',
		hideOnMouseOut: false
	}
});
