 jQuery.extend({
        numberFormat: function ($number, $decimals, $dec_point, $thousands_sep, $roundType){
            if($dec_point == undefined || $dec_point == null){
                $dec_point = '.';
            }
            if($thousands_sep == undefined || $thousands_sep == null){
                $thousands_sep = ' ';
            }
            if($roundType == undefined || $roundType == null){
                $roundType = 'round';
            }
            if($decimals != undefined && $decimals != null){
                if(typeof $number == 'string'){
                    $number = parseFloat($number);
                }
                var $pow = Math.pow(10, $decimals);
                $number *= $pow;

                if($roundType == 'round'){
                    $number = Math.round($number);
                }else if($roundType == 'ceil'){
                    $number = Math.ceil($number);
                }else if($roundType == 'floor'){
                    $number = Math.floor($number);
                }
                $number /= $pow;
            }

            $number += '';
            var $x = $number.split('.');
            $number = $x[0];
            var $dec = $x[1];

            if($thousands_sep != ''){
                var $i = 0;
                var rgx = /(\d+)(\d{3})/;
                while (rgx.test($number)) {
                    $number = $number.replace(rgx, '$1' + $thousands_sep + '$2');
                    if($i++ > 5){
                        break;
                    }
                }
            }
            if($dec != undefined){
                $dec += '';
                for(var $i = 0; $i<$decimals - $dec.length; $i++){
                    $dec += '0';
                }
                $number = $number + $dec_point + $dec;
            }
            return $number;
        }
	});
		function login_dialog(status) {

      if (status == "ok") {
        $(document).ready(function(){
          $( "#login_ok" ).dialog({ modal: true, minWidth: 300, minHeight: 185, resizable: false})
        });
      } else {
        $(document).ready(function(){
          $( "#login_nok" ).dialog({ modal: true, minWidth: 300, minHeight: 185, resizable: false})
        });
      }
		};
		function kod_dialog(status) {
			if (status == "ok") {
				$(document).ready(function(){
					$("#kupon_ok").dialog({ modal: true, minWidth: 300, minHeight: 185, resizable: false})
				});
			} else {
				$(document).ready(function(){
					$("#kupon_nok").dialog({ modal: true, minWidth: 300, minHeight: 185, resizable: false})
				});
			}
		};

		function error_dialog() {
			$(document).ready(function(){
				$("#error-message").dialog({ modal: true, minWidth: 300, minHeight: 185, resizable: false, buttons: { Ok: function() { $( this ).dialog( "close" ); }}})
			});
		};
		function success_dialog() {
			$(document).ready(function(){
				$("#success-message").dialog({ modal: true, minWidth: 300, minHeight: 185, resizable: false, buttons: { Ok: function() { $( this ).dialog( "close" ); }}})
			});
		};

    function detail_dotaz(){

    };
    
    
        Shadowbox.init({
			language:   "cs",
			players:    ["img"]
		});

        $(document).ready(function(){
			$('input.star').rating();

            $("#treeview_solar").treeview({
// 				persist: "cookie",
				persist: "location",
				animated: "fast",
				collapsed: true,
				unique: true
			});
            $("#treeview_foto").treeview({
		// 		persist: "cookie",
				persist: "location",
				animated: "fast",
				collapsed: true,
				unique: true
			});


         $( "#detail_dotaz_tlac" ).click(function(){
             $( "#detail_dotaz" ).dialog({
                modal: true,
                minWidth: 300,
                minHeight: 185,
                resizable: false
             })
        });

        $( "#tlac_novinky" ).click(function(){
             $( "#popup_novinky_email" ).dialog({
                modal: true,
                minWidth: 300,
                minHeight: 90,
                resizable: false
             })
        });

        $( "#dialog").dialog("destroy");

    		$( "#sdHc2" ).click(function(){
                                            $( "#dialog-message" ).dialog({
                                    			modal: true,
                                    			minWidth: 305,
                                    			minHeight: 190,
                                    			resizable: false

                                    		})
    		});

            jQuery('#jcarousel_1').jcarousel({scroll: 1});
            jQuery('#jcarousel_2').jcarousel({scroll: 1});
            jQuery('#jcarousel_3').jcarousel({vertical:true, scroll: 1});
            jQuery('#jcarousel_4').jcarousel({scroll: 1});

            $('#tabs1').tabs();
            $('#tabs2').tabs();
            $("ul.sf-menu").supersubs({
      				minWidth:    6,   // minimum width of sub-menus in em units
      				maxWidth:    25,   // maximum width of sub-menus in em units
      				extraWidth:  1     // extra width can ensure lines don't sometimes turn over
      								// due to slight rounding differences and font-family
      			}).superfish({
       				hoverClass:    'sfHover',          // the class applied to hovered list items
      				animation:     {opacity:'show', height:'show', width:'show'},   // an object equivalent to first parameter of jQuery’s .animate() method
      				speed:         'fast',           // speed of the animation. Equivalent to second parameter of jQuery’s .animate() method
      			  dropShadows:   false,               // completely disable drop shadows by setting this to false
      				delay:         300
      			});


      $('#slider1').anythingSlider({
               buildArrows         : false,
               pauseOnHover        : true,
               startText           : "",   // Start button text
               stopText            : "",    // Stop button text
               navigationFormatter : function(index, panel){
                  return index;
                }
            });

      $("#slide_button1_left").click(function(){
            $(".slide_box1").animate({"left": "-=240px"}, "slow");
            $("#slide_button1_left").hide();
            $("#slide_button1_right").show();
      });
      $("#slide_button1_right").click(function(){
            $(".slide_box1").animate({"left": "+=240px"}, "slow");
            $("#slide_button1_right").hide();
            $("#slide_button1_left").show();
      });
      $("#slide_button2_left").click(function(){
            $(".slide_box2").animate({"left": "-=240px"}, "slow");
            $("#slide_button2_left").hide();
            $("#slide_button2_right").show();
      });
      $("#slide_button2_right").click(function(){
            $(".slide_box2").animate({"left": "+=240px"}, "slow");
            $("#slide_button2_right").hide();
            $("#slide_button2_left").show();
      });


      $(".filtr_barvy_tlac").click(function(){
           // $(".filtr_barvy_tlac").toggleClass("active");
            $(".filtr_barvy").slideToggle("slow");
      });

      $(".sf-menu li ul li ul:not(:has(li))").addClass("test");    //zjistime jestli UL obsahuje LI pokud ne tak pridame tridu test
      $(".sf-menu li ul li:has(ul.test)").addClass("test1");       //zjistime jestli LI obsahuje UL s tridou test a pokud ano pridame tridu test1 podle ktere pak skryjeme SPAN se sipkou


      $('.tip_trigger').tooltip({
          track: true,
          delay: 0,
          showURL: false,
          top: 20,
          left: 20,
        	bodyHandler: function() {
        		return $("<img/>").attr("src", this.src);
        	}
      });
		
	   $(".filtr_nabidky2 select").mouseleave(function(event){
         event.stopPropagation();
       });

     $('.tool').tooltip({
                  showURL: false,
                  showBody: false,
                  top: -30,
                  left: 0,
                  opacity: 1
     });
     $('.kosik_odkazx').tooltip({
                  showURL: false,
                  showBody: false,
                  top: 20,
                  left: 0,
                  opacity: 1
     });

	$( "#tlac_hlidac" ).click(function(){
        $("#popup_hlidac" ).dialog({
			modal: true,
			minWidth: 345,
			minHeight: 185,
			resizable: false
		})
	});




    });

	
	
	
