// 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"); }
			}
		}

////////randomimg
		if(document.getElementById('homeflashstatic')){
		var img = document.getElementById('homeflashstatic');
		img.src = '/img/rand/' + (Math.floor(Math.random()*3) + 1) + '.jpg';
	}

////////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";
		}		

////////submit in a Box form in new window
		if(document.getElementById('inaboxform')){
			var inaboxform = document.getElementById("inaboxform");
			inaboxform.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(53.68758,-1.49284), 13);
				map.panBy(new GSize(10,70));
				// Place a marker at the right coordinate
				var marker = new GMarker(new GLatLng(53.68758,-1.49284));	
				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
		}
			
		if(document.getElementById('googlemap2')){
			if(GBrowserIsCompatible()){
				var map2 = new GMap2(document.getElementById('googlemap2'));
				map2.addControl(new GLargeMapControl());
				map2.addControl(new GMapTypeControl());
				map2.setCenter(new GLatLng(53.3714,-1.4881), 13);
				map2.panBy(new GSize(10,70));
				// Place a marker at the right coordinate
				var marker2 = new GMarker(new GLatLng(53.3714,-1.4881));	
				var maptext2 = "<div id=\"maptext\"><img src=\"/img/logomap.gif\" alt=\"Logo\" /></div>";
				GEvent.addListener(marker2, "click", function() {
					marker2.openInfoWindowHtml(maptext2);
				});
				map2.addOverlay(marker2);
				marker2.openInfoWindowHtml(maptext2);
			}//end if GBrowserIsCompatible
		}
		
		if(document.getElementById('googlemap3')){
			if(GBrowserIsCompatible()){
				var map3 = new GMap2(document.getElementById('googlemap3'));
				map3.addControl(new GLargeMapControl());
				map3.addControl(new GMapTypeControl());
				map3.setCenter(new GLatLng(51.4844,-3.1726), 13);
				map3.panBy(new GSize(10,70));
				// Place a marker at the right coordinate
				var marker3 = new GMarker(new GLatLng(51.4844,-3.1726));	
				var maptext3 = "<div id=\"maptext\"><img src=\"/img/logomap.gif\" alt=\"Logo\" /></div>";
				GEvent.addListener(marker3, "click", function() {
					marker3.openInfoWindowHtml(maptext3);
				});
				map3.addOverlay(marker3);
				marker3.openInfoWindowHtml(maptext3);
			}//end if GBrowserIsCompatible
		}

		if(document.getElementById('googlemap4')){
			if(GBrowserIsCompatible()){
				var map4 = new GMap2(document.getElementById('googlemap4'));
				map4.addControl(new GLargeMapControl());
				map4.addControl(new GMapTypeControl());
				map4.setCenter(new GLatLng(53.7959,-1.5583), 13);
				map4.panBy(new GSize(10,70));
				// Place a marker at the right coordinate
				var marker4 = new GMarker(new GLatLng(53.7959,-1.5583));	
				var maptext4 = "<div id=\"maptext\"><img src=\"/img/logomap.gif\" alt=\"Logo\" /></div>";
				GEvent.addListener(marker4, "click", function() {
					marker4.openInfoWindowHtml(maptext4);
				});
				map4.addOverlay(marker4);
				marker4.openInfoWindowHtml(maptext4);
			}//end if GBrowserIsCompatible
		}
		
		if(document.getElementById('googlemap5')){
			if(GBrowserIsCompatible()){
				var map5 = new GMap2(document.getElementById('googlemap5'));
				map5.addControl(new GLargeMapControl());
				map5.addControl(new GMapTypeControl());
				map5.setCenter(new GLatLng(53.99218,-1.53693), 13);
				map5.panBy(new GSize(10,70));
				// Place a marker at the right coordinate
				var marker5 = new GMarker(new GLatLng(53.99218,-1.53693));	
				var maptext5 = "<div id=\"maptext\"><img src=\"/img/logomap.gif\" alt=\"Logo\" /></div>";
				GEvent.addListener(marker5, "click", function() {
					marker5.openInfoWindowHtml(maptext5);
				});
				map5.addOverlay(marker5);
				marker5.openInfoWindowHtml(maptext5);
			}//end if GBrowserIsCompatible
		}
		if(document.getElementById('googlemap6')){
			if(GBrowserIsCompatible()){
				var map6 = new GMap2(document.getElementById('googlemap6'));
				map6.addControl(new GLargeMapControl());
				map6.addControl(new GMapTypeControl());
				map6.setCenter(new GLatLng(53.4808,-2.2437), 13);
				map6.panBy(new GSize(10,70));
				// Place a marker at the right coordinate
				var marker6 = new GMarker(new GLatLng(53.4808,-2.2437));	
				var maptext6 = "<div id=\"maptext\"><img src=\"/img/logomap.gif\" alt=\"Logo\" /></div>";
				GEvent.addListener(marker6, "click", function() {
					marker6.openInfoWindowHtml(maptext6);
				});
				map6.addOverlay(marker6);
				marker6.openInfoWindowHtml(maptext6);
			}//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=\"195\" height=\"80\"><param name=\"wmode\" value=\"opaque\" /><param name=\"movie\" value=\"/img/intro.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() }