//----------------------------------------------------------------------
// FUNCTION: Housekeeping
//----------------------------------------------------------------------
function houseKeeping() {
	
	checkBrowser();
	
	/*  Use small background images for small screen resolutions  */
	var minWindowW = 1025;
	var thisWindowW = window.getWidth();
	if (thisWindowW < minWindowW) 
		linkCSS('mainSmall');
	
	/*  Make all links to external sites open in a new window  */
	window.addEvent('domready',function() {
		/* grab all complete linked anchors */
		$$('a[href^="http://"]').each(function(a) {
			/* if it's not this domain */
			var href = a.get('href');
			if(!href.contains(window.location.host)) {
				a.setProperties({
					rel: 'nofollow',
					target: '_blank'
				});
			}
		});
	});									 
	
	//  add event for mouseover image - all mouseover images have a "-mo" extension, and the <img> tag has a class = "mo"
	window.addEvent('domready', function() {
		$$('img.mo').each(function(img) {
			var src = img.getProperty('src');
			var extension = src.substring(src.lastIndexOf('.'),src.length)
			img.addEvent('mouseenter', function() { img.setProperty('src',src.replace(extension,'-mo' + extension)); });
			img.addEvent('mouseleave', function() { img.setProperty('src',src); });
		});
	});
}


//----------------------------------------------------------------------
// FUNCTION: Link to a Stylesheet 
//----------------------------------------------------------------------
function linkCSS(title) {
   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     	if (a.getAttribute("rel").indexOf("style") != -1  && a.getAttribute("title")== title) {
			a.disabled = true;
			a.disabled = false;
		}
    }
}


//---------------------------------------------------------------------------
//  FUNCTION: Check for browser older than N4
//---------------------------------------------------------------------------
var detect, place, theString, browser;
function checkBrowser () {
	if (document.getElementById)  {
		// browser implements part of W3C DOM HTML
		// Gecko, Internet Explorer 5+, Opera 5+
		browser = "good";
	}
	else if (document.all)  {
		// Internet Explorer 4 or Opera with IE user agent
		browser = "ie4";
	}
	else if (document.layers) {
		// Navigator 4
		browser = "net4";
		location.href = "oldbrowser.html";
	}
	
	detect = navigator.userAgent.toLowerCase(); 

	var version = 99;
	if (checkIt('msie')) { // browser is IE
		version = detect.charAt(place + theString.length);
		if (checkIt('mac'))
			location.href = "maciebrowser.html";
		if (version < 6)
			location.href = "oldbrowser.html";
	}
}
function checkIt(string) {
	place = detect.indexOf(string) + 1;
	theString = string;
	return place;
}

//----------------------------------------------------------------------
// FUNCTION: Open a new window
//----------------------------------------------------------------------
function targetBlank (url) {
  blankWin = window.open(url,'_blank','menubar=yes,toolbar=yes,location=yes,directories=yes,fullscreen=no,titlebar=yes,hotkeys=yes,status=yes,scrollbars=yes,resizable=yes');
}

//----------------------------------------------------------------------
// FUNCTION: addresses
//----------------------------------------------------------------------
