function createCookie(name,value,days,date) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	} else {
		var expires = "";
	}
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0; i<ca.length; i++) {
		var c = ca[i];
		while (c.charAt(0) == ' ') {
			c = c.substring(1,c.length);
		}
		if (c.indexOf(nameEQ) == 0) {
			return c.substring(nameEQ.length,c.length);
		}
	}
	return null;
}



//setTimeout("close_floater('floater1')",60 * 1000);

var empty = true;

function close_floater(id) {
	if (empty) {
		document.getElementById(id).style.display = 'none';
	}
}

function close_floater2(id) {
	
		document.getElementById(id).style.display = 'none';
	
}


//configuration
// print_first is the pageview upon which the floater will pop. It is clicks minus 1 
// renew_days is number of days till next pop.
var print_first = 2;
var renew_days = 1;

//logic
var pages = readCookie('pages');
var exp = readCookie('expire');
var floater = 0;
if ((pages == null) || (isNaN(pages)) || (pages <= 1)) {
	pages = 1;
} else {
	pages = parseInt(pages);
	if ((exp == null) || (exp == '')) {
		if (pages == print_first) {
			createCookie('expire', 'no', renew_days);
			floater = 1;
		}
	}
}

//update control cookie
//createCookie('pages', pages+1, renew_days); permanent cookie
//createCookie('pages', pages+1); session cookie
createCookie('pages', pages+1);

