﻿        // Obrazki Produktów
          
          function KolterImage(id,thin, medium, large, path){
                this.id = id;
                this.thin = thin;
                this.medium = medium;
                this.large = large;
                this.path = path + '/';
            }
            
            KolterImage.prototype = {
                getID: function(){return this.id; },
                getThin: function(){return this.thin; },
                getMedium: function(){return this.medium; },
                getLarge: function(){return this.large; },
                getPath: function(){return this.path; }
            };
              
            function switchImage(ctrl){
                var ii = ctrl.KolterImage;
                mainImage.src = imgPrefix + ii.getPath() + ii.getMedium();
                var tmp = currentImage;
                currentImage = ii;
                ctrl.KolterImage = tmp;
                ctrl.src = imgPrefix + tmp.getPath() + tmp.getThin();
               
            };                
                
            function initImages(){
                var img_list = document.getElementById('img_list');
                for(var i = 1; i < img.length; ++i){       
                    img_list.style.display = ''; 
                    var ii = new Image();
                    ii.src = imgPrefix + img[i].getPath() + img[i].getThin();
                    ii.onmouseover = function(){
                        mainImage.src = imgPrefix + this.KolterImage.getPath() + this.KolterImage.getMedium();
                        var tmp = currentImage;
                        currentImage = this.KolterImage;
                        this.KolterImage = tmp;
                        this.src = imgPrefix + this.KolterImage.getPath() + this.KolterImage.getThin();
                    };
                    ii.KolterImage = img[i];
                    img_list.appendChild(ii);
                }
            }

            function removeChildrens(elem){
                while(elem.childNodes.length > 0){
                    elem.removeChild(elem.childNodes[elem.childNodes.length - 1]);
                }
            }

            function findPos(obj) {
	            var curleft = curtop = 0;
	            if (obj.offsetParent) {
		            curleft = obj.offsetLeft
		            curtop = obj.offsetTop
		            while (obj = obj.offsetParent) {
			            curleft += obj.offsetLeft
			            curtop += obj.offsetTop
		            }
	            }
	            return [curleft,curtop];
            }

            function PopupMainImage(){                    
                window.open( '/ViewImage.aspx?imageId='+currentImage.getID(),'_blank','');
            }

            var imgPrefix = 'http://static.kolter.pl/img/'; 
            var img = new Array(); 
            
            // Drzewko kategorii
            
                var colapsed = null;
                
                function colap(elem, head){
                    var a_colaps = elem.parent().parent().find('a.colap');
                    
                    a_colaps.parent().parent().find('ul').hide('normal');
                    head.find('a').addClass('colap');
                    a_colaps.removeClass('colap');
                }
                
                function pokaz(elem){
                    var tmp = $(elem).next();
                    
                    tmp.show('normal');
                        
                    colapsed = tmp;
                    colap(tmp, $(elem));
                }
                
                // Search
                
                function PokazProdukty() {
                    $('.pro').parent().removeClass('h_gray_r').addClass('h_green_r');
                    $('.pro').parent().find('.h_gray_l').removeClass('h_gray_l').addClass('h_green_l');
                    $('.akt').parent().removeClass('h_green_r').addClass('h_gray_r');
                    $('.akt').parent().find('.h_green_l').removeClass('h_green_l').addClass('h_gray_l');
                    $('.now').parent().removeClass('h_green_r').addClass('h_gray_r');
                    $('.now').parent().find('.h_green_l').removeClass('h_green_l').addClass('h_gray_l');
                    
                    $('.produkt').show();
                    $('.aktualnosci').hide();
                    $('.nowosci').hide();
                }
                function PokazAktualnosci() {
                    $('.akt').parent().removeClass('h_gray_r').addClass('h_green_r');
                    $('.akt').parent().find('.h_gray_l').removeClass('h_gray_l').addClass('h_green_l');
                    $('.pro').parent().removeClass('h_green_r').addClass('h_gray_r');
                    $('.pro').parent().find('.h_green_l').removeClass('h_green_l').addClass('h_gray_l');
                    $('.now').parent().removeClass('h_green_r').addClass('h_gray_r');
                    $('.now').parent().find('.h_green_l').removeClass('h_green_l').addClass('h_gray_l');
                    
                    $('.produkt').hide();
                    $('.aktualnosci').show();
                    $('.nowosci').hide();
                }
                
                function PokazNowosci() {
                    $('.now').parent().removeClass('h_gray_r').addClass('h_green_r');
                    $('.now').parent().find('.h_gray_l').removeClass('h_gray_l').addClass('h_green_l');
                    $('.pro').parent().removeClass('h_green_r').addClass('h_gray_r');
                    $('.pro').parent().find('.h_green_l').removeClass('h_green_l').addClass('h_gray_l');
                    $('.akt').parent().removeClass('h_green_r').addClass('h_gray_r');
                    $('.akt').parent().find('.h_green_l').removeClass('h_green_l').addClass('h_gray_l');
                    
                    $('.produkt').hide();
                    $('.aktualnosci').hide();
                    $('.nowosci').show();
                }
                
                // Taby
                
                function PokazOpis() {
                    $('.Topi').parent().removeClass('h_gray_r').addClass('h_green_r');
                    $('.Topi').parent().find('.h_gray_l').removeClass('h_gray_l').addClass('h_green_l');
                    $('.Tpel').parent().removeClass('h_green_r').addClass('h_gray_r');
                    $('.Tpel').parent().find('.h_green_l').removeClass('h_green_l').addClass('h_gray_l');
                    $('.Tdan').parent().removeClass('h_green_r').addClass('h_gray_r');
                    $('.Tdan').parent().find('.h_green_l').removeClass('h_green_l').addClass('h_gray_l');
                    
                    $('.Topis').show();
                    $('.Tpelny').hide();
                    $('.Tdane').hide();
                }
                function PokazOpisPelny() {
                    $('.Tpel').parent().removeClass('h_gray_r').addClass('h_green_r');
                    $('.Tpel').parent().find('.h_gray_l').removeClass('h_gray_l').addClass('h_green_l');
                    $('.Topi').parent().removeClass('h_green_r').addClass('h_gray_r');
                    $('.Topi').parent().find('.h_green_l').removeClass('h_green_l').addClass('h_gray_l');
                    $('.Tdan').parent().removeClass('h_green_r').addClass('h_gray_r');
                    $('.Tdan').parent().find('.h_green_l').removeClass('h_green_l').addClass('h_gray_l');
                    
                    $('.Topis').hide();
                    $('.Tpelny').show();
                    $('.Tdane').hide();
                }
                
                function PokazDane() {
                    $('.Tdan').parent().removeClass('h_gray_r').addClass('h_green_r');
                    $('.Tdan').parent().find('.h_gray_l').removeClass('h_gray_l').addClass('h_green_l');
                    $('.Topi').parent().removeClass('h_green_r').addClass('h_gray_r');
                    $('.Topi').parent().find('.h_green_l').removeClass('h_green_l').addClass('h_gray_l');
                    $('.Tpel').parent().removeClass('h_green_r').addClass('h_gray_r');
                    $('.Tpel').parent().find('.h_green_l').removeClass('h_green_l').addClass('h_gray_l');
                    
                    $('.Topis').hide();
                    $('.Tpelny').hide();
                    $('.Tdane').show();
                }
                
         
              