$(document).ready(function() {

  //*** language select box
  $("#top-nav .language a").click(function() {
	$("#language-box").show().mouseleave(function() { 
      $("#language-box").fadeOut(); 
	}); 
	$("body").click(function(event) {
      if (!$(event.target).closest("#top-nav .language a").length) {
        $("#language-box").hide();
      };
    }).mousemove(function(event) {
      if (!$(event.target).closest("#header .header-top").length && !$(event.target).closest("#language-box").length) {
        $("#language-box").fadeOut();
      };
    });
	return false;
  });

  //*** panel toggle function
  $(".product-info-panel")
    .toggleClass("close")
    .children("h2").bind("click", function(){
      $(this).nextAll().toggle().end()
        .parent().toggleClass("open").toggleClass("close");
    })
	.nextAll().toggle();

  //*** open second panel
  $(".product-info-panel").eq(1)
    .toggleClass("open").toggleClass("close")
    .children("h2").nextAll().toggle();

  //*** product visual toggle
  $("#visual-box ul.product li").mouseover(function() {
	var pn = $(this).attr("id");
	var pos = $("#visual-box .product-visual #v-"+pn).index();
	$("#visual-box .product-visual .visual-items").stop().animate({'top': pos*-316+'px'}, 400);
  });
  $("#visual-box").mouseleave(function() {
	var apos = $("#visual-box .product-visual .active").index();
	if (apos > -1) {
	  $("#visual-box .product-visual .visual-items").delay(2500).animate({'top': apos*-316+'px'}, 400);
	}
  });

});

