/* full background
credit: http://www.buildinternet.com/project/supersized/ */
(function($){$.fn.supersized=function(){var options=$.extend($.fn.supersized.defaults,$.fn.supersized.options);if(options.slideshow==1){setInterval("theslideshow()",options.slideinterval);}
$().ready(function(){$('#supersize').resizenow();});$(window).bind("resize",function(){$('#supersize').resizenow();});};$.fn.resizenow=function(){var options=$.extend($.fn.supersized.defaults,$.fn.supersized.options);return this.each(function(){var minwidth=options.minsize*(options.startwidth);var minheight=options.minsize*(options.startheight);var ratio=options.startheight/options.startwidth;var imagewidth=$(this).width();var imageheight=$(this).height();var browserwidth=$(window).width();var browserheight=$(window).height();if((browserheight<minheight)&&(browserwidth<minwidth)){$(this).height(minheight);$(this).width(minwidth);}
else{if(browserheight>browserwidth){imageheight=browserheight;$(this).height(browserheight);imagewidth=browserheight/ratio;$(this).width(imagewidth);if(browserwidth>imagewidth){imagewidth=browserwidth;$(this).width(browserwidth);imageheight=browserwidth*ratio;$(this).height(imageheight);}}
if(browserwidth>=browserheight){imagewidth=browserwidth;$(this).width(browserwidth);imageheight=browserwidth*ratio;$(this).height(imageheight);if(browserheight>imageheight){imageheight=browserheight;$(this).height(browserheight);imagewidth=browserheight/ratio;$(this).width(imagewidth);}}}
return false;});};$.fn.supersized.defaults={startwidth:640,startheight:480,minsize:.5,slideshow:1,slideinterval:5000};})(jQuery);function theslideshow(){var currentslide=$('#supersize .activeslide');if(currentslide.length==0)currentslide=$('#supersize :last');var nextslide=currentslide.next().length?currentslide.next():$('#supersize :first');nextslide.addClass('activeslide');currentslide.removeClass('activeslide');}

(function($) {
	var cache = [];
	// Arguments are image paths relative to the current page.
	$.preLoadImages = function() {
		var args_len = arguments.length;
		for (var i = args_len; i--;) {
			var cacheImage = document.createElement('img');
			cacheImage.src = arguments[i];
			cache.push(cacheImage);
		}
	}
})(jQuery)


$(document).ready(function(){
	
	if($("#hotel").length > 0) {
		
		$("#hotel").each(function(){
			
			var wurl = $(this).attr("href");
			var wname = 'skitourhotel';
			var warg = 'location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0,width=1024';
					
				if(typeof(popupWin) != "object"){
					popupWin = window.open(wurl,wname,warg);
				} else {
					if(!popupWin.closed){
						popupWin.location.href = wurl;
					} else {
						popupWin = window.open(wurl,wname,warg);
					}
				}
				popupWin.focus();		
				
		});
	}
	
	if($("#page.print").length > 0) {
		if(confirm("Přejete si vytisknout tuto stránku?")) {
			window.print();
		}
	}
	
	if($.browser.msie && $.browser.version.substr(0,1)<7) {
		nossize = true;
	} else {
		$("body").prepend('<div id="supersize"><span class="activeslide"><img src="/img/bg.jpg" />&nbsp;</span></div>');	
		// supersized initialization
		$(function(){
			$.fn.supersized.options = {  
				startwidth: 1024,  
				startheight: 709,
				minsize: .50,
				slideshow: 0,
				slideinterval: 5000  
			};
			$('#supersize').supersized(); 
		});
		$('#supersize').show();
		/* setTimeout(function(){
			$('#supersize').fadeIn("slow");    
		}, 500); */
	}
	
	lightboxes();
	carousel();
	pgIndex();
	
	// bannery
	//flashMovieWithVars = $.flash.create();
	$('#bn1').flash({
		swf: '/img/banners/o2_300x60.swf',
		width: 300,
		height: 60,
		wmode: 'transparent',
		flashvars: {
			clickTAG: 'http://www.o2extra.cz/klub',
			clickTarget: '_blank'
		}
	});
	
	
	$("a[rel=external]").each(function(){ $(this).attr("target","_blank");})
	
	// fb
	$("#fb-faces").hide();
	$("#fb-faces").append('<iframe id="fb" scrolling="no" frameborder="0" allowTransparency="true" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; overflow-x: hidden; overflow-y: hidden; height: 70px; width: 275px;" src="http://www.facebook.com/plugins/fan.php?colorscheme=light&amp;header=false&amp;css=http%3A%2F%2Fskitour.2142.net%2Fs_facebook.css%3F&amp;height=70&amp;href=https%3A%2F%2Fwww.facebook.com%2Fpages%2FSkiTour%2F71565231085&amp;locale=cs_CZ&amp;sdk=joey&amp;show_faces=true&amp;stream=false&amp;width=275"></iframe>');
	setTimeout(function(){$("#fb-faces").fadeIn();}, 1500);
	
	$("#fb-line").hide();
	$("#fb-line").append('<iframe src="http://www.facebook.com/plugins/like.php?app_id=274297689248274&amp;href=https%3A%2F%2Fwww.facebook.com%2Fskitour&amp;send=false&amp;layout=standard&amp;width=200&amp;show_faces=false&amp;action=like&amp;colorscheme=dark&amp;font&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:200px; height:80px;" allowTransparency="true"></iframe>');
	setTimeout(function(){$("#fb-line").fadeIn();}, 1000);
	
	$("#sl-flt").keyup(function(){
		//alert("tr[title*=\"" + $(this).val() + "\"] td");
		$("tr.sl-row").show();
		$("tr.sl-row").not($("tr[title*=" + $(this).val().toLowerCase().replace("/","-").replace(" ","_") + "]")).hide();
	});
	
	$('#fadein img:gt(0)').hide();
    setInterval(function(){
      $('#fadein :first-child').fadeOut(2000)
         .next('img').fadeIn(2000)
         .end().appendTo('#fadein');}, 
      5000);
	
	/* if($("a.go-to-gallery").length > 0) {
		$("a.go-to-gallery").click(function(){
			$(this).siblings("a.gal-thumb.js-hide").fadeIn();
			return false;
		});
		
	} */
	
	$("#Ff_price_grp_1").change(function(){
		if($(this).val() == 1) {
			$(".pgrp2").show();
		} else {
			$(".pgrp2").hide();
		}
		
		var wurl = 'http://www.cedok.com/Jizerska50/default.aspx';
		var wname = 'jiz50hotel';
		var warg = 'location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0,width=1024';
		
		if($(this).val() == 2) {
			if(typeof(popupWin) != "object"){
				popupWin = window.open(wurl,wname,warg);
			} else {
				if(!popupWin.closed){
					popupWin.location.href = wurl;
				} else {
					popupWin = window.open(wurl,wname,warg);
				}
			}
			popupWin.focus();
		}	
	});
	
	if($("#Ff_price_grp_1").val() == 1) {
		$(".pgrp2").show();
	} else {
		$(".pgrp2").hide();
	}
	
	$("input[name=price_grp_3]").change(function(){
		if($(this).val() >= 1) {
			$(".spz").show();
		} else {
			$(".spz").hide();
		}
	});
	
	if(($("input[name=price_grp_3]").attr("checked") != "undefined") && ($("input[name=price_grp_3]").attr("checked") == "checked")) {
		$(".spz").show();
	} else {
		$(".spz").hide();
	}

	$(".registree a.title").click(function(){
		$(this).parent().siblings("ul").toggle();
		$(this).toggleClass("rg_close");
		$(this).toggleClass("rg_open");
	});
	
});

this.lightboxes = function() {
	
	// lb musi byt <a rel="lightbox-galerie"..
	
	str = '';
	$('a[rel^=lightbox]').each(function(){
		uq = $(this).attr("rel").substr(9);
		if(str.indexOf("<" + uq + ">") == -1) {
			str += "<" + uq + ">";
		}
	});
	gals = str.substr(1, str.length-2).split("><");
	for(i = 0; i < gals.length; i++) {
		$("a[rel=lightbox-" + gals[i] + "]").lightBox({
			containerResizeSpeed: 400,
			txtImage: "Obrázek / Image :",
			txtOf: "/",
			imageLoading: "/img/lb-loading.gif",
			imageBtnClose: "/img/lb-btn-close.gif",
			imageBtnPrev: "/img/lb-btn-prev.gif",
			imageBtnNext: "/img/lb-btn-next.gif"
		});
	}

}

this.wcam = function(){
	
	$("#cams .links a").click(function(){
		if(!$(this).hasClass("active")) {
			$("#cams .links a").toggleClass("active");
			if($("#cams .links a.active").hasClass("wcl1")){
				$("#cams .wc1").show();
				$("#cams .wc2").hide();
			} else {
				$("#cams .wc2").show();
				$("#cams .wc1").hide();
			}
		} 
		return false;
	});
	 
	
}

this.carousel = function() {
	
 	if($("#carousel").length > 0) {	
		
 		$("#carousel a.js-hide").toggleClass("js-hide");
		$("#carousel .c-holder").prepend("" +
			'<div class="c-btns clear"><a href="javascript:void()" class="cb-prev c-btn" title="&lt;">&lt;</a>' +
			'<a href="javascript:void()" class="cb-next c-btn" title="&gt;">&gt;</a>' +
			'<a href="javascript:void()" class="cb-stop c-btn" title="stop">stop</a></div>');
	
		$("#carousel .c-holder").jCarouselLite({
				btnNext: ".cb-next",
				btnPrev: ".cb-prev",
				btnStop: ".cb-stop",
				auto: 1000,
				speed: 1500,
				visible: 7
		});
	}

}


this.pgIndex = function(){
	if($(".pgIndex").length < 1) return false;
	
	$(".v-link").hover(function(){
		$(".v-link.active").toggleClass("active-disabled");
		tmp = $(this).attr("title").split(" || ");
		$("#vdate").html(tmp[0]);
		$("#vdesc").html(tmp[1]);
	},function(){
		$(".v-link.active-disabled").toggleClass("active-disabled");
	});


}

