$(function()
{
	$('#text').jScrollPane({scrollbarWidth:7, scrollbarMargin:14});

	$('input[title!=""]').hint();	// input hint


	$('img.changer').each(function(){
		var t=$(this);
		var initSrc = t.attr('src'); // initial src
		var initPath = initSrc.substring(0, initSrc.lastIndexOf('/')+1); // initial path
		var FileName = initSrc.substring(initSrc.lastIndexOf('/')+1, initSrc.lastIndexOf('.')); // file name without extension
		t.mouseover(function(){
			$(this).attr('src', initPath + FileName+ 'Over.' + /[^.]+$/.exec(initSrc)); //last part is for extension
		})
		.mouseout(function(){
			$(this).attr('src', initPath + FileName + '.' + /[^.]+$/.exec(initSrc)); //removing 'Over' from the name
		});
	});

	$('.submitChanger').each(function(){
		var t=$(this);
		var initSrc = t.attr('src'); // initial src
		var initPath = initSrc.substring(0, initSrc.lastIndexOf('/')+1); // initial path
		var FileName = initSrc.substring(initSrc.lastIndexOf('/')+1, initSrc.lastIndexOf('.')); // file name without extension
		t.mouseover(function(){
			$(this).attr('src', initPath + FileName+ 'Over.' + /[^.]+$/.exec(initSrc)); //last part is for extension
		})
		.mouseout(function(){
			$(this).attr('src', initPath + FileName + '.' + /[^.]+$/.exec(initSrc)); //removing 'Over' from the name
		});
	});

	// checkbox style
	//$(":checkbox").uniform();

});

$(document).ready(function() {
	$('#supersize').resizenow();

	// intro pre note
	var browserwidth = $(window).width();
	var browserheight = $(window).height();
	$('div.introPre').css('width', browserwidth);
	$('div.introPre').css('height', browserheight);

/*
  $.fn.wait = function(time, type) {
      time = time || 4000;
      type = type || "fx";
      return this.queue(type, function() {
          var self = this;
          setTimeout(function() {
              $(self).dequeue();
          }, time);
      });
  };
  function runIt() {
    $("div.introPre").wait().fadeOut('slow', function() { runIntro(); });
  }
  runIt();
*/
	$('div.introPre img').click(function() {
//		$('div.introPre').css("display", "none");
//		runIntro();
		$("div.introPre").fadeOut('slow', function() { runIntro(); });
	});


	// foot bg
	var browserheight = $(window).height();
	$('#pageFoot').css('top', browserheight - 21);


	// intro
	var introRunned = 0;
  function runIntro() {
  	if (introRunned == 0) {
			$('div.intro div.topImg').animate({ "top": 0 }, "slow");

			$('div.intro div.bottomImg').css('top', browserheight);
			$('div.intro div.bottomImg').animate({ "top": 0, "height": browserheight - 159 }, "slow");

			$('div.intro div.lang').css('top', browserheight + 400);
			$('div.intro div.lang').animate({ "top": 400 }, "slow");
		}
		introRunned = 1;
	}


	// menu
	$("#dropList ul#menu").mouseenter(function() {
		$("#dropList ul#menu div[label=selected2]").removeClass("selected2");
		$("#dropList ul#menu div[label=selected3]").removeClass("selected3");
		$("#dropList ul#menu div[label=selected4]").removeClass("selected4");
		$("#dropList ul#menu div[label=selected5]").removeClass("selected5");
	});
	$("#dropList ul#menu").mouseleave(function() {
		$("#dropList ul#menu div[label=selected2]").addClass("selected2");
		$("#dropList ul#menu div[label=selected3]").addClass("selected3");
		$("#dropList ul#menu div[label=selected4]").addClass("selected4");
		$("#dropList ul#menu div[label=selected5]").addClass("selected5");
	});

	$("#dropList ul#menu li[class$=sub][label!=selected]").hover(function(){$(this).children().children().fadeOut(0);$(this).children().children().fadeIn(500);});



	// show/hide div
	$("div#ShowHideContent").hide();

	$("div#ShowHide").click(function() {
	if (this.className.indexOf('clicked') != -1 ) {
			$(this).next().slideUp(500);
			$(this).removeClass('clicked')
			$(this).children().attr('src', 'tpls/_img/btnSmallShow.png');
			}
			else {
			$(this).addClass('clicked')
			$(this).next().slideDown(500);
			$(this).children().attr('src', 'tpls/_img/btnSmallHide.png');
			}
	});


	// mainBtn underliner
	$("a.mainBtn").mouseenter(function() {
		//alert($(this).children().get(0).tagName);
		$(this).children().css('text-decoration', 'underline');
	});
	$("a.mainBtn").mouseleave(function() {
		//alert($(this).children().get(0).tagName);
		$(this).children().css('text-decoration', 'none');
	});


	// form validation
	$("#validateForm").validationEngine()
});

$(window).bind("resize", function(){
	$('#supersize').resizenow();

	// foot bg
	var browserheight = $(window).height();
	$('#pageFoot').css('top', browserheight - 21);

	// intro
	$('div.intro div.bottomImg').css('height', browserheight - 159);
});

$(window).scroll(function() {
	$('#pageFoot').css('top', $(window).scrollTop()+$(window).height()-21+"px");
});

Shadowbox.init({
    language: 'en',
    players:  ['img', 'html', 'iframe', 'qt', 'wmp', 'swf', 'flv']
});

function ShadowboxGoogleMaps(){
    Shadowbox.open({
        player:     'html',
        content:    '',
        height:     300,
        width:      500,
        options:    {
            onFinish: function(item){
                if(GBrowserIsCompatible()){
                    var body = document.getElementById(Shadowbox.contentId());
                    var map = new GMap2(body);
                    map.addControl(new GSmallMapControl());
                    map.addControl(new GMapTypeControl());

                    //map.setCenter(new GLatLng(37.4419, -122.1419), 13);

								    geocoder = new GClientGeocoder();
								    var address = '1126 Budapest Kiss János Altábornagy utca 38.';

									  if (geocoder) {
									    geocoder.getLatLng(
									      address,
									      function(point) {
									        if (!point) {
									          alert(address + " not found");
									        } else {
									          map.setCenter(point, 15);
									          var marker = new GMarker(point);
									          map.addOverlay(marker);
									          marker.openInfoWindowHtml(infotext);
									        }
									      }
									    );
									  }
                }
            }
        }
    });
}