function progressiveEnhance() {
	window.status='Running javascript';
	
	/* social bookmarking */
	var addthis_config = { pubid: 'ra-4e79eefc608285c9', ui_cobrand: 'Yellsites' };
	var shareHTML = '<div id="share"><div class="addthis_toolbox addthis_default_style contactInfo" style="float:right;width:auto;">' +
		'<span style="float:left;"><p>Share:&nbsp;</p></span><span style="float:right;"><a class="share_facebook addthis_button_facebook"></a>' +
		'<a class="share_twitter addthis_button_twitter"></a>' +
		'<a class="share_google addthis_button_google_plusone" g:plusone:size="small" g:plusone:count="false" rel="nofollow"></a>' +
		'<a class="share_stumbleupon addthis_button_stumbleupon"></a>' +
		'<a class="share_addthis addthis_button_compact"></a></span>' +
		'</div></div>';
	var findHTML = '<div id="find"><div class="addthis_toolbox"><span style="float:left; font-size:11px;"><p>Find us:&nbsp;</p></span><span style="float:right;">' +
		'<a href="#" class="find_yell" alt="Business Information Page" title="Visit our Business Page on Yell.com"></a>' + 
		'<a href="#" class="find_facebook" alt="Facebook Page" title="Visit our Facebook Page"></a>' + 
		'<a href="#" class="find_google" alt="Google Places" title="Find us on Google Places"></a>' + 
		'<a href="#" class="find_twitter" alt="Twitter Profile" title="Visit our Twitter Profile"></a></span>' +
		'</div></div>';

	
	var footer = document.getElementById('footer');
	var bookmarks = document.createElement('div');
	bookmarks.id = 'bookmarks';
	bookmarks.className = 'skinBg';
	bookmarks.style.width = 'auto';
	bookmarks.style.backgroundPosition = '50% 50%';
	bookmarks.innerHTML = shareHTML + findHTML;
	
	document.getElementById('page').insertBefore( bookmarks, footer );
	
	/* find us */
	var findCount = 0;
	var findLinks = document.getElementById('find').getElementsByTagName('a');
	
	for(var i = 0; i < findLinks.length; i++){
		switch( findLinks[i].className ){
			case 'find_yell':
				if( !(typeof yellFind == 'undefined') ){
					findLinks[i].href = yellFind;
					findLinks[i].target = '_blank';
					findLinks[i].style.display = 'block';
					findCount++;
				}
				break;
			case 'find_facebook':
				if( !(typeof facebookFind == 'undefined') ){
					findLinks[i].href = facebookFind;
					findLinks[i].target = '_blank';
					findLinks[i].style.display = 'block';
					findCount++;
				}
				break;
			case 'find_google':
				if( !(typeof googleFind == 'undefined') ){
					findLinks[i].href = googleFind;
					findLinks[i].target = '_blank';
					findLinks[i].style.display = 'block';
					findCount++;
				}
				break;
			case 'find_twitter':
				if( !(typeof twitterFind == 'undefined') ){
					findLinks[i].href = twitterFind;
					findLinks[i].target = '_blank';
					findLinks[i].style.display = 'block';
					findCount++;
				}
				break;
		}
	
	}
	if( findCount > 0 ){
		document.getElementById('find').style.display = 'block';
	}
	
	/* like and tweet cleanup */
	var links = document.getElementById('content').getElementsByTagName("a");
	for(var i = 0; i < links.length; i++){
		if( links[i].className == 'addthis_button_facebook_like' || links[i].className == 'addthis_button_tweet' ){
			links[i].innerHTML = '';
			links[i].href = '';
		}
	}

	/* start addthis api */
	var addthisapi = document.createElement('script');
	addthisapi.type="text/javascript";
	addthisapi.src="http://s7.addthis.com/js/250/addthis_widget.js?domready=1";
	document.getElementsByTagName('head')[0].appendChild( addthisapi );
	
	setTimeout("enhanceCode()",10);
	// After 1/100th of a second, sort out bullet colour, alternate table row styles, remove full stop from H1 text, hide missing header image and allow png transparency in IE6 and IE7 even with WebsPlanet's php output bug. Tim Jones 2010.
}

function enhanceCode() {

	var blankGif = "/templates/creator/common-file-library/Turquoise/en/gfx/clear.gif"; 

	// Allow bullet points their own style
	var bullet = document.getElementById('content').getElementsByTagName("li");
	i=0;
	while (i<bullet.length) {
	  if (navigator.appVersion.indexOf("MSIE 7") != -1) bullet[ i ].parentNode.style.marginLeft = '40px';
	  bullet[ i ].parentNode.className="bullet";
	  bullet[ i ].innerHTML = '<span>' + bullet[ i ].innerHTML + '</span>';
	  i++;
	  }
	
	// Alternate table row styles in the content area
	var rows = document.getElementById('content').getElementsByTagName("tr"); 
	var numberInArray = rows.length;
	window.status = ' ' + numberInArray + ' rows on this page.';
	   for(i = 0; i < numberInArray; i++){          
	     if(i % 2 == 0){
	       var currentClass = rows[i].getAttribute('class') ;
	       
	       	rows[i].className = ''+ currentClass + ' even';
	       
	     }     
	   }
	
	// Kyle Smith the QA geezer wants to remove any final full stop from the H1 text. 
		var headlines = document.getElementsByTagName('h1');
		var headline = headlines[0].innerHTML;
		if (/\.$/.test(headline)) { 
			newHeadline = headline.replace(/\.$/,"");
			headlines[0].innerHTML = newHeadline;
			}
	var imgURL = document.getElementById('siteMainDynHeaderImage1').src;
	window.status=''+imgURL;
	lastChar = imgURL.substring(imgURL.length-1);
	//alert(lastChar);
	
	// What if there is no image? (03/08/10 Seb reported) Well if WebsPlanet insists on an image when there's nothing there, let's give it a transparent pixel to appease it.
	
	if ((lastChar == '/' ) || (imgURL == "")) document.getElementById('siteMainDynHeaderImage1').src = blankGif;
	if (imgURL == "undefined") document.getElementById('siteMainDynHeaderImage1').src = blankGif;
		
	if ((navigator.appVersion.indexOf("MSIE 6") != -1) || (navigator.appVersion.indexOf("MSIE 7") != -1)){
		window.status='Correcting png transparencies on old Microsoft browsers';
		var clear="/templates/creator/common-file-library/Turquoise/en/gfx/clear.gif"; 
		var els=document.getElementsByTagName('*'),ip=/.png/i,al="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='",i=els.length,uels=new Array(),c=0;while(i-->0){if(els[i].className.match(/unitPng/)){uels[c]=els[i];c++;}}if(uels.length==0)pfx(els);else pfx(uels);function pfx(els){i=els.length;while(i-->0){var el=els[i],es=el.style,elc=el.currentStyle,elb=elc.backgroundImage;if(el.src&&el.src.match(ip)&&!es.filter){es.height=el.height;es.width=el.width;es.filter=al+el.src+"',sizingMethod='crop')";el.src=clear;}else{if(elb.match(ip)){var path=elb.split('"'),rep=(elc.backgroundRepeat=='no-repeat')?'crop':'scale',elkids=el.getElementsByTagName('*'),j=elkids.length;es.filter=al+path[1]+"',sizingMethod='"+rep+"')";es.height=el.clientHeight+'px';es.backgroundImage='none';if(j!=0){if(elc.position!="absolute")es.position='static';while(j-->0)if(!elkids[j].style.position)elkids[j].style.position="relative";}}}}};
		// But WebsPlanet exports the header image differently
		var textImage = new Image();
		textImage.src = imgURL;
		var timg_src = textImage.src;
		var new_img = new Image();
		new_img.src = timg_src;
		new_img.onload = function(){
			var ti = document.getElementById("siteMainDynHeaderImage1"); 
			ti.style.width = new_img.width; 
			ti.style.height = new_img.height; 
			ti.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + timg_src + "', sizingMethod='scale')";
			ti.setAttribute('src', blankGif); 
		}
	
	
	window.status='Ready';
	
	}
	
}

