var debug = false;
var debugString = "";

$().ready(function()
{
	showJSIcons();
	setLinkIcons();
	$("#content > object").each(function() {
		if (470 < $(this).width())
		{
			$(this).wrap('<div class="wide"></div>');
		}
	});

//	if (debug && !self.console) alert(debugString);
});


function setLinkIcons()
{
	$('#content a').each(
		function() {
			setIconIfAllowed(this);
		}
	);
	$('#rightColumn a').each(
		function() {
			setIconIfAllowed(this);
		}
	);
	$('#leftNavigation .box a').each(
		function() {
			setIconIfAllowed(this);
		}
	);
}

function setIconIfAllowed(e)
{
	var icons = ",.pdf,.doc,.dwg,.txt,.xls,.wmv,.exe,.ppt,";
	if (icons.indexOf(',' + e.href.substr(e.href.length - 4).toLowerCase() + ',') > -1)
	{
		if ($(e).children("img").length > 0)
		{
		}
		else if ($(e).parent().is("p") && ($(e).parent().html().substr(0,2).toLowerCase() == "<a"))
		{
			log($(e).html() + " " + $(e).parent().html());
			$(e).addClass(e.href.substr(e.href.length - 3).toLowerCase());
		}
		else if ($(e).parent().is("p") && !($(e).parent().html().substr(0,2).toLowerCase() == "<a"))
		{
			log($(e).html());
		}
		else
		{
			$(e).addClass(e.href.substr(e.href.length - 3).toLowerCase());
		}
	}
}

function showJSIcons()
{
	$(".jsshow").removeClass("jsshow");
}



function log(s)
{
	var now = new Date();
	s = (now.getTime() + '').substr(9) + ": " + s;
	if (debug && self.console) console.log(s);
	debugString += s + '\n';
}