/*
Title:     Javascript for the Churchtown Morgan Stud Farm 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 June 2007
Notes:     Web site www.churchtownmorgans.co.uk
*/

/* The javascript functions are disabled for older browsers. */

/* Preload images and initialise text and background colours. */
if (document.images)
	{
	img0 = new Image();      
	img0.src = "http://www.churchtownmorgans.co.uk/style/title_0.jpg"; 
	color0 = '#3399ff';
	text0 = "Churchtown Morgan Stud Farm";
	img1 = new Image();      
	img1.src = "http://www.churchtownmorgans.co.uk/style/title_1.jpg"; 
	color1 = '#33cc00';
	text1 = "About Morgan Horses";
	img2 = new Image(); 
	img2.src = "http://www.churchtownmorgans.co.uk/style/title_2.jpg";  
	color2 = '#ff0033';
	text2 = "Our Stud Service";
	img3 = new Image();
	img3.src = "http://www.churchtownmorgans.co.uk/style/title_3.jpg";
	color3 = '#ff00cc';
	text3 = "Stock for Sale";
	img4 = new Image();
	img4.src = "http://www.churchtownmorgans.co.uk/style/title_4.jpg";
	color4 = '#33cc00';
	text4 = "Riding Holidays";
	img5 = new Image();      
	img5.src = "http://www.churchtownmorgans.co.uk/style/title_5.jpg"; 
	color5 = '#ff99ff';
	text5 = "Photo Gallery";
	img6 = new Image();      
	img6.src = "http://www.churchtownmorgans.co.uk/style/title_6.jpg"; 
	color6 = '#0000ff';
	text6 = "Contact Churchtown Morgan Stud Farm";
	}

/* 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 our_nav = document.getElementById('our_nav');
	var divs = our_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');
	document.getElementById('picture_bar').style.backgroundColor = eval('color' + image);
	document.getElementById('title_text').innerHTML = eval('text' + image);
	}
}

/* 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');
	document.getElementById('picture_bar').style.backgroundColor = eval('color' + l_image);
	document.getElementById('title_text').innerHTML = eval('text' + l_image);
	}
}

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;
				}
			}
		} 
	}
}
