$(document).ready(function()
    {

//horizontal menu
    $("#nav li:has(ul)").hover(function()
        {
 		if (!$(this).children("ul").is(':animated'))
     	 {
        $(this).children("ul").css("display", "none");
        $(this).children("ul").slideDown("normal");
     	 }
        },
     function()
     {
        $(this).children("ul").slideUp("fast");
     });

    $("#nav li.parent").hover(function()
        {
        $(this).addClass("act");
        },
     function()
     {
        $(this).removeClass("act");
     });
//horizontal menu

//homepage showroom
    $("#nav-sr li:has(div.panel-bg)").hover(function()
        {
        $(this).children("div.panel-bg").css("display", "none");
        $(this).children("div.panel-bg").slideDown("fast");
        },
     function()
     {
        $(this).children("div.panel-bg").slideUp("fast");
     });

//homepage showroom

//Showroom category
    $("#nav-sr li:has(div.panel-bg-category)").hover(function()
        {
        $(this).children("div.panel-bg-category").css("display", "none");
        $(this).children("div.panel-bg-category").slideDown("fast");
        },
     function()
     {
        $(this).children("div.panel-bg-category").slideUp("fast");
     });

//Showroom category


//Gallery
    $("ul#g-list li a").click(function(){
	   var index = $("ul#g-list li a").index(this);
	   var next = index+1;
	   var counter = ($("ul#g-list li a").size())-1;
      var idString = $(this).children("img").attr("alt");
      var idPath1 = $(this).attr("alt");
      var idPath2 = $(this).attr("title");
      $("#gal-text").text(idString);
      $("img#galerie-foto").attr({ 
          src: idPath1,
          title: idString,
          alt: idString
        });
      $("div#gal-download a").attr({ 
          href: idPath2
        });
    	$("ul#g-list li a").removeClass("act");
        $(this).addClass("act");
	
		if(index>0){$("#gal-prev").css("display", "block");
					$("#gal-prev").attr({
          alt: index
        });}
			else {$("#gal-prev").css("display", "none");}

		if(index==counter){$("#gal-next").css("display", "none");}
			else {$("#gal-next").css("display", "block");					
					$("#gal-next").attr({
          alt: index
        });}
    });


	//Previous
    $("#gal-prev").click(function(){
	   var index_prev = $(this).attr("alt");
	   var prev_prev = index_prev-1;
      var idString_prev =$("ul#g-list li a:eq("+ prev_prev +") img").attr("alt");
      var idPath1_prev =$("ul#g-list li a:eq("+ prev_prev +")").attr("alt");
      var idPath2_prev =$("ul#g-list li a:eq("+ prev_prev +")").attr("title");
       $("#gal-text").text(idString_prev);
      $("img#galerie-foto").attr({ 
          src: idPath1_prev,
          title: idString_prev,
          alt: idString_prev
        });
      $("div#gal-download a").attr({ 
          href: idPath2_prev
        });

    	$("ul#g-list li a").removeClass("act");
        $("ul#g-list li a:eq("+ prev_prev +")").addClass("act");

		if(prev_prev>0){$("#gal-prev").css("display", "block");
					$("#gal-prev").attr({
          alt: prev_prev
        });}
			else {$("#gal-prev").css("display", "none");}

		$("#gal-next").attr({
          alt: prev_prev
});
		$("#gal-next").css("display", "block");

   });

	//Previous

	//Next
    $("#gal-next").click(function(){
	   var index_next = $(this).attr("alt");
	   var next_next = (index_next*1)+1;
	   var counter_next = ($("ul#g-list li a").size())-1;
      var idString_next =$("ul#g-list li a:eq("+ next_next +") img").attr("alt");
      var idPath1_next =$("ul#g-list li a:eq("+ next_next +")").attr("alt");
      var idPath2_next =$("ul#g-list li a:eq("+ next_next +")").attr("title");
       $("#gal-text").text(idString_next);
      $("img#galerie-foto").attr({ 
          src: idPath1_next,
          title: idString_next,
          alt: idString_next
        });
      $("div#gal-download a").attr({ 
          href: idPath2_next
        });

    	$("ul#g-list li a").removeClass("act");
        $("ul#g-list li a:eq("+ next_next +")").addClass("act");

		if(next_next==counter_next){$("#gal-next").css("display", "none");}
			else {$("#gal-next").css("display", "block");					
					$("#gal-next").attr({
          alt: next_next
        });}

					$("#gal-prev").attr({
          alt: next_next
        });

		$("#gal-prev").css("display", "block");

   });
	//Next

//Gallery

//Colour chooser
    $("ul#color-thumbs li a").click(function(){
      var idString_color = $(this).children("img").attr("alt");
      var idPath1_color = $(this).attr("title");
      $("img#barvy-foto").attr({ 
          src: idPath1_color,
          title: idString_color,
          alt: idString_color
        });
        $("#color-label").text(idString_color);
    	$("ul#color-thumbs li a").removeClass("act");
        $(this).addClass("act");	
    });




//Hover
    $("#left-column-big ul#color-thumbs li a").hover(function(){
      var idString_hover = $(this).children("img").attr("alt");
        $("#color-label").text(idString_hover);
    },
     function()
     {
    	var idString_hover_1 = $("#left-column-big ul#color-thumbs li a.act").children("img").attr("alt");
        $("#color-label").text(idString_hover_1);
     });
//Hover
//Colour chooser


//striped tabulka normal
$(".normal tr").mouseover(function() {$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");});
$(".normal tr:even").addClass("alt");
//striped tabulka normal

//striped tabulka .tabspec
$(".tabspec tr").mouseover(function() {$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");});
$(".tabspec tr:even").addClass("alt");
//striped tabulka .tabspec


//Zobrazeni galerie v akcnich modelech

    $("#galerie-akcni").toggle(function()
        {
   		$(this).children("a").addClass("act");
   		$(".akcni-active-window").removeClass("act");
   		$(".akcni-active-window:eq(1)").addClass("act");	
     	$("ul#g-list").slideDown("normal");
     	$("ul#color-thumbs").slideUp("normal");
   		$("#barvy-akcni a").removeClass("act"); 
        },
     function()
     {
    	$(this).children("a").removeClass("act");
     	$("ul#g-list").slideUp("normal");
   		$(".akcni-active-window").removeClass("act");
   		$(".akcni-active-window:eq(0)").addClass("act");
     });

//Zobrazeni galerie v akcnich modelech

//Zobrazeni barev v akcnich modelech

    $("#barvy-akcni").toggle(function()
        {
   		$(this).children("a").addClass("act");
   		$(".akcni-active-window").removeClass("act");
   		$(".akcni-active-window:eq(2)").addClass("act");	
     	$("ul#color-thumbs").slideDown("normal");
     	$("ul#g-list").slideUp("normal");
   		$("#galerie-akcni a").removeClass("act"); 
        },
     function()
     {
    	$(this).children("a").removeClass("act");
     	$("ul#color-thumbs").slideUp("normal");
   		$(".akcni-active-window").removeClass("act");
   		$(".akcni-active-window:eq(0)").addClass("act");
     });

//Zobrazeni barev v akcnich modelech

//model-container
   $(".news_slider .item a").click(function(){
	return false;
      });

    $(".news_slider .item a").click(function(){
	$("#model-container").text("");
    $(".news_slider .item a img").removeClass("act");
        $(this).children("img").addClass("act");
		$("#model-container").load('../includes/modely-container/'+$(this).attr("title")+'.html');
		$("#model-container").css("display", "block");
      });

//model-container

     	$(".tabspec tbody tr").hide("");
     	$(".tabspec tbody tr.nadpisova").show("");


    $(".tabspec .nadpisova").toggle(function()
        {
     	$(".tabspec tr."+$(this).attr("title")).show("");
   		$(this).addClass("act");
        },
     function()
     {
     	$(".tabspec tr."+$(this).attr("title")).hide("");
   		$(this).removeClass("act");
     });



    });



/* carconfig */
function open_fullscreen(lnk,wd,ht,wn,parms){
	var strSb='scrollbars', strSt='status', strRsz='resizable', n='no',y='yes',s=screen,sw=s.availWidth-0,sh=s.availHeight-0,l,t,wp,sb='no'
	
	if(parms){wp = parms;} 
	else if (parms == undefined) {wp = strRsz+'='+n+', '+strSb+'='+n;}
	l=parseInt((sw-s.availWidth-10)/2);	if(l<0){w=sw-10;l=0;sb=y}
	t=parseInt((sh-s.availHeight-10)/2);if(t<0){h=sh-35;t=0;sb=y}
	if (sb==y){
	  if(parms.indexOf(strSb)!=-1){wp=wp.replace((strSb+'='+y),(strSb+'='+y))}
	  else {wp+= ', '+strSb+'='+y}}

	if (wp.indexOf(strRsz+'='+y) !=-1){wp+=','+strSt+'='+y;h=h-26}
        else{wp+=','+strSt+'='+n}

	window.open(lnk,wn,wp+',width='+w+',height='+h+',left='+l+',top='+t)
}


