//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);
			}
		}
	}
}


//jquery functions
$(document).ready(function() {
	initialize();

	var mydate = new Date();

	$(".zoom").lightBox();

	$(".top-photo").each( function() {
		$this = $(this);
		$this.wrap("<div class=\"photo_area_top\" style=\"width:"+$this.attr("width")+"px; height:"+$this.attr("height")+"px; background-image: url("+$this.attr("src")+");\"></div>");
	});

	$(".photo").each( function() {
		$this = $(this);
		$this.wrap("<div class=\"photo_area\" style=\"width:"+$this.attr("width")+"px; height:"+$this.attr("height")+"px; background-image: url("+$this.attr("src")+");\"></div>");
	});

	$(".photo_train").each( function() {
		$this = $(this);
		$this.wrap("<div class=\"photo_area_train\" style=\"width:"+$this.attr("width")+"px; height:"+$this.attr("height")+"px; background-image: url("+$this.attr("src")+");\"></div>");
	});

	$(".photo_area_top").corner("10px");

	$(".photo_area").corner("10px");

	$(".photo_area_train").corner("10px");

	$("#newfor2010").corner("10px");

});