// JavaScript Document

xmlHttp = GetXmlHttpObject();
itemHtml = "";

function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP.3.0");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
    if (xmlHttp==null)
    {
        alert ("Sorry, your browser does not appear to support AJAX.");
        return;
    } 
  return xmlHttp;
}

function show(what)
{
	obj=document.getElementById(what);
	if (obj)
	{
		obj.className="unfold";
	}
}

function hide(what)
{
	obj=document.getElementById(what);
	if (obj)
	{
		obj.className="fold";
	}
}

function showMap()
{
	hide("dmsHolder");
	show("mapHolder");
}

function showDms()
{
	hide("mapHolder");
	show("dmsHolder");
}

function active(what)
{
	for (i=1; i<=4; i++)
	{
		obj=document.getElementById("t" + i);
		obj.className="";
	}
	obj=document.getElementById(what);
	obj.className="on";
}

function getDmsPage(url)
{
	//Strip the &amp; s from the url
	rExp = /&amp;/gi;
	url = url.replace(rExp,"&");
	
	//rExp = /www.golakes.co.uk/gi;
	//url = url.replace(rExp,"www.golakes.co.uk");
	
	//rExp = /thedms.asp/gi;
	//url = url.replace(rExp,"/thedms_ajax.aspx");
	
	//url = "http://www.golakes.co.uk/maps/thedms_ajax.aspx" + url;
	//url = "http://www.golakes.co.uk/thedms.asp" + url;

	var d = new Date();
	url = url + "&nocache=" + d.getTime();
	//url = escape(url);
	
	xmlHttp.onreadystatechange = stateChanged;
	
    //xmlHttp.open("GET","repipe.aspx?url="+url,true);
	
	//Disable click through
	//xmlHttp.open("GET",url,true);
    //xmlHttp.send(null);
}

function stateChanged()
{ 
	if (xmlHttp.readyState==4)
	{ 
		itemHtml=xmlHttp.responseText;
		updateDisplay();
		
		//Re-get a new object for IE 7
		xmlHttp=GetXmlHttpObject();
	}
}

function updateDisplay()
{
    document.getElementById("dmsHolder").innerHTML = itemHtml + "<br/>";
	showDms();
	//Automatically turn on the second tab
	active("t2");
}

//NV Popup

var newWindow = null; 

function buzzPopWindow(url)
{
	NMS_popUpWin(url, "standard", 1000, 700, "Detials");
}

function NMS_closeWin()
{ 
	if (newWindow != null){ 
		if(!newWindow.closed) 
			newWindow.close(); 
	} 
} 

function NMS_popUpWin(url, type, strWidth, strHeight,target)
{ 
	NMS_closeWin(); 
	if (type == "fullScreen"){ 
	strWidth = screen.availWidth - 10; 
	strHeight = screen.availHeight - 160; 
	} 
	
	var tools=""; 
	if (type == "standard" || type == "fullScreen") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0"; 
	if (type == "console") tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left=0,top=0"; 
	if (type == "popup") tools = "resizable,toolbar=no,location=no,scrollbars=yes,width="+strWidth+",height="+strHeight+",left=0,top=0"; 
	newWindow = window.open(url, target, tools); 
	newWindow.focus(); 
}

function NMS_CloseWindow() {
// this works in most browsers. (doesn;t work on  Mozilla on a PC, preIE5.5 on PC and NS7 on the MAC) 
	window.opener = window;
	window.close();
}

function NMS_Print() {
// 
	window.opener = window;
	window.close();
}

function NMS_showElement(ele) {
    var srcElement = document.getElementById(ele);
    if(srcElement != null) {
    if(srcElement.style.display != 'none') {
       srcElement.style.display= 'none';
    }
    else {
       srcElement.style.display='inline';
    }
    return false;
  }
}