// 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";
		}
		
// newsletter form onfocus cleaning
	if(document.getElementById('newsletter')){
		var ffields = document.getElementById('newsletter').getElementsByTagName('input');
		for (f in ffields){
			ffields[f].onfocus = function () { if(this.value == this.defaultValue){ this.value=''; }};
			ffields[f].onblur = function () { if(this.value.replace(/\s+/g,"") == '' ){ this.value=this.defaultValue; }};
		}
	}
	
// 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(){
					if(this.src.match('.gif')){ this.src = this.src.replace(/.gif/, "_o.gif"); }
					else if(this.src.match('.jpg')){ this.src = this.src.replace(/.jpg/, "_o.jpg");}
				}
				images[y].onmouseout = function(){ 
					if(this.src.match('.gif')){ this.src = this.src.replace(/_o.gif/, ".gif"); }
					else if(this.src.match('.jpg')){ this.src = this.src.replace(/_o.jpg/, ".jpg");}
				}
			}
		}

////////calculatord form made XHTML 1.0 strict compliant
		if(document.getElementById('formc')){
			document.formc = document.getElementById('formc');
		}
		
////////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;			
				}
			}
		}
		
////////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"), "");
					}
				}
		}


////////popup navigation menus
		if(window.attachEvent){// window.attachevent is IE only
			var sfEls = document.getElementById("top_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
		//start
		if(document.getElementById('googlemap')){
			var office = new google.maps.LatLng(53.26805,-1.264753);
			var mapOptions = { zoom: 14, center:office, backgroundColor: "#ffffff", mapTypeControl: true, mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}, navigationControl: true, navigationControlOptions: {style: google.maps.NavigationControlStyle.DEFAULT }, mapTypeId: google.maps.MapTypeId.ROADMAP };
			var map = new google.maps.Map(document.getElementById("googlemap"), mapOptions);
		    var infowindow = new google.maps.InfoWindow({ content: '<div id="maptext"><img style="display:block" src="/img/logomap.gif" alt="Logo" /></div>'});
			var marker = new google.maps.Marker({ position: office, map: map, animation: google.maps.Animation.BOUNCE });		 
			infowindow.open(map,marker);
			map.panBy(0,-70);
			
			google.maps.event.addListener(marker, 'click', function() { 
				if (this.getAnimation() != null) { this.setAnimation(null);  } 
		  		else { this.setAnimation(google.maps.Animation.BOUNCE); } });
		}
		//end
	
		//start
		/*		
		if(document.getElementById('googlemap2')){
			var office2 = new google.maps.LatLng(0,0);
			var mapOptions = { zoom: 14, center:office2, backgroundColor: "#ffffff", mapTypeControl: true, mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}, navigationControl: true, navigationControlOptions: {style: google.maps.NavigationControlStyle.DEFAULT }, mapTypeId: google.maps.MapTypeId.ROADMAP };
			var map2 = new google.maps.Map(document.getElementById("googlemap2"), mapOptions);
		    var infowindow = new google.maps.InfoWindow({content: '<div id="maptext"><img src="/img/logomap.gif" alt="Logo" /></div>'});
			var marker2 = new google.maps.Marker({ position: office2, map: map2, animation: google.maps.Animation.BOUNCE});		 
			infowindow.open(map2,marker2);
			map2.panBy(0,70);
			
			google.maps.event.addListener(marker2, 'click', function() { 
				if (this.getAnimation() != null) { this.setAnimation(null);  } 
		  		else { this.setAnimation(google.maps.Animation.BOUNCE); } });
		}
		*/
		//end 
		
}//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=\"770\" height=\"167\"><param name=\"wmode\" value=\"opaque\" /><param name=\"movie\" value=\"/img/header.swf\" /></object>";
				break    
			case 'homeaudio':
				document.getElementById(id).innerHTML = "<object type=\"application/x-shockwave-flash\" data=\"/img/audio.swf\" width=\"206\" height=\"96\"><param name=\"wmode\" value=\"opaque\" /><param name=\"movie\" value=\"/img/audio.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    
		}
	}
}
