// FUNCTIONS
function imageSupport() {
	var image_support = (navigator.userAgent.indexOf('Gecko') != -1) ? 'png' : 'gif';
	return image_support;
}

function addStyleSheet(filename) {
	var success = false;

	// Use DOM
	if (document.getElementsByTagName) {
		// Create LINK element and spec attrs
		var link = document.createElement("link");
		link.setAttribute("rel","stylesheet");
		link.setAttribute("type","text/css");
		link.setAttribute("href",filename);

		// Attempt to add to HEAD
		var h = document.getElementsByTagName("head");
		if (h[0]) {
			h[0].appendChild(link);
			success = true;
		}
	}

	// Otherwise use document.write
	if (!success) {
		document.write('<link rel="stylesheet" type="text/css" href="' + filename + '" />' + "\n");
	}
}

function swapSrc(obj,str_find,str_rep) {
	if (!document[obj]) return;
	document[obj].src = document[obj].src.replace(str_find,str_rep);
}

function cancelEvts(obj) {
	if (!obj) return false;
//	obj.onmouseover = null;
//	obj.onmouseout = null;
	if (obj.blur) obj.blur();
	return true;
}


// ADD AUX STYLESHEET
addStyleSheet('/content/includes/style_' + imageSupport() + '.css');

// DO PRELOADS
var btns = new Array(
	"/assets/images/layout/relic_logo.gif",
	"/assets/images/layout/bg_texture.gif",
	"/assets/images/nav/wines.gif",
	"/assets/images/nav/vineyards.gif",
	"/assets/images/nav/people.gif",
	"/assets/images/nav/ordering.gif",
	"/assets/images/nav/list.gif",
	"/assets/images/nav/contact.gif",
	"/assets/images/nav/wines_on.gif",
	"/assets/images/nav/vineyards_on.gif",
	"/assets/images/nav/people_on.gif",
	"/assets/images/nav/ordering_on.gif",
	"/assets/images/nav/list_on.gif",
	"/assets/images/nav/contact_on.gif",
	"/assets/images/layout/relic_logo_on.gif"
);

// GLOBAL array to hold preloads
var imgs = new Array();

for (x in btns) {
	imgs[x] = new Image();
	imgs[x].src = btns[x];
}
