﻿function OpenServiceList(PCT) {
  newwindow = window.open('http://dev2.gtd.emerald-design.co.uk/PCTservices.aspx?PCT=' + PCT, 'PCTservices', 'height=800,width=600,scrollbars=1');
  if (window.focus) { newwindow.focus(); }
}
function FindMap(GTD_PC) {
  var PC = (document.getElementById('PracticeTabs_txtPostcode').value);
  if (PC.length > 0) {
    var link = ('http://maps.google.co.uk/maps?saddr=' + PC + '&daddr=' + GTD_PC);
    window.open(link, "mywindow");
  }
}
function loadmap(divid, postcode, zoom) {
  var map = null;
  var geocoder = null;
  var addr_num = 0;
  var addrs;
  var localSearch = new GlocalSearch();

  if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById(divid));
    map.addControl(new GSmallMapControl());
    //map.addControl(new GMapTypeControl());
    geocoder = new GClientGeocoder();
  }

  localSearch.setSearchCompleteCallback(null,
		function() {

		  if (localSearch.results[0]) {
		    var resultLat = localSearch.results[0].lat;
		    var resultLng = localSearch.results[0].lng;
		    var point = new GLatLng(resultLat, resultLng);
		    map.setCenter(point, zoom);
		    var marker = new GMarker(point);
		    map.addOverlay(marker);
		  } else {
		    document.getElementById(divid).style.display = 'none';
		  }
		});

  localSearch.execute(postcode + ", UK");
}
function createCookie1(name, value, days) {
  if (ReadCookie("GTDCookiesAllowed") != null) {
    var expires = "";
    if (days) {
      var date = new Date();
      date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
      expires = "; expires=" + date.toGMTString();
    }
    document.cookie = name + "=" + value + expires + "; path=/";
  }
}

function resizeText(multiplier) {
  if (document.body.style.fontSize == "") {
    document.body.style.fontSize = "0.75em";
  }

  switch (multiplier) {
    case 0:
      document.body.style.fontSize = "0.75em";
      break;
    case 1:
      document.body.style.fontSize = parseFloat(document.body.style.fontSize) + (1 * 0.1) + "em";
      break;
    case -1:
      if (document.body.style.fontSize != "0.75em") {
        document.body.style.fontSize = parseFloat(document.body.style.fontSize) + (-1 * 0.1) + "em";
      }
      break;
  }
  createCookie1('fontsize', parseFloat(document.body.style.fontSize), 365);
}


function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for (var i = 0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0) === ' ') {
      c = c.substring(1, c.length);
      if (c.indexOf(nameEQ) === 0) {
        return c.substring(nameEQ.length, c.length);
      }
    }
  }
  return null;
}

function eraseCookie(name) {
  if (ReadCookie("GTDCookiesAllowed") != null) {
    createCookie1(name, "", -1);
  } 
}

function loadTextSize() {
  var size = readCookie('fontsize');
  if (size !== null) {
    document.body.style.fontSize = readCookie('fontsize') + "em";
  }
}
function CallPrint(strid) {
  if (strid == 'bad') {
    alert('You cant print this page');
  } else {
    var prtContent = document.getElementById(strid);
    var WinPrint = window.open('', '', 'left=0,top=0,width=1,height=1,toolbar=0,scrollbars=1,status=0');
    WinPrint.document.write(prtContent.innerHTML);
    WinPrint.document.close();
    WinPrint.focus();
    WinPrint.print();
    WinPrint.close();
    prtContent.innerHTML = strOldOne;
  }
}
