function load_comp()
{
  if(document.getElementById('firma').value==''){
  
  }else{
    document.location = 'http://okazyjni.pl/firma-' + document.getElementById('firma').value + '.htm';
  }
}

function load_search()
{
	if (document.getElementById('szukaj').value != '')
	{
		var str = encodeURI(document.getElementById('szukaj').value);
		str = str.replace(/-/g, '_');
		str = str.replace(/\./g, '_');
		document.location = 'szukaj-1-' + str + '.htm';
	}
}

function press_enter(e){
  var keychar
  if(window.event)
  {
    keynum = e.keyCode
  }
  else if(e.which)
  {
    keynum = e.which
  }
  keychar = String.fromCharCode(keynum)
  if(keynum=='13'){
  
  }
  return !numcheck.test(keychar) 
}

function realizuj(id)
{
	window.open('realizacja.php?id=' + id, "realizacja", "status=1,width=440"); 
}

function change_sposob()
{
	var select = document.getElementById('sposobselect');
	var sp1 = document.getElementById('spos-1');
	var sp2 = document.getElementById('spos-2');
	var sp3 = document.getElementById('kod-rab');
	if (select != null && sp1 != null && sp2 != null)
	{
		if (select.value == 1)
		{
			sp1.style.display = '';
			sp2.style.display = 'none';
			sp3.style.display = '';
		}
		if (select.value == 2)
		{
			sp1.style.display = 'none';
			sp2.style.display = '';
		}
		if (select.value == 3)
		{
		  sp1.style.display = '';
		  sp2.style.display = 'none';
		  sp3.style.display = 'none';
		}		
	}
	else
		alert('Niedostępne');
}

function window_help(id)
{	
	window.open('pomoc.php?go=' + id, 'Pomoc', 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,fullscreen=no,channelmode=no,resizable=no,width=400,height=600,left=5,top=5');
}

function window_help(id)
{	
	window.open('pomoc.php?go=' + id, 'Pomoc', 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,fullscreen=no,channelmode=no,resizable=no,width=400,height=600,left=5,top=5');
}

function zliczajznaki(nr_f, nr_l, nr_t) { 
    with(document.forms[0]) { 

        var tekst = elements[nr_t].value; // cały text z pola textarea 
        var dl_tresc = elements[nr_t].value.length; // długoś tekstu z textarea 
        var maxlen = 30; // maxymalna dozwolona długość 
        var prawdziwa = 0; // licznik znaków 
        var entery = 0; 
        
        for (i=0; i<dl_tresc; i++) { 
            if (tekst.charAt(i) == "\n") { 

                prawdziwa++; 
                entery++;
 
                if (navigator.appName != "Netscape") 
                    i++; 
            } 
            prawdziwa++; 
        } // koniec for i 
        
        elements[nr_l].value= maxlen - prawdziwa; // wyświetl komunikat o licznie znaków 
        if (prawdziwa>maxlen) { 
            if (navigator.appName != "Netscape") 
                elements[nr_t].value = elements[nr_t].value.substring(0,maxlen);
            else 
                elements[nr_t].value = elements[nr_t].value.substring(0,maxlen-entery);
    
        elements[nr_l].value = 30 - maxlen; 
        alert("Maksymalna długość to " + maxlen +"!"); 
        } 
    } // koniec with 
} 
//liczba znaków polu Opis kuponu.
function zliczajopiskuponu(e){
  if(window.event) { keynum = e.keyCode }
  else if(e.which) { keynum = e.which }
  if(document.getElementById('opiskuponu123').value.length>=209){
    if(keynum!=8){
      alert('Liczba znaków  w polu "Opis kuponu" przekroczyła 210.');
    }
  }  
}
function zliczajopisrealizacji(e){
  if(window.event) { keynum = e.keyCode }
  else if(e.which) { keynum = e.which }
  if(document.getElementById('opisrealizacji123').value.length>=179){
    if(keynum!=8){
      alert('Liczba znaków  w polu "Opis sposobu realizacji" przekroczyła 180.');
    }
  }  
}
function zliczajopisskrocony(e){
  if(window.event) { keynum = e.keyCode }
  else if(e.which) { keynum = e.which }
  if(document.getElementById('opisskrocony123').value.length>=79){
    if(keynum!=8){
      alert('Liczba znaków  w polu "Opis kuponu skrócony" przekroczyła 80.');
    }
  }  
}

/* o stronie */
    function close_div_ostronie(){
      var contener1 = document.getElementById('ostronie1');
      contener1.style.display = 'none';
      var contener2 = document.getElementById('ostronie2');
      contener2.style.display = 'none';
      var contener3 = document.getElementById('ostronie3');
      contener3.style.display = 'none';
      var contener4 = document.getElementById('ostronie4');
      contener4.style.display = 'none'; 
      var contener5 = document.getElementById('ostronie5');
      contener5.style.display = 'none'; 
      var contener6 = document.getElementById('ostronie6');
      contener6.style.display = 'none';                           
    }
    function close_div(id){
      var contener = document.getElementById(id);
      contener.style.display = 'none';
    }
    function open_div(id){
      var contener = document.getElementById(id);
      contener.style.display = '';
    }
    
  /* konkursy */
  
  function konkursy_window(id){
    window.open('konkurs.php?id='+id, 'Pomoc', 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,fullscreen=no,channelmode=no,resizable=no,width=400,height=500,left=5,top=5');
  }
  
  /* generowanie raportów */
  function kuponselected(){
    if(document.getElementById('hgdtwy362f').value==''){
      alert('Wybierz kupon.')
      return false;
    }else{
      return true;
    }
  }
  
  /* ponowne wysłanie aktywacji newslettera */
  function remindnews(){
    if(document.getElementById('rem12news').value==''){
      alert('Podaj adres e-mail.')
      return false;
    }else{
      return true;
      }  
  }
  
  function check_wstrzymaj(){
    if(confirm("Czy na pewno chcesz wstrzymać wyświetlanie kuponu?\nWznowienie emisji będzie wymagało kontaktu z serwisem")){
      return true;
    }else{
      return false;
    }  
  }
  
  /* pokaż komenarz */
  
  function coment_see(id){
    var content = 'koment_'+id;
    var see = 'koment_see_'+id;
    var hidd = 'koment_hidden_'+id;
    
    document.getElementById(content).style.display='';
    document.getElementById(see).style.display='none';
    document.getElementById(hidd).style.display='';
    
  }
  function coment_hidd(id){
    var content = 'koment_'+id;
    var see = 'koment_see_'+id;
    var hidd = 'koment_hidden_'+id;
    
    document.getElementById(content).style.display='none';
    document.getElementById(see).style.display='';
    document.getElementById(hidd).style.display='none';    
  }
  
  /* dodaj komentarz */  
  
  function add_coment_see(id){  
    var content = 'koment_add_'+id; 
    document.getElementById(content).style.display='';  
  }
  function add_coment_hidd(id){  
    var content = 'koment_add_'+id; 
    document.getElementById(content).style.display='none';  
  } 
  
  /* pole więcej */ 
  
  function more_see(id){
    var linksee = 'lmore_see_'+id;
    var linkhidd = 'lmore_hidd_'+id;  
    var content = 'more_'+id;
  
    document.getElementById(linksee).style.display='none';     
    document.getElementById(linkhidd).style.display='';     
    document.getElementById(content).style.display='';   
  }
  
  function more_hidd(id){  
    var linksee = 'lmore_see_'+id;
    var linkhidd = 'lmore_hidd_'+id;  
    var content = 'more_'+id;
  
    document.getElementById(linksee).style.display=''; 
    document.getElementById(linkhidd).style.display='none';     
    document.getElementById(content).style.display='none';  
  } 
  
  /* pole polec kupon - niewykorzystywane teraz */

    function polec_see(id){
    var linksee = 'lpolec_see_'+id;
    var linkhidd = 'lpolec_hidd_'+id;
    var content = 'polec_'+id;
    
    document.getElementById(linksee).style.display='none';     
    document.getElementById(linkhidd).style.display='';     
    document.getElementById(content).style.display='';   
  }
  
  function polec_hidd(id){  
    var linksee = 'lpolec_see_'+id;
    var linkhidd = 'lpolec_hidd_'+id;  
    var content = 'polec_'+id;
  
    document.getElementById(linksee).style.display=''; 
    document.getElementById(linkhidd).style.display='none';     
    document.getElementById(content).style.display='none';  
  }    
  /* pole polec kupon - zamykanie pola na kuponie szczegolowym*/
  
  function close_polec_box(){
    document.getElementById('polecbox').style.display='none';
  }
  
  
  /* product feeds */
  
  function open_product_feeds(id){
    var kupon = id;
    window.open('product_feeds.php?id=' + kupon, "Przykładowe produkty w promocji", "status=1,width=440, scrollbars=yes"); 
  }
    
