$(document).ready(function() {

	$('a[rel*="clearbox"]').attr('rel','fancybox');
	$('a[rel*="fancybox"]').fancybox({
		'titleShow': false,
		'overlayColor': '#0D488A',
		'hideOnContentClick': true
	});

	if($('#headerimg.start').length > 0) {
		$('#headerimg').tinycarousel({interval: true, intervaltime: 5000, rewind: true, pager: true});
	}

	if($('#productslider').length > 0) {
		$('#productslider').tinycarousel({display: 1, interval: true, intervaltime: 4000, rewind: false, pager: true});
	}
	
	if($('#map').length > 0) {

	jQuery('#map').jmap('init', {'mapType':'hybrid','mapZoom':15,'mapCenter':[47.4354, 19.0467],'mapControl':'large'});
	
	jQuery('#map').jmap('AddMarker', {
		'pointLatLng': [47.4354, 19.0467],
		'pointHTML': '<b>Watt22 Kft</b><br /><br />1116, Budapest<br />Hunyadi János út 162.'
	});

	}
	
	$("input#searchfield").focus(function() {$(this).addClass("active");});
	$("input#searchfield").blur(function() {$(this).removeClass("active");});
	
	$("#m_lang").mouseover(function() {
		$("#langsel").show();
	});

	$("#langsel").mouseout(function() {
		$("#langsel").hide();
	});
	

	$('#searchresults').click(function() {$('#searchresults').fadeOut('fast');});
	$('#searchfield').keydown(function() {if($('#searchfield').val()=='') $('#searchresults').fadeIn('fast');});

	$('#searchfield').keyup(function() {
		if($('#searchfield').val()=='') $('#searchresults').fadeOut('fast');
		$.ajax({
		   type: "GET",
		   url: "/pages/search.php",
		   data: "find=" + $('#searchfield').val(),
		   success: function(msg){
		   	$('#searchresults').html(msg);
		   }
		 });
		
		});
		

$(window).scroll(function () { 
	  if($(window).scrollTop() > 1000) 
	  	{$('.totop:hidden').fadeIn("fast");}
		else
		{$('.totop:visible').hide();}
	});
	
$("#scrolltotop").click(function() {
	$('html,body').animate({scrollTop: 0}, 500);
	return false;
	});

	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname) {
 			var $target = $(this.hash);
 			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
 			if ($target.length) {
 				var targetOffset = $target.offset().top;
 				$('html,body').animate({scrollTop: targetOffset}, 500);
		 	return false;
			}
		}	
	});


	$.preloadImages(
			"./images/start/menu/hun_about_h.jpg", 
			"./images/start/menu/hun_sol_h.jpg",
			"./images/start/menu/hun_prod_h.jpg",
			"./images/start/menu/hun_supp_h.jpg",
			"./images/start/menu/hun_cont_h.jpg",
			"./images/content/menu/hun_about_h.jpg", 
			"./images/content/menu/hun_sol_h.jpg",
			"./images/content/menu/hun_prod_h.jpg",
			"./images/content/menu/hun_supp_h.jpg",
			"./images/content/menu/hun_cont_h.jpg",
			"./images/content/menu/ddbg.png"
	);

	
});

jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

	$("#nw_trigg").click(function () {
	  $('#nw_start').trigger('click');
	  });

	$("#rms_trigg").click(function () {
	  $('#rms_start').trigger('click');
	  });



