// 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";
		}
// search form onfocus cleaning
	if(document.getElementById('sitesearch')){
		var ffields = document.getElementById('sitesearch').getElementsByTagName('input');
		for (g in ffields){
			ffields[g].onfocus = function () { if(this.value == this.defaultValue){ this.value=''; }};
			ffields[g].onblur = function () { if(this.value.replace(/\s+/g,"") == '' ){ this.value=this.defaultValue; }};
		}
	}
		
////////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"); }
			}
		}
		
////////select all checkboxes
	if(document.getElementById('termsform')){
		var inputs = document.getElementById('termsform').getElementsByTagName("input");
		var checkall = document.getElementById('tickall');
		var ccb=0;
		for(which in inputs){
			inputs[which].onclick=function(){
					if(this.checked==true){ccb++;}else{ccb--;}
					if(ccb == inputs.length){checkall.checked = true;}else{checkall.checked = false;}
			}
		}//end for
		checkall.onclick = function(){
			if(checkall.checked==true){for(which in inputs){if(inputs[which].type="checkbox"){inputs[which].checked=true;ccb=inputs.length;}}
			}else{for(which in inputs){if(inputs[which].type="checkbox"){inputs[which].checked=false;ccb=0}}
			}
		}
	}
	
////////calculatord form made XHTML 1.0 strict compliant
		if(document.getElementById('formc')){
			document.formc = document.getElementById('formc');
		}

////////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(51.45488,-2.60995), 13);
				map.panBy(new GSize(10,70));
				// Place a marker at the right coordinate
				var marker = new GMarker(new GLatLng(51.45488,-2.60995));	
				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 'homeflash':
				document.getElementById(id).innerHTML = "<object type=\"application/x-shockwave-flash\" data=\"/img/header.swf\" width=\"532\" height=\"232\"><param name=\"wmode\" value=\"opaque\" /><param name=\"movie\" value=\"/img/header.swf\" /><img src=\"/img/header.jpg/\" width=\"530\" height=\"231\" alt=\"\" /></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() }

//terms slider
var TINY={};function T$(i){return document.getElementById(i)}function T$$(e,p){return p.getElementsByTagName(e)}TINY.accordion=function(){function slider(n){this.n=n;this.a=[]}slider.prototype.init=function(t,e,m,o,k){var a=T$(t),i=s=0,n=a.childNodes,l=n.length;this.s=k||0;this.m=m||0;for(i;i<l;i++){var v=n[i];if(v.nodeType!=3){this.a[s]={};this.a[s].h=h=T$$(e,v)[0];this.a[s].c=c=T$$('div',v)[0];h.onclick=new Function(this.n+'.pr(0,'+s+')');if(o==s){h.className=this.s;c.style.height='auto';c.d=1}else{c.style.height=0;c.d=-1}s++}}this.l=s};slider.prototype.pr=function(f,d){for(var i=0;i<this.l;i++){var h=this.a[i].h,c=this.a[i].c,k=c.style.height;k=k=='auto'?1:parseInt(k);clearInterval(c.t);if((k!=1&&c.d==-1)&&(f==1||i==d)){c.style.height='';c.m=c.offsetHeight;c.style.height=k+'px';c.d=1;h.className=this.s;su(c,1)}else if(k>0&&(f==-1||this.m||i==d)){c.d=-1;h.className='';su(c,-1)}}};function su(c){c.t=setInterval(function(){sl(c)},20)};function sl(c){var h=c.offsetHeight,d=c.d==1?c.m-h:h;c.style.height=h+(Math.ceil(d/5)*c.d)+'px';c.style.opacity=h/c.m;c.style.filter='alpha(opacity='+h*100/c.m+')';if((c.d==1&&h>=c.m)||(c.d!=1&&h==1)){if(c.d==1){c.style.height='auto'}clearInterval(c.t)}};return{slider:slider}}();

