function SetNotes(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 var cookieValueTmp = ReadNotes(cookieName);
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 if(cookieValueTmp.search("#"+cookieValue+"#")==-1) {
 document.cookie = cookieName+"="+escape(cookieValueTmp+"#"+cookieValue+"#")+";expires="+expire.toGMTString()+";path=/";
 } else {
 cookieValueTmp = cookieValueTmp.replace("#"+cookieValue+"#", "");	
 document.cookie = cookieName+"="+escape(cookieValueTmp)+";expires="+expire.toGMTString()+";path=/"; 	
 }
 ChkNotes(cookieName,cookieValue);
 ReadListaNotes('notes_portal-n.pl');
}

function ReadNotes(cookieName) {
 var theCookie=" "+document.cookie;
 var ind=theCookie.indexOf(" "+cookieName+"=");
 if (ind==-1) ind=theCookie.indexOf(";"+cookieName+"=");
 if (ind==-1 || cookieName=="") return "";
 var ind1=theCookie.indexOf(";",ind+1);
 if (ind1==-1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+2,ind1));
}

function ReadListaNotes(cookieName) {
 var ciag_zwrotny = ReadNotes(cookieName);
 document.getElementById("notes_oferty").value = ciag_zwrotny; 
 var text1 = ciag_zwrotny;
 var text2 = text1.replace(/\s+/g, '');
 var text3 = text2.split('##');
 var numberOfWords = text3.length;
 if(ciag_zwrotny.search("#")==-1) {
 	numberOfWords=0;
 	}
 document.getElementById("of_count").value = "["+numberOfWords+"]";
 return ciag_zwrotny;
}

function ChkNotes(cookieName,cookieValue) {
  var cookieValueTmp = ReadNotes(cookieName);
  var dodaj = "notes_dodaj_";
  var usun = "notes_usun_";
  document.getElementById(dodaj+cookieValue).style.display = 'none';
  document.getElementById(usun+cookieValue).style.display = 'none';
  if(cookieValueTmp.search("#"+cookieValue+"#")==-1) {
  document.getElementById(dodaj+cookieValue).style.display = 'block';
  } else {
  document.getElementById(usun+cookieValue).style.display = 'block';
  }
}

function KasujWszystkieNotes() {
	r=confirm('Chcesz usunąć wszystkie zapamiętane w notesie ogłoszenia ?');
	if (r == true) {
    window.location = "/oferta/notes";
	SetNotes('notes_portal-n.pl', 'kasuj', -10);
	}
}
