/*** prevent enter key from submitting form ***/
function entrytest() {    
   if (event.keyCode == 13)    {        
      event.cancelBubble = true;
      event.returnValue = false;
   }
} 

function win_close() { 
   setTimeout('window.close()', 600); 
} 


/*** script to prevent framing of website ***/
if (parent.frames.length > 0) {
    parent.location.href = self.document.location;
}


/*** rewrite external links to open in new window ***/
function externalLinks() { 
    if (!document.getElementsByTagName) {
        return; }

    var anchors = document.getElementsByTagName("a"); 
    for (var i=0; i<anchors.length; i=i+1) { 
        var anchor = anchors[i]; 
        if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") { 
            anchor.target = "_blank"; }
    } 


    var forms = document.getElementsByTagName("form"); 
    for(var i = 0; i < forms.length; i=i+1) { 
       var form = forms[i]; 
       if(form.getAttribute("action").substring(0, 4) == "http") {
          form.target = "_blank"; 
       } 
     } 
} 
//  window.onload = externalLinks;
// event added using setup() function 


/*** anti-spam script ***/
var show, name, dom, m;
function ns(show, name, dom) { 
   m = "<a class=\"mail\" href=\"mailto:" +name+"@"+dom+"\" title=\"send mail to "+show+"\"  ";
   m += "onmouseover=\"window.status='Send mail to "+ show+"'; return true;\" ";
   m += "onmouseout=\"window.status=''; return true;\" ";
   m += "onfocusout=\"window.status='opening e-mail program'; return true;\">";
   m += show+"</a>";
   document.write(m);
}

var show, name, dom, m;
function nsnew(show, name, dom) { 
   m = "<a href=\"mailto:" +name+"@"+dom+"\" title=\"send mail to "+show+"\"  ";
   m += "onmouseover=\"window.status='Send mail to "+ show+"'; return true;\" ";
   m += "onmouseout=\"window.status=''; return true;\" ";
   m += "onfocusout=\"window.status='opening e-mail program'; return true;\">";
   m += show+"</a>";
   document.write(m);
}





/*** toggle div ***/
function toggle(d){ 
    style = document.getElementById(d).style ; 
    if(style.display == "block") { 
        style.display = "none"; 
    } else { 
        style.display = "block"; 
    } 
} 


/*** kill focus borders  ***/
//add event function
function addEvent(obj, evType, fn) { 
   if (obj.addEventListener) { 
      obj.addEventListener(evType, fn, true); 
      return true; 
   } else if (obj.attachEvent) { 
      var r = obj.attachEvent("on"+evType, fn); 
      return r; 
   } else { 
      return false; 
   } 
}

// Find all link elements and add an onfocus attribute and value
function hideFocusBorders() {
   var theahrefs = document.getElementsByTagName("a");
   if (!theahrefs) {
      return;
   }
   for(var x=0;x!=theahrefs.length;x++) {
      theahrefs[x].onfocus = function stopLinkFocus() {
         this.hideFocus=true;
      };
   }
}
//event added using the addEvent() function above
// addEvent(window, 'load', hideFocusBorders);


/*** scroll to top of page: Dave Lindquist
           http://www.octavioheredia.com/blog/archives/2005/10/javascript-back-to-top-links.php  ***/
    function top() {
        var x1 = 0; x2 = 0; x3 = 0;
        var y1 = 0; y2 = 0; y3 = 0;

        if (document.documentElement) {
            x1 = document.documentElement.scrollLeft || 0;
            y1 = document.documentElement.scrollTop || 0;
        }

        if (document.body) {
            x2 = document.body.scrollLeft || 0;
            y2 = document.body.scrollTop || 0;
        }

        x3 = window.scrollX || 0;
        y3 = window.scrollY || 0;

        var x = Math.max(x1, Math.max(x2, x3));
        var y = Math.max(y1, Math.max(y2, y3));

        window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));

        if (x > 0 || y > 0) {
            window.setTimeout("top()", 36);
        }
    }

/*
	function post() {
		if (document.getElementById) {
			var alltags = document.all? document.all : document.getElementsByTagName("*");
			for (i=0; i < alltags.length; i++) {
			  if (alltags[i].className == "post") {
			  	var oldText = alltags[i].firstChild;
			  	var emailAddress = alltags[i].firstChild.nodeValue;
			  	var user = emailAddress.substring(0, emailAddress.indexOf("("));
			  	var website = emailAddress.substring(emailAddress.indexOf(")")+1, emailAddress.length);
			  	var newText = user+"@"+website;
			  	var a = document.createElement("a");
			  	a.href = "mailto:"+newText;
				var address = document.createTextNode(newText);
				a.appendChild(address);
				alltags[i].replaceChild(a,oldText);
			  }
			}
		}
	}

//	window.onload = post;

*/

function getfocus(){
    document.getElementById('access').focus()
}


/*** script to initiate javascripts  ***/
 
function setup() {
    externalLinks();
    addEvent(window, 'load', hideFocusBorders);
}
window.onload=setup;



        function bkform(data) {
           visit = 'http://www.bwysoutheast.org.uk/booking-info.htm';
           theURL = visit + data;
           newwindow = window.open(theURL, 'booking_form', 'width=560,height=650,resizable=0,status=0,left=25, top=25, menubar=0, toolbar=0, sName=_blank, location=0,scrollbars=1'); 
           if ( window.focus ) { newwindow.focus(); }
        }

        function bookform(data) {
           visit = 'http://www.bwysoutheast.org.uk/booking-info.htm';
           theURL = visit + data;
           newwindow = window.open(theURL, 'booking_form', 'width=560,height=650,resizable=0,status=0,left=25, top=25, menubar=0, toolbar=0, sName=_blank, location=0,scrollbars=1'); 
           if ( window.focus ) { newwindow.focus(); }
        }
/*
        function bkform2(data) {
           visit = 'http://www.bwysoutheast.org.uk/booking_form2.php';
           theURL = visit + data;
           newwindow = window.open(theURL, 'booking_form', 'width=560,height=560,resizable=0,status=1,left=25, top=25, menubar=1, toolbar=1, sName=_blank, location=0,scrollbars=1'); 
           if ( window.focus ) { newwindow.focus(); }
        }
*/
        function map(data) {
           visit = 'http://www.bwysoutheast.org.uk/map.php';
           theURL = visit + data;
           newwindow = window.open(theURL, 'map', 'width=600,height=430,resizable=0,status=0,left=25, top=25, menubar=0, toolbar=0, sName=_blank, location=0,scrollbars=0'); 
           if ( window.focus ) { newwindow.focus(); }
        }


        function contact(data) {
           visit = 'http://www.bwysoutheast.org.uk/contact.htm';
           theURL = visit + data;
           newwindow = window.open(theURL, 'contact', 'width=560,height=510,resizable=0,status=1,left=25, top=25, location=0,scrollbars=1'); 
           if ( window.focus ) { newwindow.focus(); }
        }

        function contact2(data) {
           visit = 'http://www.bwysoutheast.org.uk/contact2.htm';
           theURL = visit + data;
           newwindow = window.open(theURL, 'contact', 'width=560,height=510,resizable=0,status=1,left=25, top=25, location=0,scrollbars=1'); 
           if ( window.focus ) { newwindow.focus(); }
        }




