

var i = 0;
jQuery(document).ready(function() {


	// jobb oldali dobozok hover effektje
	jQuery(".box_yellow").hover(function () {
		jQuery(".box_yellow").addClass("box_yellow_hover");
	}, function () {
		jQuery(".box_yellow").removeClass("box_yellow_hover");
	});

	jQuery(".box_teal").hover(function () {
		jQuery(".box_teal").addClass("box_teal_hover");
	}, function () {
		jQuery(".box_teal").removeClass("box_teal_hover");
	});

	jQuery(".box_blue").hover(function () {
		jQuery(".box_blue").addClass("box_blue_hover");
	}, function () {
		jQuery(".box_blue").removeClass("box_blue_hover");
	});



	// veletlenszeru fejlec valtogatas elinditasa
	changeHeader();



	var maxRef = jQuery('.referencia').length - 1;
	
	jQuery(".box_1").hover(function() {jQuery(this).addClass("box_1_h");}, function() {jQuery(this).removeClass("box_1_h");});
	jQuery(".box_2").hover(function() {jQuery(this).addClass("box_2_h");}, function() {jQuery(this).removeClass("box_2_h");});
	jQuery(".box_3").hover(function() {jQuery(this).addClass("box_3_h");}, function() {jQuery(this).removeClass("box_3_h");});
	
	jQuery("#prev").click(function() {
		if( i == 0) i=maxRef+1;
		i--;
		jQuery("#referenciak_scroller").animate({
			left: -901 * i + "px"
		});
	});
	
	jQuery("#next").click(function() {
		if( i+1 > maxRef) i=-1;
		i++;
		jQuery("#referenciak_scroller").animate({
			left: -901 * i + "px"
		});
	});



	jQuery(".mayoka-referencia").hover(function () {
		jQuery(".mayoka-referencia-leiras", this).fadeIn("fast");
	}, function () {
		jQuery(".mayoka-referencia-leiras", this).fadeOut("fast");
	});




	var search_input = $("#search_input");
	search_input.focus(function() {
		if(search_input.val() == "Keresés")
		search_input.val("")
	});

	search_input.blur(function() {
		if(search_input.val() == "")
		search_input.val("Keresés")
	})


	
});



$(function(){

    $("ul#menu li").hover(function(){
    
        $(this).addClass("hover");
        $('ul:first',this).show();
    
    }, function(){
    
        $(this).removeClass("hover");
        $('ul:first',this).hide();
    
    });
    
//    $("ul#menu li ul li:has(ul)").find("a:first").append(" » ");

});






function changeHeader() {

	var i = Math.floor(Math.random()*5)+1; // 1 es 6 kozott
	var time = Math.floor(Math.random()*5) + 3 // 3 es 8 kozott

	// tobbi reteg elrejtese kozepes sebesseggel
	jQuery(".header_img").fadeOut(2000);

	// kivalasztott reteg megjelenitese lassan
	jQuery("#header_img_"+i).fadeIn(2000);

	setTimeout("changeHeader()", time * 1000);

}
