var regEx_email = /^[\ a-z0-9._-]+@[a-z0-9.-]+\.[a-z]{2,6}$/i;

if(typeof String.prototype.trim !== 'function')
{
  String.prototype.trim = function()
  {
    return this.replace(/^\s+|\s+$/g, ''); 
  }
}

$(document).ready(function() {
	
	//addEvent(window, 'load', initCorners);

	  //function initCorners() {
		var settings = {
		  tl: { radius: 10 },
		  tr: { radius: 10 },
		  bl: { radius: 10 },
		  br: { radius: 10 },
		  antiAlias: true
		}
	
		/*
		Usage:
	
		curvyCorners(settingsObj, selectorStr);
		curvyCorners(settingsObj, Obj1[, Obj2[, Obj3[, . . . [, ObjN]]]]);
	
		selectorStr ::= complexSelector [, complexSelector]...
		complexSelector ::= singleSelector[ singleSelector]
		singleSelector ::= idType | classType
		idType ::= #id
		classType ::= [tagName].className
		tagName ::= div|p|form|blockquote|frameset // others may work
		className : .name
		selector examples:
		  #mydiv p.rounded
		  #mypara
		  .rounded
		*/
		curvyCorners(settings, ".corner10");
	 // }



	$().piroBox({
		  my_speed: 400, //animation speed
		  bg_alpha: 0.5, //background opacity
		  slideShow : false, // true == slideshow on, false == slideshow off
		  slideSpeed : 3, //slideshow
		  close_all : '.piro_close, .piro_overlay' // add class .piro_overlay(with comma)if you want overlay click close piroBox
		  });
		  
		  
		  
	tooltip();
				
	
	$('#menubottom').meerkat({
		background: 'transparent',
		height: '51px',
		width: '100%',
		position: 'bottom',
		close: '.close-meerkat',
		dontShowAgain: '.dont-show',
		animationIn: 'fade',
		animationSpeed: 1000
	});
			
	$('#menutopfixed').meerkat({
		background: 'transparent',
		height: '33px',
		width: '100%',
		position: 'top',
		close: '.close-meerkat',
		dontShowAgain: '.dont-show',
		animationIn: 'fade',
		animationSpeed: 1000
	});
	
	
	
	$(".menu-item").hover(
		function()
		{
			var submenu = $("> .menu-item-innerfirst", this);
			if ( submenu.css("display") == "none" )
			{
				submenu.fadeIn('fast');
			}
		},
		function()
		{
			$("> .menu-item-innerfirst", this).fadeOut('fast');
		}
	);


	var contactBox = $(".contact-downbox");
	contactBox.hover(
		function()
		{
			
			if ( contactBox.css("height") == "51px" )
			{
				contactBox.css("cursor" , "pointer").animate({height: "60px"}, 400).animate({height: "55px"}, 250);
			}
		},
		function()
		{
			contactBox.animate({height: "51px"});
		}
	);

//	contactBox.click(
//		function()
//		{
//			
//			contactBox.css("cursor" , "default").animate({height: "233px"});
//			
//		});


	$(".innerfirst-item").hover(
		function()
		{
			var submenu = $("> .menu-item-innersecond", this);
			if ( submenu.css("display") == "none" )
			{
				submenu.fadeIn(300).animate( {top: "-10px"} , {duration: 150} );
			}
		},
		function()
		{
			$("> .menu-item-innersecond", this).fadeOut(200).animate({top: "10px"});
		}
	);


	//$(".banner-menu").fadeOut('fast');
	$(".ivf, .gynekologie, .genetika").hover(
		function()
		{
			var submenu = $("> .banner-menu", this);
			if ( submenu.css("display") == "none" )
			{
				submenu.fadeIn('fast');
			}
		},
		function()
		{
			$("> .banner-menu", this).fadeOut('fast');
		}
	);





	var order = [],
        loc   = [];
    $(".slider", this).okSlide({
      panelSelector: "li.panel",
      afterNext: function() {
        order.push(this.html());
      },
      afterPrev: function() {
        order.pop();
      },
      afterSelect: function() {
        order.push(this.html());
       // alert("Your order: " + order.join(","))
      },
      backtrack: function(link){
        this.find("ul:first").prepend("<li>"+link+"</li>");
      }
    });
	
	$(".banner-menu").fadeOut(0);


	if ( $(".left-main-side").length && $(".right-main-side").length )
	{
		var leftmainside = $(".left-main-side").height();
		var rightmainside = $(".right-main-side").height();
		
		var rightwhiteboxcenterHeight = $(".right-white-box-center").height();
		
		var rightwhiteboxcenter = $(".right-white-box-center");
		var leftwhiteboxcenter = $(".bigbox-center");
		
		if ( leftmainside > rightmainside )
		{
			rightwhiteboxcenter.css({height : leftmainside - 140});
		}
		else 
		{
			leftwhiteboxcenter.animate({height : rightwhiteboxcenterHeight + 90});
		}
	}
	
	
	if ( $(".left-main-side-inverted").length && $(".right-main-side-inverted").length )
	{
		var leftmainside = $(".left-main-side-inverted").height();
		var rightmainside = $(".right-main-side-inverted").height();
		
		var rightwhiteboxcenterHeight = $(".right-white-box-center").height();
		
		var rightwhiteboxcenter = $(".right-white-box-center");
		var leftwhiteboxcenter = $(".bigbox-center");
		
		if ( leftmainside > rightmainside )
		{
			rightwhiteboxcenter.css({height : leftmainside - 140});
		}
		else 
		{
			leftwhiteboxcenter.css({height : rightwhiteboxcenterHeight + 90});
		}
	}
	
	
	
	$(".slidetabs").tabs(".rotate-index > div", {
	
		// enable "cross-fading" effect
		effect: 'fade',
		fadeOutSpeed: 1000,
		fadeInSpeed: 1000,
	
		// start from the beginning after the last tab
		rotate: true
		
	
	// use the slideshow plugin. It accepts its own configuration
	}).slideshow(
	{
		autoplay: true,
		interval: 3000
	}
	);
	
	
	

	$(".detail").hover(
		function()
		{
			var prejitnadetail = $(".prejitnadetail", this);
			var lideteamjmeno = $(".lide-team-jmeno", this);

			if ( prejitnadetail.css("display") == "none" )
			{
				lideteamjmeno.animate({top: "160px"});
				prejitnadetail.fadeIn('slow');
			}
		},
		function()
		{
			var prejitnadetail = $(".prejitnadetail", this);
			var lideteamjmeno = $(".lide-team-jmeno", this);
			
			lideteamjmeno.animate({top: "190px"});
			prejitnadetail.fadeOut('fast');
		}
	);
	
	$('#contactForm2Submit').click( function(event) {
		
		
			if ( ($('#jmeno').val().trim() == '') || ($('#prijimeni').val().trim() == '') || 
			     ($('#email').val().trim() == '') || ($('#dvacetdva').val().trim() == '') )
			{
				alert( 'Vyplňte všechny položky nutné k odeslání.' );
				return false;
			}
			else
			{
				if ( regEx_email.test( $('#email').val().trim() ) == false )
				{
					alert( 'Zadejte spravný e-mail.' );
					return false;
				}
				
				if ( $('#dvacetdva').val().trim() != '22' )
				{
					alert( 'Vyplňte správne všechny položky nutné k odeslání.' );
					return false;
				}	
			}
			
			document.forms['contactForm2'].submit();
	});


});


