/* rounded corners */
;(function($){var style=document.createElement('div').style;var moz=style['MozBorderRadius']!==undefined;var webkit=style['WebkitBorderRadius']!==undefined;var radius=style['borderRadius']!==undefined||style['BorderRadius']!==undefined;var mode=document.documentMode||0;var noBottomFold=$.browser.msie&&(($.browser.version<8&&!mode)||mode<8);var expr=$.browser.msie&&(function(){var div=document.createElement('div');try{div.style.setExpression('width','0+0');div.style.removeExpression('width')}catch(e){return false}return true})();function sz(el,p){return parseInt($.css(el,p))||0};function hex2(s){var s=parseInt(s).toString(16);return(s.length<2)?'0'+s:s};function gpc(node){while(node){var v=$.css(node,'backgroundColor');if(v&&v!='transparent'&&v!='rgba(0, 0, 0, 0)'){if(v.indexOf('rgb')>=0){var rgb=v.match(/\d+/g);return'#'+hex2(rgb[0])+hex2(rgb[1])+hex2(rgb[2])}return v}if(node.nodeName.toLowerCase()=='html')break;node=node.parentNode}return'#ffffff'};function getWidth(fx,i,width){switch(fx){case'round':return Math.round(width*(1-Math.cos(Math.asin(i/width))));case'cool':return Math.round(width*(1+Math.cos(Math.asin(i/width))));case'sharp':return Math.round(width*(1-Math.cos(Math.acos(i/width))));case'bite':return Math.round(width*(Math.cos(Math.asin((width-i-1)/width))));case'slide':return Math.round(width*(Math.atan2(i,width/i)));case'jut':return Math.round(width*(Math.atan2(width,(width-i-1))));case'curl':return Math.round(width*(Math.atan(i)));case'tear':return Math.round(width*(Math.cos(i)));case'wicked':return Math.round(width*(Math.tan(i)));case'long':return Math.round(width*(Math.sqrt(i)));case'sculpt':return Math.round(width*(Math.log((width-i-1),width)));case'dogfold':case'dog':return(i&1)?(i+1):width;case'dog2':return(i&2)?(i+1):width;case'dog3':return(i&3)?(i+1):width;case'fray':return(i%2)*width;case'notch':return width;case'bevelfold':case'bevel':return i+1}};$.fn.corner=function(options){if(this.length==0){if(!$.isReady&&this.selector){var s=this.selector,c=this.context;$(function(){$(s,c).corner(options)})}return this}return this.each(function(index){var $this=$(this);var o=[$this.attr($.fn.corner.defaults.metaAttr)||'',options||''].join(' ').toLowerCase();var keep=/keep/.test(o);var cc=((o.match(/cc:(#[0-9a-f]+)/)||[])[1]);var sc=((o.match(/sc:(#[0-9a-f]+)/)||[])[1]);var width=parseInt((o.match(/(\d+)px/)||[])[1])||10;var re=/round|bevelfold|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dogfold|dog/;var fx=((o.match(re)||['round'])[0]);var fold=/dogfold|bevelfold/.test(o);var edges={T:0,B:1};var opts={TL:/top|tl|left/.test(o),TR:/top|tr|right/.test(o),BL:/bottom|bl|left/.test(o),BR:/bottom|br|right/.test(o)};if(!opts.TL&&!opts.TR&&!opts.BL&&!opts.BR)opts={TL:1,TR:1,BL:1,BR:1};if($.fn.corner.defaults.useNative&&fx=='round'&&(radius||moz||webkit)&&!cc&&!sc){if(opts.TL)$this.css(radius?'border-top-left-radius':moz?'-moz-border-radius-topleft':'-webkit-border-top-left-radius',width+'px');if(opts.TR)$this.css(radius?'border-top-right-radius':moz?'-moz-border-radius-topright':'-webkit-border-top-right-radius',width+'px');if(opts.BL)$this.css(radius?'border-bottom-left-radius':moz?'-moz-border-radius-bottomleft':'-webkit-border-bottom-left-radius',width+'px');if(opts.BR)$this.css(radius?'border-bottom-right-radius':moz?'-moz-border-radius-bottomright':'-webkit-border-bottom-right-radius',width+'px');return}var strip=document.createElement('div');$(strip).css({overflow:'hidden',height:'1px',minHeight:'1px',fontSize:'1px',backgroundColor:sc||'transparent',borderStyle:'solid'});var pad={T:parseInt($.css(this,'paddingTop'))||0,R:parseInt($.css(this,'paddingRight'))||0,B:parseInt($.css(this,'paddingBottom'))||0,L:parseInt($.css(this,'paddingLeft'))||0};if(typeof this.style.zoom!=undefined)this.style.zoom=1;if(!keep)this.style.border='none';strip.style.borderColor=cc||gpc(this.parentNode);var cssHeight=$(this).outerHeight();for(var j in edges){var bot=edges[j];if((bot&&(opts.BL||opts.BR))||(!bot&&(opts.TL||opts.TR))){strip.style.borderStyle='none '+(opts[j+'R']?'solid':'none')+' none '+(opts[j+'L']?'solid':'none');var d=document.createElement('div');$(d).addClass('jquery-corner');var ds=d.style;bot?this.appendChild(d):this.insertBefore(d,this.firstChild);if(bot&&cssHeight!='auto'){if($.css(this,'position')=='static')this.style.position='relative';ds.position='absolute';ds.bottom=ds.left=ds.padding=ds.margin='0';if(expr)ds.setExpression('width','this.parentNode.offsetWidth');else ds.width='100%'}else if(!bot&&$.browser.msie){if($.css(this,'position')=='static')this.style.position='relative';ds.position='absolute';ds.top=ds.left=ds.right=ds.padding=ds.margin='0';if(expr){var bw=sz(this,'borderLeftWidth')+sz(this,'borderRightWidth');ds.setExpression('width','this.parentNode.offsetWidth - '+bw+'+ "px"')}else ds.width='100%'}else{ds.position='relative';ds.margin=!bot?'-'+pad.T+'px -'+pad.R+'px '+(pad.T-width)+'px -'+pad.L+'px':(pad.B-width)+'px -'+pad.R+'px -'+pad.B+'px -'+pad.L+'px'}for(var i=0;i<width;i++){var w=Math.max(0,getWidth(fx,i,width));var e=strip.cloneNode(false);e.style.borderWidth='0 '+(opts[j+'R']?w:0)+'px 0 '+(opts[j+'L']?w:0)+'px';bot?d.appendChild(e):d.insertBefore(e,d.firstChild)}if(fold&&$.support.boxModel){if(bot&&noBottomFold)continue;for(var c in opts){if(!opts[c])continue;if(bot&&(c=='TL'||c=='TR'))continue;if(!bot&&(c=='BL'||c=='BR'))continue;var common={position:'absolute',border:'none',margin:0,padding:0,overflow:'hidden',backgroundColor:strip.style.borderColor};var $horz=$('<div/>').css(common).css({width:width+'px',height:'1px'});switch(c){case'TL':$horz.css({bottom:0,left:0});break;case'TR':$horz.css({bottom:0,right:0});break;case'BL':$horz.css({top:0,left:0});break;case'BR':$horz.css({top:0,right:0});break}d.appendChild($horz[0]);var $vert=$('<div/>').css(common).css({top:0,bottom:0,width:'1px',height:width+'px'});switch(c){case'TL':$vert.css({left:width});break;case'TR':$vert.css({right:width});break;case'BL':$vert.css({left:width});break;case'BR':$vert.css({right:width});break}d.appendChild($vert[0])}}}}})};$.fn.uncorner=function(){if(radius||moz||webkit)this.css(radius?'border-radius':moz?'-moz-border-radius':'-webkit-border-radius',0);$('div.jquery-corner',this).remove();return this};$.fn.corner.defaults={useNative:true,metaAttr:'data-corner'}})(jQuery);


function panel() {

	var effect_speed = 400;

	

	$('.panel').hide();

	$('.panel:first').show();

	

	$('#panel1-click').click(function() {

		if(!$("#panel1").is(":visible")) {

			 if ( !$('.panel').is(':animated') ) {

				$('.panel').slideUp(effect_speed);

				$('#panel1').slideDown(effect_speed);

			 }

		} else {

			window.location = "destinacije-karta.php";	

		}

	});

	

	$('#panel2-click').click(function() {

		if(!$("#panel2").is(":visible")) {

			if ( !$('.panel').is(':animated') ) {

				$('.panel').slideUp(effect_speed);

				$('#panel2').slideDown(effect_speed);

			}

		} else {

			//window.location = "plan-zracne-luke.php";	

		}

	});

	

	$('#panel3-click').click(function() {

		if(!$("#panel3").is(":visible")) {	

			if ( !$('.panel').is(':animated') ) {

				$('.panel').slideUp(effect_speed);

				$('#panel3').slideDown(effect_speed);

			}

			

		} else {

			window.location = "kako-do-nas.php";	

		}

	});

	

	$('#panel4-click').click(function() {

		if(!$("#panel4").is(":visible")) {

			if ( !$('.panel').is(':animated') ) {

				$('.panel').slideUp(effect_speed);

				$('#panel4').slideDown(effect_speed);

			}

		} else {

			window.location = "tourist-info.php";	

		}

	});

}

/*
 * jQuery mail validator 1.0
 * by Juraj Hilje - Futuro I.S.
 */
 
function isValid(emailAddress) {
var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
return pattern.test(emailAddress);
} 

function validate(selector) {
	var error = 0;
	var n = $(selector+" .required").size();
	var n_mail = $(selector+" .mail").size();
	$(selector).submit(function() {
		error = 0;					   
		for(i=0; i<n; i++) {					   
			if ($.trim($(selector+" .required:eq("+i+")").val()) == '')	{
				$(selector+" .required:eq("+i+")").addClass("error");
				error = 1;
			} else {
				$(selector+" .required:eq("+i+")").removeClass("error");
			}
		}
		for(i=0; i<n_mail; i++) {					   
			if ( !isValid($.trim($(".mail:eq("+i+")").val())) )	{
				$(selector+" .mail:eq("+i+")").addClass("error");
				error = 1;
			} else {
				$(selector+" .mail:eq("+i+")").removeClass("error");
			}
		}
		if(error) { return false; }
	});
	
	$(selector+" .required").keypress(function() {
		$(this).removeClass("error");							   
	});
}



function contentMenu() {

	

	

	$('#content-menu .content-block').hide();

	$('#content-menu .content-block:first').show();

	

	$('#content-menu h2').click(function() {

		if(!$(this).next().is(':visible')) {									 

											 

		$('.content-block').slideUp('normal');									  

		$(this).next().slideDown('normal');

		

		}

	});

  

  }

  

  

$(document).ready(function() {

	$('h2#lulic').click(function() {
		window.open('http://www.lulic.hr','childWin','');
	});

								

	panel();

	

	contentMenu();	

								

	$("a.lightbox").fancybox({

			'zoomSpeedIn': 0, 'zoomSpeedOut': 0, 'overlayShow': true

	});

	$("a.lightbox-webcam").fancybox({

			'zoomSpeedIn': 0, 'zoomSpeedOut': 0, 'overlayShow': true, 'frameWidth': 736, 'frameHeight': 480 , 'imageScale': true

	});
	
	$("a.lightbox-checkin").fancybox({

			'zoomSpeedIn': 0, 'zoomSpeedOut': 0, 'overlayShow': true, 'frameWidth': 880, 'frameHeight': 630 , 'imageScale': true

	});

								

							



	var speed = 1;



	//izbornik					   

	$(function() {

		$('#nav').droppy();

	});

	

	//png fix

	$('.corner').ifixpng();

	$('.corner2').ifixpng();

	$('.corner3').ifixpng();

	$('#corner4').ifixpng();

	$('.corner20').ifixpng();

	$('.corner21').ifixpng();

	

	$('#toggler1').ifixpng();

	$('#toggler2').ifixpng();

	$('#toggler3').ifixpng();

	$('#toggler4').ifixpng();

	

	$('.avion-ikona1').ifixpng(); 

	$('.avion-ikona2').ifixpng(); 

	

	$('#fancy_loading div').ifixpng();

	

	//letovi

	

	

	$('.letovi').hide();

	$('#letovi-content-arrivals').show(speed);	

	$('#arrivals').addClass('letovi-active');

	$('#letovi-content-departures').css("left","0px");
	

	$('#departures').click(function () {
									 				 

		if (!$('#letovi-content-departures').is(':visible')) {

			$('.letovi').hide(speed);

			$('#arrivals').removeClass('letovi-active');

			$('#departures').addClass('letovi-active');

			$('#letovi-content-departures').show(speed);

		}

	});

	$('#arrivals').click(function () {

		if (!$('#letovi-content-arrivals').is(':visible')) {								

			$('.letovi').hide(speed);

			$('#departures').removeClass('letovi-active');

			$('#arrivals').addClass('letovi-active');

			$('#letovi-content-arrivals').show(speed);

		}

	});

	

	

	//vijeti

	

	$('.vijesti').hide();

	$('#vijesti-content-departures').show(speed);	

	$('#btn-vijesti').addClass('vijesti-active');
	
	$('#vijesti-content-arrivals').css("left","0px");

	

	$('#btn-vijesti').click(function () {

		if (!$('#vijesti-content-departures').is(':visible')) {

			$('.vijesti').hide(speed);

			$('#btn-arhiva').removeClass('vijesti-active');

			$('#btn-vijesti').addClass('vijesti-active');

			$('#vijesti-content-departures').show(speed);

		}

	});

	$('#btn-arhiva').click(function () {

		if (!$('#vijesti-content-arrivals').is(':visible')) {								

			$('.vijesti').hide(speed);

			$('#btn-vijesti').removeClass('vijesti-active');

			$('#btn-arhiva').addClass('vijesti-active');

			$('#vijesti-content-arrivals').show(speed);

		}

	});

	

	//table colors

	$("table.tablica tr:even").addClass("even");

	$("table.tablica tr:odd").addClass("odd");
	
	validate(".forma");
	
	

// Tool tip
	
    $.fn.tipsy = function(options) {

        options = $.extend({}, $.fn.tipsy.defaults, options);
        
        return this.each(function() {
            
            var opts = $.fn.tipsy.elementOptions(this, options);
            
            $(this).hover(function() {

                $.data(this, 'cancel.tipsy', true);

                var tip = $.data(this, 'active.tipsy');
                if (!tip) {
                    tip = $('<div class="tipsy"><div class="tipsy-inner"/></div>');
                    tip.css({position: 'absolute', zIndex: 100000});
                    $.data(this, 'active.tipsy', tip);
                }

                if ($(this).attr('title') || typeof($(this).attr('original-title')) != 'string') {
                    $(this).attr('original-title', $(this).attr('title') || '').removeAttr('title');
                }

                var title;
                if (typeof opts.title == 'string') {
                    title = $(this).attr(opts.title == 'title' ? 'original-title' : opts.title);
                } else if (typeof opts.title == 'function') {
                    title = opts.title.call(this);
                }

                tip.find('.tipsy-inner')[opts.html ? 'html' : 'text'](title || opts.fallback);

                var pos = $.extend({}, $(this).offset(), {width: this.offsetWidth, height: this.offsetHeight});
                tip.get(0).className = 'tipsy'; // reset classname in case of dynamic gravity
                tip.remove().css({top: 0, left: 0, visibility: 'hidden', display: 'block'}).appendTo(document.body);
                var actualWidth = tip[0].offsetWidth, actualHeight = tip[0].offsetHeight;
                var gravity = (typeof opts.gravity == 'function') ? opts.gravity.call(this) : opts.gravity;

                switch (gravity.charAt(0)) {
                    case 'n':
                        tip.css({top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}).addClass('tipsy-north');
                        break;
                    case 's':
                        tip.css({top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}).addClass('tipsy-south');
                        break;
                    case 'e':
                        tip.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}).addClass('tipsy-east');
                        break;
                    case 'w':
                        tip.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}).addClass('tipsy-west');
                        break;
                }

                if (opts.fade) {
                    tip.css({opacity: 0, display: 'block', visibility: 'visible'}).animate({opacity: 0.8});
                } else {
                    tip.css({visibility: 'visible'});
                }

            }, function() {
                $.data(this, 'cancel.tipsy', false);
                var self = this;
                setTimeout(function() {
                    if ($.data(this, 'cancel.tipsy')) return;
                    var tip = $.data(self, 'active.tipsy');
                    if (opts.fade) {
                        tip.stop().fadeOut(function() { $(this).remove(); });
                    } else {
                        tip.remove();
                    }
                }, 100);

            });
            
        });
        
    };
    
    // Overwrite this method to provide options on a per-element basis.
    // For example, you could store the gravity in a 'tipsy-gravity' attribute:
    // return $.extend({}, options, {gravity: $(ele).attr('tipsy-gravity') || 'n' });
    // (remember - do not modify 'options' in place!)
    $.fn.tipsy.elementOptions = function(ele, options) {
        return $.metadata ? $.extend({}, options, $(ele).metadata()) : options;
    };
    
    $.fn.tipsy.defaults = {
        fade: false,
        fallback: '',
        gravity: 'n',
        html: false,
        title: 'title'
    };
    
    $.fn.tipsy.autoNS = function() {
        return $(this).offset().top > ($(document).scrollTop() + $(window).height() / 2) ? 's' : 'n';
    };
    
    $.fn.tipsy.autoWE = function() {
        return $(this).offset().left > ($(document).scrollLeft() + $(window).width() / 2) ? 'e' : 'w';
    };
	
	
	
	//pozivanje funkcije za tooltip
	$(function() {  
    	//$('.dutyfreetooltip').tipsy({gravity: $.fn.tipsy.autoNS});
		$('.dutyfreetooltip').tipsy({gravity: 'sw'});
  	});


	//tabs
	$('ul#tab-nav li a').corner('tl 7px');
	$('#tabs-container a.more').corner('8px');
	$('#tabs-container .tab-cont').css({'visibility': 'hidden', 'z-index': '1'});
	$('#tabs-container .tab-cont:eq(0)').css({'visibility': 'visible', 'z-index': '2'});
	$('#tabs-container').css({'height': $('#tabs-container .tab-cont:eq(0)').height()+'px'});
	
	$('#tab-nav li a').click(function() {
		$('#tab-nav li a').removeClass('current');
		$(this).addClass('current');
		
		$('#tabs-container .tab-cont').css({'visibility': 'hidden', 'z-index': '1'});
		$('#tabs-container .tab-cont[class$='+$(this).attr('rel')+']').css({'visibility': 'visible', 'z-index': '2'});
		
		
		//console.log($('div.tab-cont[class$='+$(this).attr('rel')+']').height());
		$('#tabs-container').css({'height': $('#tabs-container .tab-cont[class$='+$(this).attr('rel')+']').height()+'px'});
		
		return false;
	});
	
	//txt replace
	
	var myText = $('.letovi-row td.textNormal strong');
	myText.each(function() {
		if( $(this).text() == 'Ostrava' ) {
			$(this).text('Ostrava(via Brno)');
		}
	});
	
	$('td.textNormal:contains("23:00")').prev().prev().prev(':contains("JBR501")').next().next('td.textNormal string').text('Ostrava');
	$('td.textNormal:contains("14:20")').prev().prev().prev(':contains("JBR501")').next().next('td.textNormal string').text('Ostrava');

});