window.onload = function() {
	if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
		fnLoadPngs();
	}
	
	soopaPopSetup();
	loadStyle();
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// google analytics

_uacct = "UA-92288-1";
urchinTracker();


// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// from 'sleight.js' at youngpup.net

if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
	document.writeln('<style type="text/css">img { visibility:hidden; } </style>');
//	window.attachEvent("onload", fnLoadPngs);
}

function fnLoadPngs() {
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);

	for (var i = document.images.length - 1, img = null; (img = document.images[i]); i--) {
		if (itsAllGood && img.src.match(/\.png$/i) != null) {
			var src = img.src;
			img.style.width = img.width + "px";
			img.style.height = img.height + "px";
			img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')"
			img.src = img.src.replace(/[^\/]+$/g, "x.gif");
		}
		img.style.visibility = "visible";
	}
}


// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// from 'soopa-pop.js' at youngpup.net

function soopaPopSetup() {
	var a;
	for (var i = 0; (a = document.links[i]); i++) {
		if (a.target && a.target.indexOf("soopaPop") == 0) {
			a.onclick = soopaPop;
		}
	}
}

function soopaPop() {
	var a = this.target.split(":");
	var sFeatures = a[1];
	window.open(this.href, a.length > 2 ? a[2] : String((new Date()).getTime()), sFeatures);
	return false;
}



// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// StyleSwitcher functions written by Paul Sowden
// For the details, visit ALA: http://www.alistapart.com/stories/alternate/

function processIndicator(title) {
	var imgUrl = 'images/pointer.gif';

	if (title == 'colors_three') {
		var page = location.href.substring(location.href.lastIndexOf('/') + 1,location.href.lastIndexOf('.'));
		if (page == 'index') page = 'home';
		imgUrl = 'images/pointer_' + page + '.gif';
	}

	var img = document.getElementById("indicator");
	if (img) img.src = imgUrl;
	
	return title;
}

function setActiveStyleSheet(title) {
	title = processIndicator(title);
	
	var i, a, main;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
			a.disabled = true;
			if(a.getAttribute("title") == title) a.disabled = false;
		}
	}
	
	saveStyle();
}

function getActiveStyleSheet() {
	var i, a;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
	}
	return null;
}


function getPreferredStyleSheet() {
	var i, a;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1
			 && a.getAttribute("rel").indexOf("alt") == -1
			 && a.getAttribute("title")
			 ) return a.getAttribute("title");
	}
	return null;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function saveStyle(e) {
	var title = getActiveStyleSheet();
	createCookie("style", title, 365);
}

function loadStyle(e) {
	var cookie = readCookie("style");
	var title = cookie ? cookie : getPreferredStyleSheet();
	setActiveStyleSheet(title);
}

window.onunload = saveStyle;

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// quickie validation

function validate(oForm) {	
	if (oForm.name.value == '') {
		alert('please enter your name and a message.');
		oForm.name.focus();
		oForm.name.select();
		return false;
	} 
	
	if (oForm.note.value == '') {
		alert('please enter your name and a message.');
		oForm.note.focus();
		oForm.note.select();
		return false;
	}
	
	return true;
}