// JavaScript Document
// See /contacts/sites/keyworth/kwhome.html for the input box to go with this code.
// Add in a postcode to get to in the variables (such as 'ng12%205gg' and google creates the directions from the input postcode.
// GVP 26/11/2007
function getDirections(src, postcode){
	var outUri='';
	var txtRef=document.getElementById('pCode');
	var newWin=new Object;
	
	if(isPostCode(txtRef.value)){
		// got valid UK postcode
		switch(src){
			case 'google': 
				outUri='http://maps.google.co.uk/maps?f=d&hl=en&z=12&om=1&pw=2&daddr='+ postcode +'&saddr=' + encodeURI(txtRef.value); 
				break;
			default: 
				outUri=''; 
				break;
			}
			
		if(outUri.length != 0){
			// got a url - open in new window
			newWin=window.open(outUri,'rfb_directionWindow');
			}
		
		}
	else{
		// problem with postcode
		alert('Postcode is not a valid UK postcode - please try again');
		txtRef.select();
		txtRef.focus();
		}
	}

function isPostCode(pCodeStr){
	var valid=true;
	return valid;
	}
