var searchtext = "";
var isexact = "no";
var searchtype = "name";
var searchcounty = "all";
var searchlang = "any";
var islabel = "no";

//document.domain = "nottingham.ac.uk";

function popmaps(href){ 
	var mapWindow;
//	alert("hello" + href);  
	mapWindow = window.open(href,"mapWindow","scrollbars=yes,resizable=yes,width=600,height=500");
//	mapWindow.document.domain = "nottingham.ac.uk";
      mapWindow.focus();
}

function popsearchmaps(href){ 
searchtext = document.forms[0].searcht.value;
searchcounty = document.forms[0].county.value;
searchlang = document.forms[0].lang.value;
document.cookie = "EPNsearchform=" + escape(searchtext + ":" + isexact + ":" + searchtype + ":" + searchcounty + ":" + searchlang + ":" + islabel);
	var mapWindow;
//	alert("hello" + href);  
	mapWindow = window.open(href,"mapWindow","scrollbars=yes,resizable=yes,width=600,height=500");
//	mapWindow.document.domain = "nottingham.ac.uk";
      mapWindow.focus();
}

function popmail(href){
    mailWindow = window.open(href,"mailWindow","scrollbars=yes,resizable=yes,width=400,height=500");
      mailWindow.focus();
//    mailWindow.document.forms[0].elements[1].focus();
}
function popdetails(href){
    detailWindow = window.open(href,"detailWindow","scrollbars=yes,resizable=yes,width=300,height=350");
    detailWindow.focus();
}
function save_settings(){
searchtext = document.forms[0].searcht.value;
searchcounty = document.forms[0].county.value;
searchlang = document.forms[0].lang.value;
document.cookie = "EPNsearchform=" + escape(searchtext + ":" + isexact + ":" + searchtype + ":" + searchcounty + ":" + searchlang + ":" + islabel);
}

function set_location(href){
document.location = href;
}

function popelements(href){
//    alert(document.epnform1.county.value);
    var hparams = "?county=" + document.epnform1.county.value + "&lang=" + document.epnform1.lang.value;
    valref = href + hparams;
    elementWindow = window.open(valref,"elementWindow","scrollbars=yes,resizable=yes,width=300,height=350");
    elementWindow.focus();
}

function putelement(e){
// sets form value from list in popup window
  top.opener.document.epnform1.searcht.value = e;
}

function pophelp(href){
    helpWindow = window.open(href,"helpWindow","scrollbars=yes,resizable=yes,width=300,height=350");
    helpWindow.focus();
}

function toggle_exact(){
if(isexact == "yes") isexact = "no";
else isexact = "yes";
}

function toggle_label(){
if(islabel == "yes") islabel = "no";
else islabel = "yes";
}

function set_searchtype(value){
searchtype = value;
}


function reset_search_form(){
var allcookies = document.cookie;
var pos = allcookies.indexOf("EPNsearchform=");
if (pos != -1){
  var start = pos + 14;
  var end = allcookies.indexOf(";",start);
  if(end == -1) end = allcookies.length;
  var value = allcookies.substring(start,end);
  value = unescape(value);
  var a = value.split(':');
  searchtext = a[0];
  isexact = a[1];
  searchtype = a[2];
  searchcounty = a[3];
  searchlang = a[4];
  islabel = a[5];
  }
document.forms[0].searcht.value = searchtext;
if(searchtype == "name") document.forms[0].type[0].checked = true;
else document.forms[0].type[1].checked = true;
if(isexact == "yes") document.forms[0].exact.checked = true;
document.forms[0].type.value = searchtype;
document.forms[0].county.value = searchcounty;
document.forms[0].lang.value = searchlang;
if(islabel == "yes") document.forms[0].label.checked = true;
}

function reset_all(){
searchtext = "";
isexact = "no";
searchtype = "name";
searchcounty = "all";
searchlang = "any";
islabel = "no";
}

