

//customised addEvent function for having a proper onload function call.
function addEvent(obj, evType, fn){ 
 if (obj.addEventListener){ 
   obj.addEventListener(evType, fn, false); 
   return true; 
 } else if (obj.attachEvent){ 
   var r = obj.attachEvent("on"+evType, fn); 
   return r; 
 } else { 
   return false; 
 } 
}

function xtractFile(data){
var m = data.match(/(.*)\/([^\/\\]+)(\.\w+)$/);
if(m == null) { m = "null"; }
return {path: m[1], file: m[2], extension: m[3]}
}


function initPage()
{
	//Initialise the SIFR heading replacement
	if(typeof sIFR == "function"){
	// This is the preferred "named argument" syntax
		sIFR.replaceElement(named({	sSelector:".homepage_content h1", sFlashSrc:"/flash/trajanPro.swf", sColor:"#333333", sWmode:"transparent" } ) );
		sIFR.replaceElement(named({	sSelector:".col_1 h1", sFlashSrc:"/flash/trajanPro.swf", sColor:"#333333", sWmode:"transparent" } ) );
		sIFR.replaceElement(named({	sSelector:".col_2 h1", sFlashSrc:"/flash/trajanPro.swf", sColor:"#333333", sWmode:"transparent" } ) );
		sIFR.replaceElement(named({	sSelector:".col_3 h1", sFlashSrc:"/flash/trajanPro.swf", sColor:"#333333", sWmode:"transparent" } ) );
		//sIFR.replaceElement(named({	sSelector:"#maincontent h1", sFlashSrc:"flash/trajanPro.swf", sColor:"#9c0432", sWmode:"transparent" } ) );
		sIFR.replaceElement(named({	sSelector:".homepage_content h3, #sidebar h3", sFlashSrc:"/flash/trajanPro.swf", sColor:"#333", sWmode:"transparent" } ) );
	};
	
	// highlight the current side-bar subnav link.
	if(document.getElementById("subnav"))
	{
		var sublinks = document.getElementById("subnav").getElementsByTagName("a");
		for(var i = 0; i < sublinks.length; i++)
		{	if(sublinks[i].href == document.location.href) { sublinks[i].parentNode.className += " currentPage"; }	}
	}
	
	// Turn on the homepage flash (if it's the homepage)
	if(document.getElementById("flasharea")) { 
		var so = new SWFObject("flash/homepage.swf", "flash_area", "635", "340", "8", "#ffffff");
		//so.addParam("wmode", "transparent");
		so.write("flasharea");  
	}
	
	// Turn on the homepage flash (if it's the homepage)
	if(document.getElementById("fitzhallOfficeFlashArea")) { 
        var so = new SWFObject("/flash/officesuites/fitzhall.swf", "fitzhall_officesuites", "620", "410", "8", "#ffffff");
        //so.addParam("wmode", "transparent");
        so.write("fitzhallOfficeFlashArea");
	}

	// Turn on the homepage flash (if it's the homepage)
	if(document.getElementById("fitzsquareOfficeFlashArea")) { 
        var so = new SWFObject("/flash/officesuites/fitzsquare.swf", "fitzsquare_officesuites", "620", "410", "8", "#ffffff");
        //so.addParam("wmode", "transparent");
        so.write("fitzsquareOfficeFlashArea");
	}

	// Turn on the homepage flash (if it's the homepage)
	if(document.getElementById("arthurhouseOfficeFlashArea")) { 
        var so = new SWFObject("/flash/officesuites/arthurhouse.swf", "arthurhouse_officesuites", "620", "410", "8", "#ffffff");
        //so.addParam("wmode", "transparent");
        so.write("arthurhouseOfficeFlashArea");
	}

	// Turn on the homepage flash (if it's the homepage)
	if(document.getElementById("fitzhallMeetingFlashArea")) { 
        var so = new SWFObject("/flash/meetingrooms/fitzHall.swf", "fitzhall_meetingrooms", "620", "410", "8", "#ffffff");
        //so.addParam("wmode", "transparent");
        so.write("fitzhallMeetingFlashArea");
	}

	// Turn on the homepage flash (if it's the homepage)
	if(document.getElementById("arthurhouseMeetingFlashArea")) { 
        var so = new SWFObject("/flash/meetingrooms/arthurHouse.swf", "arthurhouse_meetingrooms", "620", "410", "8", "#ffffff");
        //so.addParam("wmode", "transparent");
        so.write("arthurhouseMeetingFlashArea");
	}

	// Turn on the old bank cafe flash
	if(document.getElementById("fitzHallRestaurantFlashArea")) { 
        var so = new SWFObject("/flash/restaurants/overview_003.swf", "fitzhall_restaurants", "620", "410", "8", "#ffffff");
        //so.addParam("wmode", "transparent");
        so.write("fitzHallRestaurantFlashArea");
	}

	

	if(document.getElementById("maincontent"))
	{
		var dls = document.getElementById("maincontent").getElementsByTagName("a");
		var link_class = "dlicon ";
		for(var x = 0; x < dls.length; x++)
		{
			var parsedObject = xtractFile(dls[x].href);
			switch(parsedObject.extension)
			{
				case ".doc": dls[x].className = dls[x].className + " " + link_class + " doc"; break;
				case ".mp3": dls[x].className = dls[x].className + " " + link_class + " mp3"; break;
				case ".pdf": dls[x].className = dls[x].className + " " + link_class + " pdf"; break;
				case ".xls": dls[x].className = dls[x].className + " " + link_class + " xls"; break;
				case ".zip": dls[x].className = dls[x].className + " " + link_class + " zip"; break;
				case ".jpg": dls[x].className = dls[x].className + " " + link_class + " jpg"; break;
				case ".gif": dls[x].className = dls[x].className + " " + link_class + " gif"; break;
				default: dls[x].className = dls[x].className + " " + link_class + " misc"; break;
			} // end switch
		} // end for
	}// end if(getElement)
	
} // end initPage()

addEvent(window, 'load', initPage); // kick start the initPage function when the page loads

function popitup(url, w,h) 
{
	newwindow=window.open(url,'name','height='+h+',width='+w+', scrollbars=1');
	if (window.focus) {newwindow.focus()}
	return false;
}

