$(document).ready(function() {


  $(".external").filter(function() {
    return this.hostname && this.hostname !== location.hostname;
  })
  .click(function() {
    window.open(this.href);
    return false;
  });
 
  
  $(".corel,.obrazok")
  .click(function() {
    window.open(this.href);
    return false;
  });
  
 // show / hide help
  $("#help_btn").click(function(){
    $(".help").slideToggle("fast");
    return false;
  });

 $(".slideshow").cycle({
  		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
  	});

// SLIDER
	$(".slider .vzorbox").hide();

	$(".slider h3").click(function(){
		$(this).next(".vzorbox").slideToggle("slow").siblings("div:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h3").removeClass("active");
  return false;
	});


// RETURN
 $("a[href^=javascript]") .addClass("return");
 $("a[class$=back]") .addClass("return");

 
 //prettyPhoto
 $(".link a[rel^='prettyPhoto']").prettyPhoto({theme:'facebook'});


 // Validate form
 $("#form, #kalkulacia").validate();

 // TABS
			var tabContainers = $('div.tabs > div').css("display","none");
			tabContainers.hide().filter(':first').show();

			$('div.tabs ul.tabNavigation a').click(function () {
				tabContainers.hide();
				tabContainers.filter(this.hash).show();
				$('div.tabs ul.tabNavigation a').removeClass('selected');
				$(this).addClass('selected');
				return false;
			}).filter(':first').click();


// KALKULACIA
	    $("#parent1").css("display","none");
        $(".formset").click(function(){
        if ($('input[name=format]:checked').val() == "a4" ) {
        	$("#parent1").slideDown("fast"); //Slide Down Effect
        } else {
            $("#parent1").slideUp("fast");	//Slide Up Effect
        }
     });

    $("#tgrafika1").css("display","block");
      $(".platno").click(function(){
      if ($('input[name=tgrafika]:checked').val() == "1" ) {
      	$("#tgrafika1").slideUp("fast"); //Slide Down Effect
      } else {
          $("#tgrafika1").slideDown("fast");	//Slide Up Effect
      }
   });

// TOOLTIPS

		offSetX = 15;
		offSetY = 10;

	$(".toptip").hover(function(e){
		topTip = '#' + $(this).attr('class').split(' ').slice(-1);

		height = $(window).height();
		width = $(window).width();
		scrTop = $(window).scrollTop();
		scrLeft = $(window).scrollLeft();
		tipWidth = $(topTip).outerWidth();
		tipHeight = $(topTip).outerHeight();
		tipLeft = e.pageX + offSetX;
		tipTop = e.pageY + offSetY;

		if ((e.pageX - scrLeft + offSetX + tipWidth) > width) {tipLeft = e.pageX - offSetX - tipWidth;}
		if ((e.pageY - scrTop + offSetY + tipHeight) > height) {tipTop = e.pageY - offSetY - tipHeight;}


		$(topTip)
			.css("top",tipTop + "px")
			.css("left",tipLeft + "px")
			.show();
	},
	function(){
		$(topTip).hide();
	});



});
