/// -----------------------------------------------------------------------------
/// <procedure>externallinks</procedure>
/// <summary>
/// 	Opens external links in a new window whilst conforming xhtml strict standards
/// </summary>
/// <remarks>
/// </remarks>
/// <history>
/// 	[Gavin Bruce] 10/03/2007 Created
/// </history>
/// -----------------------------------------------------------------------------


function bookmarkPage(){
	if (window.sidebar) // firefox
		window.sidebar.addPanel(document.title, window.location.href, window.location.href);
	else if(document.all)// ie
		window.external.AddFavorite(window.location.href, document.title);
}

function externallinks()
{
    var c=document.getElementById('container');
    if(c)
    {
        var ls=c.getElementsByTagName('a');
        for(var i=0;i<ls.length;i++){
            if(ls[i].getAttribute('rel')=='external')
            {
                ls[i].onclick=function(){window.open(this.href);return false}
            }
        }
    }
}

window.onload=function(){
    if(!document.getElementById && !document.createTextNode){return;}
    externallinks();

    //execute the loadmap function for the google map.
    if (document.getElementById('googlemap')) {
        loadmap();
    }
}

window.onunload=function() {
	 //execute the loadmap function for the google map.
    if (document.getElementById('googlemap')) {
		GUnload();
    }
}



	//dhtml rows code
ie = document.all?1:0;
ns4 = document.layers?1:0;




// a few functions for google maps

var icons = {};

var iconData = {
  "mapicon": { width: 39, height: 30 },
  "mapicon-shadow": { width: 52, height: 30 } //removed , - ie7 js error
}

function getIcon(images) {
  var icon = null;
  if (images) {
    if (icons[images[0]]) {
      icon = icons[images[0]];
    } else {
      icon = new GIcon();
      icon.image = "/media/images/" + images[0] + ".png";
      var size = iconData[images[0]];
      icon.iconSize = new GSize(size.width, size.height);
      icon.iconAnchor = new GPoint(size.width/2, size.height);
      icon.infoWindowAnchor = new GPoint(size.width, 0);
      icon.shadow = "/media/images/" + images[1] + ".png";
      size = iconData[images[1]];
      icon.shadowSize = new GSize(size.width, size.height);
      icons[images[0]] = icon;
    }
  }
  return icon;
}

function createMarker(point, name, html) {
  var icon = getIcon(["mapicon", "mapicon-shadow"]);
  var marker = new GMarker(point, { title: name, icon: icon });
  GEvent.addListener(marker, "click", function() {
    //map.setCenter(marker.getPoint(), 13);
    marker.openInfoWindowHtml(html);
  });
  return marker;
}


function setupEventMarkers() {
  mgr = new GMarkerManager(map);
  for (var i in eventsLayer) {
    var layer = eventsLayer[i];
    var markers = [];
    for (var j in layer["places"]) {
      var place = layer["places"][j];
      var posn = new GLatLng(place["posn"][0], place["posn"][1]);
      markers.push(createMarker(posn, place['name'], place['html']));
    }
    mgr.addMarkers(markers, layer["zoom"][0], layer["zoom"][1]);
  }
  mgr.refresh();
}

function everyday_indulgence_phone(id) {
	if (document.getElementById('phonenumber').style.visibility != 'visible') {
		document.getElementById('phonenumber').style.visibility = 'visible';
		document.getElementById('phonenumberclick').style.visibility = 'hidden';
		frames['everydayindulgence'].location.href = 'stat.php?s=p&id=' + id;
	}
}
function everyday_indulgence_website(id) {
	frames['everydayindulgence'].location.href = 'stat.php?s=w&id=' + id;
}
function everyday_indulgence_website2(id, url) {
	frames['everydayindulgence'].location.href = 'stat.php?s=w&id=' + id;
	window.open(url);
}

function everyday_indulgence_enquiry() {
	if (document.getElementById('enquiryform').style.display != 'block') {
		document.getElementById('enquiryform').style.display = 'block';
	} else {
		document.getElementById('enquiryform').style.display = 'none';
	}
}

