var thisServerURL = "http://www.tourismbc.com";

$(document).ready(function(){
	if ($(".documentList").length > 0) {
		$(".documentList tr:even").addClass("even");
	}
	if ($(".documentListNoIcon").length > 0) {
		$(".documentListNoIcon tr:even").addClass("even");
	}
	
	//proces the right column links for length & external link icon
	if ($("#rightColumn a").length > 0) {
		$("#rightColumn a").each(function(i){
			thisLinkText = $(this).html();
			if (thisLinkText.length > 22 && (thisLinkText.indexOf(" ") == -1)) {
				//is this an email link?
				if (thisLinkText.indexOf("@") > 0) {
					revisedLinkText = thisLinkText.replace("@", "@ ");
					$(this).html(revisedLinkText);
				}
				//otherwise, pick an appropriate place to insert a space
			}
			
			//for external links, append the external link icon
			if (!$("#pageContainer").hasClass("home")) {
				thisLinkUrl = $(this).attr("href");
				if (thisLinkUrl != null && (thisLinkUrl.indexOf("http") >= 0) && (thisLinkUrl.indexOf(thisServerURL) == -1)) {
					$(this).attr("target", "_blank");
					if ($(this).find("img").length == 0) {
						$(this).after("<img src=\"/images/icon_externallink.gif\" alt=\"External site link\" class=\"externallinkIcon\" />");
					}
				}
			}
		});
	}
	
	
	if ($("#centerColumn a").length > 0) {
		$("#centerColumn a").each(function(i){
			//for external links, append the external link icon
			thisLinkUrl = $(this).attr("href");
			if (thisLinkUrl != null && (thisLinkUrl.indexOf("http") >= 0) && (thisLinkUrl.indexOf(thisServerURL) == -1)) {
				$(this).attr("target", "_blank");
				$(this).after("<img src=\"/images/icon_externallink.gif\" alt=\"External site link\" class=\"externallinkIcon\" />");
			}
		});
	}
});