// Custom Favicon - http://philippe.chappuis.googlepages.com/favicon-feed-redirection
var ico_ie = document.createElement('link');
ico_ie.setAttribute('rel', 'shortcut icon');
ico_ie.setAttribute('type', 'image/x-icon');
ico_ie.setAttribute('href', '/favicony.ico');
document.getElementsByTagName('head')[0].appendChild(ico_ie);

// Change the width of the content column
// http://codepunk.hardwar.org.uk/ajs29.htm
// http://philippe.chappuis.googlepages.com/victoria-vinyl
document.getElementById("container").style.width = "1000px";
// Change the width of the content column
document.getElementById("main-content").style.width = "700px";
// A bit less spacing, please - I have a title to write
document.getElementsByTagName("h1")[0].style.letterSpacing = "0px";

// RSS Autodiscovery
var feed_ad = document.createElement('link');
feed_ad.setAttribute('rel', 'alternate');
feed_ad.setAttribute('type', 'application/rss+xml');
feed_ad.setAttribute('title', "Yossi Oren's Home Page Updates");
feed_ad.setAttribute('href', '/rss.xml');
document.getElementsByTagName('head')[0].appendChild(feed_ad);

// Statcounter code
var sc_project=1383200;
var sc_invisible=1;
var sc_partition=12;
var sc_security="c329a21c";
var sc_remove_link=1;
// (http://www.statcounter.com/counter/counter.js still needs to be included after this)

// Computer-Aided Program Telling Spiders and Browsers Apart
// Basically, this will rewrite your e-mail using Javascript.  
// Web spiders typically don't bother to execute code on the page, so your e-mail is safe from them.
// Usage: set an ID on each e-mail address you want protected, then call the function with the IDs
// For example:
// <span id="myMail">postmaster@localhost.localdomain</span>
// <script> capsba("myMail") </script>
// You can also fix multiple spans at once:
// captsba(["email1", "email2"]);
function fixEmailDelayed(spans) {
	for (var entry in this.spansToFix) {
		var e = this.spansToFix[entry].element;
		e.style.backgroundColor = "#cccccc";
	}

	window.setTimeout(function () {
		for (var entry in this.spansToFix) {
			var e = this.spansToFix[entry].element;
			e.innerHTML = 
				unescape(e.innerHTML).replace(/\|/g,"");
			e.style.backgroundColor = this.spansToFix[entry].bgcolor;
		}
	}, 150);
}

function captsba(spans) {
	// Handle a single span or an array of several spans
	if (typeof spans == "string") 
		spans = [spans];

	this.spansToFix = new Array();
	for (var span in spans) {
		e = document.getElementById(spans[span]);
		if (e != null) {
		    entry = {"element" : e, "bgcolor" : e.style.backgroundColor};
		    this.spansToFix.push(entry);
		}

	}
	
	window.setTimeout(fixEmailDelayed,1000);
}
