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 = '#fff';
var bckg_color2 = '#fff';
var brd_color = '#DD5D13';
var brd_color2 = '#dcdcdc';

///baner glowny
var cp_procent = 1;
      var cp_step_procent = 0.025;
if(getBrowser()[0] == "msie")
      var cp_timeout = 55;
else
      var cp_timeout = 35;
var cp_timeout2 = 3000;
var next = 1;

function change_photo_time()
{
      setTimeout(change_photo(),3000);
}

function change_photo()
{
      if(cp_procent == 1)
      {
            document.getElementById('banner_main').style.backgroundPosition = '0px 0px';
      }
      
      if(cp_procent > 0)
      {
            cp_procent -= cp_step_procent;      
            document.getElementById('banner_main_img').style.opacity = cp_procent;
            document.getElementById('banner_main_img').style.filter = "alpha(opacity="+(cp_procent*100)+")";
            timer_run = setTimeout(function(){change_photo();},cp_timeout);
      }
      else
      {
            document.getElementById('banner_main_img').src = tab_img[next];
            document.getElementById('banner_main').style.background = "url('" + tab_img[next + 1] + "')";
            document.getElementById('banner_main_url').href = tab_url[next];
            
            if(++next == max_photo)
                  next = 0;
            cp_procent = 1;
            clearTimeout(timer_run);
            document.getElementById('banner_main_img').style.opacity = 1;
            document.getElementById('banner_main_img').style.filter = "alpha(opacity=100)";    
                                   
            timer_run2 = setTimeout(function(){change_photo();},cp_timeout2);
      }
}

/*
var cp_timeout2 = 3000;
function rotate_photo(img1, img2)
{
      setTimeout(function(){rotate_photo(img1, img2);},cp_timeout2);
}
*/

function calc_yes()
{
      var ile = 0;
      var ile_no = 0;
      for(i=1;i<tab_ans.length;i++)
      {
            if(document.getElementById('yes' + i).style.backgroundPosition == '0px -50px')
            {
                  ile++;
            }
                  
            if(document.getElementById('no' + i).style.backgroundPosition == '0px -50px')
            {
                  ile_no++;
            }                  
      }

      for(i=1;i<=ile;i++)
      {
            document.getElementById('ans' + i).className='answer_yes';
      }
      
      for(i>ile;i<tab_ans.length;i++)
      {
            document.getElementById('ans' + i).className='';
      }
      
      if(ile + ile_no == (tab_ans.length-1))//wyswietlamy text tylko po kliknieciu all
            document.getElementById('answer_text').innerHTML = tab_ans[ile];
}

function click_yes(id)
{
      var idek_yes = document.getElementById('yes' + id);
      var idek_no = document.getElementById('no' + id);
      idek_yes.style.backgroundPosition = '0px -50px';
      idek_no.style.backgroundPosition = '0px 0px';
      
      calc_yes();
}

function click_no(id)
{
      var l = tab_ans.length;
      var idek_yes = document.getElementById('yes' + id);
      var idek_no = document.getElementById('no' + id);
      idek_yes.style.backgroundPosition = ' 0px 0px';
      idek_no.style.backgroundPosition = ' 0px -50px';
      
      calc_yes();
}

function main_calendar_change(val, sign)
{
      var sel = document.getElementById(val);
      if(sign == 0)//poprzedni
      {
            if(sel.selectedIndex < (sel.length-1))
            {
                  sel.selectedIndex += 1;
                  sel.options[sel.selectedIndex].selected=true;
            }
            else 
                  return false;
      }
      else if(sign == 1)//nastepny
      {
            if(sel.selectedIndex > 0)
            {
                  sel.selectedIndex -= 1;
                  sel.options[sel.selectedIndex].selected=true;
            }
            else 
                  return false;
      }
      return true;
}


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


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(id).style.borderColor = brd_color;
            document.getElementById(id2).style.backgroundColor = bckg_color;
            document.getElementById(id2).style.borderColor = brd_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(id).style.borderColor = brd_color2;
            document.getElementById(id2).style.backgroundColor = bckg_color2;
            document.getElementById(id2).style.borderColor = brd_color2;
            return true;
      }
}

function check_alfanum(id)
{
      if(!wzor_alfanum.test(document.getElementById(id).value) == true)
      {
            document.getElementById(id).style.backgroundColor = bckg_color;
            document.getElementById(id).style.borderColor = brd_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;
            document.getElementById(id).style.borderColor = brd_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 == "video")
            {
                  txtar.focus();
                  document.selection.createRange().text = strSelection + '<script type="text/javascript">swf_write(\'640\', \'480\', \'../flvplayer.swf?file=../files/others/' + val + '\');</script>';
            }
            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 == "video")
            {
                  var str_to_scroll = '<script type="text/javascript">swf_write(\'640\', \'480\', \'../flvplayer.swf?file=../files/others/' + val + '\');</script>';
                  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;
}

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 = brd_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 = brd_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 = brd_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 = brd_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 = brd_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 = brd_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 = brd_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 = brd_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 = brd_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 = brd_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 foto_mini_start_idd()
{
      if(document.getElementById('photo_b').value == '' && !document.getElementById('photo_loaded'))
      {
            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" />' + wmode="transparent" 
        '<param name="bgcolor" value="#000000" />' +
        '<param name="allowFullScreen" value="true" />' +
        '<embed src="' + file + '" quality="best" bgcolor="#000000" allowFullScreen="true" 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')
      {
            hide_photo('war_foto');
      }
}

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.backgroundColor = bckg_color;
             document.getElementById(id).style.borderColor = brd_color;
             alert('Wypełnij poprawnie pole!');
             //document.getElementById(id).select();
             document.getElementById(id).focus();
             return false;
         }
     }
      document.getElementById(id).style.backgroundColor = bckg_color2;
      document.getElementById(id).style.borderColor = brd_color2;
      return true;
}
