/* ** new result page script */
function initTooltip(){
var ttext,dw,x,y;

$('.nr_tooltip').mouseover(function(e)
{
  ttext = $(this).attr('title');
  dw = parseInt($(document).width());
  x = e.pageX; y = e.pageY;
	
  $(this).attr('title','');
   
  x = ( (dw - x) < 300 ) ? x -= 275 : x + 5; /* where 280 is the width of tooltip */
	
  $("<p></p>").appendTo("body").attr("class","nr_tooltip_text").css({ "left": x + "px", "top": y + 5 + "px" }).html(ttext);
	
}).mousemove( function(e)
{
  x = e.pageX; y = e.pageY;
  
  x = ( (dw - x) < 300 ) ? x -= 275 : x + 5;
  
  $(".nr_tooltip_text").css({ "left": x + "px", "top": y + 5 + "px" });
}).mouseout( function()
{
  $('.nr_tooltip_text').remove();
  $(this).attr('title',ttext);
});
}

function closePopup() {
$('.popup_overlay,.popup').remove();
$('body').css('overflow','auto');
}

function initPopup(text,url){
$('body').css('overflow','hidden');

var pad = 200, dim = {}, page = url, gap = {};
var scroll = parseInt($(window).scrollTop());
dim.x = parseInt($(window).width());
dim.y = parseInt($(window).height());

/* ** ie correction ** */
gap.h = ( $.support.boxModel ) ? 40 : 0;
gap.v = ( $.support.boxModel ) ? gap.h*2 : 40;

$.get(page, function(resp){
  $('<div></div>')
	.appendTo('body')
	.addClass('popup_overlay')
	.css({
	  'width': dim.x + 'px',
	  'height': dim.y + 'px',
	  'top': scroll + 'px'
	  });
  
  $('<div></div>')
	.appendTo('body')
	.addClass('popup')
	.css({
	  'width': dim.x - pad + 'px',
	  'height': dim.y - pad + 'px',
	  'top': pad/2 + scroll + 'px',
	  'left': pad/2 + 'px'
	})
	.append('<a>' + text + '</a>')
	.find('a')
	.attr({
	  'href': 'javascript:closePopup()',
	  'class': 'popup_close'
	})
	.end()
	.append('<div class="popup_content">' + resp + '</div>')
	.find('.popup_content')
	.css({
	  'width': dim.x - pad - gap.h + 'px',
	  'height': dim.y - pad - gap.v + 'px'
	});
});
}

$(function(){
initTooltip();

/* catch IE6 */
var display = (typeof document.body.style.maxHeight === "undefined")
  ? 'block'
  : 'table-row-group';

  $('tbody.hidden').css('display','none');
 
  $('.show_more').click(function(e){
	e.preventDefault();
	
	var $to_show = $(this).parents('tbody').next('.hidden');
	
	( $to_show.css('display') == 'table-row-group' || $to_show.css('display') == 'block')
	? $to_show.css('display','none')
	: $to_show.css('display',display);
	
  });
  
  /* loader */
  
  $('.load').click(function(e){
  e.preventDefault();
  $('#loader01').show();
  setTimeout(function(){ $('#loader01').hide(); }, 2000);
  });
  
  /* ** init sliders ** */
$(".slider").each(function(){
  var current = $(this).attr('rel');
  var cvalue = parseInt($("input[name='" + current + "']").val());

  $(this).slider({
	value: cvalue * 10,
	min: 0,
	max: 60,
	range: "min",
	orientation: "vertical",
	slide: function( event, ui ) {
		$("input[name='" + current + "']").val( Math.round(ui.value/10) );
	}
  });
});

/* ** popup ** */
$('.popup_link').click(function(e){
  e.preventDefault();
  url = $(this).attr('href');
  closelink = "Vissza az eredm&eacute;ny oldalra";
  
  initPopup(closelink,url);
});

});
/* new result page script ** */

