function cookie(document, name, hours, path, domain, secure) {
	this.$document = document;
	this.$name = name;
	if (hours) this.$expiration = new Date((new Date()).getTime() + hours*3600000);
	else this.$expiration = null;
	if (path) this.$path = path; else this.$path = "/";
	if (domain) this.$domain = domain; else this.$domain = null;
	if (secure) this.$secure = secure; else this.$secure = false;
}

function _cookie_store() {
	var cookieval = "";
	for (var prop in this) {
		if ((prop.charAt(0) == '$') || ((typeof this[prop]) == 'function')) continue;
		if (cookieval != "") cookieval += '&';
		cookieval += prop + ':' + escape(this[prop]);
	}
	var cookie = this.$name + '=' + cookieval;
	if (this.$expiration) cookie += '; expires=' + this.$expiration.toGMTString();
	if (this.$path) cookie += '; path=' + this.$path;
	if (this.$domain) cookie += '; domain=' + this.$domain;
	if (this.$secure) cookie += '; secure';
	this.$document.cookie = cookie;
}

function _cookie_load() {
	var allcookies = this.$document.cookie;
	if (allcookies == "") return false;
	var start = allcookies.indexOf(this.$name + '=');
	if (start == -1) return false;
	start += this.$name.length + 1;
	var end = allcookies.indexOf(';', start);
	if (end == -1) end = allcookies.length;
	var cookieval = allcookies.substring(start, end);
	var a = cookieval.split('&');
	for (var i=0; i < a.length; i++) a[i] = a[i].split(':');
	for (var i=0; i < a.length; i++) this[a[i][0]] = unescape(a[i][1]);
	return true;
}

function _cookie_remove() {
	var cookie;
	cookie = this.$name + '=';
	if (this.$path) cookie += '; path=' + this.$path;
	if (this.$domain) cookie += '; domain=' + this.$domain;
	cookie += '; expires=Fri, 02-Jan-1970 00:00:00 GMT';
	this.$document.cookie = cookie;
}

new cookie();
cookie.prototype.store = _cookie_store;
cookie.prototype.load = _cookie_load;
cookie.prototype.remove = _cookie_remove;

var visitordata = new cookie(document, "name_count_state", 720);
if (!visitordata.load() || !visitordata.name || !visitordata.datum) {
	visitordata.name = "BIOTREND";
	visitordata.datum = new Date(1999, 4, 1);	// novy navsevnik, vse je pro nej nove
}

lastvisit = Date.parse(visitordata.datum)/60000;		// min
modified = Date.parse(document.lastModified)/60000;		// min
today = new Date();						// Locale
visitordata.datum = today;				// Locale
newshow = (lastvisit <= modified);						// navsteva po modifikaci: ukazovat novinky
delay = 1;												// min
refresh = (today.getTime()/60000 - lastvisit) < delay;		// navrat do delay minut jako tataz navsteva
if (visitordata.visits == null || newshow) visitordata.visits = 0;	// novy navstevnik nebo po oaktualizaci nuluje pocitadlo
visitordata.visits++;
if (!refresh || newshow) {
	visitordata.store();
}			// ulozeni soucasne navstevy do cookie


var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");

function countdown(yr,m,d,after){
	var today=new Date(); var todayy=today.getYear();
	if (todayy < 1000) todayy+=1900;
	var todaym=today.getMonth(); var todayd=today.getDate();
	var todaystring=montharray[todaym]+" "+todayd+", "+todayy;
	var futurestring=montharray[m-1]+" "+d+", "+yr;
	var difference=(Math.round((Date.parse(futurestring)-Date.parse(todaystring))/(24*60*60*1000))*1);
	
	if (difference<=0 && difference>=-(after)) return 1; //new
	else return 0; // old
}

function leadnull(num){
	return (num > 9 ? num : "0"+num);
}

function published(yr,m,d) {
	return yr+"-"+leadnull(m)+"-"+leadnull(d);
}
news = 14; // days to be news

// ************ MEDIA ************
// Czech
cpd = 2; cpm = 2; cpy = 2008;
// English
epd = 15; epm = 11; epy = 2006;
md   = new Array(countdown(cpy,cpm,cpd,news),published(cpy,cpm,cpd),countdown(epy,epm,epd,news),published(epy,epm,epd));	
// ************ MEDIA ************

// ************ What is NEW ************
// Czech
cpd = 10; cpm = 4; cpy = 2007;
// English
epd = 2; epm = 1; epy = 2008;
nw   = new Array(countdown(cpy,cpm,cpd,news),published(cpy,cpm,cpd),countdown(epy,epm,epd,news),published(epy,epm,epd));
// ************ What is NEW ************

// ************ INFORMATION ************
// Czech
cpd = 12; cpm = 1; cpy = 2008;
// English
epd = 7; epm = 12; epy = 2007;
inf   = new Array(countdown(cpy,cpm,cpd,news),published(cpy,cpm,cpd),countdown(epy,epm,epd,news),published(epy,epm,epd));
// ************ INFORMATION ************

// ************ OPINION ************
// Czech
cpd = 23; cpm = 4; cpy = 2007;
// English
epd = 1; epm = 8; epy = 2004;
op   = new Array(countdown(cpy,cpm,cpd,news),published(cpy,cpm,cpd),countdown(epy,epm,epd,news),published(epy,epm,epd));
// ************ OPINION ************

// ************ LEGISLATURE ************
// Czech
cpd = 12; cpm = 12; cpy = 2000;
// English
epd = 12; epm = 12; epy = 2000;
lg   = new Array(countdown(cpy,cpm,cpd,news),published(cpy,cpm,cpd),countdown(epy,epm,epd,news),published(epy,epm,epd));
// ************ LEGISLATURE ************

// ************ INTERESTING PAGES ************
// Czech
cpd = 7; cpm = 12; cpy = 2006;
// English
epd = 30; epm = 11; epy = 2006;
intr   = new Array(countdown(cpy,cpm,cpd,news),published(cpy,cpm,cpd),countdown(epy,epm,epd,news),published(epy,epm,epd));
// ************ INTERESTING PAGES ************

// ************ ABOUT BIOTRIN ************
// Czech
cpd = 6; cpm = 8; cpy = 2001;
// English
epd = 17; epm = 2; epy = 2002;
wb   = new Array(countdown(cpy,cpm,cpd,news),published(cpy,cpm,cpd),countdown(epy,epm,epd,news),published(epy,epm,epd));
// ************ ABOUT BIOTRIN ************

// ************ BIOTRIN ACTIVITY ************
// Czech
cpd = 30; cpm = 11; cpy = 2006;
// English
epd = 17; epm = 2; epy = 2002;
ab   = new Array(countdown(cpy,cpm,cpd,news),published(cpy,cpm,cpd),countdown(epy,epm,epd,news),published(epy,epm,epd));
// ************ BIOTRIN ACTIVITY ************

// ************ ČESK8 PERIODIKA ************
// Czech
cpd = 9; cpm = 10; cpy = 2006;
// English
epd = 17; epm = 2; epy = 2002;
pe   = new Array(countdown(cpy,cpm,cpd,news),published(cpy,cpm,cpd),countdown(epy,epm,epd,news),published(epy,epm,epd));
// ************ ČESK8 PERIODIKA ************

// ************ BULLETIN ************
// Czech
cpd = 2; cpm = 2; cpy = 2008;
// English
epd = 17; epm = 2; epy = 2002;
bu   = new Array(countdown(cpy,cpm,cpd,news),published(cpy,cpm,cpd),countdown(epy,epm,epd,news),published(epy,epm,epd));
// ************ BULLETIN ************


// ************ OUR POINT of VIEW ************
// Czech
cpd = 26; cpm = 11; cpy = 2007;
// English
epd = 17; epm = 2; epy = 2002;
see   = new Array(countdown(cpy,cpm,cpd,news),published(cpy,cpm,cpd),countdown(epy,epm,epd,news),published(epy,epm,epd));
// ************ OUR POINT of VIEW ************

//Global variable pth ukazuje na adresář s obrázky
function shownew(){
	if (newshow) document.write('<img src="'+pth+'new_ani.gif" alt="NEW" align="middle" border="0" WIDTH="25" HEIGHT="14" hspace="0" vspace="0">'); 
	else {
		if (!refresh) document.write('<img src="'+pth+'new_a.gif" alt="NEW" align="middle" border="0" WIDTH="25" HEIGHT="14" hspace="0" vspace="0">'); 
		else document.write('<img src="'+pth+'smallnew.gif" alt="NEW" align="middle" border="0" WIDTH="25" HEIGHT="14" hspace="0" vspace="0">');
	}
}


function note(item,offset) {
// offset: Czech=0 English=2
	if (item[0+offset]) ii = shownew(); 	// show NEW picture
	else document.write('<img src="'+pth+'1x1.gif" width="25" height="14" border="0" hspace="0" vspace="0">');	// show blank space
	document.write(item[1+offset]);	// publish date
}