var d = new Date();
var time = d.getHours();
var sty=readCookie('styler');
if (time >= 6 && time <= 18)
{
document.getElementById('styles').href = "http://www.joncairns.com/styles.css";
document.getElementById('body').href = "http://www.joncairns.com/body.css";
}
if (sty=="light")
{
document.getElementById('styles').href = "http://www.joncairns.com/styles.css";
document.getElementById('body').href = "http://www.joncairns.com/body.css";
}
if (sty=="dark")
{
document.getElementById('styles').href = "http://www.joncairns.com/styles2.css";
document.getElementById('body').href = "http://www.joncairns.com/body2.css";
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=200,height=270');");
}


function setstyle(style)
{
if (style=="light")
 {
 createCookie("styler","light",1)
 }
if (style=="dark")
 {
 createCookie("styler","dark",1)
 }
window.location.reload();
}
 
function load()
{
var blog = readCookie('blog');
var hi = readCookie('hi');
var updates = readCookie('updates');
if (blog=="min") {
 document.getElementById("blog_content").style.display = "none";
 }
if (hi=="min") {
 document.getElementById("hi_content").style.display = "none";
 }
if (updates=="min") {
 document.getElementById("updates_content").style.display = "none";
 }
return null;
}

function minimise(id)
 {
 var min_id = id + "_content"; 
 Effect.BlindUp(min_id);
 Effect.Fade(min_id);
 createCookie(id,"min",7)
 return false;
 }
 function maximise(id)
 {
 var max_id = id + "_content"; 
 Effect.BlindDown(max_id);
 Effect.Appear(max_id);
 createCookie(id,"max",7)
 return false;
 }

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);
}