wzor=/^[0-9]{4}-((0[1-9]{1})|(1[0-2]{1}))-((0[1-9]{1})|(1[0-9]{1})|(2[0-9]{1})|(3[0-1]{1}))$/;
wzor2=/^((0[0-9]{1})|(1[0-9]{1})|(2[0-3]{1})):(([0-5]{1}[0-9]{1}))$/;
wzor_mail=/^[0-9a-zA-Z._-]+\@[0-9a-zA-Z._-]+\.[0-9a-zA-Z.]{2,4}$/;
wzor_link=/^[0-9a-zA-Z._-]+\.[0-9a-zA-Z._-]+$/;
wzor_alfanum=/^[0-9a-zA-Z._-]{5,16}$/;

var bckg_color = '#0979BB';
var bckg_color2 = '';

var gb_margin_act = 0;
var gb_timer1, gb_timer2;
var fb_step = 2;

function gp_auto()
{
      clearTimeout(gb_timer2);
      gb_margin_act -= 5;
      document.getElementById('gp_main').style.marginLeft = gb_margin_act + 'px'; 
      
      if(gb_margin_act > -310)     
            gb_timer1 = setTimeout("gp_auto()", fb_step); 
      else
            gb_margin_act = -310;
       
}

function gp_auto_hide()
{
      clearTimeout(gb_timer1);
      gb_margin_act += 5;
      document.getElementById('gp_main').style.marginLeft = gb_margin_act + 'px'; 
      
      if(gb_margin_act < 0)     
            gb_timer2 = setTimeout("gp_auto_hide()", fb_step);  
      else
            gb_margin_act = 0;
}

var fb_margin_act = 0;
var fb_timer1, fb_timer2;

function fb_auto()
{
      clearTimeout(fb_timer2);
      fb_margin_act -= 5;
      document.getElementById('fb_main').style.marginLeft = fb_margin_act + 'px'; 
      
      if(fb_margin_act > -250)     
            fb_timer1 = setTimeout("fb_auto()", fb_step);  
      else
            fb_margin_act = -250;
}

function fb_auto_hide()
{
      clearTimeout(fb_timer1);
      fb_margin_act += 5;
      document.getElementById('fb_main').style.marginLeft = fb_margin_act + 'px'; 
      
      if(fb_margin_act < 0)     
            fb_timer2 = setTimeout("fb_auto_hide()", fb_step);  
      else
            fb_margin_act = 0;     
}

//przesuwanie panoramki
/*
var pano_timer_run;
var pano_timeout_ = 50;
var pano_margin_act = 0;//aktualne polozenia warstwy
var pano_step = 1;//przesuniecie px co jednostke czasu
var pano_div_width = 800;//szerokosc zdjecia

function pano_next()//-330,0
{
      //alert(pano_margin_act + ' -> ' + pano_div_width);
      if(pano_margin_act <= (-1)*pano_div_width/2)
      {
            pano_margin_act = 0;
      }
      
      document.getElementById('panoramy').style.marginLeft = pano_margin_act + 'px';
      pano_margin_act = pano_margin_act - pano_step;
      
      pano_timer_run = setTimeout(function(){pano_next();},pano_timeout_);
}
*/

//zmiana hovera fotki
var p_row_actual_click = 1;
var pm_actual_click = 1;

function change_photo_hover(id, id_base, type, type_img)
{     
      if(type == "over")
            document.getElementById(id_base + id).style.backgroundPosition='0px 100%';                 
      else if(type == "out")
      { 
            if((type_img == "mid" && id != p_row_actual_click) || (type_img == "min" && id != pm_actual_click))
                  document.getElementById(id_base + id).style.backgroundPosition='0px 0px';  
      }  
}

//zmiana tla fotki
function change_photo_bckg(id, id_base, max, type_img)
{
      if(type_img == "mid")
            p_row_actual_click = id;
      else if(type_img == "min")
            pm_actual_click = id;            
      
      for(var i = 1;i <= max;i++)
      {
            if(document.getElementById(id_base + i))
            {
                  document.getElementById(id_base + i).style.backgroundPosition='0px 0px';   
                  document.getElementById(id_base + i).style.cursor='pointer'; 
            }    
      }
      
      if(document.getElementById(id_base + id))
      {
            document.getElementById(id_base + id).style.backgroundPosition='0px 100%';           
            document.getElementById(id_base + id).style.cursor='auto';    
      }
             
}

//podmiana zdjec w portfolio
var cp_procent = 1;
if(getBrowser()[0] == "msie")
      cp_step_procent = 0.05;
else
      var cp_step_procent = 0.025;
var cp_timeout = 1;
var cp_actual_click = 1;

function change_photo(id, img1, img2)
{
      if(cp_actual_click != id)
      {
            if(cp_procent == 1)
            {
                  document.getElementById('photo_big_bckg').style.backgroundPosition = '0px 0px';
            }
            
            if(cp_procent > 0)
            {
                  cp_procent -= cp_step_procent;      
                  document.getElementById('photo_big_img').style.opacity = cp_procent;
                  document.getElementById('photo_big_img').style.filter = "alpha(opacity="+(cp_procent*100)+")";
                  setTimeout(function(){change_photo(id, img1, img2);},cp_timeout);
            }
            else
            {
                  document.getElementById('photo_big_img').src = img1;
                  document.getElementById('photo_big_bckg').style.background = "url('" + img2 + "')";
                  
                  cp_procent = 1;
                  cp_actual_click = id;
                  document.getElementById('photo_big_img').style.opacity = 1;
                  document.getElementById('photo_big_img').style.filter = "alpha(opacity=100)";                 
            }
      }
}

var zero_procent = 0;
var od_timeout = 1;
function opacity_div(id)
{
      if(zero_procent < 1)
      {
            zero_procent += cp_step_procent;      
            document.getElementById(id).style.opacity = zero_procent;
            document.getElementById(id).style.filter = "alpha(opacity="+(zero_procent*100)+")";
            setTimeout(function(){opacity_div(id);},od_timeout);
      }
      else
      {
            zero_procent = 0;
            document.getElementById(id).style.opacity = 1;
            document.getElementById(id).style.filter = "alpha(opacity=100)";   
            if(document.getElementById('photo_big_bckg'))  
                  document.getElementById('photo_big_bckg').style.filter = "alpha(opacity=100)";      
            /* 
            if(document.getElementById('photo_min1'))  
                  document.getElementById('photo_min1').style.filter = "alpha(opacity=100)";      
            if(document.getElementById('portfolio_left'))  
                  document.getElementById('portfolio_left').style.filter = "alpha(opacity=100)";      
            */    
      }
}

//przesuwane portfolio
var p_timer_run;
var p_timeout_ = 10;
var p_div_amount = 10 - 3;//5 pozycji ale 4 widoczne
var p_margin_act = 0;//aktualne polozenia warstwy
var p_step = 20;//przesuniecie px co jednostke czasu
var p_div_width = 234;//szerokosc zdjecia - 306
//-(0.036*(x-117))^2 + 20
//-(0.046*(x-117))^2 + 30
//-(0.038*(x-117))^2 + 20
//-(0.029*(x-153))^2 + 20
//-(0.032*(x-165))^2 + 30//offset/2/165
//-(0.016*(x-330))^2 + 30

function p_wzor_math(x, distance)
{
      var wsp_wykresu = 0.036;///(distance/2/117)chust wie czemu taki wyszedl ;) - zalezny tez od step=30
      return -(Math.pow(wsp_wykresu*(x-distance/2),2)) + p_step;
}

function p_to_right()
{
      clearTimeout(p_timer_run);

      if(p_margin_act > -(p_div_amount - 1)*p_div_width)
            p_run_to_next(p_margin_act, p_margin_act + Math.abs(p_margin_act)%p_div_width - p_div_width);
}

function p_to_left()
{
      clearTimeout(p_timer_run);

      if(p_margin_act < 0)
            p_run_to_prev(p_margin_act, p_margin_act - (p_div_width - Math.abs(p_margin_act)%p_div_width)%p_div_width + p_div_width);
}


function p_run_to_prev(from, to)//-330,0
{
      if(p_margin_act < to)
      {
            p_margin_act = p_margin_act + p_wzor_math((Math.abs(p_margin_act-from))%Math.abs(to - from), Math.abs(to - from));
            document.getElementById('roll2').style.marginLeft = p_margin_act + 'px';
            p_timer_run = setTimeout(function(){p_run_to_prev(from, to);},p_timeout_);
      }
      else
      {
            p_margin_act = to;
            document.getElementById('roll2').style.marginLeft = p_margin_act + 'px';    
            //podsw. buttonow 
      }
}

function p_run_to_next(from, to)//0, -330
{
      if(p_margin_act > to)
      {
            p_margin_act = p_margin_act - p_wzor_math((Math.abs(p_margin_act-from))%Math.abs(to - from), Math.abs(to - from));
            document.getElementById('roll2').style.marginLeft = p_margin_act + 'px';
            p_timer_run = setTimeout(function(){p_run_to_next(from, to);},p_timeout_);
      }
      else
      {
            p_margin_act = to;
            document.getElementById('roll2').style.marginLeft = p_margin_act + 'px';      
      }
}

//przesuwane oferty
var timer_run;
var timeout_ = 10;
var more_visible = 2;
var div_amount = 13 - more_visible;//7( + 6) pozycji ale 3 widoczne
var margin_act = -918;//aktualne polozenia warstwy
var step = 20;//przesuniecie px co jednostke czasu
var div_width = 306;//szerokosc zdjecia
//-(0.029*(x-153))^2 + 20
//-(0.032*(x-165))^2 + 30//offset/2/165
//-(0.016*(x-330))^2 + 30

function wzor_math(x, distance)
{
      var wsp_wykresu = 0.029/(distance/2/153);//chust wie czemu taki wyszedl ;) - zalezny tez od step=30
      return -(Math.pow(wsp_wykresu*(x-distance/2),2)) + step;
}

function to_right()
{
      clearTimeout(timer_run);

      //if(margin_act > -(div_amount - 1)*div_width)
            run_to_next(margin_act, margin_act + Math.abs(margin_act)%div_width - div_width);
}

function to_left()
{
      clearTimeout(timer_run);

      //if(margin_act < 0)
            run_to_prev(margin_act, margin_act - (div_width - Math.abs(margin_act)%div_width)%div_width + div_width);
}


function run_to_prev(from, to)//-330,0
{
      if(margin_act < to)
      {
            margin_act = margin_act + wzor_math((Math.abs(margin_act-from))%Math.abs(to - from), Math.abs(to - from));
            //margin_act = margin_act + wzor_math(Math.abs(margin_act)%Math.abs(to - from), Math.abs(to - from));
            document.getElementById('roll').style.marginLeft = margin_act + 'px';
            timer_run = setTimeout(function(){run_to_prev(from, to);},timeout_);
      }
      else
      {
            margin_act = to;
            //jak dojdzie do konca to ustawiamy startowo
            if(margin_act == 0)
            {
                  margin_act = -1*div_width*(div_amount - 2*more_visible);
                  document.getElementById('roll').style.marginLeft = margin_act + 'px';     
            }                   
            else
            {
                  margin_act = to;
                  document.getElementById('roll').style.marginLeft = margin_act + 'px';     
            }         
      }
}

function run_to_next(from, to)//0, -330
{
      if(margin_act > to)
      {
            margin_act = margin_act - wzor_math((Math.abs(margin_act-from))%Math.abs(to - from), Math.abs(to - from));
            //margin_act = margin_act - wzor_math(Math.abs(margin_act)%Math.abs(to - from), Math.abs(to - from));
            document.getElementById('roll').style.marginLeft = margin_act + 'px';
            timer_run = setTimeout(function(){run_to_next(from, to);},timeout_);
      }
      else
      {
            margin_act = to;
            //jak dojdzie do konca to ustawiamy startowo
            if(margin_act == -1*div_width*(div_amount - 1))
            {
                  margin_act = (-1*div_width*(more_visible + 1));
                  document.getElementById('roll').style.marginLeft = margin_act + 'px';     
            }                   
            else
            {
                  margin_act = to;
                  document.getElementById('roll').style.marginLeft = margin_act + 'px';     
            }         
      }
}


function change_button(id)
{
      //buttony
      for(var i = 1;i <= 7;i++)
            document.getElementById('i' + i).className = 'i' + i + 'g';
      
      document.getElementById('i' + id).className = 'i' + id + ' sel_blue';
      
      //tresci
      for(var i = 1;i <= 7;i++)
      {
            if(document.getElementById('d' + i))
                  document.getElementById('d' + i).style.display = 'none';
      }
      
      if(document.getElementById('d' + id))
            document.getElementById('d' + id).style.display = 'block';
}

//przesuwane klientów
var k_div_pouse = 0;
var k_timer_run;
var k_timer;
var k_timeout_ = 60;
var k_div_amount = 3;//7( + 6) pozycji ale 3 widoczne
var k_margin_act = 0;//aktualne polozenia warstwy
var k_div_width = 60;//wys zdjecia
//-(0.029*(x-153))^2 + 20
//-(0.032*(x-165))^2 + 30//offset/2/165
//-(0.016*(x-330))^2 + 30

function k_wzor_math(x, distance)
{
      var wsp_wykresu = 0.029/(distance/2/153);//chust wie czemu taki wyszedl ;) - zalezny tez od step=30
      return -(Math.pow(wsp_wykresu*(x-distance/2),2)) + step;
}

function k_to_right()
{
      clearTimeout(k_timer_run);

      //if(margin_act > -(div_amount - 1)*div_width)
            k_run_to_next(k_margin_act, k_margin_act + Math.abs(k_margin_act)%k_div_width - k_div_width);
}

function k_run_to_next(from, to)//0, -330
{
      if(k_margin_act > to)
      {
            k_margin_act = k_margin_act - k_wzor_math((Math.abs(k_margin_act-from))%Math.abs(to - from), Math.abs(to - from));
            document.getElementById('logos_roll').style.marginTop = k_margin_act + 'px';
            k_timer_run = setTimeout(function(){k_run_to_next(from, to);},k_timeout_);
      }
      else
      {
            k_margin_act = to;
            //jak dojdzie do konca to ustawiamy startowo
            if(k_margin_act <= -1*k_div_width*k_div_amount)
            {
                  k_margin_act = 0;
                  document.getElementById('logos_roll').style.marginTop = k_margin_act + 'px';     
            }                   
            else
            {
                  k_margin_act = to;
                  document.getElementById('logos_roll').style.marginTop = k_margin_act + 'px';     
            }         
      }
}

function k_roll_auto()
{
      if(k_div_pouse == 1)
            k_to_right();  
      else
            k_div_pouse = 1;
            
      k_timer = setTimeout("k_roll_auto()", 5000);      
}




function coma_to_dot(str, kind)
{
      if(kind == 0)
            return parseFloat(str.replace(',','.'));
      else
      {
            return str.toString().replace('.',',');
      }
}

function basket_calc_cost(id1, id2, id3, val)
{
      var temp_value = 0;
      temp_value = coma_to_dot(document.getElementById(id1).innerHTML ,0) + parseFloat(val);
      document.getElementById(id3).innerHTML = coma_to_dot(temp_value.toFixed(2), 1);
      
      document.getElementById(id2).innerHTML = coma_to_dot(val.toFixed(2), 1);
}

function set_def_val(id, val)
{
      idek = document.getElementById(id);
      if(!parseInt(idek.value))
      {
            idek.value = 1;
      }
}

function only_numbers(t,ev)
{
         //38 - gora, 40 - dol
      if(ev.keyCode == '38')
            set_amount(t, 0);
      else if(ev.keyCode == '40')
            set_amount(t, 1);
         
      var cos = "";
      if(ev.keyCode != '37' && ev.keyCode != '35' && ev.keyCode != '36' && ev.keyCode != '39')
      {
            for(i=0;i<document.getElementById(t).value.length;i++)
            {
                  if(document.getElementById(t).value.charAt(i) >= 0 && document.getElementById(t).value.charAt(i) <= 9 && document.getElementById(t).value.charAt(i) != ' ')
                        cos = cos + document.getElementById(t).value.charAt(i).toString();
            }
            document.getElementById(t).value = cos;
      }
}

function set_amount(id, kind)
{
      idek = document.getElementById(id);
      var val = parseInt(idek.value);
      if(val < 1 || !val) val = 1;
      if(kind == 0)//up
      {
            idek.value = val + 1;
      }
      else if(kind == 1)//down
      {
            if(val >= 2)
                  idek.value = val - 1;   
            else   
                  idek.value = 1;   
      }    
}

function change_photo_js(id, path, path_b, photo_b, id_b, w_b, h_b, e)
{
      idek = document.getElementById(id);
      
      idek.src = path;
      
      if(photo_b)
            idek.onclick = function() {show_photo('../pl/ajax_photo.php', 'path=' + path_b + '&photo=' + photo_b + '&id=' + id_b + '&table=photo', 'war_foto', e, w_b, h_b);};
      else
            idek.onclick = function() {};
            
      /*
      if(idek.addEventListener)
      {
            idek.setAttribute('onclick', '');
            //idek.removeEventListener();
            idek.addEventListener("click", function(e){show_photo('../pl/ajax_photo.php', 'path=' + path_b + '&photo=' + photo_b + '&id=' + id_b + '&table=photo', 'war_foto', e, w_b, h_b);}, false);
      }
      else
              idek.attachEvent("onclick", function(){show_photo('../pl/ajax_photo.php', 'path=' + path_b + '&photo=' + photo_b + '&id=' + id_b + '&table=photo', 'war_foto', e, w_b, h_b);});
      */
}

function change_new_hit(i)
{
      if(i == 0)
      {
            document.getElementById('product_new').style.background='url("images/main_content_left1.jpg") no-repeat 0 0';
            document.getElementById('product_hit').style.background='url("images/main_content_right2.jpg") no-repeat 0 0';
            
            document.getElementById('div_new').style.display='block';
            document.getElementById('div_hit').style.display='none';
      }
      else if(i == 1)
      {
            document.getElementById('product_new').style.background='url("images/main_content_left2.jpg") no-repeat 0 0';
            document.getElementById('product_hit').style.background='url("images/main_content_right1.jpg") no-repeat 0 0';
            
            document.getElementById('div_new').style.display='none';
            document.getElementById('div_hit').style.display='block';      
      }
      if(i == 2)
      {
            document.getElementById('product_buy').style.background='url("images/main_content_down_left1.jpg") no-repeat 0 0';
            document.getElementById('product_fly').style.background='url("images/main_content_down_right2.jpg") no-repeat 0 0';
            
            document.getElementById('div_buy').style.display='block';
            document.getElementById('div_fly').style.display='none';
      }
      else if(i == 3)
      {
            document.getElementById('product_buy').style.background='url("images/main_content_down_left2.jpg") no-repeat 0 0';
            document.getElementById('product_fly').style.background='url("images/main_content_down_right1.jpg") no-repeat 0 0';
            
            document.getElementById('div_buy').style.display='none';
            document.getElementById('div_fly').style.display='block';      
      }
}

function getBrowser(obj) 
{
      var b = new Array();
      b[0]="other";
      (isE(obj) ? browser=navigator.userAgent.toLowerCase() : browser=obj);
      
      if (browser.search(/msie\s(\d+(\.?\d)*)/) != -1) 
      {
            b[0]="msie";
      } 
      else
      {
            b[0]="other";
      }
      return b;
}

function isE(input) 
{
      return (input == null || input == "")
}

function check_comp(id, id2)
{       
      if(document.getElementById(id).value != document.getElementById(id2).value)
      {
            document.getElementById(id).style.backgroundColor = bckg_color;
            document.getElementById(id2).style.backgroundColor = bckg_color;
            alert('Hasła muszą być identyczne!');
            document.getElementById(id).focus();
            document.getElementById(id).select();
            return false;
      }
      else
      {
            document.getElementById(id).style.backgroundColor = bckg_color2;
            document.getElementById(id2).style.backgroundColor = bckg_color2;
            return true;
      }
}

function check_alfanum(id)
{
      if(!wzor_alfanum.test(document.getElementById(id).value) == true)
      {
            document.getElementById(id).style.backgroundColor = bckg_color;
            alert('Wypełnij poprawnie pole (5 - 16 znaków: litery (a-z), cyfry (0-9), ".", "-", "_") !');
            document.getElementById(id).focus();
            document.getElementById(id).select();
            return false;
      }
      else
      {
            document.getElementById(id).style.backgroundColor = bckg_color2;
            return true;
      }
}

function insert_tag(id, x, val)
{
      var txtar = document.getElementById(id);
      if(getBrowser()[0] == "msie")
      {
            var strSelection = document.selection.createRange().text;
            
            if(x == "<br/>")
            {
                  txtar.focus();
                  document.selection.createRange().text = strSelection + x;
                              
            }
            else if(x == "center" || x == "left" || x == "right" || x == "justify")
            {
                  if(strSelection == '')
                  {
                        do
                        {
                              var text = prompt('Podaj tekst linku:','');
                              if(text == null)
                              return;
                        }
                        while(!text);
                        txtar.focus();
                        document.selection.createRange().text = '<div style="text-align:' + x + ';">' + text + '</div>';
                  }
                  else
                  {
                        txtar.focus();
                        document.selection.createRange().text = '<div style="text-align:' + x + ';">' + strSelection + '</div>';
                  }
            }
            else if(x == "link")
            {
                  do
                  {
                        link = prompt('Podaj adres:','http://');
                        if(link == null)
                        return;
                  }
                  while(!link);
                  if(strSelection == '')
                  {
                        do
                        {
                              text = prompt('Podaj tekst linku:', link);
                              if(text == null)
                              return;
                        }
                        while(!text);
                        txtar.focus();
                        document.selection.createRange().text = '<a href="' + link + '" onclick="window.open(this.href,\'_blank\');return false;">' + text + '</a>';
                  }
                  else
                  {
                        txtar.focus();
                        document.selection.createRange().text = '<a href="' + link + '" onclick="window.open(this.href,\'_blank\');return false;">' + strSelection + '</a>';
                  }
            }
            else if(x == "mail")
            {
                  do
                  {
                        link = prompt('Podaj adres maila:','');
                        if(link == null)
                        return false;
                  }
                  while(!link);
                  if(strSelection == '')
                  {
                        do
                        {
                              text = prompt('Podaj tekst maila:',link);
                              if(text==null)
                              return;
                        }
                        while(!text);
                        txtar.focus();
                        document.selection.createRange().text = '<a href="mailto:' + link+'">' + text + '</a>';
                  }
                  else
                  {
                        txtar.focus();
                        document.selection.createRange().text = '<a href="mailto:'+link+'">' + strSelection + '</a>';
                  }
                  return;
            }            
            else if(x == "ul")
            {
                  if(strSelection == '')
                  {
                        do
                        {
                              text = prompt('Podaj tekst:','');
                              if(text == null)
                              return;
                        }
                        while(!text);
                        txtar.focus();
                        document.selection.createRange().text = '<ul class="ul_">\n' + text + '\n</' + x + '>';
                  }
                  else
                  {
                        txtar.focus();
                        document.selection.createRange().text = '<ul class="ul_">\n' + strSelection + '\n</'+ x +'>';
                  }
            }
            else if(x == "ol")
            {
                  if(strSelection == '')
                  {
                        do
                        {
                              text = prompt('Podaj tekst:','');
                              if(text == null)
                              return;
                        }
                        while(!text);
                        txtar.focus();
                        document.selection.createRange().text = '<' + x + '>\n' + text + '\n</' + x + '>';
                  }
                  else
                  {
                        txtar.focus();
                        document.selection.createRange().text = '<' + x + '>\n' + strSelection + '\n</' + x + '>';
                  }
            }
            else if(x == "photo")
            {
                  txtar.focus();
                  document.selection.createRange().text = strSelection + '<img src="' + val + '" alt=""/>';
            }
            else if(x == "file")
            {
                  if(strSelection == '')
                  {
                        do
                        {
                              text = prompt('Podaj nazwę pliku:','');
                              if(text == null)
                              return;
                        }
                        while(!text);
                        txtar.focus();
                        document.selection.createRange().text = '<a href="' + val + '"  onclick="window.open(this.href,\'_blank\');return false;">' +  text + '</a>';
                  }
                  else
                  {
                        txtar.focus();
                        document.selection.createRange().text = '<a href="' + val + '"  onclick="window.open(this.href,\'_blank\');return false;">' +  strSelection + '</a>';
                  }
            }
            else
            {
                  if(strSelection == '')
                  {
                        do
                        {
                              text = prompt('Podaj tekst:','');
                              if(text == null)
                              return;
                        }
                        while(!text);
                        txtar.focus();
                        document.selection.createRange().text = '<' + x + '>' + text + '</' + x + '>';
                  }
                  else
                  {
                        txtar.focus();
                        document.selection.createRange().text = '<' + x + '>' + strSelection + '</' + x + '>';
                  }
            }
      }
      else
      {
            var end = txtar.value.length;
            var selS = txtar.selectionStart;
            var selE = txtar.selectionEnd;
            var strSelection = txtar.value.substring(selS, selE);          
            var scrolling = txtar.scrollTop;
            
            if(x == "<br/>")
            {
                  txtar.value = txtar.value.substring(0,selS) + strSelection + x + txtar.value.substring(selE,end);
                  txtar.focus();
                  txtar.setSelectionRange(selE + x.length, selE + x.length);
                  txtar.scrollTop = scrolling;
            }
            else if(x == "center" || x == "left" || x == "right" || x == "justify")
            {
                  if(strSelection=='')
                  {
                        do
                        {
                              text=prompt('Podaj tekst linku:','');
                              if(text==null)
                              return;
                        }
                        while(!text);
                        var str_to_scroll = '<div style="text-align:' + x + ';">' + text + '</div>';
                        txtar.value = txtar.value.substring(0,selS) + str_to_scroll + txtar.value.substring(selE,end);
                  }
                  else
                  {
                        var str_to_scroll = '<div style="text-align:' + x + ';">'+strSelection+'</div>';
                        txtar.value = txtar.value.substring(0,selS) + str_to_scroll + txtar.value.substring(selE,end);
                  }
                  txtar.focus();
                  txtar.setSelectionRange(selS + str_to_scroll.length, selS + str_to_scroll.length);
                  txtar.scrollTop = scrolling;
            }
            else if(x == "link")
            {
                  do
                  {
                        link = prompt('Podaj adres:','http://');
                        if(link == null)
                        return;
                  }
                  while(!link);
                  if(strSelection == '')
                  {
                        do
                        {
                              text = prompt('Podaj tekst linku:',link);
                              if(text == null)
                              return;
                        }
                        while(!text);
                        var str_to_scroll = '<a href="' + link + '" onclick="window.open(this.href,\'_blank\');return false;">' + text + '</a>';
                        txtar.value = txtar.value.substring(0,selS) + str_to_scroll + txtar.value.substring(selE,end);
                  }
                  else
                  {
                        var str_to_scroll = '<a href="'+link+'" onclick="window.open(this.href,\'_blank\');return false;">'+ strSelection + '</a>';
                        txtar.value = txtar.value.substring(0,selS) + str_to_scroll + txtar.value.substring(selE,end);
                  }
                  txtar.focus();
                  txtar.setSelectionRange(selS + str_to_scroll.length, selS + str_to_scroll.length);
                  txtar.scrollTop = scrolling;
            }
            
            else if(x == "mail")
            {
                  do
                  {
                        link = prompt('Podaj adres maila:','');
                        if(link == null)
                        return false;
                  }
                  while(!link);
                  if(strSelection == '')
                  {
                        do
                        {
                              text = prompt('Podaj tekst maila:',link);
                              if(text == null)
                              return;
                        }
                        while(!text);
                        var str_to_scroll = '<a href="mailto:' + link + '">' + text + '</a>';
                        txtar.value = txtar.value.substring(0,selS) + str_to_scroll + txtar.value.substring(selE,end);
                  }
                  else
                  {
                        var str_to_scroll = '<a href="mailto:' + link+'">'+strSelection + '</a>';
                        txtar.value = txtar.value.substring(0,selS) + str_to_scroll + txtar.value.substring(selE,end);
                  }
                  txtar.focus();
                  txtar.setSelectionRange(selS + str_to_scroll.length, selS + str_to_scroll.length);
                  txtar.scrollTop = scrolling;
            }
            else if(x == "ul")
            {
                  if(strSelection == '')
                  {
                        do
                        {
                              text = prompt('Podaj tekst:','');
                              if(text == null)
                              return;
                        }
                        while(!text);
                        var str_to_scroll = '<ul class="ul_">\n' + text + '\n</' + x + '>';
                        txtar.value = txtar.value.substring(0,selS) + str_to_scroll + txtar.value.substring(selE,end);
                  }
                  else
                  {
                        var str_to_scroll = '<ul class="ul_">\n' + strSelection+'\n</' + x + '>';
                        txtar.value = txtar.value.substring(0,selS) + str_to_scroll + txtar.value.substring(selE,end);
                  }
                  txtar.focus();
                  txtar.setSelectionRange(selS + str_to_scroll.length, selS + str_to_scroll.length);
                  txtar.scrollTop = scrolling;
            }
            else if(x == "ol")
            {
                  if(strSelection == '')
                  {
                        do
                        {
                              text = prompt('Podaj tekst:','');
                              if(text == null)
                              return;
                        }
                        while(!text);
                        var str_to_scroll = '<' + x + '>\n' + text + '\n</' + x + '>';
                        txtar.value = txtar.value.substring(0,selS) + str_to_scroll + txtar.value.substring(selE,end);
                  }
                  else
                  {
                        var str_to_scroll = '<' + x + '>\n' + strSelection + '\n</' + x + '>';
                        txtar.value = txtar.value.substring(0,selS) + str_to_scroll + txtar.value.substring(selE,end);
                  }
                  txtar.focus();
                  txtar.setSelectionRange(selS + str_to_scroll.length, selS + str_to_scroll.length);
                  txtar.scrollTop = scrolling;
            }
            else if(x == "photo")
            {
                  var str_to_scroll = '<img src="' + val  + '" alt=""/>';
                  txtar.value = txtar.value.substring(0,selS) + str_to_scroll + txtar.value.substring(selE,end);

                  txtar.focus();
                  txtar.setSelectionRange(selS + str_to_scroll.length, selS + str_to_scroll.length);
                  txtar.scrollTop = scrolling;
            }
            else if(x == "file")
            {
                  if(strSelection == '')
                  {
                        do
                        {
                              text = prompt('Podaj nazwę pliku:','');
                              if(text == null)
                              return;
                        }
                        while(!text);
                        var str_to_scroll = '<a href="' + val + '"  onclick="window.open(this.href,\'_blank\');return false;">' + text + '</a>';
                        txtar.value = txtar.value.substring(0,selS) + str_to_scroll + txtar.value.substring(selE,end);
                  }
                  else
                  {
                        var str_to_scroll = '<a href="' + val + '"  onclick="window.open(this.href,\'_blank\');return false;">' + strSelection + '</a>';
                        txtar.value=txtar.value.substring(0,selS) + str_to_scroll + txtar.value.substring(selE,end);
                  }
                  txtar.focus();
                  txtar.setSelectionRange(selS + str_to_scroll.length, selS + str_to_scroll.length);
                  txtar.scrollTop = scrolling;
            }
            else
            {
                  if(strSelection == '')
                  {
                        do
                        {
                              text = prompt('Podaj tekst:','');
                              if(text == null)
                              return;
                        }
                        while(!text);
                        var str_to_scroll = '<' + x + '>' + text + '</' + x + '>';
                        txtar.value = txtar.value.substring(0,selS) + str_to_scroll + txtar.value.substring(selE,end);
                  }
                  else
                  {
                        var str_to_scroll = '<' + x + '>' + strSelection + '</' + x + '>';
                        txtar.value = txtar.value.substring(0,selS) + str_to_scroll + txtar.value.substring(selE,end);
                  }
                  txtar.focus();
                  txtar.setSelectionRange(selS + str_to_scroll.length, selS + str_to_scroll.length);
                  txtar.scrollTop = scrolling;
            }
      }     
}
function check_form_no_bckg()
{
      for(i=0;i<check_form_no_bckg.arguments.length-1;i++)
      {
            var formik = document.getElementById(arguments[check_form_no_bckg.arguments.length-1]);
            
            if(formik[arguments[i]])
            {
                  if(formik[arguments[i]].type == 'text' || formik[arguments[i]].type == 'password')
                  {
                        if(formik[arguments[i]].value == '')
                        {
                              if(formik[arguments[i]].type == 'file')
                                    alert('Wybierz plik !!!');
                              else
                                    alert('Wypełnij podane pole !!!');
                              formik[arguments[i]].focus();
                              return false;
                        }
                  }
            }
      }
      return true;
}

/* 
//oldd
function check_form()
{
      for(i=0;i<check_form.arguments.length-1;i++)
      {
            var formik = document.getElementById(arguments[check_form.arguments.length-1]);
            
            if(formik[arguments[i]])
            {
                  if(formik[arguments[i]].type == 'file' || formik[arguments[i]].type == 'text' || formik[arguments[i]].type == 'password' || formik[arguments[i]].type == 'textarea')
                  {
                        if(formik[arguments[i]].value == '')
                        {
                              formik[arguments[i]].style.borderColor = bckg_color;
                              if(formik[arguments[i]].type == 'file')
                                    alert('Wybierz plik !!!');
                              else
                                    alert('Wypełnij podane pole !!!');
                              formik[arguments[i]].focus();
                              return false;
                        }
                        else
                              formik[arguments[i]].style.borderColor = bckg_color2;
                  }
                  else if(formik[arguments[i]].type == 'select-one')
                  {
                        if(formik[arguments[i]].value == '-1')
                        {
                              formik[arguments[i]].style.borderColor = bckg_color;
                              alert('Wypełnij podane pole !!!');
                              formik[arguments[i]].focus();
                              return false;
                        }
                        else
                              formik[arguments[i]].style.borderColor = bckg_color2;
                  }
                  else if(formik[arguments[i]].type == 'select-multiple')
                  {
                        if(formik[arguments[i]].value == '')
                        {
                              formik[arguments[i]].style.borderColor = bckg_color;
                              alert('Wypełnij podane pole !!!');
                              formik[arguments[i]].focus();
                              return false;
                        }
                        else
                              formik[arguments[i]].style.borderColor = bckg_color2;
                  }
                  else if(formik[arguments[i]].type == 'checkbox')
                  {
                        if(formik[arguments[i]].checked == false)
                        {
                              formik[arguments[i]].style.borderColor = bckg_color;
                              alert('Wypełnij podane pole !!!');
                              formik[arguments[i]].focus();
                              return false;
                        }
                        else
                              formik[arguments[i]].style.borderColor = bckg_color2;
                  }
                  else if(formik[arguments[i]].type == 'radio')
                  {
                        var good = 0;
                        
                        for(ii=0;ii<formik[arguments[i]].length;ii++)
                        {
                              if(formik[arguments[i]][ii].checked == true)
                                    good = 1;
                        }
                        
                        if(good == 0)
                        {
                              formik[arguments[i]].style.borderColor = bckg_color;
                              alert('Wypełnij podane pole !!!');
                              formik[arguments[i]][0].focus();
                              return false;
                        }
                        else
                              formik[arguments[i]].style.borderColor = bckg_color2;
                  }
            }
      }
      return true;
}
*/

function check_form()
{
      var error = 0;
      var focus = 0;
      for(i=0;i<check_form.arguments.length-1;i++)
      {
            var formik = document.getElementById(arguments[check_form.arguments.length-1]);
            
            if(formik[arguments[i]])
            {
                  if(formik[arguments[i]].type == 'file' || formik[arguments[i]].type == 'text' || formik[arguments[i]].type == 'password' || formik[arguments[i]].type == 'textarea')
                  {
                        if(formik[arguments[i]].value == '')
                        {
                              //formik[arguments[i]].style.backgroundColor = bckg_color;
                              formik[arguments[i]].style.borderColor = bckg_color;
                              /*
                              if(formik[arguments[i]].type == 'file')
                                    alert('Wybierz plik !!!');
                              else
                                    alert('Wypełnij podane pole !!!');
                              */
                              if(focus == 0)
                              {
                                    formik[arguments[i]].focus();
                                    focus++;                                    
                              }
                              //return false;
                              error++;                              
                        }
                        else
                        {
                              //formik[arguments[i]].style.backgroundColor = bckg_color2;
                              formik[arguments[i]].style.borderColor = bckg_color2;
                        }
                  }
                  else if(formik[arguments[i]].type == 'select-one')
                  {
                        if(formik[arguments[i]].value == '-1')
                        {
                              //formik[arguments[i]].style.backgroundColor = bckg_color;
                              formik[arguments[i]].style.borderColor = bckg_color;
                              //alert('Wypełnij podane pole !!!');
                              if(focus == 0)
                              {
                                    formik[arguments[i]].focus();
                                    focus++;                                    
                              }
                              //return false;
                              error++;                              
                        }
                        else
                        {
                              //formik[arguments[i]].style.backgroundColor = bckg_color2;
                              formik[arguments[i]].style.borderColor = bckg_color2;
                        }
                  }
                  else if(formik[arguments[i]].type == 'select-multiple')
                  {
                        if(formik[arguments[i]].value == '')
                        {
                              //formik[arguments[i]].style.backgroundColor = bckg_color;
                              formik[arguments[i]].style.borderColor = bckg_color;
                              //alert('Wypełnij podane pole !!!');
                              if(focus == 0)
                              {
                                    formik[arguments[i]].focus();
                                    focus++;                                    
                              }
                              //return false;
                              error++;                              
                        }
                        else
                        {
                              //formik[arguments[i]].style.backgroundColor = bckg_color2;
                              formik[arguments[i]].style.borderColor = bckg_color2;
                        }
                  }
                  else if(formik[arguments[i]].type == 'checkbox')
                  {
                        if(formik[arguments[i]].checked == false)
                        {
                              //formik[arguments[i]].style.backgroundColor = bckg_color;
                              formik[arguments[i]].style.borderColor = bckg_color;
                              //alert('Wypełnij podane pole !!!');
                              if(focus == 0)
                              {
                                    formik[arguments[i]].focus();
                                    focus++;                                    
                              }
                              //return false;
                              error++;                              
                        }
                        else
                        {
                              //formik[arguments[i]].style.backgroundColor = bckg_color2;
                              formik[arguments[i]].style.borderColor = bckg_color2;
                        }
                  }
                  else if(formik[arguments[i]].type == 'radio')
                  {
                        var good = 0;
                        
                        for(ii=0;ii<formik[arguments[i]].length;ii++)
                        {
                              if(formik[arguments[i]][ii].checked == true)
                                    good = 1;
                        }
                        
                        if(good == 0)
                        {
                              //formik[arguments[i]][0].style.backgroundColor=bckg_color;
                              formik[arguments[i]][0].style.borderColor = bckg_color;
                              //alert('Wypełnij podane pole !!!');
                              if(focus == 0)
                              {
                                    formik[arguments[i]][0].focus();
                                    focus++;                                    
                              }
                              //return false;
                              error++;                              
                        }
                        else
                        {
                              //formik[arguments[i]][0].style.backgroundColor = bckg_color2;
                              formik[arguments[i]][0].style.borderColor = bckg_color2;
                        }
                  }
            }
      }
      if(error > 0)
      {
            alert('Wypełnij wymagane pola !');
            return false;
      }
      else
            return true;
}

function check_link()
{
      if(check_form('link_type','form'))
      {
            if(document.getElementById('link_type').value == 2)
            {
                  if(file_ext('link_inp[2]','all'))
                        if(check_form('link_inp[' + document.getElementById('link_type').value + ']','form'))
                              document.getElementById('form').submit();
            }
            else
            {
                  if(check_form('link_inp[' + document.getElementById('link_type').value + ']','form'))
                        document.getElementById('form').submit();
            }    
      }
}

function text_display(war, input, width)
{
      var text = document.getElementById(input);
      if(text.value)
      {
            //ts=text.value.replace('<a','<a target="_blank"');
            //ts=text.value.replace(/src=\"img/gi,"src=\"../img");                
            document.getElementById(war).innerHTML = '<div style="background:#F7FBFD;border:solid #53A0DF 1px;width:' + width + 'px;text-align:left;"><div onselectstart="return false;" onmousedown="setMovingLayer(\'' + war + '\', event);" style="cursor:move;text-align:right;background:#eee;padding:1px 1px 0 0;"><a href="javascript:void(0);" onClick="hide_menu(\'' + war + '\');"><img src="img/menu_close.gif" alt=""/></a></div><div style="padding:5px;">' + text.value + '</div></div>';
            if(getBrowser()[0] == "msie")
            {
                  //document.body.scrollTop 
                  document.getElementById(war).style.top = document.documentElement.scrollTop + 10;
                  document.getElementById(war).style.left = 10;
                  document.getElementById(war).style.visibility = "visible";
            }
            else
            {
                  document.getElementById(war).style.top = document.documentElement.scrollTop + 10 + "px";
                  document.getElementById(war).style.left = 10 + "px";
                  document.getElementById(war).style.visibility = "visible";
            }
      }
      else
      {
            alert("Proszę wypełnić wskazane pole !");
            text.focus();
      }

}

function photo_display(war, img)
{
      document.getElementById(war).innerHTML = '<img src="' + img + '" style="border:solid #333 1px;cursor:pointer;" onclick="hide_menu(\'' + war + '\');" alt=""/>';
      if(getBrowser()[0] == "msie")
      {
            //document.body.scrollTop 
            document.getElementById(war).style.top = document.documentElement.scrollTop + 10 + "px";
            document.getElementById(war).style.left = 10;
            document.getElementById(war).style.visibility = "visible";
      }
      else
      {
            document.getElementById(war).style.top = document.documentElement.scrollTop + 10 + "px";
            document.getElementById(war).style.left = 10 + "px";
            document.getElementById(war).style.visibility = "visible";
      }
}

function swf_display(w, h, file, war)
{
        var obj = '<object width="' + w + '" height="' + h + '" id="mymovie" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0">' +
        '<param name="movie" value="' + file + '" />' +
        '<param name="quality" value="best" />' +
        '<param name="wmode" value="transparent" />' +
        '<param name="bgcolor" value="#ffffff" />' +
        '<embed src="' + file + '" quality="best" wmode="transparent" bgcolor="#ffffff" width="' + w + '" height="' + h + '" name="mymovie" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>' +
        '</object>';
        
      document.getElementById(war).innerHTML = obj;
      if(getBrowser()[0] == "msie")
      {
            //document.body.scrollTop 
            document.getElementById(war).style.top = document.documentElement.scrollTop + 10 + "px";
            document.getElementById(war).style.left = 10;
            document.getElementById(war).style.visibility = "visible";
      }
      else
      {
            document.getElementById(war).style.top = document.documentElement.scrollTop + 10 + "px";
            document.getElementById(war).style.left = 10 + "px";
            document.getElementById(war).style.visibility = "visible";
      }
}

function set_near_position(id, e)
{
      document.getElementById(id).style.visibility='visible';
      if(getBrowser()[0] == "msie")
      {
            document.getElementById(id).style.pixelTop=document.documentElement.scrollTop + e.clientY - 100;
            document.getElementById(id).style.pixelLeft=document.documentElement.scrollLeft + e.clientX + 10;
      }
      else
      {
            document.getElementById(id).style.top=e.pageY - 100 + "px";
            document.getElementById(id).style.left=e.pageX + 10 + "px";
      }
}

var movingLayer = "";

function setMovingLayer(n,e)
{
        movingLayer=n;
        if (n == "") return true;
        if(getBrowser()[0] == "msie")
        {
                lastX=event.clientX;
                lastY=event.clientY;
        }
        else
        {
                lastX=e.pageX;
                lastY=e.pageY;
        }
        var l = getLayerStyle(n);
        lastLayerX=parseInt(l.left);
        lastLayerY=parseInt(l.top);
        if (lastMovingLayer!="" && lastMovingLayer!=movingLayer)
        {
                var lastLayerStyle=getLayerStyle(lastMovingLayer);
                var tempZIndex=l.zIndex;
                l.zIndex=lastLayerStyle.zIndex;
                lastLayerStyle.zIndex=tempZIndex;
        }
}

function clearMovingLayer()
{
        lastMovingLayer=movingLayer;
        movingLayer="";
}

function mouseMoving(e) 
{
      if (movingLayer=="") return;
      var xpos=(getBrowser()[0] != "msie")?e.pageX:event.clientX;
      var ypos=(getBrowser()[0] != "msie")?e.pageY:event.clientY;
      var l=getLayerStyle(movingLayer);
      l.left=lastLayerX+xpos-lastX + "px";
      subMenuLeft=lastLayerX+xpos-lastX-document.body.scrollLeft;
      l.top=lastLayerY+ypos-lastY + "px";
      subMenuTop=lastLayerY+ypos-lastY-document.body.scrollTop;
}

function getLayerStyle(layerName)
{
      var layerStyle;
      layerStyle = document.getElementById(layerName).style;
      return layerStyle;
}

function array_key_exist(str, tab)
{
      for (var x in tab)
      {
            if(x == str)
                  return true;
      }
      return false;
}

function array_in(str, tab)
{
      for (var y in tab)
      {
            if(tab[y].toLowerCase() == str)
            return true;
      }
      return false;
}

function file_ext(file, type)
{   
      var f = document.getElementById(file).value;
      if(f != "")
      {
            var zm = f.substring(f.lastIndexOf('.',f.length) + 1,f.length).toLowerCase();
            for(i=1;i<file_ext.arguments.length;i++)
            {
                  if(array_key_exist(arguments[i], tab_f))
                  {
                        if(array_in(zm, tab_f[arguments[i]][0]))
                              return true;
                  }
                  else if(arguments[i] == 'all')
                  {
                        for (var ii in tab_f)
                        {
                              if(array_in(zm, tab_f[ii][0]))
                              return true;
                        }
                  }
            }
            
            document.getElementById(file).focus();
            document.getElementById(file).select();
            alert('Niepoprawny format pliku !');
            return false;
      }
      else 
            return true;
}

function foto_mini_start()
{
      document.getElementById('foto_mini').disabled=true;
      document.getElementById('position').disabled=true;
      document.getElementById('photo_b').onchange = new Function("disable_foto_mini();");
      document.getElementById('photo_b').onblur = new Function("disable_foto_mini();");
}

function disable_foto_mini()
{
         if(document.getElementById('photo_b').value != '')
         {
                  document.getElementById('foto_mini').disabled=false;
                  document.getElementById('position').disabled=false;
         }   
         else
         {
                  document.getElementById('foto_mini').disabled=true;
                  document.getElementById('position').disabled=true;
         }
}

function check_foto()
{
         if(file_ext('photo_m','img') && file_ext('photo_b','img'))
         {
                  if(document.getElementById('photo_m').value == "" && document.getElementById('foto_mini').checked == false)
                  {
                           document.getElementById('form')['photo_m'].style.backgroundColor = bckg_color;
                           if(document.getElementById('foto_mini').disabled == false)
                                    document.getElementById('form')['foto_mini'].style.backgroundColor = bckg_color;
                           alert('Wypełnij podane pole !!!');
                           document.getElementById('form')['photo_m'].focus();
                           return false;
                  }
                  else
                  {
                           document.getElementById('form')['photo_m'].style.backgroundColor = bckg_color2;
                           document.getElementById('form')['foto_mini'].style.backgroundColor = bckg_color;
                  }
                  
                  if(check_form('ord','form'))
                        document.getElementById('form').submit();
         }
}

function check_user()
{
      if(check_form('name','login','pass','id_guru','form'))
      {
            
            if(check_alfanum('login'))
                  if(check_alfanum('pass'))
                  {      
                        if(document.getElementById('id_guru').value != 1)
                        {
                              if(check_form('access_type','form'))
                              {
                                    if(document.getElementById('access_type').value == 1)
                                    {
                                          if(check_form('access_inp[1][]','form'))
                                                document.getElementById('form').submit();
                                    }
                                    else if(document.getElementById('access_type').value == 2)
                                    {
                                          if(document.getElementById('access_inp[2][]').length < 1)
                                          {
                                                document.getElementById('access_inp[2][]').style.backgroundColor = bckg_color;
                                                alert('Wypełnij podane pole !!!');
                                                document.getElementById('access_inp[2][]').focus();
                                          }
                                          else
                                          {
                                                for(i=0; i < document.getElementById('access_inp[2][]').length; i++)//zaznaczmy wszystkie wybrane strony
                                                      document.getElementById('access_inp[2][]').options[i].selected = true;
                                                document.getElementById('form').submit();
                                          
                                          }
                                    }                 
                              }
                        }
                        else if(document.getElementById('id_guru').value == 1)
                        {
                              document.getElementById('form').submit();
                        }
                  }
      }
}

function check_banner(id)
{
      if(document.getElementById('type').value == 0)//img
      {
            if(file_ext('path','img'))
            {
                  if(document.getElementById('link_kind').value == 1)// link zew.
                  {
                        if(!check_form('link_inp[1]','form'))
                              return false;
                  }
                  else if(document.getElementById('link_kind').value == 3)// strona w serwise
                  {
                        if(!check_form('link_inp[3]','form'))
                              return false;                 
                  }
                  
                  if(document.getElementById('banner_lang2').value != -1)
                  {
                        if(!check_form('banner_site2','form'))
                              return false;                 
                  }
                  
                  if(id == "-1")//nowy rekord
                  {
                        if(check_form('path','id_category','ord','form'))
                              document.getElementById('form').submit();
                  }
                  else//edycja
                  {
                        if(document.getElementById('type').value == id)//apropos zmian img => swf
                        {
                              if(check_form('id_category','ord','form'))
                                    document.getElementById('form').submit();    
                        } 
                        else
                        {
                              if(check_form('path','id_category','ord','form'))
                                    document.getElementById('form').submit();                            
                        }             
                  }
            }
      }
      else//flash
      {
            if(file_ext('path','flash'))
            {
                  if(document.getElementById('banner_lang2').value != -1)
                  {
                        if(!check_form('banner_site2','form'))
                              return false;                 
                  }
                  
                  if(id == "-1")//nowy rekord
                  {
                        if(check_form('path','id_category','ord','form'))
                              document.getElementById('form').submit();
                  }
                  else//edycja
                  {
                        if(document.getElementById('type').value == id)//apropos zmian img => swf
                        {
                              if(check_form('id_category','ord','form'))
                                    document.getElementById('form').submit();    
                        } 
                        else
                        {
                              if(check_form('path','id_category','ord','form'))
                                    document.getElementById('form').submit();                            
                        }             
                  }
            }     
      }
}

function check_div(id)
{
      if(document.getElementById('type').value == 0)//img
      {
            if(file_ext('path','img'))
            {
                  if(document.getElementById('link_kind').value == 1)// link zew.
                  {
                        if(!check_form('link_inp[1]','form'))
                              return false;
                  }
                  else if(document.getElementById('link_kind').value == 3)// strona w serwise
                  {
                        if(!check_form('link_inp[3]','form'))
                              return false;                 
                  }
                  
                  if(document.getElementById('banner_lang2').value != -1)
                  {
                        if(!check_form('banner_site2','form'))
                              return false;                 
                  }
                  
                  if(id == "-1")//nowy rekord
                  {
                        if(check_form('path','date_from','close_type','close_map','form'))
                              document.getElementById('form').submit();
                  }
                  else//edycja
                  {
                        if(document.getElementById('type').value == id)//apropos zmian img => swf
                        {
                              if(check_form('date_from','close_type','close_map','form'))
                                    document.getElementById('form').submit();    
                        } 
                        else
                        {
                              if(check_form('path','date_from','close_type','close_map','form'))
                                    document.getElementById('form').submit();                            
                        }             
                  }
            }
      }
      else//flash
      {
            if(file_ext('path','flash'))
            {
                  if(document.getElementById('banner_lang2').value != -1)
                  {
                        if(!check_form('banner_site2','form'))
                              return false;                 
                  }
                  
                  if(id == "-1")//nowy rekord
                  {
                        if(check_form('path','w','h','date_from','form'))
                              document.getElementById('form').submit();
                  }
                  else//edycja
                  {
                        if(document.getElementById('type').value == id)//apropos zmian img => swf
                        {
                              if(check_form('w','h','date_from','form'))
                                    document.getElementById('form').submit();    
                        } 
                        else
                        {
                              if(check_form('path','w','h','date_from','form'))
                                    document.getElementById('form').submit();                            
                        }             
                  }
            }     
      }
}

function set_date(znak, t)
{
      if(t.value != '')
      {
            tab_t = t.value.split('-');
            if(znak == "plus")
                  tab_t[2] = parseFloat(tab_t[2])+1;
            else if(znak == "minus")
                  tab_t[2] = parseFloat(tab_t[2])-1;
            tab_t[1] = parseFloat(tab_t[1])-1;
            
            data = new Date(tab_t[0],tab_t[1],tab_t[2]);
            var ile = data.getTime();
            data = new Date(ile);
      }
      else
      {
            data = new Date();
            data.setDate(parseFloat(data.getDate()));
      }
      var dzien = data.getDate().toString();
      if(dzien.length == "1")
            dzien = "0" + dzien;
      var mies = parseFloat(data.getMonth())+1;
      mies = mies.toString();
      if(mies.length == "1")
            mies = "0" + mies;
      
      if(wzor.test(data.getFullYear() + "-" + mies + "-" + dzien) == true)
            t.value = data.getFullYear() + "-" + mies + "-" + dzien;
      else
      {
            alert('Błąd !!! Wypełnij poprawnie podane pole.');
            t.value = '';
            t.focus();
      }

}

function go(id,val)
{
      p = document.getElementById('access_inp[2][]');
      var goo = 0;
      for(i=0; i < p.length; i++)
      {
            if(p.options[i].value == id)
            {
                  goo = 1;
                  break;
            }
      }
      if(goo == 0)
      {
            nex=p.length;
            p.length++;
            p.options[nex].text = val;
            p.options[nex].value = id;
      }
}
function go_back(id,val)
{
      p = document.getElementById('access_inp[2][]');
      for(i=0; i < p.length; i++)
      {
            if(p.options[i].value == id)
            {
                  p.options[i] = null;
            }
      }
}

function swf_write(w, h, file)
{
        var obj = '<object width="' + w + '" height="' + h + '" id="mymovie" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0">' +
        '<param name="movie" value="' + file + '" />' +
        '<param name="quality" value="best" />' +
        '<param name="wmode" value="transparent" />' +
        '<param name="bgcolor" value="#ffffff" />' +
        '<embed src="' + file + '" quality="best" wmode="transparent" bgcolor="#ffffff" width="' + w + '" height="' + h + '" name="mymovie" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>' +
        '</object>';
        document.write(obj);
}

function close_war(e)
{
      if(e.keyCode == '27' && document.getElementById('war_foto').style.visibility=='visible')
      {
            if(document.getElementById('warstwa_gray'))
                  document.getElementById('warstwa_gray').style.visibility="hidden";
            document.getElementById('war_foto').style.visibility='hidden';
      }
}

function pos_center(w, h, name)
{
      if(getBrowser()[0] == "msie")
      {
            document.getElementById(element).style.top=document.documentElement.scrollTop + document.documentElement.clientHeight/2 - h/2;
            document.getElementById(element).style.left=document.documentElement.scrollLeft + document.documentElement.clientWidth/2 - w/2;                  
      }
      else
      {
            document.getElementById(element).style.top=document.documentElement.scrollTop + document.documentElement.clientHeight/2 - h/2 + "px";
            document.getElementById(element).style.left=document.documentElement.scrollLeft + document.documentElement.clientWidth/2 - w/2 + "px";
      }
}

























function dodaj_do_ulub(tytul,url)
{
         if (window.sidebar)
                  return window.sidebar.addPanel(tytul, url, "");
         else if( window.external )
                        return window.external.AddFavorite(url, tytul);
         else if(window.opera && window.print)
         {
                  var op_add = document.createElement('a');
                  op_add.setAttribute('rel','sidebar');
                  op_add.setAttribute('href',url);
                  op_add.setAttribute('title',tytul);
                  op_add.click();
         }
}
function find_option(id_m, text_m)
{
         for(var i=0;i<document.getElementById(id_m).length;i++)
         {
                  var temp_txt = document.getElementById(id_m).options(i).text.toLowerCase();
                  text_m = text_m.toLowerCase();
                  if(temp_txt.indexOf(text_m) == 0)
                  {
                         document.getElementById(id_m).options(i).selected='true';
                         break;
                  }
         }
}

function in_array(tab, val)
{
     for(g=0;g<tab.length;g++)
     {
         if(tab[g] == val) return true;
     }
     return false;
}

function in_array_key(tab, val)
{
      for (i in tab)
      {
         if (i == val)
         {
            return true;
         }
      }
     return false;
}


function check_mail(id)
{
     if(document.getElementById(id).value != "")
     {
         if(!wzor_mail.test(document.getElementById(id).value) == true)
         {
             document.getElementById(id).style.borderColor = bckg_color;
             alert('Wypełnij poprawnie pole!');
             document.getElementById(id).select();
             return false;
         }
     }
     document.getElementById(id).style.borderColor = bckg_color2;
     return true;
}
