//when page loads start standard functions
function initialize() {
	//replace external links with open in new window
	externalLinks();
}

window.onload = initialize;


function $import(src){
	var scriptElem = document.createElement('script');
  scriptElem.setAttribute('src',src);
	scriptElem.setAttribute('type','text/javascript');
	document.getElementsByTagName('head')[0].appendChild(scriptElem);
}


// import with a random query parameter to avoid caching
function $importNoCache(src){
	var ms = new Date().getTime().toString();
	var seed = "?" + ms; 
	$import(src + seed);
}


function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors .length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
			anchor.target = "_blank";
			anchor.title = (anchor.title != "") ? anchor.title+" (opens in a new window) ": "opens in a new window";
			anchor.className = (anchor.className != '') ? anchor.className+' external' : 'external';
//			anchor.onclick = 'javascript: pageTracker._trackPageview (\'/outgoing/'+anchor.href+'\');';
			var track = anchor.href;
			track = track.replace('http://','');
			anchor.onclick = function() { 
				pageTracker._trackPageview('/outgoing/'+track);
			}
		}
	}
}

$(document).ready(function()
{
	$(".year-link").click(function(){
		$($(this).attr("rel")).css("display", "block");
		var arrowId = $(this).attr("rel");
		$(arrowId+"-arrow").attr("src", "/images/blog-open.gif");
	});

	$(".comments-link").click(function(){
		window.open( $(this).attr('href'),'comments','width=440,height=700,scrollbars=1' );
		return false;
	});


});






function checkSubmitComment()
{

	var errorList = "";
	if(document.comments_form.name.value=="") errorList += "\n - Name";
	if(document.comments_form.email.value=="") errorList += "\n - Email";
	if(document.comments_form.comment.value=="") errorList += "\n - Comment";

	if (errorList!='')
	{
		errorList = "Please complete the following information" + errorList;
		alert(errorList);
		return false;
	} else {
		return true;
	}
}