﻿        var tab_i = new Array(), pos = new Array();
        var cells, frames = 14;
         
        function onLoadFunctions(id,master_url){
            GetCells(id);
            ChangeMasterUrl(master_url);                    
        }          

        
        function ChangeMasterUrl (master_url) 
        {
            var ids = new Array('menu','leftmenu','toplinks', 'subpage','produkty', 'formularze', 'big-start-links');
            var i, j, k;
            for (i=0; i < ids.length; i++) 
            {            
                var element = document.getElementById(ids[i]);
                if(element)
                {
                    var links = element.getElementsByTagName('a');
                    for (j=0; j < links.length; j++) 
                    {
                        var PathArray = links[j].href.split('/');
                        PathArray[2] = master_url;
                        var newPath = '';
                        for (k=0; k < PathArray.length; k++)
                        {                      
                            newPath += PathArray[k];
                            if (k < PathArray.length-1)
                            newPath += '/';                       
                        }
                        if (links[j].href != 'http://www.vig-polska.pl/' && links[j].href != 'http://www.koloryzycia.pl/')
                            links[j].href = newPath;
                    }
                }
            }            
           
        }        
        
        function GetCells(id) {
            var table, i;
            if (document.getElementById(id) != null) {
                table = document.getElementById(id);
                cells = table.getElementsByTagName('td');
                    for (i=0; i < cells.length; i++){
                         if (i*2 <= cells.length) {
                            cells[i*2].onmouseover = new Function("Animation("+i*2+",'in');");
                            cells[i*2].onmouseout = new Function("Animation("+i*2+",'out');");
                        }
                        tab_i[i] = 0;
                        pos[i] = 0;
                    }
             } else alert('Nie ma elementu o podanym ID!');         
        }       
       function Animation(nr,change) {
           var ob = cells[nr];
           var browser = navigator.appName;
           var version = navigator.appVersion.indexOf('6.0');
           if ((browser == 'Microsoft Internet Explorer') && (version == 22)) {
                   if (change == 'out') 
                        ob.style.backgroundPosition = '0px 0px';
                   else 
                        ob.style.backgroundPosition = '0px -462px';
            } else {       
               if(ob['timer'])clearTimeout(ob['timer']);
               var kierunek = -1, roznica = frames - tab_i[nr];
               if (change == 'out') {
                    kierunek = 1;
                    tab_i[nr]--;
               } else tab_i[nr]++;
               pos[nr] = pos[nr] + kierunek*33;
               ob.style.backgroundPosition = '0px ' + pos[nr] + 'px';
               if ((tab_i[nr] < frames) && (tab_i[nr] > 0) ) 
                    ob['timer'] = setTimeout(function(){ Animation(nr,change)},8);
           }
        } 