//--------------------------------------------------

var toString = function(number) {
	var string = "";

	if(number < 10) {
		string += "0";
	}

	return (string + parseInt(number)).toString();
}

//--------------------------------------------------

var toDigit = function(string) {
	var html = "";
	var i = 0;

	for(i = 0; i < string.length; i++) {
		html += "<img src=\"/content/pictures/digits/" + string.charAt(i) + ".png\" />";
	}

	return html;
}

//--------------------------------------------------
/* Countdown
var startCountdown = function() {
	var current = new Date();
	var end = new Date("November 11, 2011, 11:11:11");

	var count = Math.floor(end.getTime() - current.getTime());
	var months, days, hours, minutes, seconds, milliseconds;

	milliseconds = toString(count % 1000);
	count = count / 1000;

	seconds = toString(count % 60);
	count = count / 60;
	
	minutes = toString(count % 60);
	count = count / 60;

	hours = toString(count % 24);
	count = count / 24;

	days = toString(count % 30);
	count = count / 30;

	months = toString(count);

	if(current < end) {
		document.getElementById("months").innerHTML = toDigit(months);
		document.getElementById("days").innerHTML = toDigit(days);
		document.getElementById("hours").innerHTML = toDigit(hours);
		document.getElementById("minutes").innerHTML = toDigit(minutes);
		document.getElementById("seconds").innerHTML = toDigit(seconds);

		if(document.getElementById("double-colon-2").style.display == "block") {
			document.getElementById("double-colon-2").style.display = "none";
		} else {
			document.getElementById("double-colon-2").style.display = "block";
		}

		window.setTimeout(startCountdown, 1000);
	}
}
*/
//--------------------------------------------------

var registerLinkEvents = function() {
	var links = document.getElementsByTagName("a");

	if(typeof(links) == "object") {
		for(link in links) {
			if(typeof(links[link]) == "object") {
				if(links[link].rel && (links[link].rel == "popup")) {
					links[link].onclick = function(event) {
						if(this.href && (this.href.length > 0)) {
							window = window.open(this.href, link, "width=800,height=600,scrollbars=yes");
						}

						event.preventDefault();
					}
				} else if(links[link].rel && (links[link].rel == "popup_philosophy")) {
					links[link].onclick = function(event) {
						if(this.href && (this.href.length > 0)) {
							window = window.open(this.href, link, "width=650,height=800,scrollbars=yes");
						}
						
						event.preventDefault();
					}
				}
			}
		}
	}
}

//--------------------------------------------------

var executeOnLoad = function() {
	//startCountdown(); Countdown
	registerLinkEvents();
}

//--------------------------------------------------

window.onload = executeOnLoad;

//--------------------------------------------------

