$(document).ready(function() {
	$('a.lightbox').lightBox();	
 	$('#slider').slides({
		preload: true,
		generateNextPrev: false,
    play: 5000
	});
	$("form.jqtransform").jqTransform();
	$('#boxes .box').hover(function(){
    $(this).find('.icon img').animate({ width: '80'}, 100);
	},function(){
	  $(this).find('.icon img').delay(0).animate({ width: '60'}, 250);
  });
		$('#prevod').CreateBubblePopup({ 
			innerHtml: $('#prevod').attr('data-title'),
			themeName: 	'blue',
			themePath: 	'/img/jquerybubblepopup-theme',
			position: 'right',
			align: 'middle',
			width: 300,
      manageMouseEvents: true
		});
    $('#transfer').CreateBubblePopup({ 
			innerHtml: $('#transfer').attr('data-title'),
			themeName: 	'blue',
			themePath: 	'/img/jquerybubblepopup-theme',
			position: 'right',
			align: 'middle',
			width: 500,
      manageMouseEvents: true
		});
  $('.invalid').each(function(){
    var err = $(this).attr('data-error');
    $(this).parent().parent().parent().parent().append("<span class='e'>"+err+"</span>");
  });
  $("a.domena_whois").click().fancybox({
                    'width': '40%',
                    'height': '800',
                    'autoScale': true,
                    'transitionIn': 'fade',
                    'transitionOut': 'fade',
                    'type':'iframe',
                    'href':$(this).attr('href')
                });
});



function draw_bubble(divid,text){
	if(!$('#'+divid).IsBubblePopupOpen()){
		$('#'+divid).CreateBubblePopup({ 
			innerHtml: text,
			themeName: 	'orange',
			themePath: 	'/img/jquerybubblepopup-theme',
			position: 'right',
			align: 'middle',
			manageMouseEvents: false
		});
		$('#'+divid).ShowBubblePopup();
		$('#'+divid).FreezeBubblePopup();
	}
}
function validate_text(divid){
	var val = $("#"+divid).val();
	if(val == null || val == "" || val.length < 3){
		draw_bubble(divid,"Vyplňte prosím povinné pole");
		return false;
	}else{
		$('#'+divid).HideBubblePopup();
		return true;
	}
}
function validate_psc(divid){
	var val = $("#"+divid).val();
	var zipCodePattern = /^\d{5}$|^\d{3} \d{2}$/;
	if(!zipCodePattern.test(val)){
		draw_bubble(divid,"Vyplňte prosím správně PSČ ve tvaru xxx xx nebo xxxxx");
		return false;
	}else{
		$('#'+divid).HideBubblePopup();
		return true;
	}
}
function validate_telefon(divid){
	var val = $("#"+divid).val();
	var Pattern = /^(\+\d{3})? ?\d{3} ?\d{3} ?\d{3}$/;
	if(!Pattern.test(val)){
		draw_bubble(divid,"Vyplňte prosím správně telefonní číslo ve tvaru +420 123 456 789 nebo +420123456789");
		return false;
	}else{
		$('#'+divid).HideBubblePopup();
		return true;
	}
}
function validate_email(divid){
	var val = $("#"+divid).val();
	var zipCodePattern = /^([\w\-\.]+)@((\[([0-9]{1,3}\.){3}[0-9]{1,3}\])|(([\w\-]+\.)+)([a-zA-Z]{2,4}))$/;
	if(!zipCodePattern.test(val)){
		draw_bubble(divid,"Vyplňte prosím správný email");
		return false;
	}else{
		$('#'+divid).HideBubblePopup();
		return true;
	}
}


