 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") {
				$( "#login_ok" ).dialog({ modal: true, minWidth: 300, minHeight: 185, resizable: false})
			} else {
				$( "#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" ); }}})
			});
		}


        Shadowbox.init({
			language:   "cs",
			players:    ["img"]
		});

        $(document).ready(function(){
			$('input.star').rating();

			$('.show_title').tooltip({
				track: true,
				delay: 250,
				showURL: false,
				showBody: " - ",
				extraClass: "pretty",
				fixPNG: true,
				width: 300
			});

            $("#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
			});


            $( "#dialog").dialog("destroy");

    		$( "#sdHc2" ).click(function(){
                                            $( "#dialog-message" ).dialog({
                                    			modal: true,
                                    			minWidth: 303,
                                    			minHeight: 185,
                                    			resizable: false

                                    		})
    		});

            jQuery('#jcarousel_1').jcarousel({scroll: 1});
            jQuery('#jcarousel_2').jcarousel({scroll: 1});
            jQuery('#jcarousel_3').jcarousel({scroll: 1});


            $('#tabs1').tabs();
            $('#tabs2').tabs();
            $("ul.sf-menu").supersubs({
				minWidth:    6,   // minimum width of sub-menus in em units
				maxWidth:    10,   // 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({
				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:   true,               // completely disable drop shadows by setting this to false
				delay:         500
			});
		});

