﻿function preloader(){
	heavyImage = new Image(); 
	heavyImage.src = "/i/imgH.png";
}

//jQuery.noConflict();

$(document).ready(function(){
/*
	// Internet Explorer
	if($.browser.msie){
		
	}
*/
	// HIGHSLIDE
//	hs.graphicsDir = '/j/g/';
//	hs.outlineType = 'rounded-white';

	var idStranky = $("body").attr("class");
	
	// JEDNÁ SE O ZOBRAZENÍ HRAČEK
	if (idStranky != 'index' && idStranky != 'os' && idStranky != 'pp' && idStranky != 'ks' && idStranky != 'ko') {
		// PŘIDÁNÍ "SPANu" PRO ZOBRAZENÍ LUPY
		$(".cbb > a").append("<span></span>");
		
		// HIGHSLIDE // duplic
	    $(".cbb a").each(function() {
	    	hs.graphicsDir = '/j/g/';
			hs.outlineType = 'rounded-white';
			
			this.onclick = function() {
				return hs.expand(this);
			}
		});
		// ZOBRAZENÍ NÁHLEDŮ // duplic
		$(".cbb p a").imgPreview({

			containerID: 'imgPreviewWithStyles',
			imgCSS: {
				// Limit preview size:
				height: 90,
				minWidth: 67
			},
			// When container is shown:
			onShow: function(link){
				// Animate link:
				$(link).stop().animate({opacity:0.65});
				// Reset image:
//				$('img', this).stop().css({opacity:0});
				$("img", this).css({opacity:0});
			},
			// When image has loaded:
			onLoad: function(){
				// Animate image
				$(this).animate({opacity:1}, 300);
			},
			// When container hides: 
			onHide: function(link){
				// Animate link:
				$(link).stop().animate({opacity:1});
			}
		});
	}
	
	if (idStranky == 'ks') {
		// ZOBRAZENÍ NÁHLEDŮ // duplic
		
		$(".ktlc a").imgPreview({

			containerID: 'imgPreviewWithStyles',
			imgCSS: {
				// Limit preview size:
				height: 90,
				minWidth: 90
			},
			// When container is shown:
			onShow: function(link){
				// Animate link:
				$(link).stop().animate({opacity:0.65});
				// Reset image:
//				$('img', this).stop().css({opacity:0});
				$("img", this).css({opacity:0});
			},
			// When image has loaded:
			onLoad: function(){
				// Animate image
				$(this).animate({opacity:1}, 300);
			},
			// When container hides: 
			onHide: function(link){
				// Animate link:
				$(link).stop().animate({opacity:1});
			}
		});
	}


	if (idStranky == 'ks' || idStranky == 'ko'){
		// ANIMACE HARMONIKY
		$('ul.accordion').accordion();
	}
	
	if (idStranky == 'ko') {
		// ANIMACE "TEXTAREA"
		$('textarea').elastic();
	}

	// ZOBRAZENÍ CERTIFIKÁTŮ V "ZIPU" + ANIMACE "ZIPU"
	if (idStranky == 'os') {

		// HIGHSLIDE // duplic
	    $("div#cert a").each(function() {
	    	hs.graphicsDir = '/j/g/';
			hs.outlineType = 'rounded-white';
			
			this.onclick = function() {
				return hs.expand(this);
			}
		});
		
		// ANIMACE ZIPU
		// Pokud nejde o Internet Explorer
		if(!$.browser.msie){
		
			var lang = $("html").attr("xml:lang");
			var showCert;
			var hideCert;
			if (lang == "en") {
				showCert = "Show certificates";
				hideCert = "Hide certificates";
			} else {
				showCert = "Zobrazit certifikáty";
				hideCert = "Skrýt certifikáty";
			}
	
			$("a.show").text(showCert);
			$("a.show").click(function(){
				if ($(this).text() == showCert) {
					$("#a-zip").animate({ marginLeft:"661px"}, 1200, "swing", success );
					$("#zip-top-end").animate({ marginLeft:"673px", width:"0px"}, 1200, "swing" );
					$("#zip-bottom-end").animate({ marginLeft:"673px", width:"0px"}, 1200, "swing" );
					$("#zip-top-start").animate({ width:"650px"}, 1200, "swing" );
					$("#zip-bottom-start").animate({ width:"650px"}, 1200, "swing" );
				} else {
					$("#cert").slideToggle(1200, zpet);
				};
				return false;
			});
			function success() {
				$("#cert").slideToggle(1200);
				$("a.show").text(hideCert);
			};
			function zpet() {
				$("#a-zip").animate({ marginLeft:"22px" }, 1200, "swing" );
				$("#zip-top-end").animate({ marginLeft:"23px", width:"650px"}, 1200, "swing" );
				$("#zip-bottom-end").animate({ marginLeft:"23px", width:"650px"}, 1200, "swing" );
				$("#zip-top-start").animate({ width:"0px"}, 1200, "swing" );
				$("#zip-bottom-start").animate({ width:"0px"}, 1200, "swing" );
				$("a.show").text(showCert);
			};
		}
	}
	
});

