var map = null;
var footer = null;
var pinid = 1;
var mymapid = 0;
var hidenav = 0;
var nointeract = false;
var maptype = 'h'; //h=hybrid, a=aerial, r=road

function GetInfo()
{
    var tmpstring=map.GetCenter().toString();
    var lat_lon_array=tmpstring.split(',');
    alert('Latitude: '+lat_lon_array[0]+'\r\nLongitude: '+lat_lon_array[1]+'\r\nZoom Level: '+map.GetZoomLevel());
    //alert('The top edge of the map on the Web page is at pixel: '+map.GetTop());
    //alert('The left edge of the map on the Web page is at pixel: '+map.GetLeft());
    //alert('The map control version is: '+VEMap.GetVersion());
} 
function ResetPosition(n)
{
    if (n == null) n=mymapid; //pick up the correct map if map number not supplied
    if      (n == 1) map.LoadMap(new VELatLong(55.6170,-4.6990), 14 ,maptype ,nointeract); //Ardeer
    else if (n == 2) map.LoadMap(new VELatLong(55.63531,-4.70927), 14 ,maptype ,nointeract); //Ardeer East Garnock
    else if (n == 3) map.LoadMap(new VELatLong(53.89043,-3.00467), 14 ,maptype ,nointeract); //Thornton Cleveleys
    else if (n == 4) map.LoadMap(new VELatLong(53.91364,-2.997204), 12 ,maptype ,nointeract); //Preesall
    else if (n == 5) map.LoadMap(new VELatLong(53.266342,-2.519903), 15 ,maptype ,nointeract); //Furey's
    else if (n == 6) map.LoadMap(new VELatLong(53.259617,-2.483682), 15 ,maptype ,nointeract); //Griffiths Park / Middlewich Road
    else if (n == 7) map.LoadMap(new VELatLong(53.243338,-2.464628), 14 ,maptype ,nointeract); //King Street
    else if (n == 8) map.LoadMap(new VELatLong(53.262132,-2.534966), 14 ,maptype ,nointeract); //Winnington Avenue
    else if (n == 9) map.LoadMap(new VELatLong(53.255087,-2.561869), 14 ,maptype ,nointeract); //Weaverham
    else if (n == 10) map.LoadMap(new VELatLong(53.273259,-2.449715), 14 ,maptype ,nointeract); //Longwood Farm //Longwood Farm_Cheshire_YQ3W3438_180.jpg
    else if (n == 11) map.LoadMap(new VELatLong(53.273361,-2.453202), 14 ,maptype ,nointeract); //Lostock //Lostock_Cheshire_YQ3W3444_180.jpg
    else if (n == 12) map.LoadMap(new VELatLong(53.268536,-2.444801), 14 ,maptype ,nointeract); //Octel //Octel_Cheshire_YQ3W3434_180.jpg
    else if (n == 13) map.LoadMap(new VELatLong(53.276499,-2.451828 ), 14 ,maptype ,nointeract); //Winnington Wood //Winnington_Wood_Cheshire_YQ3W3440_180.jpg
    else             n=0; //USE THE DEFAULT VIEW
    if (n == 0){
        map.LoadMap(new VELatLong(53.89043,-3.00000), 6 ,'a' ,nointeract); //DEFAULT TO MOST OF UK
        AddPins(1); //BUT SET THE FLAG TO REPOSITION AND RESCALE FOR BEST FIT
    }else{
        AddPins(0); //ADD ALL THE PINS KEEPING THE CURRENT VIEW INTACT
    }
    if (hidenav == 1){
        map.HideDashboard();
    }
}
function GetMap()
{
    map = new VEMap('myMap');
    ResetPosition(mymapid);
}
function AddPins(n)
{
    var locs = new Array;
    var nams = new Array;
    var dtls = new Array;
    var dtlpre = '<div style="font-size:8pt;text-align:justify;">'

    var loc = new VELatLong(55.60875,-4.6945);
    locs.push(loc);
    nams.push('Ardeer - Millennium Building');
    dtls.push(dtlpre+'<IMG alt="Ardeer - Millenium Building" src="/Portals/0/Ardeer-AllImages/pin1.jpg" border=0"><BR>This fantastic building is being considered by BBC and other production companies as a filming location. </div>');
    
    var loc = new VELatLong(55.61476498859007,-4.706354141235359);
    locs.push(loc);
    nams.push('Energetics Expansion');
    dtls.push(dtlpre+'<IMG alt="Energetics Expansion" src="/Portals/0/Ardeer-AllImages/pin2.jpg" border=0"><BR>This land will be used to safeguard the adjacent Energetics businesses.</div>');

    var loc = new VELatLong(55.628989308063574,-4.721674919128422);
    locs.push(loc);
    nams.push('Large Manufacturing Site');
    dtls.push(dtlpre+'<IMG alt="Large Manufacturing Site" src="/Portals/0/Ardeer-AllImages/pin3.jpg" border=0"><BR>This former power station area is being promoted by Scottish Enterprise for various industrial uses.</div>');

    var loc = new VELatLong(55.63061253934359,-4.732038974761963);
    locs.push(loc);
    nams.push('Business Park');
    dtls.push(dtlpre+'<IMG alt="Business Park" src="/Portals/0/Ardeer-AllImages/pin4.jpg" border=0"><BR>Land allocated to provide smart new office complexes.</div>');

    var loc = new VELatLong(55.634900453767784,-4.734592437744129);
    locs.push(loc);
    nams.push('Housing Phase 1');
    dtls.push(dtlpre+'<IMG alt="Housing Phase 1" src="/Portals/0/Ardeer-AllImages/pins5-7-12.jpg" border=0"><BR>Area for required growth in Ayrshire\'s Housing Needs.</div>');

    var loc = new VELatLong(55.6362206493186,-4.7375321388244584);
    locs.push(loc);
    nams.push('Park &amp; Ride');
    dtls.push(dtlpre+'<IMG alt="Park &amp; Ride" src="/Portals/0/Ardeer-AllImages/pin6.jpg" border=0"><BR>A new privately funded station incorporating Park &amp; Ride facilities together with cycle route provision.</div>');

    var loc = new VELatLong(55.63657188651413,-4.7279834747314515);
    locs.push(loc);
    nams.push('Housing Phase 2');
    dtls.push(dtlpre+'<IMG alt="Housing Phase 2" src="/Portals/0/Ardeer-AllImages/pins5-7-12.jpg" border=0"><BR>Area required for future growth in Ayrshire\'s Housing Needs.</div>');

    var loc = new VELatLong(55.63288979526254,-4.720945358276371);
    locs.push(loc);
    nams.push('Public Facilities');
    dtls.push(dtlpre+'<IMG alt="Public Facilities" src="/Portals/0/Ardeer-AllImages/pin8.jpg" border=0"><BR>Area envisaged for sports and other social recreation requirements.</div>');

    var loc = new VELatLong(55.63783146987203,-4.721975326538072);
    locs.push(loc);
    nams.push('Sand Extraction');
    dtls.push(dtlpre+'<IMG alt="Sand Extraction" src="/Portals/0/Ardeer-AllImages/pin9.jpg" border=0"><BR>Ongoing sand operations will continue.</div>');

    var loc = new VELatLong(55.635215366838345,-4.704208374023441);
    locs.push(loc);
    nams.push('Sand Extraction');
    dtls.push(dtlpre+'<IMG alt="Sand Extraction" src="/Portals/0/Ardeer-AllImages/pin10.jpg" border=0"><BR>Proposed operations will create new Wetland habitat enhancing the area\'s ecology.</div>');

    var loc = new VELatLong(55.620193617316694,-4.692535400390638);
    locs.push(loc);
    nams.push('SSI');
    dtls.push(dtlpre+'<IMG alt="SSI" src="/Portals/0/Ardeer-AllImages/pin11.jpg" border=0"><BR>Existing SSI will be protected with potential for managed levels of access.</div>');

    var loc = new VELatLong(55.62688142979156,-4.7424030303955025);
    locs.push(loc);
    nams.push('Beach Park Housing');
    dtls.push(dtlpre+'<IMG alt="Beach Park Housing" src="/Portals/0/Ardeer-AllImages/pins5-7-12.jpg" border=0"><BR>A new housing development proposed to offer enhanced grade availability.</div>');

    var loc = new VELatLong(53.88795,-2.99737);
    locs.push(loc);
    nams.push('Hillhouse Business Park, Thornton Cleveleys');
    dtls.push(dtlpre+'<IMG alt="Hillhouse Business Park, Thornton Cleveleys" src="/Portals/0/Thornton-AllImages/Thornton_Cleveleys_YQ3W3584_180.jpg" border=0"><BR> </div>');

    var loc = new VELatLong(53.893521,-3.017678);
    locs.push(loc);
    nams.push('Burnhall Site, Thornton-Cleveleys');
    dtls.push(dtlpre+'<IMG alt="Burnhall Site, Thornton-Cleveleys" src="/Portals/0/Thornton-AllImages/Fleetwood_Road_Thornton_YQ3W3572_180.jpg" border=0"><BR> </div>');

    var loc = new VELatLong(53.9141689,-2.9685938);
    locs.push(loc);
    nams.push('Preesall - Five Lane Ends');
    dtls.push(dtlpre+'<IMG alt="Preesall - Five Lane Ends" src="/Portals/0/Preesall-AllImages/Preesall_Five_Lanes_End_YQ3W3597_180.jpg" border=0"><BR> </div>');

    var loc = new VELatLong(53.910848,-2.9679608);
    locs.push(loc);
    nams.push('Preesall - Pump House');
    dtls.push(dtlpre+'<IMG alt="Preesall - Pump House" src="/Portals/0/Preesall-AllImages/Pump_House_Preesall_YQ3W3596_180.jpg" border=0"><BR> </div>');

    var loc = new VELatLong(53.898554,-2.9620814);
    locs.push(loc);
    nams.push('Preesall - Stalmine');
    dtls.push(dtlpre+'<IMG alt="Preesall - Stalmine" src="/Portals/0/Preesall-AllImages/Preesall_Stalmine_YQ3W3585_180.jpg" border=0"><BR> </div>');

    var loc = new VELatLong(53.9248375,-2.98115730);
    locs.push(loc);
    nams.push('Preesall - Knott End On Sea');
    dtls.push(dtlpre+'<IMG alt="Preesall - Knott End On Sea" src="/Portals/0/Preesall-AllImages/Knott_End_On_Sea_Preesall_YQ3W3606_180.jpg" border=0"><BR> </div>');

    var loc = new VELatLong(53.26018,-2.48354);
    locs.push(loc);
    nams.push('Griffiths Park - Cheshire');
    dtls.push(dtlpre+'<IMG alt="Griffiths Park - Cheshire" src="/Portals/0/Cheshire-AllImages/Griffiths_Park_Cheshire_YQ3W3424_180.jpg" border=0"><BR> </div>');

    var loc = new VELatLong(53.2608876,-2.490892);
    locs.push(loc);
    nams.push('Middlewich Road - Cheshire');
    dtls.push(dtlpre+'<IMG alt="Middlewich Road - Cheshire" src="/Portals/0/Cheshire-AllImages/Middlewich_Road_Cheshire_YQ3W3427_180.jpg" border=0"><BR> </div>');

    var loc = new VELatLong(53.244365,-2.46437);
    locs.push(loc);
    nams.push('King Street - Cheshire');
    dtls.push(dtlpre+'<IMG alt="King Street - Cheshire" src="/Portals/0/Cheshire-AllImages/King_Street_king_3_180.jpg" border=0"><BR> </div>');

    var loc = new VELatLong(53.241232,-2.473126);
    locs.push(loc);
    nams.push('Rudheath - Cheshire');
    dtls.push(dtlpre+'<IMG alt="Rudheath - Cheshire" src="/Portals/0/Cheshire-AllImages/Rudheath_YQ3W3410_180.jpg" border=0"><BR> </div>');

    var loc = new VELatLong(53.266701,-2.518358);
    locs.push(loc);
    nams.push('Furey\'s - Cheshire');
    dtls.push(dtlpre+'<IMG alt="Furey\'s - Cheshire" src="/Portals/0/Cheshire-AllImages/Furys_Cheshire_YQ3W3459_180.jpg" border=0"><BR> </div>');

    var loc = new VELatLong(53.262132,-2.534966);
    locs.push(loc);
    nams.push('Winnington Avenue - Cheshire');
    dtls.push(dtlpre+'<IMG alt="Winnington Avenue - Cheshire" src="/Portals/0/Cheshire-AllImages/Winnington_Avenue_Cheshire_YQ3W3463_180.jpg" border=0"><BR> </div>');

    var loc = new VELatLong(53.267382,-2.561123);
    locs.push(loc);
    nams.push('Former BWB Lagoon - Cheshire');
    dtls.push(dtlpre+'<IMG alt="Former BWB Lagoon - Cheshire" src="/Portals/0/Cheshire-AllImages/Former_Canal_Dredging_Lagoon_Cheshire_YQ3W3467_180.jpg" border=0"><BR> </div>');

    var loc = new VELatLong(53.273259,-2.449715);
    locs.push(loc);
    nams.push('Longwood Farm - Cheshire');
    dtls.push(dtlpre+'<IMG alt="Longwood Farm" src="/Portals/0/Cheshire-AllImages/Longwood Farm_Cheshire_YQ3W3438_180.jpg" border=0"><BR> </div>');

    var loc = new VELatLong(53.273361,-2.453202);
    locs.push(loc);
    nams.push('Lostock - Cheshire');
    dtls.push(dtlpre+'<IMG alt="Lostock - Cheshire" src="/Portals/0/Cheshire-AllImages/Lostock_Cheshire_YQ3W3444_180.jpg" border=0"><BR> </div>');

    var loc = new VELatLong(53.268536,-2.444801);
    locs.push(loc);
    nams.push('Octel site - Cheshire');
    dtls.push(dtlpre+'<IMG alt="Octel site - Cheshire" src="/Portals/0/Cheshire-AllImages/Octel_Cheshire_YQ3W3434_180.jpg" border=0"><BR> </div>');

    var loc = new VELatLong(53.276499,-2.451828);
    locs.push(loc);
    nams.push('Winnington Wood - Cheshire');
    dtls.push(dtlpre+'<IMG alt="Winnington Wood - Cheshire" src="/Portals/0/Cheshire-AllImages/Winnington_Wood_Cheshire_YQ3W3440_180.jpg" border=0"><BR> </div>');

    var loc = new VELatLong(53.257113,-2.556746);
    locs.push(loc);
    nams.push('Weaverham - Cheshire');
    dtls.push(dtlpre+'<IMG alt="Weaverham - Cheshire" src="/Portals/0/Cheshire-AllImages/Weaverham_I_Cheshire_YQ3W3468_180.jpg" border=0"><BR> </div>');

    var loc = new VELatLong(53.252839,-2.5696805);
    locs.push(loc);
    nams.push('Weaverham - Cheshire');
    dtls.push(dtlpre+'<IMG alt="Weaverham - Cheshire" src="/Portals/0/Cheshire-AllImages/Weaverham_II_Cheshire_YQ3W3472_180.jpg" border=0"><BR> </div>');

//BSL below here - comment out until ready

//    var loc = new VELatLong(53.2531985,-2.4669456);
//    locs.push(loc);
//    nams.push('Cooke\'s Lane - Cheshire');
//    dtls.push(dtlpre+'<IMG alt="Cooke\'s Lane - Cheshire" src="/Portals/0/Cheshire-AllImages/Cookes_Lane_Cheshire_YQ3W3421_180.jpg" border=0"><BR> </div>');

//    var loc = new VELatLong(53.278609,-2.486429);
//    locs.push(loc);
//    nams.push('Wincham Lane (large section)');
//    dtls.push(dtlpre+'<IMG alt="Wincham Lane (large section)" src="/Portals/0/NNN-AllImages/NNN.jpg" border=0"><BR> </div>');

//    var loc = new VELatLong(53.284049,-2.4958705);
//    locs.push(loc);
//    nams.push('Wincham Lane (small section)');
//    dtls.push(dtlpre+'<IMG alt="Wincham Lane (small section)" src="/Portals/0/NNN-AllImages/NNN.jpg" border=0"><BR> </div>');

//    var loc = new VELatLong(53.17954957,-2.4295234);
//    locs.push(loc);
//    nams.push('Cledford Lane / Faulkner Drive');
//    dtls.push(dtlpre+'<IMG alt="Cledford Lane / Faulkner Drive" src="/Portals/0/NNN-AllImages/NNN.jpg" border=0"><BR> </div>');

//    var loc = new VELatLong(53.1406182,-2.456946);
//    locs.push(loc);
//    nams.push('Hole House Farm');
//    dtls.push(dtlpre+'<IMG alt="Hole House Farm" src="/Portals/0/NNN-AllImages/NNN.jpg" border=0"><BR> </div>');

//    var loc = new VELatLong(53.1443507,-2.4613666);
//    locs.push(loc);
//    nams.push('Parkfields Farm');
//    dtls.push(dtlpre+'<IMG alt="Parkfields Farm" src="/Portals/0/NNN-AllImages/NNN.jpg" border=0"><BR> </div>');

//    var loc = new VELatLong(53.149807,-2.4482989);
//    locs.push(loc);
//    nams.push('Hilltop Farm');
//    dtls.push(dtlpre+'<IMG alt="Hilltop Farm" src="/Portals/0/NNN-AllImages/NNN.jpg" border=0"><BR> </div>');

//    var loc = new VELatLong(53.12704956,-2.427635);
//    locs.push(loc);
//    nams.push('Bottoms Farm');
//    dtls.push(dtlpre+'<IMG alt="Bottoms Farm" src="/Portals/0/NNN-AllImages/NNN.jpg" border=0"><BR> </div>');

    for (i=0; i < locs.length; i++)
    {
        var pin = new VEPushpin(pinid, locs[i], '/Portals/0/Skins/Snow_White_Skin/images/bul.gif', nams[i], dtls[i]);
        map.AddPushpin(pin);
        pinid++;
    }
    if (n != 0) map.SetMapView(locs); //IF FLAG SET, REPOSITION AND RESCALE FOR BEST FIT
}

function addEvent(obj, evType, fn)
{ 
    if (obj.addEventListener){ 
        obj.addEventListener(evType, fn, true); 
        return true; 
    }
    else if (obj.attachEvent)
    { 
        var r = obj.attachEvent("on"+evType, fn); 
        return r; 
    }
    else
    { 
        return false; 
    } 
}


function mapbig(){
 e=document.getElementById("myMap");
 e.style.width = '770px';
 e.style.height = '460px';
// t=setTimeout("mapbig();",0);
 hidenav=0;
 ResetPosition();
}
function mapsmall(){
 e=document.getElementById("myMap");
 e.style.width = '300px';
 e.style.height = '180px';
 //t=setTimeout("mapsmall();",0);
 hidenav=1;
 ResetPosition();
}

