// Gazetteer for Scotland JavaScript Functions (c) Bruce M. Gittings, 2008

// JavaScript One-Off Alert (c) Bruce M. Gittings / The Gazetteer for Scotland, 2004.  Please keep this copyright with the code
var pmap = '';
var pmap2 = '';
var pmap3 = '';
Msg = "All Images and Text are Copyright (c) The Gazetteer for Scotland 1995-"+new Date().getFullYear()+". \n\nThe Editors thank you for respecting our copyright. It has taken us a great deal of time and \nmoney to assemble this information and, in the interests of ensuring the future of this web \nsite, we have to protect our text and images from theft. \n\nIn brief, you may link to this page or copy the information for your own personal use only. \nYou must not make our text or images available on another web site, or use them \ncommercially, without permission. \n\nPlease read our detailed copyright statement linked from the bottom of each page for \nfurther information. \n\nPress OK and repeat your right-click to access the usual menu."
DoneIt = false; IsNS = navigator.appName=="Netscape"; document.onmousedown = DoIt; 
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (IsNS&&parseInt(navigator.appVersion)<5) window.onmousedown = DoIt;

function DoIt(a) 
{ if (DoneIt) { return true }
  else if ((IsNS&&a.which>1)||(navigator.appName=="Microsoft Internet Explorer"&&(event.button>1))) { DoneIt=true; alert(Msg); return false } 
}

// Tracking stuff

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-16707816-1']);
_gaq.push(['_trackPageview']);

(function() {
   var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
   ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

function loadmapquest08()
{
var load = window.open('/scotgaz/mapquest_feedback08.html','QuestWin',
'scrollbars=yes,menubar=no,height=700,width=1000,resizable=yes,toolbar=no,location=no,status=yes,top=200,left=150');
}

function popupModMap(e,n)
{
  window.open('http://getamap.ordnancesurvey.co.uk/getamap/frames.htm?mapAction=zoomabs&mapX='+e+'&mapY='+n+'&zoomLevel=6&isGeo=y',
    'ModMapWin','width=580,height=520,resizable=no,scrollbars=no,status=no,top=200,left=100');
}

function popupPhotoMap(e,n,nam,zm)



{
  if (!pmap.closed && pmap.location)
  {
    var newURL = 'http://www.scottish-places.info/pmap.html?I:'+e+'|'+n+'|'+zm+'|'+nam;
    pmap.location= newURL;
    pmap.location.reload(true);
  }
  else
  {
    pmap = window.open('http://www.scottish-places.info/pmap.html?I:'+e+'|'+n+'|'+zm+'|'+nam,
    'PhotoMapWin','width=700,height=500,resizable=no,scrollbars=no,status=no,top=200,left=100');
  }
}

function popup20thMap(e,n,nam,zm)

// http://nls.tileserver.com/?lat=55.9&lng=-2.8&zoom=13
// fix zoom rather than varying from page ??

{
  if (!pmap2.closed && pmap2.location)
  {
    var newURL = 'http://www.scottish-places.info/pmap.html?P:'+e+'|'+n+'|'+zm+'|'+nam;
    pmap2.location= newURL;
    pmap2.location.reload(true);
  }
  else
  {
    pmap2 = window.open('http://www.scottish-places.info/pmap.html?P:'+e+'|'+n+'|'+zm+'|'+nam,
    'p20thMapWin','width=700,height=500,resizable=no,scrollbars=no,status=no,top=140,left=100');
  }
}

function popup19thMap(lat,long,zm)
{
  if (!pmap3.closed && pmap3.location)
  {
    var newURL = 'http://www.scottish-places.info/tmap.html?'+lat+'|'+long+'|'+zm;
    pmap3.location= newURL;
    pmap3.location.reload(true);
  }
  else
  {
    pmap3 = window.open('http://www.scottish-places.info/tmap.html?'+lat+'|'+long+'|'+zm,
    'OldMapWin2','width=700,height=500,resizable=no,scrollbars=no,status=no,top=140,left=100');
  }
}

function popupMagicMap(e,n)
{
  window.open('http://www.magic.gov.uk/website/magic/viewer.htm?startTopic=magicall&chosenLayers=gazIndex&startScale=8000&xygridref='+e+','+n,
    'MagicMapWin','width=700,height=500,resizable=no,scrollbars=no,status=no,top=200,left=100');
}

function popupHistMap(e,n)
{
// alert("We are sorry, but historical maps are temporarily unavailable because Landmark Information Group are updating their Old Maps Service, on which we rely.");
  window.open('http://www.old-maps.co.uk/indexmappage2.aspx?action=forcexy&easting='+e+'&northing='+n,
    'HistMapWin','width=790,height=850,resizable=no,scrollbars=no,status=no,top=100,left=250');
}

function popupBuyMap(e,n)
{
  window.open('http://www.ordnancesurvey.co.uk/oswebsite/jsp/mapshop/grLink.jsp?shop_id=193&scale=50k&x='+e+'&y='+n,
    'BuyMapWin','width=780,height=600,toolbar=yes,scrollbars=yes,top=0,left=0');
}

function popupBuyMap25K(e,n)
{
  window.open('http://www.ordnancesurvey.co.uk/oswebsite/jsp/mapshop/grLink.jsp?shop_id=193&scale=25k&x='+e+'&y='+n,
    'BuyMapWin','width=780,height=600,toolbar=yes,scrollbars=yes,top=0,left=0');
}

function popupDirMap(gridref)
{
  window.open('http://www.multimap.com/directions/?qs_1='+document.DirMap.startpc.value+'&qs_2='+gridref,
    'DirWin','width=1000,height=600,resizable=yes,scrollbars=yes,menubar=yes,top=300,left=0');
}

function popupGDirMap(lat,long)
{
  window.open('http://maps.google.com/maps?f=d&saddr='+document.DirMap.startpc.value+'&daddr='+lat+'+'+long,
    'DirWin','width=1000,height=600,resizable=yes,scrollbars=yes,menubar=yes,top=300,left=0');
}

function popupGloss()
{
  window.open('/scotgaz/glossw.html',
    'GlossWin','width=640,height=400,resizable=no,scrollbars=yes,status=no,top=300,left=0');
}

function popupDonate(r)
{
  var ref = r;
//  alert(ref);
  window.open('/scotgaz/donate.html',
    'DonateWin','width=790,height=690,resizable=no,scrollbars=yes,status=no,top=100,left=0');
}


function popupHelp(link)
{
  window.open('/scotgaz/newhelp.html#'+link,
    'HelpWin','width=780,height=600,toolbar=yes,scrollbars=yes,top=0,left=0');
}


var which='';
function ShowHide()
{
 changeCSS('.hiderows','display',which)
 if (which=='none') { which = '' }
 else { which = 'none' }
}

function changeCSS(Class,element,value) {
 var cssr;
 if (document.all) {
  cssr = 'rules';
 }
 else if (document.getElementById) {
  cssr = 'cssRules';
 }
 for (var S = 0; S < document.styleSheets.length; S++){
  for (var R = 0; R < document.styleSheets[S][cssr].length; R++) {
   if (document.styleSheets[S][cssr][R].selectorText == Class) {
        document.styleSheets[S][cssr][R].style[element] = value;
   }
  }
 }
}

function getGKey(){
    myregexp = new RegExp("geo.ed.ac.uk|scottish-people.info|scottish-places.info");
    var domain = myregexp.exec(location.href);
    if (domain == "geo.ed.ac.uk")
        { return ("ABQIAAAA9HgLrFcAOwVKi-3zLqbtcBRKKyPFEeGLJcsXwrPDEkPPw1Cn-RREHs8cmtO2fN2R92vb2ZKuSmCHPA") }
    else if (domain == "scottish-people.info")
        { return ("ABQIAAAA9HgLrFcAOwVKi-3zLqbtcBT9OHyM70jBt22L4PN2wKFPefFpyBQTuD3vKTMzAmUODutc2wnSzzviYA") }
    else if (domain == "scottish-places.info")
        { return ("ABQIAAAA9HgLrFcAOwVKi-3zLqbtcBS8l0DC_sSy90v66r8v8bE0sQQ0dBS0D9BtvHBkBKsHUAL1fubnGjI1yA") }
    else { alert("Invalid domain / map combination"); return; }
}


