/*
Title:     Javascript for the Mount's Bay Sailing Club web site
           navigation system. Based on the Cornwall Internet x_nav
           scripts.
Author:    Clive Goodhead, Cornwall Internet Limited
Copyright: (c) 2005-2007 Cornwall Internet Limited
Version:   13 April 2007
Notes:     Web site www.mbsc.org.uk
*/

/* The javascript functions are disabled for older browsers. */

/* Preload images. */
if (document.images)
	{
	img0 = new Image();      
	img0.src = "imgs/title_home.jpg"; 
	img1 = new Image();      
	img1.src = "imgs/title_about.jpg"; 
	img2 = new Image(); 
	img2.src = "imgs/title_sailing.jpg";  
	img3 = new Image();
	img3.src = "imgs/title_classes.jpg";
	img4 = new Image();
	img4.src = "imgs/title_social.jpg";
	img5 = new Image();      
	img5.src = "imgs/title_juniors.jpg"; 
	img6 = new Image();      
	img6.src = "imgs/title_champs.jpg"; 
	img7 = new Image();      
	img7.src = "imgs/title_photos.jpg"; 
	img8 = new Image();      
	img8.src = "imgs/title_forum.jpg"; 
	img9 = new Image();      
	img9.src = "imgs/title_accommodation.jpg"; 
	img10 = new Image();      
	img10.src = "imgs/title_home.jpg";
	img11 = new Image();      
	img11.src = "imgs/title_home.jpg";
	img12 = new Image();      
	img12.src = "imgs/title_laser.jpg";
	}

/* Detect if IE5 because this browser can cause problems. */
function detect_ie5() {
var ua = navigator.userAgent.toLowerCase(); 
var opera = (ua.indexOf('opera') != -1); 
var webtv = (ua.indexOf('webtv') != -1);
var isIE = (ua.indexOf('msie') != -1 && !opera && !webtv); 
var ver = 0;
if (isIE)
	{
	ver = parseFloat(navigator.appVersion); 
	if (ver >= 4)
		{
		ver = parseFloat(ua.substring(ua.indexOf('msie ')+5));
		}
	ver = parseInt(ver); 
	}
return (ver == 5);
}
var g_isIE5 = detect_ie5();


/* The 'onmouseover' function. */
function picture_on(l_dd) {
if (document.getElementById && !g_isIE5)
	{
	var mbsc_nav = document.getElementById('mbsc_nav');
	var divs = mbsc_nav.getElementsByTagName('DIV');
	var image = 0;
	for (var i=0; i < divs.length; i++)
		{
		if (divs[i] == l_dd)
			{
			image = i;
			}
		}
	var title_img = document.getElementById('title_img');
	title_img.src = eval('img' + image + '.src');
	}
}

/* The 'onmouseout' function. */
function picture_off(l_image) {
if (document.getElementById && !g_isIE5)
	{
	var title_img = document.getElementById('title_img');
	title_img.src = eval('img' + l_image + '.src');
	}
}

function whichBrs() {
var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("opera") != -1) return 'Opera';
if (agt.indexOf("staroffice") != -1) return 'Star Office';
if (agt.indexOf("webtv") != -1) return 'WebTV';
if (agt.indexOf("beonex") != -1) return 'Beonex';
if (agt.indexOf("chimera") != -1) return 'Chimera';
if (agt.indexOf("netpositive") != -1) return 'NetPositive';
if (agt.indexOf("phoenix") != -1) return 'Phoenix';
if (agt.indexOf("firefox") != -1) return 'Firefox';
if (agt.indexOf("safari") != -1) return 'Safari';
if (agt.indexOf("skipstone") != -1) return 'SkipStone';
if (agt.indexOf("msie") != -1) return 'Internet Explorer';
if (agt.indexOf("netscape") != -1) return 'Netscape';
if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
if (agt.indexOf('\/') != -1) {
if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
return navigator.userAgent.substr(0,agt.indexOf('\/'));}
else return 'Netscape';} else if (agt.indexOf(' ') != -1)
return navigator.userAgent.substr(0,agt.indexOf(' '));
else return navigator.userAgent;
}

/* The 'hideSelects' function. This function deals with a bug in IE6 
   that renders select elements on top of all other elements; they 
   do not respect the z index. */
function hideSelects(action) {
// action may be either 'hidden' or 'visible'
if (action != 'visible') {action = 'hidden';}
if (whichBrs() != 'Internet Explorer') return;
if (navigator.appName.indexOf("MSIE"))
	{
	for (var S = 0; S < document.forms.length; S++)
		{
		for (var R = 0; R < document.forms[S].length; R++)
			{
			if (document.forms[S].elements[R].options)
				{
				document.forms[S].elements[R].style.visibility = action;
				}
			}
		} 
	}
}
