// JavaScript Document	
var d = document;
var i = 0;
var n = navigator;
var s = d.styleSheets[0];

var nVer = n.appVersion;
var nApp = n.appName;
var nUser = n.userAgent;

var isIE6 = nVer.toLowerCase().indexOf("msie 6.0")!=-1;
var isIE  = nVer.indexOf("MSIE")!=-1;
var isWin = nVer.toLowerCase().indexOf("win")!=-1;
var isOpera = nUser.indexOf("Opera")!=-1;
var isSafari = nVer.indexOf("Safari")!=-1;
var isFirefox = nUser.indexOf("Firefox")!=-1;
var isChrome = nUser.indexOf("Chrome")!=-1;
	
function gE(elem) { return d.getElementById(elem) };
function addCSS(elem, rule) { isIE ? s.addRule(elem, rule) : s.insertRule(elem + '{' + rule + '}', 1); } 

function onLoad(curPage) { 
  var BtnsArray = new Array('home', 'venue', 'mixology', 'events', 'functions', 'gallery', 'contact');
	
	for (var i=0; i < BtnsArray.length; i++) {
		var btn = gE(BtnsArray[i]);
		addBtn(btn, "images/menu/" + btn.id + "-mo.jpg");
	}
	
	function addBtn(btn, file) { 
		var img = new Image();
		!isIE6 ? btn.style.visibility = "visible" : 0;
		img.src = file;
		
		if (btn.id != curPage) { 
			btn.attachEvent ? btn.attachEvent('onmouseover', switchImage) : btn.addEventListener('mouseover', switchImage, true);
			btn.attachEvent ? btn.attachEvent('onmouseout', restoreImage) : btn.addEventListener('mouseout', restoreImage, true);
			//btn.attachEvent ? btn.attachEvent('onclick', clickImage) : btn.addEventListener('click', clickImage, true);
			btn.style.cursor = "pointer";
		} else {
 			btn.style.backgroundImage = "url(images/menu/"+btn.id+"-mo.jpg)";
		}
 		function switchImage() {
 			btn.style.backgroundImage = "url(images/menu/"+btn.id+"-mo.jpg)";
 		}
		function restoreImage() {
 			btn.style.backgroundImage = "url(images/menu/"+btn.id+".jpg)";
		}
		//function clickImage() { 
		//	btn.id!="home" ? window.location=btn.id+".php" : window.location="index.php";
		//} 
	}
	checkBrowser();
}
 
function checkCalibri() { 
	var detectFont = new Detector();
	return (!(detectFont.test('Calibri'))); 
}
 	
	function mouseover(button) {
 		button.style.backgroundImage = "url(images/menu/"+button.id+"-mo.jpg)";
 	}
	function mouseout(button) {
 		button.style.backgroundImage = "url(images/menu/"+button.id+".jpg)";
 	}
	function clickButton(button) {
		button.id!="home" ? window.location=button.id+".php" : window.location="index.php";
	}
	
	function startGallery() {
		var myGallery = new gallery($('myGallery'), {timed: true, showArrows: false, showInfopane: false, showCarousel: false, embedLinks: false, delay: 5000});
	}
	
	function googleAnalytics() { 
		var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
		d.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
 		try { var pageTracker = _gat._getTracker("UA-5720745-11"); pageTracker._trackPageview(); } catch(err) { } ;
	}
	
 	
	function checkBrowser() {
//		var isIE6 = (navigator.appVersion.toLowerCase().indexOf("msie 6.0") != -1);
//		var isIE  = (navigator.appVersion.indexOf("MSIE") != -1);
//		var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1);
//		var isOpera = (navigator.userAgent.indexOf("Opera") != -1);
//		var isSafari = (navigator.appVersion.indexOf("Safari") != -1);
//		var isFirefox = (navigator.appName=="Netscape" != -1);

		var browser = navigator.appName;
		var sWidth = screen.availWidth;
		var sHeight = screen.availHeight;
		var width = 1000, height = 550;
		var verticalBorder, horizontalBorder;
		
		
		//document.write('bHeight: ', bHeight, ' bWidth: ', bWidth, ' bHeight: ', bHeight, ' width: ', width, ' height: ', height);
 		//document.write("appName: ", navigator.appName, " appVersion: ", navigator.appVersion, " userAgent: ", navigator.userAgent)
 		//document.write(isSafari, document.body.offsetWidth, document.documentElement.clientHeight, 'bHeight: ', bHeight, ' bWidth: ', bWidth, ' bHeight: ', bHeight, ' width: ', width, ' height: ', height);
		var bWidth, bHeight;
		if (parseInt(navigator.appVersion)>3) {
			if (isSafari) {
				bWidth = d.documentElement.clientWidth;
				bHeight = d.documentElement.clientHeight;
				verticalBorder = 0;
				horizontalBorder = 0;	
			} else if (navigator.appName=="Netscape" || isOpera) {
				bWidth = window.innerWidth;
				bHeight = window.innerHeight;
				verticalBorder = 22;	
				horizontalBorder = 40;
			} else if (isIE) {
				bWidth = d.documentElement.clientWidth;
				bHeight = d.documentElement.clientHeight;
				verticalBorder = 33;	
				horizontalBorder = 60;
			} 
		}  

		var nMaxHeight = bWidth * (550/1000) 	
		var nMaxWidth = bHeight * (1000/550)  
	
		if (bWidth >= 1000 && bHeight >= 550) {
			width = "1000";
			height = "550"; 
		} else {
			if (bHeight >= nMaxHeight.toFixed(0)) {
				width = (nMaxHeight * (1000/550)).toFixed(0) - horizontalBorder;
				height = nMaxHeight.toFixed(0) - verticalBorder; 
			} else if (bWidth >= nMaxWidth.toFixed(0)) { 
				width = nMaxWidth.toFixed(0) - horizontalBorder;
				height = (nMaxWidth * (550/1000)).toFixed(0) - verticalBorder;
			}
		}
 		//' bWidth: ' + bWidth + ' nMaxWidth: ' + nMaxWidth.toFixed(0) + ' nMaxHeight: ' + nMaxHeight.toFixed(0) + ' bHeight: ' + bHeight + ' bWidth >= nMaxWidth: ' + bWidth >= nMaxWidth + ' bHeight >= nMaxHeight: ' + bHeight >= nMaxHeight.toFixed(0) + ' width: ' + width, ' height: ' + height);
		if (!isIE6) { 
			gE('fixed') ? gE('fixed').style.position = 'fixed' : 0;
			gE('shadow').style.visibility = "visible";
			gE('shadow-bottom').style.visibility = "visible";
			gE('onyx-logo').style.visibility = "visible";
			gE('shadow-gallery') ? gE('shadow-gallery').style.visibility = "visible" : 0;
		} else {
			gE('onyx-logo').style.visibility = "visible";
			gE('onyx-logo').style.backgroundImage = "url(images/logo-onyx.jpg)";
			gE('onyx-logo').style.left = "58px"; 
		}
	}
	
/*	function disableButton(id) { 
		document.getElementById(id).removeEventListener(
		btn.attachEvent ? btn.removeEvent('onmouseover', switchImage) : btn.addEventListener('mouseover', switchImage, true);
		btn.attachEvent ? btn.removeEvent('onmouseout', restoreImage) : btn.addEventListener('mouseout', restoreImage, true);
		btn.attachEvent ? btn.removeEvent('onclick', clickImage) : btn.addEventListener('click', clickImage, true);

	}
*/
