var hidecolumn = null;
$(document).ready(function(){
	
	var thisUrl = location.href;
	var trail = thisUrl.substring(thisUrl.length-1,thisUrl.length);
	if (trail == '/') {
		location.href = thisUrl + "index.html";
	}
	
	
	
	if($.cookie('cu-facman-resources') != 'default') {
		var linktext = null;
		var cv = $.cookie('cu-facman-resources');
		
		if (cv =="Consultants") {
			$("a#back2resources").html('<< Resources for Consultants');
			$("a#back2resources").attr("href", "/facilitiesmanagement/resources/consultants.html");
			$("a#back2resources").addClass("showResources");
			$("a#back2resources").show();
			hidecolumn = false;
		}
		if (cv =="Contractors") {
			$("a#back2resources").html('<< Resources for Contractors');
			$("a#back2resources").attr("href", "/facilitiesmanagement/resources/contractors.html");
			$("a#back2resources").addClass("showResources");
			$("a#back2resources").show();
			hidecolumn = false;
		}
		if (cv =="Proctors") {
			$("a#back2resources").html('<< Resources for Building Proctors');
			$("a#back2resources").attr("href", "/facilitiesmanagement/resources/proctors.html");
			$("a#back2resources").addClass("showResources");
			$("a#back2resources").show();
			hidecolumn = false;
		}
		
	}
	
	
	
	$("ul#navmenu a").each(function(){
		if ($(this).attr("href") == location.pathname) {
			
			$(this).addClass("selected");
			//alert($(this).html());
			//alert($(this).parent().parent().attr("id"));
			
			
			if($(this).parent().parent().attr("id") =="navmenu") {
				var subnav = $(this).next("ul");
			} else if ($(this).parent().parent().parent().parent().attr("id") =="navmenu"){
				
				var subnav = $(this).parent().parent();
				$(this).parent().parent().prev("a").addClass("selected");
				
			} else if ($(this).parent().parent().parent().parent().parent().parent().attr("id") =="navmenu") {
				
				var subnav = $(this).parent().parent().parent().parent();
				$(this).parent().parent().prev("a").addClass("selected");
				$(this).parent().parent().parent().parent().prev("a").addClass("selected");
			} else if ($(this).parent().parent().parent().parent().parent().parent().parent().parent().attr("id") =="navmenu") {
				
				var subnav = $(this).parent().parent().parent().parent().parent().parent();
				$(this).parent().parent().parent().parent().prev("a").addClass("selected");
				$(this).parent().parent().parent().parent().parent().parent().prev("a").addClass("selected");
			}
			
			
			
			$("div#level2").prepend(subnav);
			
			
			

		}
	});
	
	
	
	$("div.content a").each(function(){
									if ($(this).attr('name')) {
										
									} else {
									 var str = $(this).attr("href");
									 //alert($(this).text());
									  if (str.lastIndexOf(".pdf",str.length) != -1) {
										 //$(this).addClass("pdfLink"); 
										 $(this).append("&nbsp;<img src='/facilitiesmanagement/images/pdf.gif' border='0' alt='Download PDF' />");
									  }
									   if (str.lastIndexOf(".doc",str.length) != -1) {
										 //$(this).addClass("wordLink"); 
										  $(this).append("<img src='/facilitiesmanagement/images/word.gif' border='0' alt='Download MS Word' />");
									  }
									  if (str.lastIndexOf(".xls",str.length) != -1) {
										 //$(this).addClass("xlsLink"); 
										  $(this).append("<img src='/facilitiesmanagement/images/xls.gif' border='0' alt='Download MS Excel' />");
									  }
									  if (str.lastIndexOf(".vsd",str.length) != -1) {
										 //$(this).addClass("vsdLink"); 
										  $(this).append("<img src='/facilitiesmanagement/images/vsd.gif' border='0' alt='Download MS Visio' />");
									  }
									}
									 });
	
	
	
		
});




			
		
		$(".navigation ul#navmenu > li:not(:first)").each(function(){
			$("> a", this).css("border-left", "1px solid #666").css("width", "124px");
		});
$(document).ready(function(){	
	if ($("div.subNavigation ul li").length < 1) {
		column();
	} 
});



function column() {
	$("div.subNavigation").hide();
	$("div.mainColumn").css("margin-left", 0);
}
