var WhyUs=0;
this.imagePreview = function(){
	/* CONFIG */
		
		xOffset = 10;
		yOffset = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$('a[rel="show_mini_image"]').hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$(".container").append("<div id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</div>");								 
		$("#preview").fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });		
};

// BG Close
function more_information_close()
	{
		if(WhyUs==0)
		{
		WhyUs=1;
		$(".more_information_close").css("display","none");
		$(".more_information_box").animate({height: $("#head").height()-28},function(){
			$('.more_information_frame').css("bottom","0");
			$(".more_information_frame").animate({height: 'hide'});
			$("#zuhanykabin_list_text1").animate({top: '0px'},function()
			{
				WhyUs=0;
			});
		});
		$(".more_information_more").text("Tovább");
		$("#more_information_bg").remove();
		moreOpen=true;
		}
	}

$(document).ready(function(){
    $(".righ_bottom_content").hide(); 
	$(".righ_bottom").click(function(){
	   $(".righ_bottom_content").slideToggle();
	});
	
	$(".righ_bottom_content").bind("mouseleave",function(){
		if(WhyUs==0)
		{
			WhyUs=1;
				$(".righ_bottom_content").slideToggle(function() {
				WhyUs=0;
				});
		};
	});
    // More information HEAD
	$(".more_information_frame").hide();
	// Open - Close
	$(".more_information").click(function(){
		// Open
	  if($(".more_information_frame").css("display")=="none")
	  {
		  WhyUs=1;
 		  $(".more_information_frame").css('height',$("#head").height());
		  // If content bigger
		  $(".more_information_box").css('height',$("#head").height());
		  $(".more_information_frame").delay(250).animate({height: 'show'}, function(){
			  WhyUs=0;
			  if($(".more_information_frame").height()<$(".more_information_content").height()) {
				  // Bigger
				  $(".more_information_frame_filter").css("top",$("#head").height());
				  $(".more_information_box").css('height',$("#head").height()-28);
				  $(".more_information_more").css('display','block');
				  $(".more_information_frame").removeClass("more_information_bottom");
			  }
			  else 
			  {
				  $(".more_information_box").css('height',$("#head").height());
			  }
			  $(".more_information_frame").css('height',"");
		   });
		  $("#zuhanykabin_list_text1").animate({top: '-38px'});
	  }
	  // Close
	  else {
		  $(".more_information_frame").addClass("more_information_bottom");
		  $(".more_information_frame").animate({height: 'hide'});
		  $("#zuhanykabin_list_text1").animate({top: '0px'});
	  }
	});
	$(".more_information_frame").bind("mouseleave",function(){
		if(moreOpen)
		if(WhyUs==0)
		{
			WhyUs=1;
			$(".more_information_frame").addClass("more_information_bottom");
			$("#zuhanykabin_list_text1").animate({top: '0px'});
				$(".more_information_frame").animate({height: 'hide'},function() {
				WhyUs=0;
				});
		};
	});
	moreOpen=true;
	$(".more_information_more").click(function(){
		// Open
		if(moreOpen)
			{
				$(".more_information_close").css("display","block");
				$(".more_information_box").animate({height: $(".more_information_content").height()+8});
				$(".more_information_more").text("Bezár");
				$('.more_information_frame').css("bottom","");

				// Append
				$("body").append('<div id="more_information_bg" onclick="more_information_close()"></div>');
				if($(".more_information_content").height()<($(".container").height()-134)) temp_height=$(".container").height();
					else temp_height=$(".more_information_content").height()+134+36;
				$("#more_information_bg").css("height",temp_height);
				moreOpen=false;
			}
			// Close
			else
				{
					more_information_close();
					moreOpen=true;
				}
	  
	});
	
	$(".more_information_close").click(function(){
		more_information_close();
	});

	$(window).load(function() {
		$('#products_sub_list tr:last td').css("padding-bottom","0");
		$('#scroll').jScrollPane({arrowSize:14,showArrows:true, scrollbarWidth: 11});
	});

	// Bind Reference Link
	$('a[rel="Reference"]').bind('click',function() {
		window.open("http://www.rikker.hu/modules/furdoszoba/ref.php?m="+$(this).attr("name"),"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no");
		return false;
	});
	// Bind Reference Link
	$('a[rel="go_to_prod"]').click(function() {
	    // set cookie by number of days
	    $.cookie("go_to_prod", $(this).find("img").attr("alt").replace(/\+/g,"_"), {path: '/'});
	});
	imagePreview();

	$('a[rel="show_mini_image"]').click(function() {
		return false;
	});
    
    jQuery('.image-flow-nyilaszaro').jcarousel();

/*	$('#trade_form_button').click(function(){
		$('#trade_form').slideToggle("slow");
	});*/

});

var MenuHeight=316;
// Menu
function MenuHandleOpen(id)
	{
	if(id!=99)
		{
		if(OpenedSubMenu!=-1)
			{
			//$("#menu"+id).css('height', MenuHeight+"px");
            $("#menu"+id).addClass("opened_menu");
			$("#menu"+id+" img").css("display","inline");
			$(".sub_menu").css('display', "none");
			}
		$("#menu"+id).prev().css("background","url(http://www.rikker.hu/design/menu/bg_active.png)");
		if(OpenedSubMenu>0)
			{
			$("#menu"+id+" li:nth-child("+OpenedSubMenu+") a").css("color","white");
            $("#menu"+id+" li:nth-child("+OpenedSubMenu+") a").css("background","black");
            $("#menu"+id+" li:nth-child("+OpenedSubMenu+") a div").remove();
            $("#menu"+id+" li:nth-child("+OpenedSubMenu+") a").append('<img src="http://www.rikker.hu/design/menu/active.png" alt="" class="menu_active_img" />');
            var height=$("#menu"+id+" li:nth-child("+OpenedSubMenu+") a").parent().height()/2-25/2;
            $("#menu"+id+" li:nth-child("+OpenedSubMenu+") a").find("img").css("top",height);
            $("#menu"+id+" li:nth-child("+OpenedSubMenu+") a").parent().parent().addClass("menu_active");
			}
		}
	}
function SubMenuHandleOpen(id)
	{
	if(id!=99)
		{
		$("#sub_menu_"+id).css("background","url(http://www.rikker.hu/design/menu/bg_2_active.png) no-repeat");
		}
	}

// Lightbox
$(function() {
        $('a[rel="lightbox"]').lightBox();
    });

function Reference(a)
	{
	window.open("http://www.rikker.hu/modules/furdoszoba/ref.php?m="+a,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no")
	}


// Ajto ablak javit more information
var ajto_ablak_open_id=0;
function ajto_ablak_open(id) {
    if(ajto_ablak_open_id>0) ajto_ablak_close()
    else {
        $("#ablak_javit_"+id).animate({height: 'show'});
        ajto_ablak_open_id=id;
        
        $("#ablak_ajto_nyil1").rotate({
           
          animateTo:180 
            });    
        }
    }
function ajto_ablak_close() {
      $("#ablak_javit_"+ajto_ablak_open_id).animate({height: 'hide'});
      $("#ablak_ajto_nyil1").rotate({
      
      animateTo:0
        });
      ajto_ablak_open_id=0;
    }

function show_compare() {
    $("#comapre_box").css("bottom",$(window).height()+$("#comapre_box").height());
    $("#comapre_box").animate({bottom:'0'});
    
}

$(document).keyup(function(e) {
    if (e.keyCode == 27) {
        // Ajto ablak close
        ajto_ablak_close();
        
        // More inf close
        if(WhyUs==0)
		{
		WhyUs=1;
		$(".more_information_close").css("display","none");
		$(".more_information_box").animate({height: $("#head").height()-28},function(){
			$('.more_information_frame').css("bottom","0");
			$(".more_information_frame").animate({height: 'hide'});
			$("#zuhanykabin_list_text1").animate({top: '0px'},function()
			{
				WhyUs=0;
			});
		});
		$(".more_information_more").text("Tovább");
		$("#more_information_bg").remove();
		moreOpen=true;
		}
    }
});

