var isNN4,isNN7, isIE
var coll = "";
var styleObj = "";
var hidden, visible;
var IEversion = true;
visible = 'visible'
hidden = 'hidden'
if (parseInt(navigator.appVersion)>=4){
	if(navigator.appName == "Netscape") {
	   if (parseInt(navigator.appVersion)==4){
		  isNN4 = true;
    	  visible = 'show';
  	      hidden = 'hide';
		} else {
		  isNN7 = true;
		}
	} else {
		isIE = true;
		coll ="all.";
		styleObj = ".style";
	}
}

function writeMainMenu(){
var html = "<table cellpadding=0 cellspacing=0 border=0>";
	   	   html += "<tr><td><div id=\"menu\"><ul id=\"rollovermenu\"><a></a>";
	   	   html += "<li id=\"events\">&nbsp;&nbsp;<b>Menu</b><ul>";
	   	   html += "<li><br><span class=mainmenu>About</span></li>";
	   	   html += "<li><a href=\"who.html\">Who we are</a></li>";
	   	   html += "<li><a href=\"fnct.html\">Friends of North Country Theatre</a></li>";
	   	   html += "<li><a href=\"how.html\">How to book a performance</a></li>";
	   	   html += "<li><a href=\"contact.html\">Contact</a></li>";
	   	   html += "<li><br><span class=mainmenu>Performances</span></li>";
	   	   html += "<li><a href=\"what.html\">What's on</a></li>";
	   	   html += "<li><a href=\"site.html\">Site specific</a></li>";
	   	   html += "<li><a href=\"education.html\">Education</a></li>";
	   	   html += "<li><a href=\"past.html\">Past performances</a></li>";
	   	   html += "<li><br><span class=mainmenu>News</span></li>";
	   	   html += "<li><a href=\"latest.html\">Latest news</a></li>";
	   	   html += "<li><a href=\"olivier.html\">Olivier Award winners <img src=\"images/news.gif\" width=12 height=12 border=0></a></li>";
	   	   html += "<li><a href=\"comment.html\">Reviews &amp; comment</a></li>";
	   	   html += "<li><a href=\"archive.html\">Archive</a></li>";
	   	   html += "<li><br><a href=\"index.html\">HOME</a><br></li></ul>";
	   	   html += "</li></ul></div></td></tr>";
		   html += "</table>";
writeOut("mainmenu",html)
}

function writeMenuBottom(){
var html = "<table cellpadding=2 cellspacing=0 border=0 width=731 height=15px class=menubottom>";
	   	   html += "<tr bgcolor=#cccc99><td align=left class=cr>&nbsp;&nbsp;Copyright&copy; 2002 - 2011 North Country Theatre - All rights reserved";
	   	   html += "</td></tr>";
		   html += "</table>";
writeOut("menubottom",html)
}


function writeOut(div,content){
var cObj = document.getElementById(div);
 if (isIE||isNN7){
   cObj.style.visibility = visible;
   cObj.innerHTML = content;
 } else {
  cObj.visibility = visible;
  var cDoc = document.layers[div].document;
  cDoc.open();
  cDoc.writeln(content);
  cDoc.close();
 }
}



sfHover = function() {
	var sfEls = document.getElementById("rollovermenu").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);



sfHover = function() {
	var sfEls = document.getElementById("aboutrollovermenu").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);



sfHover = function() {
	var sfEls = document.getElementById("perfrollovermenu").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);



sfHover = function() {
	var sfEls = document.getElementById("newsrollovermenu").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);



var map;
var icon0;
var newpoints = new Array();
 
function addLoadEvent(func) { 
	var oldonload = window.onload; 
	if (typeof window.onload != 'function'){ 
		window.onload = func
	} else { 
		window.onload = function() {
			oldonload();
			func();
		}
	}
}
 
addLoadEvent(loadMap);
addLoadEvent(addPoints);
 
function loadMap() {
	map = new GMap2(document.getElementById("map"));
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
	map.setCenter(new GLatLng( 54.24383, -1.69187), 9);
	map.setMapType(G_NORMAL_MAP);
 
	icon0 = new GIcon();
	icon0.image = "http://www.google.com/mapfiles/marker.png";
	icon0.shadow = "http://www.google.com/mapfiles/shadow50.png";
	icon0.iconSize = new GSize(20, 34);
	icon0.shadowSize = new GSize(37, 34);
	icon0.iconAnchor = new GPoint(9, 34);
	icon0.infoWindowAnchor = new GPoint(9, 2);
	icon0.infoShadowAnchor = new GPoint(18, 25);
}
 
function addPoints() {

    newpoints[0] = new Array(54.34739, -1.566455, icon0, '1906', 'Egil Skallagrimson Keeps his Head<br><br>Friday 17th February<br>Kirkby Fleetham Village Hall<br>DL7 0TX<br>01609 748258');

    newpoints[1] = new Array(54.284995, -1.809572, icon0, '1906', 'Egil Skallagrimson Keeps his Head<br><br>Saturday 18th February<br>Middleham Key Centre<br>DL8 4RA<br>01969 624002');

    newpoints[2] = new Array(53.655601, -0.596613, icon0, '1906', 'Egil Skallagrimson Keeps his Head<br><br>Wednesday 22nd February<br>Winterton All Saints Church<br>DN15 9TU<br>01724 732668');

    newpoints[3] = new Array(54.181388, -1.406897, icon0, '1906', 'Egil Skallagrimson Keeps his Head<br><br>Thursday 23rd February<br>Queen Mary School Balderby Park<br>YO7 3BZ<br>Private booking');

    newpoints[4] = new Array(54.450056, -1.156079, icon0, '1906', 'Egil Skallagrimson Keeps his Head<br><br>Friday 24th February<br>Great Broughton Village Hall<br>TS9 7ER<br>01642  713410');

    newpoints[5] = new Array(53.704493, -0.872301, icon0, '1906', 'Egil Skallagrimson Keeps his Head<br><br>Saturday 25th February<br>The Junction, Goole<br>DN14 5DL<br>01405 763652');

    newpoints[6] = new Array(54.136093, -1.529807, icon0, '1906', 'Egil Skallagrimson Keeps his Head<br><br>Wednesday 29th February<br>Ripon Spa Hotel (Supper and a Saga)<br>HG4 2BU<br>01748 825288');

    newpoints[7] = new Array(54.325597, -1.713313, icon0, '1906', 'Egil Skallagrimson Keeps his Head<br><br>Thursday 1st March<br>Hunton Village Hall<br>DL8 1QZ<br>07702521410');

    newpoints[8] = new Array(54.302477, -1.669325, icon0, '1906', 'Egil Skallagrimson Keeps his Head<br><br>Friday 2nd March<br>Newton le Willows Village Hall<br>DL8 1SH<br>01677 450715');

    newpoints[9] = new Array(54.122111, -1.191548, icon0, '1906', 'Egil Skallagrimson Keeps his Head<br><br>Saturday 3rd March<br>Easingwold The Galtres Centre<br>YO61 3AD<br>01347 822472');



 
	for(var i = 0; i < newpoints.length; i++) {
		var point = new GPoint(newpoints[i][1],newpoints[i][0]);
		var popuphtml = newpoints[i][4] ;
		var marker = createMarker(point,newpoints[i][2],popuphtml);
		map.addOverlay(marker);
	}
}
 
 
function createMarker(point, icon, popuphtml) {
	var popuphtml = "<div id=\"popup\">" + popuphtml + "<\/div>";
	var marker = new GMarker(point, icon);
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(popuphtml);
	});
	return marker;
}

