// 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";
		}
	
// share icons opening in new window
	if(document.getElementById('shareme')){
		var sharelinks = document.getElementById('shareme').getElementsByTagName('a');
		for (var w=0; w<sharelinks.length; w++){ 
			if(sharelinks[w].getAttribute('rel')=='nofollow'){sharelinks[w].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');}
					else if(this.src.match('.png')){ this.src = this.src.replace(/.png/, '_o.png');}
				}
				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');}
					else if(this.src.match('.png')){ this.src = this.src.replace(/_o.png/, '.png');}
				}
			}
		}

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

////////submit paypal form in new window
		if(document.getElementById('paypalform')){
			var paypalform = document.getElementById('paypalform');
			paypalform.target= "_blank";
		}		

////////Google Map
		//start
		if(document.getElementById('googlemap')){
			var office = new google.maps.LatLng(55.974387,-3.167702);
			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: '<img style="display:block" src="/img/logomap.gif" alt="Logo" />'});
			var marker = new google.maps.Marker({ position: office, map: map, animation: google.maps.Animation.BOUNCE });		 
			map.panBy(0,-100);
			infowindow.open(map,marker);
			
			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: '<img style="display:block" src="/img/logomap.gif" alt="Logo" />'});
			var marker2 = new google.maps.Marker({ position: office2, map: map2, animation: google.maps.Animation.BOUNCE});		 
			map2.panBy(0,-100);
			infowindow.open(map2,marker2);
			
			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 'audio':
				document.getElementById(id).innerHTML = "<object type=\"application/x-shockwave-flash\" data=\"/img/audio.swf\" width=\"99\" height=\"109\"><param name=\"wmode\" value=\"opaque\" /><param name=\"movie\" value=\"/img/audio.swf\" /><img src=\"/img/audio.jpg\" width=\"99\" height=\"109\" alt=\"\" /></object>";
				break
				case 'righthead':
				document.getElementById(id).innerHTML = "<object type=\"application/x-shockwave-flash\" data=\"/img/righthead.swf\" width=\"601\" height=\"132\"><param name=\"wmode\" value=\"opaque\" /><param name=\"movie\" value=\"/img/righthead.swf\" /><img src=\"/img/head.jpg\" width=\"601\" height=\"132\" 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    
		}
	}
}

//NEWS Sliders
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}}();

