
var HOST = 'earthlingsoft.net';

function toggleAds () {
	var theCookie = getCookie('noads');
	var statusmark = document.getElementById('adstatustext');

	if (theCookie == '') {
		// we are currently showing ads:
		// 1. set cookie
		var myDate = new Date();
		fixDate(myDate);
		myDate.setTime(myDate.getTime() + 1000 * 24 * 60 * 60 * 1000);
		setCookie('noads', 'Hey there', myDate, '/ssp/blog/', HOST, '');
		// 2. change status text
		statusmark.innerText = 'on';
		// 3. hide visible ads
		var adframes = document.getElementsByName('google_ads_frame');
		var aaa = adframes.length;
		for (var i = 0; i <= adframes.length; i++) {
			adframes[i].style.display = 'none';
		}
	}
	else {
		// we are currently not showing ads
		// 1. delete cookie
		deleteCookie('noads', '/ssp/blog/', HOST);
		// 2. change status Text
		statusmark.innerText = 'off';
	}
}



// Originally Copyright (c) 1996-1997 Athenia Associates.
// http://www.webreference.com/js/
// License is granted if and only if this entire
// copyright notice is included. By Tomer Shiran.

// + some changes for this site

function setCookie (name, value, expires, path, domain, secure) {
	//path = 0;
   // var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
   var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ";path=/ssp/blog/" + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
    document.cookie = curCookie;
}

function getCookie (name) {
    var prefix = name + '=';
    var c = document.cookie;
    var nullstring = '';
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1)
        return nullstring;
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
        cookieEndIndex = c.length;
    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function deleteCookie (name, path, domain) {
    if (getCookie(name))
        document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function fixDate (date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
}

function rememberMe (f) {
    var now = new Date();
    fixDate(now);
    now.setTime(now.getTime() + 1000 * 24 * 60 * 60 * 1000);
    setCookie('mtcmtauth', f.author.value, now, '', HOST, '');
    setCookie('mtcmtmail', f.email.value, now, '', HOST, '');
    setCookie('mtcmthome', f.url.value, now, '', HOST, '');
    setCookie('noads', 'blah', now, '', '', '')
}

function forgetMe (f) {
    deleteCookie('mtcmtmail', '', HOST);
    deleteCookie('mtcmthome', '', HOST);
    deleteCookie('mtcmtauth', '', HOST);
    f.email.value = '';
    f.author.value = '';
    f.url.value = '';
}





///////////////////////////////////
// ssp anti spam addition
///////////////////////////////////


function writeCommentsForm (nr) {
	var commentscript = "http://earthlingsoft.net/cgi-bin/mt/mt-komment.cgi";

	document.write("<form method='post' action='");
	document.write(commentscript);
	document.write("' name='actual_comments_form' onsubmit='if (this.bakecookie.checked) rememberMe(this)'>\n <p> \n");
	document.write("<input id='author' name='author'> <span class='label'>&nbsp;&larr; name</span> <br> \n");
	document.write("<input id='email' name='email'> <span class='label'>&nbsp;&larr; e-mail</span><br> \n");
	document.write("<input id='url' name='url'> <span class='label'>&nbsp;&larr;  web page</span><br> \n"); 	
	document.write("<textarea id='text' title='Your comment here' name='text' rows='15' cols='50'></textarea><br> \n");
	document.write("<input type='checkbox' id='bakecookie' name='bakecookie'><label for='bakecookie'>Remember me</label> \n");
	document.write("<input class='commentsubmitbutton' type='submit' name='post' value='Post my comment'> \n"); 	
	document.write("<input type='hidden' name='entry_id' value='");
	document.write(nr);
	document.write("'><input type='hidden' name='static' value='1'> \n 	</form>");
	
	document.write("<p> \nYou can use <code>_underscores_</code> to <em>emphasise</em> bits of your comment &ndash; and any other feature that <a href=\"http://daringfireball.net/projects/markdown/\">Markdown</a> offers. \n 	</p><p> \n 	Please note that I have to approve your comment before it appears on the site. I will not approve any commercial, vastly off-topic, tasteless or otherwise meaningless comments. \n </p> \n");
		
	document.actual_comments_form.email.value = getCookie("mtcmtmail");
	document.actual_comments_form.author.value = getCookie("mtcmtauth");
	document.actual_comments_form.url.value = getCookie("mtcmthome");
}

