// Take off the padding that is used for the left hand side
// so that the requested width is the width they really get
racWidth = racWidth-15;

if(racWidth<160)racWidth=160;
if(racWidth<350) {
	racMapSize=racWidth-25;
	racInputSize=racMapSize+10;
	racInputSizeInside=racInputSize-67;
	racCopySize=racMapSize;
} else {
	racMapSize=200;
	racCopySize=racWidth-racMapSize-35;
	racInputSize=racCopySize;
	racInputSizeInside=racInputSize-67;
}


racRoot='http://www.rac.co.uk/library/route-planner/widget/';
racAddress=unescape(racAddress);
racPostcode=racPostcode.toUpperCase();
searchAddress = racAddress.replace(/\*\*/gi,', ') + ', '+racPostcode;
racAddress=racAddress.replace(/\*\*/gi,'<br />');
racAddress=racAddress+'<br />'+racPostcode;
racRoutePlannerMap='http://clients.multimap.com/API/map/1.2/racapi?postalCode='+escape(racPostcode)+'&countryCode=GB&width='+racMapSize+'&height=147';

racRoutePlannerAddress='http://www.rac.co.uk/route-planner/?cmp=routeplannerwidget';
document.write('<style type="text/css">');
	document.write('.rac-clearfix:after{ content: "."; display: block; height: 0; clear: both; visibility: hidden; }');
	document.write('.rac-clearfix {display:inline-block;}');
	document.write('/* Hides from IE-mac \*/');
	document.write('.rac-clearfix {display:block;}');
	document.write('/* End hide from IE-mac */');
    document.write('#rac-widget {font:12px arial,sans-serif; position:relative; margin:0px; width:'+racWidth+'px; z-index:1; padding-left:15px;}');
    document.write('#rac-w-content,  #rac-w-t, #rac-w-footer, #rac-w-footer-t, #rac-w-b,  #rac-w-b div {background:transparent url('+racRoot+'images/bg.png) no-repeat top right; _background:transparent url('+racRoot+'images/bg.gif) no-repeat top right;}');
	document.write('#rac-w-content {position:relative; zoom:1; _overflow-y:hidden; padding:0px 15px 0px 0px;}');
	document.write('#rac-w-t {position:absolute; left:0px; top:0px; width:15px; margin-left:-15px; height:100%; _height:1600px; background-position:top left;}');
	document.write('#rac-w-mast {padding:12px 0 0 0; height:45px;}');
		document.write('#rac-w-logo, #rac-w-map, #rac-w-copy {float:left;}');
		document.write('#rac-w-strap {float:right; padding-right:5px; text-align:right;}');
	document.write('#rac-w-mid {clear:both;}');
		document.write('#rac-w-map {padding-bottom:10px; width:'+racMapSize+'px; padding-right:10px;}');
		document.write('#rac-w-copy {color:#fff; float:left; padding-bottom:7px; text-align:left; width:'+racCopySize+'px;}');
		document.write('#rac-w-form {margin:0; padding:0;}');
			document.write('#rac-w-form-pcbg {background: url('+racRoot+'images/bg-form-pc.gif) no-repeat top right; height:30px; width:'+racInputSize+'px;}');
			document.write('#rac-w-form-pc {background: url('+racRoot+'images/bg-form-pc.gif) no-repeat top left; border:0; color:#76685f; height:28px; padding:4px 0 0 5px; float:left; width:'+racInputSizeInside+'px;}');
				document.write('#rac-w-form-pc:focus {outline:none;}');
				document.write('#rac-w-form-btn {background: url('+racRoot+'images/go.gif) no-repeat bottom left; border:0; cursor:pointer; height:25px; margin:0 0 0 15px; float:left; width:36px;}');
				document.write('#rac-w-ad {border-left:24px solid #fc9747; font-weight:bold; margin-top:10px; padding-left:7px;}');
	        document.write('#rac-w-footer {color:#76685f; font-size:11px; position:relative; padding:8px 15px 0px 0px; height:58px; background-position:100% 100%;}');
		document.write('#rac-w-footer-t {position:absolute; left:0px; top:0px; width:15px; margin-left:-15px; height:100%; background-position:0% 100%;}');
		document.write('#rac-w-get {padding:5px 10px 0 0; text-align:right;}');
		document.write('#rac-w-get a {color:#abaaa9! important;}');
	document.write('#rac-widget a {color:#f15c22; text-decoration:none;}');
	document.write('.rac-clr {clear:both;}');
document.write('</style>');

document.write('<div id="rac-widget">');
	document.write('<div id="rac-w-content">');
		document.write('<div id="rac-w-t"></div>'); 
		document.write('<div id="rac-w-mast">');
			document.write('<div id="rac-w-logo">');
			    document.write('<a href="http://www.rac.co.uk" target="_blank"><img src="'+racRoot+'images/logo.gif" alt="RAC - the driving people" border="0" /></a>');
			document.write('</div>');
			if(racWidth>=220) {
			    document.write('<div id="rac-w-strap"> ');
				    document.write('<a href="http://www.rac.co.uk/routeplanner/"><img src="'+racRoot+'images/route-planner.gif" alt="Route planner" border="0" /></a>');
			    document.write('</div> ');
			}
		document.write('</div> ');
		document.write('<div id="rac-w-mid">');
			document.write('<div id="rac-w-map">');
				document.write('<img src="' +racRoutePlannerMap+ '" />');
			document.write('</div>');
			document.write('<div id="rac-w-copy">');
			    document.write('<form id="racWidgetForm" name="racWidgetForm" class="rac-clearfix" action="'+racRoutePlannerAddress+'" method="post" target="_new">');
    			    document.write('<div id="rac-w-form-pcbg" class="rac-clearfix"><input id="rac-w-form-pc" type="text" name="qs_1" size="" /><input id="rac-w-form-btn" type="submit" name="" size="" value="" />');
					document.write('<input type="hidden" name="countryCode_1" id="id_countryCode_1" value="UK" />');
					document.write('<input type="hidden" name="countryCode_2" id="id_countryCode_2" value="UK" />');
					document.write('<input type="hidden" name="countryCode_3" id="id_countryCode_3" value="UK" />');
					document.write('<input type="hidden" name="countryCode_4" id="id_countryCode_4" value="UK" />');
					document.write('<input type="hidden" name="qs_2" id="id_qs_2" value="" />');
					document.write('<input type="hidden" name="qs_3" id="id_qs_3" value="" />');
					document.write('<input type="hidden" name="qs_4" id="id_qs_4" value="'+racPostcode+'" />');
					document.write('<input type="hidden" name="rtype" id="rtype" value="true" />');
					document.write('<input type="hidden" name="rpref" id="fastest" value="true" />');
					document.write('<input type="hidden" name="mapType" id="interactive" value="interactive" />');
					document.write('<input type="hidden" id="optimizeIntermediates" name="optimizeIntermediates" value="true" />');				
					document.write('<input type="hidden" name="jsOption" id="jsOption" value="true" />');
					document.write('<input type="hidden" name="lang" id="lang" value="en_gb" />');
					document.write('<input type="hidden" name="formtype" value="routeplanner" /></div>');
					document.write('<input type="hidden" name="mileage_rate" value="40" />');
				document.write('</form>');
				document.write('Enter your location or postcode above to get a personalised route to:');
				document.write('<div id="rac-w-ad">');
				  document.write(racAddress);
				document.write('</div>'); 
			document.write('</div>');
			document.write('<div class="rac-clr"></div>');
		document.write('</div>');
	document.write('</div>');
	document.write('<div id="rac-w-footer">');
		document.write('<div id="rac-w-footer-t"></div>');
		document.write('RAC products:');