/*** script to prevent framing of website ***/
if (parent.frames.length > 0) {
    parent.location.href = self.document.location;
}


function go2(f) { 
    window.location.hash=f; 
}

function formfocus() { 
    if(document.getElementById('nmbr')) 
    { 
        document.getElementById('nmbr').focus(); 
    }
}


/*** toggle div ***/

   function toggle(d)
   { 
      style = document.getElementById(d).style ; 
      if(style.display == "block") 
      { 
         style.display = "none"; 
      } else { 
         style.display = "block"; 
      } 
   } 

/*** toggle2 div ***/
function toggle2(shID) {
	if (document.getElementById(shID)) {
		if (document.getElementById(shID+'-show').style.display != 'none') {
			document.getElementById(shID+'-show').style.display = 'none';
			document.getElementById(shID).style.display = 'block';
		}
		else {
			document.getElementById(shID+'-show').style.display = 'inline';
			document.getElementById(shID).style.display = 'none';
		}
	}
}

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 
/*** END rewrite external links ***/


var qTipTag = "a.ext"; //Which tag do you want to qTip-ize? Keep it lowercase!//
var qTipX = -10; //This is qTip's X offset//
var qTipY = -36; //This is qTip's Y offset//



//There's No need to edit anything below this line//
tooltip = {
  name : "qTip",
  offsetX : qTipX,
  offsetY : qTipY,
  tip : null
}

tooltip.init = function () {
	var tipNameSpaceURI = "http://www.w3.org/1999/xhtml";
	if(!tipContainerID){ var tipContainerID = "qTip";}
	var tipContainer = document.getElementById(tipContainerID);

	if(!tipContainer) {
	  tipContainer = document.createElementNS ? document.createElementNS(tipNameSpaceURI, "div") : document.createElement("div");
		tipContainer.setAttribute("id", tipContainerID);
	  document.getElementsByTagName("body").item(0).appendChild(tipContainer);
	}

	if (!document.getElementById) return;
	this.tip = document.getElementById (this.name);
	if (this.tip) document.onmousemove = function (evt) {tooltip.move (evt)};

	var a, sTitle;
	var anchors = document.getElementsByTagName (qTipTag);

	for (var i = 0; i < anchors.length; i ++) {
		a = anchors[i];
		sTitle = a.getAttribute("title");
		if(sTitle) {
			a.setAttribute("tiptitle", sTitle);
			a.removeAttribute("title");
			a.onmouseover = function() {tooltip.show(this.getAttribute('tiptitle'))};
			a.onmouseout = function() {tooltip.hide()};
		}
	}
}

tooltip.move = function (evt) {
	var x=0, y=0;
	if (document.all) {//IE
		x = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		y = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		x += window.event.clientX;
		y += window.event.clientY;
		
	} else {//Good Browsers
		x = evt.pageX;
		y = evt.pageY;
	}
	this.tip.style.left = (x + this.offsetX) + "px";
	this.tip.style.top = (y + this.offsetY) + "px";
}

tooltip.show = function (text) {
	if (!this.tip) return;
	this.tip.innerHTML = text;
	this.tip.style.display = "block";
}

tooltip.hide = function () {
	if (!this.tip) return;
	this.tip.innerHTML = "";
	this.tip.style.display = "none";
}
/*
window.onload = function () {
	tooltip.init ();
}
*/

/*** initiate javascripts  ***/
 function setup() {
    externalLinks();
    formfocus();
    tooltip.init ();
}
window.onload=setup;
/*** END: initiate javascripts  ***/

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);
}

/*
        function contact(data) {
           visit = 'http://bwywales.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 bkform(data) {
           visit = 'http://bwywales.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(); }
        }
*/
        function bkform2(data) {
           visit = 'http://bwywales.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 contact(data) {
   visit = 'http://bwywales.org.uk/admin/bookings_contact.php';
   theURL = visit + data;
   newwindow = window.open(theURL, 'contact', 'width=560,height=510,resizable=0,status=1,left=30, top=30, location=0, directories=0, personalbar=0, scrollbars=1'); 
   if ( window.focus ) 
   { 
      newwindow.focus(); 
   }
}

function confirmbooking(data) {
   visit = 'http://bwywales.org.uk/admin/bookings_confirm.php';
   theURL = visit + data;
   newwindow = window.open(theURL, 'contact', 'width=560,height=360,resizable=0,status=1,left=30, top=30, location=0, directories=0, personalbar=0, scrollbars=1'); 
   if ( window.focus ) 
   { 
      newwindow.focus(); 
   }
}

function email(data) {
   visit = 'http://bwywales.org.uk/admin/bookings_contact_all.php';
   theURL = visit + data;
   newwindow = window.open(theURL, 'contact', 'width=560,height=510,resizable=0,status=1,left=30, top=30, location=0, directories=0, personalbar=0, scrollbars=1'); 
   if ( window.focus ) 
   { 
      newwindow.focus(); 
   }
}

function csv(data) {
   visit = 'http://bwywales.org.uk/admin/bookings_csv.php';
   theURL = visit + data;
   newwindow = window.open(theURL, 'csv', 'width=700,height=700,resizable=1,status=1,left=30, top=30, location=0, directories=0, personalbar=0, scrollbars=1'); 
   if ( window.focus ) 
   { 
      newwindow.focus(); 
   }
}

function printregister(data) {
   visit = 'http://bwywales.org.uk/admin/bookings_print_register.php';
   theURL = visit + data;
   newwindow = window.open(theURL, 'csv', 'width=880,height=600,resizable=1,status=1,left=30, top=30, location=0, directories=0, personalbar=0, menubar=1, scrollbars=1'); 
   if ( window.focus ) 
   { 
      newwindow.focus(); 
   }
}

function printsummary(data) {
   visit = 'http://bwywales.org.uk/admin/bookings_print_summary.php';
   theURL = visit + data;
   newwindow = window.open(theURL, 'csv', 'width=880,height=600,resizable=1,status=1,left=30, top=30, location=0, directories=0, personalbar=0, menubar=1, scrollbars=1'); 
   if ( window.focus ) 
   { 
      newwindow.focus(); 
   }
}

function printcertificates(data) {
   visit = 'http://bwywales.org.uk/admin/bookings_print_certificates.php';
   theURL = visit + data;
   newwindow = window.open(theURL, 'csv', 'width=880,height=600,resizable=1,status=1,left=30, top=30, location=0, directories=0, personalbar=0, menubar=1, scrollbars=1'); 
   if ( window.focus ) 
   { 
      newwindow.focus(); 
   }
}

function notes(data) {
   visit = 'http://bwywales.org.uk/admin/bookings_add_notes.php';
   theURL = visit + data;
   newwindow = window.open(theURL, 'csv', 'width=560,height=340,resizable=0,status=1,left=30, top=30, location=0, directories=0, personalbar=0, scrollbars=1'); 
   if ( window.focus ) 
   { 
      newwindow.focus(); 
   }
}



/* *** booking_fncts *** */
function win_close() { 
   setTimeout('window.close()', 600); 
} 

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);
}

/*** 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);
        }
    }




/*
var xmlhttp; if (window.ActiveXObject) { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } else { xmlhttp = new XMLHttpRequest(); } 
*/
var xmlhttp; 
if (window.XMLHttpRequest) {
  xmlhttp = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}

function fetch(serverPage, objID) { var obj = document.getElementById(objID); xmlhttp.open("GET", serverPage); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { obj.innerHTML = xmlhttp.responseText; } }; xmlhttp.send(null); }

