var version = '';          
var agent   = '';
if (navigator.userAgent.search('MSIE') >= 0) {
	if (navigator.userAgent.search('MSIE 4') >= 0 || navigator.userAgent.search('MSIE 3') >= 0) {
		var agent = '';
	} else {
		var agent = 'ie';
		version = parseFloat(navigator.userAgent.substr(navigator.userAgent.indexOf('MSIE ')+5));
	}
} else if (navigator.userAgent.search('Konqueror') >= 0 || navigator.userAgent.search('Safari') >= 0) {
	var agent = 'konqueror';
} else if (navigator.userAgent.search('Gecko') >= 0) {
	var agent = 'gecko';
} else if (navigator.appName == 'Netscape' && navigator.userAgent.search('Mozilla/4') >= 0) {
	var agent = 'ns4';
} else {
	var agent = '';
}

if (navigator.userAgent.search('Mac') >= 0) {
	var os = 'Mac';
} else {
	var os = '';
}

function initSubNav(id) {
	var tmp = document.getElementById(id);
	if (tmp) {
		for (var i = 0; i < tmp.rows.length; i++) {
			if (i%2 == 0 && !tmp.rows[i].getAttribute('current')) {
				tmp.rows[i].onmouseover = rowover;
				tmp.rows[i].onmouseout = rowout;
			}
		}
	}
			
	function rowover() {
		this.style.backgroundColor = '#ffffff';
	}
	
	function rowout() {
		this.style.backgroundColor = '#f5f5f5';
	}
}

function popup(url, name) {
	var newwin = window.open(url, name, 'width=405,height=600,toolbars=no,screenX=50,screenY=50,personbar=no,menubar=no,resizable,scrollbars');
	newwin.focus();
	return false;
}

function ng_dump(obj) {
	var result = '';
	for (var i in obj) if (arguments.length == 1 || i.search(arguments[1]) >= 0) result += '.' + i + ' = ' + obj[i] +'<br />\n';
	return result;
}

function Point(x,y) {
	this.x=x; this.y=y; return this;
}

function getPagePos(node) {
	if (agent == 'ns4') return new Point(node.pageX, node.pageY);
	var x = 0;
	var y = 0;
	while (node && node.tagName != 'BODY') {
		x += node.offsetLeft;
		y += node.offsetTop;
		if (node.tagName == 'TD' && os == 'Mac' && agent == 'ie') y += node.parentNode.offsetTop;
		node = node.offsetParent;
	}
	// Bug is fixed on MacOS X IE5.21 (maybe earlier?)
	
	if (!node && os == 'Mac' && agent == 'ie' && version < 5.21) {
		x += (document.body.leftMargin*1);
		y += (document.body.topMargin*1);
	}
	
	return new Point(x, y);
}

var haveFlash = 0;
var ranVb = "";

if(agent == 'ie' && os != 'Mac'){
	//document.write("<scr"+"ipt language='VBScript' src='/fdetection.vbs' > </scr"+"ipt>\n");
}

function detectFlash() {
	var fallback = arguments.length > 0 ? arguments[0] : false;
	if (navigator.plugins) {
		if (navigator.plugins["Shockwave Flash"]) {
			return true;
		}
	}
	if (ranVb && haveFlash) return true;
	return fallback;
}

function flash_or_image(flashsrc, imgsrc, width, height) {
	if (detectFlash()) {
		document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="'+width+'" height="'+height+'" id="Morrisons"><param name="movie" value="'+flashsrc+'" /><param name="quality" value="high" /><param name="bgcolor" value="#e1e1e1" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="wmode" value="opaque" /><embed src="'+flashsrc+'" loop="false" menu="false" quality="high" wmode="opaque" bgcolor="#000000" width="'+width+'" height="'+height+'" swLiveConnect="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object>');
	} else {
		document.writeln('<img src="'+imgsrc+'" border="0" width="'+width+'" height="'+height+'" />');
	}
}

function flash_or_nothing(flashsrc, width, height) {
	if (detectFlash()) {
		document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="'+width+'" height="'+height+'" id="Morrisons"><param name="movie" value="'+flashsrc+'" /><param name="quality" value="high" /><param name="bgcolor" value="#e1e1e1" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="wmode" value="opaque" /><embed src="'+flashsrc+'" loop="false" menu="false" quality="high" wmode="opaque" bgcolor="#000000" width="'+width+'" height="'+height+'" swLiveConnect="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object>');
	}
}

function fixNavPadding() {
	if (os == "Mac") {
		if (agent == "ie") {
			document.getElementById("section-nav").style.paddingBottom = "180px";
			document.getElementById("section-nav").style.paddingTop = "7.80em";
		} else {
			document.getElementById("section-nav").style.paddingBottom = "300px";
			document.getElementById("section-nav").style.paddingTop = "7.75em";
		}
	} else {
		document.getElementById("section-nav").style.paddingBottom = "300px";
		if (agent == "ie") {
			document.getElementById("section-nav").style.paddingTop = "7.80em";
		} else {
			document.getElementById("section-nav").style.paddingTop = "7.75em";
		}
	}
}