    var $j = jQuery.noConflict();
    
    $j(function(){
        
            //dvouřádkové menu v headru
            if($j('.central_div .main_navigation').height() > 32)
            {
                   $j('.central_div .header').height($j('.central_div .header').height()+32);
                   $j('.header_spacer').css('display','inline');
                   $j('.central_div .status_img').css('top', 200);
            }                     
            
            jQuery('#mycarousel').jcarousel();
            jQuery('#mycarousel1').jcarousel();
            jQuery('#mycarouselver').jcarousel({
                vertical: true
            });
            jQuery('#mycarouselver2').jcarousel({
                vertical: true
            });
            
            var winheight = $j(window).height()-60;
            var bimgh = $j('.inside .big_img').height();
            
            if(winheight<bimgh)
            {
                $j('.jcarousel-skin-tango2 .jcarousel-clip-vertical').height(winheight-80);
                $j('.jcarousel-skin-tango2 .jcarousel-container-vertical').height(winheight-80);

            }else
            {
                $j('.jcarousel-skin-tango2 .jcarousel-clip-vertical').height(bimgh-80);
                $j('.jcarousel-skin-tango2 .jcarousel-container-vertical').height(bimgh-80);
            }
            
            if($j('.detail_center_panel').height()>$j('.detail_left_panel').height())
            {
               $j('.jcarousel-skin-tango .jcarousel-clip-vertical').height($j('.detail_center_panel').height()-80);
               $j('.jcarousel-skin-tango .jcarousel-container-vertical').height($j('.detail_center_panel').height()-80);
            }
            else
            {
                $j('.jcarousel-skin-tango .jcarousel-clip-vertical').height($j('.detail_left_panel').height()-80);
                $j('.jcarousel-skin-tango .jcarousel-container-vertical').height($j('.detail_left_panel').height()-80);
            }   

            //selecty
            selectBox('#select_velikost');
            selectBox('.pag1 .sort_by');
            selectBox('.pag2 .sort_by');
            
            //colorboxy
            $j("a[rel='foto']").colorbox();
            $j("a[rel='foto1']").colorbox();
            
            $j("a[rel='iframe']").each(function()
            {
                
                href = "#matdet_"+$j(this).attr('id').substring(9);
                $j(this).colorbox({width:"900px", inline:true, href:href});
            });
            
            var options = {
                width:"900px", 
                inline:true, 
                href:"#vel_modal"
            };
            $j('#velikosti_odkaz').colorbox(options);
            
            //výměna textu popisy->materiály u detailu výrobku
            $j('#show_mat a').click(function()
            {
                $j('#desc_mat').css('display', 'block');
                $j('#desc_text').css('display', 'none');
                $j('#show_mat').addClass("active");
                $j('#show_desc').removeClass("active");
            });
            $j('#show_desc a').click(function()
            {
                $j('#desc_text').css('display', 'block');
                $j('#desc_mat').css('display', 'none');
                $j('#show_desc').addClass("active");
                $j('#show_mat').removeClass("active");
            });
            
            //výška názvu produktů u itemlist
            $j('.central_div .content .right_panel .vypis li').each(function(i) {
                if(i%4==0)
                {
                    li1 = $j(this).find('.name');
                    li2 = $j(this).next().find('.name');
                    li3 = $j(this).next().next().find('.name');
                    li4 = $j(this).next().next().next().find('.name');
                    
                    price1 = $j(this).find('.name .price');
                    price2 = $j(this).next().find('.name .price');
                    price3 = $j(this).next().next().find('.name .price');
                    price4 = $j(this).next().next().next().find('.name .price');
                    
                    oldheight1 = li1.height();
                    oldheight2 = li2.height();
                    oldheight3 = li3.height();
                    oldheight4 = li4.height();
                    
                    maxheight = li1.height();
                    if(li2.height() != null && li2.height() > maxheight) maxheight = li2.height();
                    if(li3.height() != null && li3.height() > maxheight) maxheight = li3.height();
                    if(li4.height() != null && li4.height() > maxheight) maxheight = li4.height();
                    
                    li1.height(maxheight);
                    li2.height(maxheight);
                    li3.height(maxheight);
                    li4.height(maxheight);
                    
                    if(oldheight1 < maxheight)price1.css("top", maxheight-oldheight1);
                    if(oldheight2 < maxheight)price2.css("top", maxheight-oldheight2);
                    if(oldheight3 < maxheight)price3.css("top", maxheight-oldheight3);
                    if(oldheight4 < maxheight)price4.css("top", maxheight-oldheight4);
                }
             });
            
//             $j('.central_div .content .detail_galerie li').each(function() {
//
//                   var hp1height = $j(this).height();
//                   var imgheight = $j(this).find('img').height();
//
//                   if(hp1height!=0 && imgheight!=0)
//                   {
//                       var fheight = hp1height-imgheight;
//                       alert(fheight+"="+hp1height+"-"+imgheight);
//
//                       fheight = fheight/2;
//                       if(fheight <0) fheight = 0;
//
//                       $j(this).find('img').css("margin-top",fheight);
//                   }
//
//             });
             
             //červená hvězdička u povinných polí formuláře
             $j('.required label').each(function() {

                lab = $j(this).text();
                $j(this).html(lab + ' <span>*</span>');
	
            })
            
            $j('.br3 tbody .cell_1,.br3 tbody .cell_2,.br3 tbody .cell_3, .br3 tbody .cell_4, .br3 tbody .cell_5, .br3 tbody .cell_6, .br3 tbody .cell_7, .br3 tbody .cell_8, .br3 tbody .cell_9').not(' .br3 tbody .cell_input').click(function() {

                   var rel = $j(this).parent().find('a').attr("rel");
                   var url = $j(this).parent().find('a').attr("href");

                   if(rel>0)
                   {

                    if(url>0)
                    $j("a[rel='foto']").colorbox();

                   }else{

                    self.location.href = url;

                   }

            });
            
            $j('.vypis_table .cell_1,.vypis_table .cell_2,.vypis_table .cell_3').click(function() {

                   var rel = $j(this).parent().find('a').attr("rel");
                   var url = $j(this).parent().find('a').attr("href");

                   if(rel>0)
                   {

                    if(url>0)
                    $j("a[rel='foto']").colorbox();

                   }else{

                    self.location.href = url;

                   }

            });
            
            //u objednávkového procesu zajíždění hesla a naopak vyjíždění registrace
            if($j('#frmuserform-type-0').attr('checked')=='checked')
            {
                   $j('#passw_for_reg_user').slideUp(0);
                   $j('#passw_for_reg_user2').slideDown(0);
            }
            
                
            $j('#frmuserform-type-0').change(function() {
                var readval = $j(this).attr('checked');
                
		if(readval=='checked')
                {
                    $j('#passw_for_reg_user').slideUp(0);
                    $j('#passw_for_reg_user2').slideDown();
                }
                else
                {
                    $j('#passw_for_reg_user').slideDown();
                    $j('#passw_for_reg_user2').slideUp(0);
                }
            });
            $j('#frmuserform-type-1').change(function() {
                var readval = $j(this).attr('checked');
                
		if(readval=='checked')
                {
                    $j('#passw_for_reg_user').slideDown();
                    $j('#passw_for_reg_user2').slideUp(0);
                }
                else
                {
                    $j('#passw_for_reg_user').slideUp(0);
                    $j('#passw_for_reg_user2').slideDown();
                }
            });
            
            //u objednávkového procesu zajíždění firemních kolonek
            if($j('#frmaddressform-type-0').attr('checked')=='checked')
                $j('#bloc_addres').slideUp(0);
                
            $j('#frmaddressform-type-0').change(function() {
                var readval = $j(this).attr('checked');
                
		if(readval=='checked')
                    $j('#bloc_addres').slideUp();
                else
                    $j('#bloc_addres').slideDown();
            });
            $j('#frmaddressform-type-1').change(function() {
                var readval = $j(this).attr('checked');
                
		if(readval=='checked')
                    $j('#bloc_addres').slideDown();
                 else
                    $j('#bloc_addres').slideUp();
            });            
            
            //zobrazení dodací adresy, pokud je jiná než fakturační
            $j('#isdel').change(function() {
		var readval = $j(this).attr('checked');
                
		if(readval=='checked')
		{
                    $j('.del').css('display','none');
		}else{
                    $j('.del').css('display','block');
		}
            });
            
            //zobrazení podvýrobků v hlevním menu
            $j('.main_navigation_li a').mouseover(function() {
                var id = $j(this).attr('id');
                
		$j('#sub_'+id+'_wrapper').css('display','inline');
            });
            $j('.main_navigation_li a').mouseleave(function() {
                var id = $j(this).attr('id');
                
		$j('#sub_'+id+'_wrapper').css('display','none');
                
                $j('#sub_'+id+'_wrapper').mouseover(function(){
                   $j(this).css('display','inline');
                });
            });
            $j('.sub_nav_wrapper').mouseleave(function() {
                var id = $j(this).attr('id');
                
		$j('.sub_nav_wrapper').css('display','none');
            });
            
            //zaškrtnutí pouze jednoho checkboxu u filtrovacího formuláře
            $j('#uaff input[type=checkbox]').change(function()
            {
                $j('#uaff input[type=checkbox]').each(function()
                {
                    $j(this).attr('checked',false);
                });
                
                $j(this).attr('checked',true);
                
                $j('#uaff').submit();
            });
            
            //zobrazit všechny formuláře
            $j('#more_comments').click(function()
            {
                $j('#comments_hidden').toggle();
                $j('#more_comments').slideUp(0);
                $j('#less_comments').slideDown(0);
            });
            $j('#less_comments').click(function()
            {
                $j('#comments_hidden').toggle();
                $j('#more_comments').slideDown(0);
                $j('#less_comments').slideUp(0);
            });
            
            $j('#a_star_1').click(function()
            {
                $j('#frmcommentadd-rating').val(1);
                leaveStar();
            });
            $j('#a_star_1').hover(function()
            {
                $j('#a_star_1').html('<img src="./images/red_star_ico.gif" width="13" height="12" alt="img" />');
                $j('#a_star_2').html('<img src="./images/grey_star_ico.gif" width="13" height="12" alt="img" />');
                $j('#a_star_3').html('<img src="./images/grey_star_ico.gif" width="13" height="12" alt="img" />');
                $j('#a_star_4').html('<img src="./images/grey_star_ico.gif" width="13" height="12" alt="img" />');
                $j('#a_star_5').html('<img src="./images/grey_star_ico.gif" width="13" height="12" alt="img" />');
                setStarName(1);
            },function()
            {
                leaveStar()
            });
            
             $j('#a_star_2').click(function()
            {
                $j('#frmcommentadd-rating').val(2);
                leaveStar();
            });
            $j('#a_star_2').hover(function()
            {
                $j('#a_star_1').html('<img src="./images/red_star_ico.gif" width="13" height="12" alt="img" />');
                $j('#a_star_2').html('<img src="./images/red_star_ico.gif" width="13" height="12" alt="img" />');
                $j('#a_star_3').html('<img src="./images/grey_star_ico.gif" width="13" height="12" alt="img" />');
                $j('#a_star_4').html('<img src="./images/grey_star_ico.gif" width="13" height="12" alt="img" />');
                $j('#a_star_5').html('<img src="./images/grey_star_ico.gif" width="13" height="12" alt="img" />');
                setStarName(2);
            },function()
            {
                leaveStar()
            });
            
             $j('#a_star_3').click(function()
            {
                $j('#frmcommentadd-rating').val(3);
                leaveStar();
            });
            $j('#a_star_3').hover(function()
            {
                $j('#a_star_1').html('<img src="./images/red_star_ico.gif" width="13" height="12" alt="img" />');
                $j('#a_star_2').html('<img src="./images/red_star_ico.gif" width="13" height="12" alt="img" />');
                $j('#a_star_3').html('<img src="./images/red_star_ico.gif" width="13" height="12" alt="img" />');
                $j('#a_star_4').html('<img src="./images/grey_star_ico.gif" width="13" height="12" alt="img" />');
                $j('#a_star_5').html('<img src="./images/grey_star_ico.gif" width="13" height="12" alt="img" />');
                setStarName(3);
            },function()
            {
                leaveStar()
            });
            
             $j('#a_star_4').click(function()
            {
                $j('#frmcommentadd-rating').val(4);
                leaveStar();
            });
            $j('#a_star_4').hover(function()
            {
                $j('#a_star_1').html('<img src="./images/red_star_ico.gif" width="13" height="12" alt="img" />');
                $j('#a_star_2').html('<img src="./images/red_star_ico.gif" width="13" height="12" alt="img" />');
                $j('#a_star_3').html('<img src="./images/red_star_ico.gif" width="13" height="12" alt="img" />');
                $j('#a_star_4').html('<img src="./images/red_star_ico.gif" width="13" height="12" alt="img" />');
                $j('#a_star_5').html('<img src="./images/grey_star_ico.gif" width="13" height="12" alt="img" />');
                setStarName(4);
            },function()
            {
                leaveStar()
            });
            
             $j('#a_star_5').click(function()
            {
                $j('#frmcommentadd-rating').val(5);
                leaveStar();
            });
            $j('#a_star_5').hover(function()
            {
                $j('#a_star_1').html('<img src="./images/red_star_ico.gif" width="13" height="12" alt="img" />');
                $j('#a_star_2').html('<img src="./images/red_star_ico.gif" width="13" height="12" alt="img" />');
                $j('#a_star_3').html('<img src="./images/red_star_ico.gif" width="13" height="12" alt="img" />');
                $j('#a_star_4').html('<img src="./images/red_star_ico.gif" width="13" height="12" alt="img" />');
                $j('#a_star_5').html('<img src="./images/red_star_ico.gif" width="13" height="12" alt="img" />');
                setStarName(5);
            },function()
            {
                leaveStar()
            });           
	});

