// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function createCookie(name,value,days) {
	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;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function setHomepageRecentPublicationsLastVisited() {
	var c = readCookie('recent_publications_last_visited');
	if (matchURL()) {
		if (c) {
			d.toggle('recent_publications', c);
		}
		else {
			createCookie('recent_publications_last_visited', 'recent_articles', 0);
		}
	}
}

function matchURL() {
	return document.URL == 'http://localhost:3003/' || document.URL == 'http://localhost:3003/#' || document.URL == 'http://localhost:3003' || document.URL == 'http://www.jstatsoft.org/' || document.URL == 'http://www.jstatsoft.org/#' || document.URL == 'http://www.jstatsoft.org';
}