var clockInited = false;
var openWindow;
var months = new Array("January","February","March","April","May","June","Juli","August","September","October","November","December");
var itemTitle = "";
var docTitle = document.title;

function setTitle()
{
	var s = document.getElementById("item_title");
	if(!s) return;

	if( document.location.href.indexOf("#") != -1)
	{
		document.title = itemTitle;
		itemTitle = docTitle;
	}
	s.innerHTML = "";
}

function setItemTitle(title)
{
	var s = document.getElementById("item_title");
	if(!s) return;

	if( document.location.href.indexOf("#") != -1)
	{
		itemTitle = document.title+"  :  "+title;
	}
	else
		s.innerHTML = "<div id=\"title\"><br/><a href=\""+document.location.href+"\">"+document.title+"</a></div><div id=\"item\">reading post: <i>"+title+"</i></div>";
}

function clock_func()
{
	var s = document.getElementById("clock");
	if(!s) return;
	
	var d = new Date();
	
	year = d.getFullYear();
	month = d.getMonth();
	day  = d.getDate() < 10 ? "0" + d.getDate() : d.getDate();
	hours = d.getHours() < 10 ? "0" + d.getHours() : d.getHours();
	minutes = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes();
	seconds = d.getSeconds() < 10 ? "0" + d.getSeconds() : d.getSeconds();
	
	var str = months[month]+" "+day+", "+year+ " "+hours+":"+minutes+":"+seconds;
	s.innerHTML = str;
}

function clock_func()
{
	var s = document.getElementById("clock");
	if(!s) return;
	
	var d = new Date();
	
	year = d.getFullYear();
	month = d.getMonth();
	day  = d.getDate() < 10 ? "0" + d.getDate() : d.getDate();
	hours = d.getHours() < 10 ? "0" + d.getHours() : d.getHours();
	minutes = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes();
	seconds = d.getSeconds() < 10 ? "0" + d.getSeconds() : d.getSeconds();
	
	var str = months[month]+" "+day+", "+year+ " "+hours+":"+minutes+":"+seconds;
	s.innerHTML = str;
}

function add_clock()
{
	var s = document.getElementById("clock");
	if(!s) return;
	
	window.setInterval("clock_func()", 1000);
	clockInited = true;
}

function init()
{
	add_clock();
}

function popup(url,title,w,h)
{	
	url = typeof(url) == "undefined" ? "http://www.suite75.com" : url;
	title = typeof(title) == "undefined" ? "More" : title;
	w = typeof(w) == "undefined" ? 480 : w;
	h = typeof(h) == "undefined" ? 320 : h;
	
	if( openWindow )
	{
		if( !openWindow.closed )
			openWindow.close();
	}
	openWindow = window.open(url, title, "width="+w+", height="+h+", location=0, resizable=1, scrollbars=0, status=0, toolbar=0, directories=0");
}

function add_valid_xhtml_icon(parentNode)
{
	var link = document.createElement("A");
	var img =  document.createElement("IMG");
	
	link.setAttribute( "href", "http://validator.w3.org/check?uri=http%3A%2F%2Fradio.weblogs.com%2F0107414%2F" );
	
	img.setAttribute("src", "http://radio.weblogs.com/0107414/images/valid-xhtml10.png" );
	img.setAttribute("border", "0");
	img.setAttribute("alt", "Valid XHTML 1.0!");
	img.setAttribute("width", "88");
	img.setAttribute("height", "31");
	
	link.appendChild(img);
	parentNode.appendChild(link);
}

function add_valid_css_icon(parentNode)
{
	var link = document.createElement("A");
	var img =  document.createElement("IMG");
	
	link.setAttribute( "href", "http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fradio.weblogs.com%2F0107414%2Fjs%2Fstyles-site.css" );
	
	img.setAttribute("src", "http://jigsaw.w3.org/css-validator/images/vcss" );
	img.setAttribute("border", "0");
	img.setAttribute("alt", "Valid CSS!");
	img.setAttribute("width", "88");
	img.setAttribute("height", "31");
	
	link.appendChild(img);
	parentNode.appendChild(link);
}