<!--
var dane=pobierzRekordy();
var ilosc_rekordow=dane.length;
var podpis_java = getCookie("podpis_java");

function pokazOkno(){
		window.open("book.htm", "ksiazka","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,width=500,height=450")
	}

function selNo() {
	for (var i=0; i<document.forma.ksiazka.options.length; i++){
		if (document.forma.ksiazka.options[i].selected)
			document.forma.numer.value = document.forma.ksiazka.options[i].value
	}
}

function pobierzRekordy() {
	dane= new Array();
	y=0;
	strCookie= document.cookie;
	arrCookie= strCookie.split("; ");
		for (var x=0 ; arrCookie[x]; x++) {
			arrTmp =arrCookie[x].split("=");
			if (arrTmp[0].substring(0,6)=="indeks") {
				arrTmp[1]=unescape(arrTmp[1]);
				dane[y]=arrTmp[1].split("|");
				dane[y][3]=arrTmp[0];
				pozycja=dane[y][0].indexOf("+");
				while (pozycja!= -1) {
					dane[y][0]=dane[y][0].substring(0,pozycja)+" "+dane[y][0].substring(pozycja+1);
					pozycja=dane[y][0].indexOf("+");
				}
				y++;
			}
		}
return dane;
}

function getCookie(Name) {
   var search = Name + "="
   if (document.cookie.length > 0) {
      offset = document.cookie.indexOf(search) 
      if (offset != -1) {
         offset += search.length 
         end = document.cookie.indexOf(";", offset) 
         if (end == -1) 
            end = document.cookie.length
         return unescape(document.cookie.substring(offset, end))
      }
   }
	 return "";
}

function setCookie(name,value) {
     document.cookie = name + "=" +escape(value) + "; expires=Sat, 05-Jul-2010 00:00:00 GMT;";
}

function wstawcookie() {
  document.forma.podpis.value = podpis_java;
}

function sprawdznumer(numer) {
  if (numer.value.length == 0) {
    alert("Podaj numer telefonu.");
    numer.focus();
    return 0;
  }
  if (numer.value.length < 9) {
    alert("Numer telefonu musi składać się z 9 znaków.");
    numer.focus();
    return 0;
  }
  if (numer.value.substring(0,2)!="50" && numer.value.substring(0,2)!="51" && numer.value.substring(0,2)!="60" && numer.value.substring(0,2)!="69" && numer.value.substring(0,2)!="66" && numer.value.substring(0,3)!="889" && numer.value.substring(0,3)!="880" && numer.value.substring(0,3)!="886" && numer.value.substring(0,3)!="888" && numer.value.substring(0,2)!="78" && numer.value.substring(0,3)!="798" && numer.value.substring(0,3)!="783" && numer.value.substring(0,3)!="785" && numer.value.substring(0,3)!="721" && numer.value.substring(0,3)!="722") {
    alert("Niepoprawny numer telefonu.");
    numer.focus();
    return 0;
  }
  return 1;
}

function check_length() {	
	if(!sprawdznumer(document.forma.numer)) {
		return 0;
	}
	else {

		if (document.forma.numer.value.substring(0,2)=="88") { var siec="heyah"; var limit=109; }		
		if (document.forma.numer.value.substring(0,2)=="50") { var siec="orange"; var limit=390; }
		if (document.forma.numer.value.substring(0,2)=="51") { var siec="orange"; var limit=390; }
		if (document.forma.numer.value.substring(0,3)=="600" || document.forma.numer.value.substring(0,3)=="660") { var siec="era"; var limit=109;  }
		if (document.forma.numer.value.substring(0,2)=="60" && parseInt(document.forma.numer.value.substring(2,3))%2==0) { var siec="era"; var limit=109; }
		if (document.forma.numer.value.substring(0,2)=="69" && parseInt(document.forma.numer.value.substring(2,3))%2==0) { var siec="era"; var limit=109; }
		if (document.forma.numer.value.substring(0,2)=="66" && parseInt(document.forma.numer.value.substring(2,3))%2==0) { var siec="era"; var limit=109; }
		if (document.forma.numer.value.substring(0,2)=="60" && parseInt(document.forma.numer.value.substring(2,3))%2!=0) { var siec="plus"; var limit=273; }
		if (document.forma.numer.value.substring(0,2)=="69" && parseInt(document.forma.numer.value.substring(2,3))%2!=0) { var siec="plus"; var limit=273; }
		if (document.forma.numer.value.substring(0,2)=="66" && parseInt(document.forma.numer.value.substring(2,3))%2!=0) { var siec="plus"; var limit=273; }
                if (document.forma.numer.value.substring(0,3)=="781") { var siec="plus"; var limit=273; }
                if (document.forma.numer.value.substring(0,3)=="782") { var siec="plus"; var limit=273; }
                if (document.forma.numer.value.substring(0,3)=="783") { var siec="plus"; var limit=273; }
                if (document.forma.numer.value.substring(0,3)=="785") { var siec="plus"; var limit=273; }
                if (document.forma.numer.value.substring(0,3)=="721") { var siec="plus"; var limit=273; }
                if (document.forma.numer.value.substring(0,3)=="722") { var siec="plus"; var limit=273; }
                if (document.forma.numer.value.substring(0,3)=="787") { var siec="heyah"; var limit=109; }
                if (document.forma.numer.value.substring(0,3)=="788") { var siec="heyah"; var limit=109; }
                if (document.forma.numer.value.substring(0,3)=="798") { var siec="orange"; var limit=390; }

znakow = document.forma.tekst.value.length+document.forma.podpis.value.length;
        document.forma.siec.value=siec;
		document.forma.licznik.value= limit-znakow;
		
if (document.forma.licznik.value<0) {alert ("Wpisany tekst jest za długi.");
document.forma.tekst.value=document.forma.tekst.value.substring(0,limit-document.forma.podpis.value.length); document.forma.licznik.value=0;}		
		
if (siec=="era" || siec=="heyah") 
 { if (znakow>0) { document.forma.wiadomosci.value=1; }
    else { document.forma.wiadomosci.value=0;}
 }
 else if (siec=="orange")
       { if (znakow>0 && znakow<92) {document.forma.wiadomosci.value=1;}
	      else if (znakow>91 && znakow<182) {document.forma.wiadomosci.value=2;}
		        else if (znakow>181 && znakow<272){document.forma.wiadomosci.value=3;}
				      else if (znakow>271) {document.forma.wiadomosci.value=4;}
				      else {document.forma.wiadomosci.value=0;}  }		
	else if (siec="plus")
	      { if (znakow>0 && znakow<132) {document.forma.wiadomosci.value=1}
		     else if (znakow>131) {document.forma.wiadomosci.value=2}
			       else {document.forma.wiadomosci.value=0} }	
		
		
 }
}



function clear_message() {
	document.forma.reset();
}

function kontrola(form) {
  var dat = document.forma;
	if (!sprawdznumer(dat.numer)) {
		dat.numer.focus();
		return false
	}
	if (dat.podpis.value.length == 0) {
		alert("Brak podpisu!");
		dat.podpis.focus();
		return false
	}
	if (dat.tekst.value.length == 0) {
		alert("Wpisz wiadomość!");
		dat.tekst.focus();
		return false
	}
	setCookie ("podpis_java" , dat.podpis.value);
  return true
} 

function wyslij(form) {
 var dat = document.forma;
	if (!kontrola(form))
		return false
	window.open("about:blank","okienko",'toolbar=no,scrollbars=no,directories=no,status=no,menubar=no,resizable=no,width=550,height=400');
	//clear_message();
	//wstawcookie();
	//window2.focus();
   return true
}
//-->

