// use javascript for icons functions as they are javascript based
// also change the title of the link if js is enabled
window.onload = function() {
	if (document.getElementById) {
////////external links to open in a new window
		var anchors = document.getElementsByTagName("a");
		for (var z=0; z<anchors.length; z++){
			var anchor = anchors[z];
			if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "_blank";
		}
		
////////rollover effect on some images
		var images = document.getElementsByTagName("img");
		for (var y=0; y<images.length; y++){
			if(images[y].className == 'rollover'){
				images[y].onmouseover = function(){ this.src = this.src.replace(/.gif/, "_o.gif"); }
				images[y].onmouseout = function(){ this.src = this.src.replace(/_o.gif/, ".gif"); }
			}
		}

////////jump menu
		if(document.getElementById('jumpbox')){
			var menu = document.getElementById('jumpbox');
			menu.onchange = function(){
				if(menu.options[menu.selectedIndex].value != ""){
					window.location = menu.options[menu.selectedIndex].value;			
				}
			}
		}

////////calculatord form made XHTML 1.0 strict compliant
		if(document.getElementById('formc')){
			document.formc = document.getElementById('formc');
		}
		
////////scrolling news on the homepage
		if(document.getElementById('scrollnews')){
			var scrollnews = document.getElementById('scrollnews');
			scrollnews.onmouseover = function() { stopScroller(); }
			scrollnews.onmouseout = function() { startScroller() }
			initScroller();
		}

////////popup navigation menus
		if(window.attachEvent){// window.attachevent is IE only
			var sfEls = document.getElementById("nav").getElementsByTagName("LI");
				for (var x=0; x<sfEls.length; x++) {
					sfEls[x].onmouseover=function() {
						this.className+=" sfhover";
					}
					sfEls[x].onmouseout=function() {
						this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
					}
				}
		}

////////print button
		if(document.getElementById('printlink')){
			var prinbtn = document.getElementById('printlink');
			var prinbtnimg = document.getElementById('printlinkimg');
			prinbtn.href='javascript:window.print()';
			prinbtn.title='print this page';
			prinbtnimg.alt='print this page';
		}
		
////////add to favorites button
		if(document.getElementById('booklink')){
			var bookmarkbtn = document.getElementById('booklink');
			var bookmarkbtnimg = document.getElementById('booklinkimg');
				if (window.sidebar){ 
					bookmarkbtn.href='javascript:window.sidebar.addPanel(document.title,location.href,"")'; 
					bookmarkbtn.title='add this page to your favourites'; 
					bookmarkbtnimg.alt='add this page to your favourites'; 
				} else if( document.all ) {
					bookmarkbtn.href='javascript:window.external.AddFavorite(location.href,document.title)';
					bookmarkbtn.title='add this page to your favourites'; 
					bookmarkbtnimg.alt='add this page to your favourites'; 
				}
		}
		
////////submit paypal form in new window
		if(document.getElementById('paypalform')){
			var paypalform = document.getElementById("paypalform");
			paypalform.target= "_blank";
		}		
		
////////Google Map
		if(document.getElementById('googlemap')){
			if(GBrowserIsCompatible()){
				var map = new GMap2(document.getElementById('googlemap'));
				map.addControl(new GLargeMapControl());
				map.addControl(new GMapTypeControl());
				map.setCenter(new GLatLng(51.5942,-0.2886), 13);
				map.panBy(new GSize(10,70));
				// Place a marker at the right coordinate
				var marker = new GMarker(new GLatLng(51.5942,-0.2886));	
				var maptext = "<div id=\"maptext\"><img src=\"/img/logomap.gif\" alt=\"Logo\" /></div>";
				GEvent.addListener(marker, "click", function() {
					marker.openInfoWindowHtml(maptext);
				});
				map.addOverlay(marker);
				marker.openInfoWindowHtml(maptext);
			}//end if GBrowserIsCompatible
		}
}//end if

//search highlighting
highlight();
}//end window.onload

writeFlash = function(id){
	if (document.getElementById(id)){
		switch(id){
			case 'intro':
				document.getElementById(id).innerHTML = "<object type=\"application/x-shockwave-flash\" data=\"/img/intro.swf\" width=\"250\" height=\"42\"><param name=\"wmode\" value=\"opaque\" /><param name=\"movie\" value=\"/img/intro.swf\" /></object>";
				break    
			case 'homeflash':
				document.getElementById(id).innerHTML = "<object type=\"application/x-shockwave-flash\" data=\"/img/header.swf\" width=\"509\" height=\"157\"><param name=\"wmode\" value=\"opaque\" /><param name=\"movie\" value=\"/img/header.swf\" /></object>";
				break    
			case 'tmgame':
				document.getElementById(id).innerHTML = "<object type=\"application/x-shockwave-flash\" data=\"/img/games/tm/tax_minefield.swf\" width=\"560\" height=\"420\"><param name=\"movie\" value=\"/img/games/tm/tax_minefield.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\"#105993\" /><param name=\"wmode\" value=\"opaque\" /></object>";
				break
			case 'ttmgame':
				document.getElementById(id).innerHTML = "<object type=\"application/x-shockwave-flash\" data=\"/img/games/ttm/taxtips_maker.swf\" width=\"360\" height=\"620\"><param name=\"allowScriptAccess\" value=\"sameDomain\" /><param name=\"movie\" value=\"/img/games/ttm/taxtips_maker.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\"#ffffff\" /><param name=\"wmode\" value=\"opaque\" /></object>";
				break    
		}
	}
}

window.onunload = function() { GUnload() }