/* 
   BWY SOUTH WEST REGION :: javascript 
   LyndworthDesign May 2009
*/

defaultStatus = 'BWY South West Region | Bristol, Cornwall, Devon, Dorset, Gloucestershire, Somerset & Wiltshire '; 
function statbar() {
    window.status = 'BWY South West Region | Bristol, Cornwall, Devon, Dorset, Gloucestershire, Somerset & Wiltshire '; 
}


function go2(f) { 
    window.location.hash=f; 
}

/*** script to prevent framing of website ***/
if (parent.frames.length > 0) {
    parent.location.href = self.document.location;
}



function win_close() { 
   setTimeout('window.close()', 600); 
} 



/*** anti-spam script ***/
var show, name, dom, m;
function ns(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);
}
var show, name, dom, m;
function ns2(show, name, dom) { 
   m = "<a class=\"link\" 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 ns3(show, name, dom) { 
   m = "<a class=\"email\" 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"; 
      } 
   } 


/*** 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"; 
         } 
      } 
   } 

/*** script to initiate javascripts  ***/
   function setup() 
   {
      externalLinks();
   }
   window.onload=setup;

/*** 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 = x2 = x3 = 0;
        var y1 = y2 = 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 bkform(data) {
           visit = 'http://www.bwysouthwest.org.uk/booking_info.htm';
           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(); }
        }

