$(document).ready(function(){
	
	if($("#page.print").length > 0) {
		if(confirm("Přejete si vytisknout tuto stránku?")) {
			window.print();
		}
	}
	
	lightboxes();
	label_in_input();
	
	$("#frmPhone, #frmContact").submit(function(){
	
		//alert($(this).find("#cpt").val().match(/^[a-z0-9]+$/));
		if($(this).find("#cpt").val().match(/^[a-z0-9]+$/)) {
			return true;
		}
		
		if(!$(this).find("#Ff_phone").val().match(/^[0-9 +]+$/)) {
			alert("Vyplnte prosim sve telefonni cislo\nPlease fill-in your phone number");
		} else if(($(this).find("#Ff_email").length > 0) && !$(this).find("#Ff_email").val().match(/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/)) {
			alert("Zadejte emailovou adresu ve spravnem tvaru xxx@yyy.zzz\nPlease fill-in your email in correct format xxx@yyy.zzz");
		} else {
			$(this).find(".onsubmit-hide").fadeOut(100, function(){
				$(this).next().fadeIn();
			});
		}
		
		return false;
		
	});
});

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.label_in_input = function() {

	$(".labelInInp input, .labelInInp textarea").each(function(){
		
		$(this).data("currentValue", $(this).val());
		
		$(this).focus(function(){
			if($(this).val() == $(this).data("currentValue")) {
				$(this).val("");
			}
		});
		
		$(this).blur(function(){
			if($(this).val() == "") {
				$(this).val($(this).data("currentValue"));
			}
		});
	
	
	});

}

