<!--

// START Dynamic Dropdowns Menus
// Note: Number of menus = 5.  This is manuallu stated in setMenuHeights function

function menuSetHeight (id_d, h) { 
document.getElementById(id_d).style.height=h + "px";
}

function menuSetWidth (id_d, w) {
document.getElementById(id_d).style.width=w + "px";
}

function menuGetDim (id) { 

document.getElementById(id).style.height="auto";
document.getElementById(id).style.width="auto";

// HEIGHT
gh = document.getElementById(id).offsetHeight;

// WIDTH
gw = document.getElementById(id).offsetWidth;


if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)){
//alert("isIE");
h = gh-20;
w = gw-20;
}
else { 
h = gh-20;
w = gw-20;
}

switch (id)
{
case "menu1":
menuSetHeight("menu1_l", h);
menuSetHeight("menu1_r", h);
menuSetWidth("menu1_t", w);
menuSetWidth("menu1_b", w);
break;

case "menu2":
menuSetHeight("menu2_l", h);
menuSetHeight("menu2_r", h);
menuSetWidth("menu2_t", w);
menuSetWidth("menu2_b", w);

break;

case "menu3":
menuSetHeight("menu3_l", h);
menuSetHeight("menu3_r", h);
menuSetWidth("menu3_t", w);
menuSetWidth("menu3_b", w);
break;

case "menu4":

menuSetHeight("menu4_l", h);
menuSetHeight("menu4_r", h);
menuSetWidth("menu4_t", w);
menuSetWidth("menu4_b", w);
break;

case "menu5":
menuSetHeight("menu5_l", h);
menuSetHeight("menu5_r", h);
menuSetWidth("menu5_t", w);
menuSetWidth("menu5_b", w);
break;

case "menu6":
menuSetHeight("menu6_l", h);
menuSetHeight("menu6_r", h);
menuSetWidth("menu6_t", w);
menuSetWidth("menu6_b", w);
break;
}

}


function setMenuHeights(){
menuGetDim('menu1');
menuGetDim('menu2');
menuGetDim('menu3');
menuGetDim('menu4');
menuGetDim('menu5'); 
/*menuGetDim('menu6'); */
}

// END Dynamic Dropdowns Menus


function ToggleVisibility(Control)
{
  Control.style["display"] = (Control.style["display"] == "none") ? "block" : "none";
}
// ------------------------------------------------------------------------------------------------

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

// ------------------------------------------------------------------------------------------------

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

// ------------------------------------------------------------------------------------------------

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// ------------------------------------------------------------------------------------------------

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}

// ------------------------------------------------------------------------------------------------

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

// ------------------------------------------------------------------------------------------------

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

// ------------------------------------------------------------------------------------------------

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

// ------------------------------------------------------------------------------------------------

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// ------------------------------------------------------------------------------------------------

function RandomPic()
{
	return Math.round((Math.random()*1)+1)+".jpg"; 
}
// ------------------------------------------------------------------------------------------------
function breakFrames()
<!-- If a visitor comes to the bell-centres.com web site and is looking through frames,
<!-- this script will automatically make the page 'break out' of frames.
{
	if (window != top) top.location.href = location.href;
}
// ------------------------------------------------------------------------------------------------
function setPhotoID(sPhoto)
	{
	document.form1.photoid.value=sPhoto.value;
	document.form1.submit(this.form);
	}		
// ------------------------------------------------------------------------------------------------
function show(id)
{
     if (document.getElementById(id).style.display == 'none')
     {
          document.getElementById(id).style.display = '';
		       }
	 
}
function hide(id)
{
          document.getElementById(id).style.display = 'none';
// ------------------------------------------------------------------------------------------------
}
function stringReverse(textString) {
   if (!textString) return '';
   var revString='';
   for (i = textString.length-1; i>=0; i--)
       revString+=textString.charAt(i)
   return revString;
}

function emLink(name, server)
{     
     //Hide the info email addresses from Spambots
	 // the name and domain are reversed into the correct reading format
     // the email link is then created on your website
     // Because there is no actual email address in the expected format
     // the email harvesters never see the links on your website.
     var rname = stringReverse(name);
     var rserver = stringReverse(server);
     var email = rname + "@" + rserver;
     var mailText = '<a href="mailto:' + email +'">' + email + '</a>';
     
     document.write(mailText);
}

function emLinkReturn(name, server)
{     
     //Hide the info email addresses from Spambots
	 // the name and domain are reversed into the correct reading format
     // the email link is then created on your website
     // Because there is no actual email address in the expected format
     // the email harvesters never see the links on your website.
     var rname = stringReverse(name);
     var rserver = stringReverse(server);
     var email = rname + "@" + rserver;
     var mailText = '<a href="mailto:' + email +'">' + email + '</a>';
     
     return mailText;
}
//-->



/*
	This function  fires a function after the page has finished loading & was stolen from: 
	http://simonwillison.net/2004/May/26/addLoadEvent/
*/
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

/*fading images */
/* REQUIRED ON PAGE 
var images = new Array('1.jpg',
					   '2.jpg',
					   '3.jpg');

var nextImage = 1;
var imageWidth = 225;
var imageHeight = 240;
var imageTimeout = 3000;

REQUIRED ON PAGE*/

	var nextImage = 1;
	var   imageWidth = 225;
	 var  imageHeight = 150;
	 var imageTimeout = 2000;
	 var stop_fade = false;

function setOpacity(el, opacity) {

	//  Which opacity method does this browser support?

	opacity /= 100;

	el.style.opacity = opacity;
	el.style.MozOpacity = opacity;
	el.style.filter = "alpha(opacity=" + (opacity*100) + ")";

}


var id_x,img_y;

function fadeImage(el, currentOpacity) {
 	//alert('current opacity ' + currentOpacity);
	currentOpacity += 5;

	if (currentOpacity > 100) {
		setOpacity(el, 100);
		var prevEl = el.previousSibling ? el.previousSibling : el.parentNode.lastChild;
		prevEl.style.visibility = 'hidden';
		el.style.zIndex = 1;
		window.setTimeout(startFading, imageTimeout);
	}
	else {
		setOpacity(el, currentOpacity);
		window.setTimeout(function() { fadeImage(el, currentOpacity); }, 50);
	}

}



function startFading() {
	//alert('Next image = ' + img_y[nextImage]);
	var el = document.getElementById(id_x).childNodes[nextImage];
	
	el.style.visibility = 'visible';
	el.style.zIndex = 2;
	
	setOpacity(el, 0);
	fadeImage(el,0);
	//alert('img_y.length -1 = ' + img_y.length-1 + ' Next image is ' + nextImage);
	
	//if (stop_fade = false){
		//alert('should be false = ' + stop_fade);
		nextImage = (nextImage < 5	) ? nextImage + 1 : 0;
	//} else if (stop_fade = true) {alert ('should be true = ' + stop_fade);}	
	
	
}


function pageLoad() {
	var el = document.getElementById('image-container');
	id_x='image-container';
	img_y='images';
	while (el.firstChild) { el.removeChild(el.firstChild); }

	el.style.width = imageWidth + 'px';
	el.style.height = imageHeight + 'px';
	
	for(var i=0; i<images.length; i++) {
		
		var t = document.createElement('IMG');
		t.setAttribute('src',images[i]);
		t.setAttribute('width',imageWidth);
		t.setAttribute('height',imageHeight);
		t.style.position = 'absolute';
		t.style.visibility = 'hidden';
		el.appendChild(t);

	}

	el.firstChild.style.visibility = 'visible';
	
	

	window.setTimeout(startFading, imageTimeout);

}

//emdeds video file into thick box - requires Jquery - used on location gallery pages
 function embed_video(vFile,vWidth,vHeight,vComment,vTitle) {
	
	$('#vid_insert').html('<object width="' + vWidth + '" height="' + vHeight + '"><param name="movie" value="' + vFile + '" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="wmode" value="transparent" /><embed src="' + vFile + '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' + vWidth + '" height="' + vHeight + '" wmode="transparent"></embed></object>');
	$('#TB_ajaxWindowTitle').html(vTitle);
	$('#comment').html(vComment);
}

