function fillAddrContent(lORR)
{
if (lORR==10 || lORR==0){
document.frmLocSelect.frmType[0].checked=true;
fillFrmPlace()
document.frmLocSelect.frmPlaceLoc.focus();}
if (lORR==11){
document.frmLocSelect.frmType[1].checked=true;
fillFrmPlace()
document.frmLocSelect.frmPlaceLoc.focus();}
if (lORR==12){
fillFromAddr()
document.frmLocSelect.frmAddress1.focus();}
if (lORR==13){
document.frmLocSelect.frmType[3].checked=true;
fillFrmPlace()
document.frmLocSelect.frmPlaceLoc.focus();}
if (lORR==20){
document.frmLocSelect.toType[0].checked=true;
fillToPlace()
document.frmLocSelect.toPlaceLoc.focus();}
if (lORR==21){
document.frmLocSelect.toType[1].checked=true;
fillToPlace()
document.frmLocSelect.toPlaceLoc.focus();}
if (lORR==22 || lORR==0){
fillToAddr()
if (lORR==22)
document.frmLocSelect.toAddress1.focus();
}
if (lORR==23){
document.frmLocSelect.toType[3].checked=true;
fillToPlace()
document.frmLocSelect.toPlaceLoc.focus();}
document.frmLocSelect.imgstage.src='./images/imgStep1.gif';
}


			function showAddressPopup(caldir) {
				var wHeight =300;
				var wWidth = 400;
				var wTop = (screen.height / 2) - ( wHeight / 2);
				var wLeft = (screen.width / 2) - ( wWidth / 2);		
				var strQueryString	;
				var strPage = "Address";
				wTop = (screen.height / 2) - ( wHeight / 2);
				wLeft = (screen.width / 2) - ( wWidth / 2);
				myURL = "http://www.startaxiz.com/star/Address/Step1.asp";
				if (caldir==1){
				    myURL += "?Direction=FromAddr";
				    var strAddress = document.frmLocSelect.frmPostcode.value;}
                else{
                    myURL += "?Direction=ToAddr";
                    var strAddress = document.frmLocSelect.toPostcode.value;}
				    myURL += "&Postcode=" + strAddress;

				try {
				    g_myWindow = window.open(myURL, strPage, "width=" + wWidth + ",height=" + wHeight + "resizable=no,location=0,toolbar=no,status=no,scrollbars=yes,left=" + wLeft + ",top=" + wTop);	
					g_myWindow.focus();
				}
				catch(e) {
					alert("An error has occurred.\r\rThe window for finding address via the postcode is currently unavailable.");
				}	
			}
function fillFromAddr()
{
document.frmLocSelect.frmType[2].checked=true;
document.getElementById('frmPlaceID').innerHTML='';
strAddContent = '<table style="width:100%";><tr>';
strAddContent = strAddContent + '<td class="genBoldText"; width="30"; align="Right";>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;From&nbsp;Address</td>';
strAddContent = strAddContent + '<td Width="70%"; align="center";><input id="frmAddress1ID" name="frmAddress1" size="32" maxlength="60" value="" tabindex="0" class="inputbox" ></td>';
strAddContent = strAddContent + '</tr><td class="genText"; width="30"; align="Right";>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Line&nbsp;2</td>';
strAddContent = strAddContent + '<td Width="70%"; align="center";><input id="frmAddress2ID" name="frmAddress2" size="32" maxlength="60" value="" tabindex=0 class="inputbox" ></td></tr>';
strAddContent = strAddContent + '<tr><td class="genBoldText"; width="30"; align="Right";>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Town</td>';
strAddContent = strAddContent + '<td Width="70%"; align="center";><input id="frmTownID" name="frmTown" size="32" maxlength="60" value=""   tabindex=0 class="inputbox"></td>';
strAddContent = strAddContent + '</tr><tr><td class="genBoldText"; width="30"; align="Right";>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;County</td>';
strAddContent = strAddContent + '<td Width="70%"; align="center";><input id="frmCountyID" name="frmCounty" size="32" maxlength="60" value="" tabindex=0 class="inputbox"></td>';
strAddContent = strAddContent + '</tr><tr><td class="genBoldText"; width="30"; align="Right";>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;From&nbsp;Postcode</td><td Width="70%"; align="center";>';
strAddContent = strAddContent + '<input id="frmPostcodeID" name="frmPostcode" size="10" maxlength="10" value="" tabindex=0 class="inputboxup">';
strAddContent = strAddContent + '&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:showAddressPopup(1);" class="genLinkText";>Find Address</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr></table>';
document.getElementById('frmAddrContentID').innerHTML=strAddContent;
strAddContent = '';
}			
function fillFrmPlace()
{
document.getElementById('frmAddrContentID').innerHTML='';
strAddContent = '<table width="460" align="right"><tr><td height="5" width="155" align="right"><div class="genBoldText";>From&nbsp;Location</div>';
strAddContent = strAddContent + '<br/></td><td width="12"></td><td height="5" width="275" valign="middle">';
strAddContent = strAddContent + '<input id="frmPlaceLocID" style="display: inline; width:185px;" name="frmPlaceLoc" onkeyup="javascript:clickHandler(1)" size="32" maxlength="60"  class="inputbox" autocomplete="off"/>';
strAddContent = strAddContent + '<div id="ajsuggs"><div id="suggs"></div></div><br/></td></tr><tr><td height="5" width="180" align="right">';
strAddContent = strAddContent + '<br/></td><td width="12"></td><td height="5" width="250"><input id="frmPostcodeID" name="frmPostcode" value="" type="hidden"/>';
strAddContent = strAddContent + '</td></tr><tr><td height="5" width="180" align="right">&nbsp;</td><td width="12">&nbsp;</td><td height="5" width="250">&nbsp;</td>';
strAddContent = strAddContent + '</tr><tr><td height="5" width="180" align="right">&nbsp;</td><td width="12">&nbsp;</td><td height="5" width="250">&nbsp;</td>';
strAddContent = strAddContent + '</tr><tr><td height="5" width="180" align="right">&nbsp;</td><td width="12">&nbsp;</td><td height="5" width="250">&nbsp;</td>';
strAddContent = strAddContent + '</tr><tr><td height="5" width="180" align="right">&nbsp;</td><td width="12">&nbsp;</td><td height="5" width="250">&nbsp;</td>';
strAddContent = strAddContent + '</tr></table>';
document.getElementById('frmPlaceID').innerHTML = strAddContent;
}
function fillToAddr()
{
document.frmLocSelect.toType[2].checked=true;
document.getElementById('toPlaceID').innerHTML = '';
strAddContent = '';
strAddContent = strAddContent + '<table style="width:100%";><tr><td class="genBoldText"; width="30"; align="Right";>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;To&nbsp;Address</td>';
strAddContent = strAddContent + '<td Width="70%"; align="center";><input id="toAddress1ID" name="toAddress1" size="32" maxlength="60" value="" tabindex="0" class="inputbox"  ></td>';
strAddContent = strAddContent + '</tr><td class="genText"; width="30"; align="Right";>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Line&nbsp;2</td>';
strAddContent = strAddContent + '<td Width="70%"; align="center";><input id="toAddress2ID" name="toAddress2" size="32" maxlength="60" value="" tabindex=0 class="inputbox"  ></td></tr>';
strAddContent = strAddContent + '<tr><td class="genBoldText"; width="30"; align="Right";>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Town</td>';
strAddContent = strAddContent + '<td Width="70%"; align="center";><input id="toTownID" name="toTown" size="32" maxlength="60" value=""   tabindex=0 class="inputbox"></td>';
strAddContent = strAddContent + '</tr><tr><td class="genBoldText"; width="30"; align="Right";>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;County</td>';
strAddContent = strAddContent + '<td Width="70%"; align="center";><input id="toCountyID" name="toCounty" size="32" maxlength="60" value="" tabindex=0 class="inputbox"></td>';
strAddContent = strAddContent + '</tr><tr><td class="genBoldText"; width="30"; align="Right";>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;To&nbsp;Postcode</td><td Width="70%"; align="center";>';
strAddContent = strAddContent + '<input id="toPostcodeID" name="toPostcode" size="10" maxlength="10" value="" tabindex=0 class="inputboxup">';
strAddContent = strAddContent + '&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:showAddressPopup(2);" class="genLinkText";>Find Address</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr></table>';
document.getElementById('toAddrContentID').innerHTML=strAddContent;
}
function fillToPlace()
{
document.getElementById('toAddrContentID').innerHTML='';
strAddContent = '<table width="460" align="right"><tr><td height="5" width="155" align="right"><div class="genBoldText";>To&nbsp;Location</div>';
strAddContent = strAddContent + '<br/></td><td width="12"></td><td height="5" width="275">';
strAddContent = strAddContent + '<input id="toPlaceLocID" style="display: inline; width:185px;" name="toPlaceLoc" onkeyup="javascript:clickHandler(2)" size="32" maxlength="60"  class="inputbox" autocomplete="off"/>';
strAddContent = strAddContent + '<div id="toajsuggs"><div id="tosuggs"></div></div><br/></td></tr><tr><td height="5" width="180" align="right">';
strAddContent = strAddContent + '<br/></td><td width="12"></td><td height="5" width="250"><input id="toPostcodeID" name="toPostcode" value="" type="hidden"/>';
strAddContent = strAddContent + '</td></tr><tr><td height="5" width="180" align="right">&nbsp;</td><td width="12">&nbsp;</td><td height="5" width="250">&nbsp;</td>';
strAddContent = strAddContent + '</tr><tr><td height="5" width="180" align="right">&nbsp;</td><td width="12">&nbsp;</td><td height="5" width="250">&nbsp;</td>';
strAddContent = strAddContent + '</tr><tr><td height="5" width="180" align="right">&nbsp;</td><td width="12">&nbsp;</td><td height="5" width="250">&nbsp;</td>';
strAddContent = strAddContent + '</tr><tr><td height="5" width="180" align="right">&nbsp;</td><td width="12">&nbsp;</td><td height="5" width="250">&nbsp;</td>';
strAddContent = strAddContent + '</tr></table>';
document.getElementById('toPlaceID').innerHTML = strAddContent;
}

    function clickHandler(tgt) {
        
		var locStr;
		var locData;
		var inhtmltxt = '<div class="suggsHolder">';

		if (tgt == 1)
		{
		  locData = assVariables(1);
		  if (document.frmLocSelect.frmPlaceLoc.value.length >= 2)
		  {
			 var srchStr = document.frmLocSelect.frmPlaceLoc.value.toUpperCase();	
			 for (x in locData)
			 {
				locStr = locData[x][0].toUpperCase();
				if (locStr.indexOf(srchStr) >= 0)
				{
					inhtmltxt = inhtmltxt + '<a name="' + locData[x][1] + '" onclick="assnvalfrm(this.innerHTML,this.name)" href="#">' + locData[x][0] + '</a><br/>';
				}
			 }
			 inhtmltxt = inhtmltxt + '</div>';
//			   alert(inhtmltxt);

		  }

          document.getElementById("suggs").innerHTML = inhtmltxt;
		  if (document.getElementById("frmPlaceLocID").value == '')
		  {
				document.getElementById("suggs").innerHTML = '';
		  }
		}
		else if (tgt == 2)
		{
		  locData = assVariables(2);
		  if (document.frmLocSelect.toPlaceLoc.value.length >= 2)
		  {
			 var srchStr = document.frmLocSelect.toPlaceLoc.value.toUpperCase();	
			 for (x in locData)
			 {
				locStr = locData[x][0].toUpperCase();
				if (locStr.indexOf(srchStr) >= 0)
				{
					inhtmltxt = inhtmltxt + '<a name="' + locData[x][1] + '" onclick="assnvalto(this.innerHTML,this.name)" href="#">' + locData[x][0] + '</a><br/>';
				}
			 }
			 inhtmltxt = inhtmltxt + '</div>';
//			   alert(inhtmltxt);

		  }

          document.getElementById("tosuggs").innerHTML = inhtmltxt;
		  if (document.getElementById("toPlaceLocID").value == '')
		  {
				document.getElementById("tosuggs").innerHTML = '';
		  }
		}		
    }
    function assnvalfrm(cntry,pcode)
    {
        document.frmLocSelect.frmPlaceLoc.value = cntry;
        document.getElementById("suggs").innerHTML = '';
		document.frmLocSelect.frmPostcode.value = pcode;
//		alert(document.frmLocSelect.frmPlaceLoc.value + ' ' + document.frmLocSelect.frmPostcode.value);
    }
    function assnvalto(cntry,pcode)
    {
        document.frmLocSelect.toPlaceLoc.value = cntry;
        document.getElementById("tosuggs").innerHTML = '';
		document.frmLocSelect.toPostcode.value = pcode;
//		alert(document.frmLocSelect.frmPlaceLoc.value + ' ' + document.frmLocSelect.frmPostcode.value);
    }
    function assVariables(tgt)
    {
		if (tgt==1)
		{
			if (document.frmLocSelect.frmType[0].checked==true)
			{
				 return airportData;
			}
			else if (document.frmLocSelect.frmType[1].checked==true)
			{
				 return stationData;  
			}
			else if (document.frmLocSelect.frmType[3].checked==true)
			{
				 return placeData; 
			}
		}
		else if (tgt==2)
		{
			if (document.frmLocSelect.toType[0].checked==true)
			{
				 return airportData;
			}
			else if (document.frmLocSelect.toType[1].checked==true)
			{
				 return stationData;  
			}
			else if (document.frmLocSelect.toType[3].checked==true)
			{
				 return placeData; 
			}
		}
		
    }
    
function checkandsubmit()
{
document.frmLocSelect.imgstage.src='./images/imgProcessing.gif';
//alert(validateFrm());
if(validateFrm()==1) 
{
    document.frmLocSelect.submit();
} 
else 
{
    document.frmLocSelect.imgstage.src='./images/imgstep1.gif';
}
}    
    
function validateFrm()
{
var isvalid=1;
    if (document.frmLocSelect.frmType[0].checked || document.frmLocSelect.frmType[1].checked || document.frmLocSelect.frmType[3].checked)
    {
        if (document.frmLocSelect.frmPlaceLoc.value=='' || document.frmLocSelect.frmPostcode.value=='')
        {
            alert('Please select from location');
            isvalid=0;
            return isvalid;
        }
    }
    else if (document.frmLocSelect.frmType[2].checked)
    {
        if (document.frmLocSelect.frmAddress1.value=='' || document.frmLocSelect.frmPostcode.value=='' || document.frmLocSelect.frmTown.value=='')
        {
            alert('From address line 1,town and postcode are mandatory');
            isvalid=0;
            return isvalid;
        }
    }
    if (document.frmLocSelect.toType[0].checked || document.frmLocSelect.toType[1].checked || document.frmLocSelect.toType[3].checked)
    {
        if (document.frmLocSelect.toPlaceLoc.value=='' || document.frmLocSelect.toPostcode.value=='')
        {
            alert('Please select to location');
            isvalid=0;
            return isvalid;
        }
    }
    else if (document.frmLocSelect.toType[2].checked)
    {
        if (document.frmLocSelect.toAddress1.value=='' || document.frmLocSelect.toPostcode.value=='' || document.frmLocSelect.toTown.value=='')
        {
            alert('To address line 1,town and postcode are mandatory');
            isvalid=0;
            return isvalid;
        }
    }    
    //alert(isvalid); 
    
return isvalid;   
}    

var stationData = [
["Amersham Train/Tube Station","HP6 5AZ"],
["Berkhamsted Station","HP4 2JU"],
["Chesham Tube Station","HP5 1DQ"],
["Chorleywood Train/Tube Station","WD3 5NF"],
["Great Missenden Station","HP16 0BT"],
["Harpenden Station","AL5 4SP"],
["Apsley Train Station","HP3 9SX"],
["Hemel Hempstead Station","HP3 9BQ"],
["Kings Langley Station","WD4 8LL"],
["Chalfont & Latimer Train/Tube Station","HP6 6RZ"],
["Luton Airport Parkway Station","LU2 0ZZ"],
["Luton Station","LU1 2LT"],
["Moor Park Station","HA6 2JQ"],
["Northwood Tube Station","HA6 2XL"],
["Radlett Station","WD7 7AH"],
["Croxley Tube Station","WD3 3QZ"],
["Rickmansworth Train/Tube Station","WD3 2AE"],
["Carpenders Park Station","WD19 7DT"],
["St Albans-Bricket Wood Station","AL2 3LN"],
["St Albans-How Wood Station","AL2 2PA"],
["St Albans-Park Street Station","AL2 2PA"],
["St Albans Abbey Station","AL1 2DN"],
["St Albans City Station","AL1 3TD"],
["Tring Station","HP23 5QP"],
["Watford-Bushey Station","AL5 4SP"],
["Watford-Garston Station","WD25 9BA"],
["Watford-Watford Junction","WD17 1SR"],
["Watford North Station","WD24 7AB"],
["Watford Tube Station","WD1 7LL"],
["London Euston","NW1 2RT"]];
var airportData = [
["Heathrow Airport T 1","TW6 1NJ"],
["Heathrow Airport T 2","TW6 1NJ"],
["Heathrow Airport T 3","TW6 1NJ"],
["Heathrow Airport T 4","TW6 3XA"],
["Heathrow Airport T 5","TW6 2GA"],
["Gatwick Airport - South","RH6 0NP"],
["Gatwick Airport - North","RH6 0NP"],
["London City Airport","E16 2PX"],
["Luton Airport","LU2 9LY"],
["Stanstead Airport","CM24 1QW"]
];
var placeData = [
["Barnet-The Spires","EN5 5XY"],
["Ashridge Management College","HP4 1NS"],
["Berkhamsted Castle","HP4 1HD"],
["Borehamwood-The Metropolis Centre","WD6 1EH"],
["Broxbourne-Paradise Wildlife Park","EN10 7QA"],
["Bushey-Lincolnsfield Childrens Centre","WD23 2ES"],
["Dunstable-Quadrant Shopping Centre","LU5 4RH"],
["Dunstable-ZSL Whipsnade Zoo","LU6 2LF"],
["Harrow-St Anns Shopping Centre","HA1 1AT"],
["Hatfield-the galleria","AL10 0XR"],
["Hemel Bus Station","HP1 1ET"],
["Hemel Old Town","HP1 3AE"],
["Hemel General Hospital","HP2 4AD"],
["Hemel Jarman Park","HP2 4JW"],
["Hemel Leisure World","HP2 4JW"],
["Hemel Marlowes Shopping Centre","HP1 1DX"],
["Hemel Riverside Shopping Centre","HP1 1BT"],
["Hemel Town Centre","HP1 1EF"],
["Hendon-Brent Cross Shopping Centre","NW4 3FP"],
["Kings Langley-Langleybury Childrens Farm","WD4 8QQ"],
["London Colney-Willows Village Farm","AL4 0PF "],
["Luton-Arndale Shopping Centre","LU1 2LJ"],
["Luton-Woodside Animal Farm ","LU1 4LT"],
["St Albans-Christopher Shopping Centre","AL3 5DQ"],
["St Albans Musuem","AL1 3RR"],
["St Albans-The Maltings Shopping Centre","AL1 3HL"],
["St Albans-Verulamium Park","AL1 2DL"],
["Stevenage-Stevenage Leisure Park","SG1 2UA"],
["Stevenage-The Glebe Shopping Centre","SG2 0LX"],
["Stevenage-West Gate Shopping Centre","SG1 1QR"],
["Tring-The Natural History Museum","HP23 6AP"],
["Watford-Harlequin Shopping Centre","WD17 2UB"],
["Watford Museum","WD1 2HG"],
["Watford-Woodside Leisure Park","WD25 0TB"],
["Welwyn Garden City-Howard Centre","AL8 6HA"],
["Whitwell-Water Hall Farm and Tea Room","SG4 8BN"],
["Woburn Safari Park","MK17 9QN"]
];
