

/* THE INFAMOUS POPUP WINDOW
javascript: popWindow('theURL','winName','scrollbars=no,width=100,height=100')
---------------------------------------- */

function popWindow(daURL,daName,daFeats) {
	window.open(daURL,daName,daFeats);
}


/* ALLOWS PNGS IN IE4+
---------------------------------------- */

if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
	document.writeln('<style type="text/css">img { visibility:hidden; } </style>');
	window.attachEvent("onload", fn_load_pngs);
}

function fn_load_pngs() {
	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 = "/images/mrI.gif";
		}
		img.style.visibility = "visible";
	}	
}


/* ALTERNAME TABLE ROWS 
---------------------------------------- */

function color_rows() {
	var targetTable		= 'list-table';
	var classToApply	= 'alt';

	var tables=document.getElementsByTagName ('table');
	for (var i=0;i<tables.length;i++){
		if(tables[i].className==targetTable){
			var myTR = document.getElementsByTagName('tr');
			for (var e=1;e < myTR.length;e+=2){
				myTR[e].className += " " + classToApply;
			}
		}
	}
}


/* TABLE RULER
---------------------------------------- */

function table_ruler(){	
	var targetTable		= 'list-table';
	var classToApply	= 'alt';

	if (document.getElementById && document.createTextNode){
		var tables=document.getElementsByTagName ('table');
		for (var i=0;i<tables.length;i++){
			if(tables[i].className==targetTable){
				var trs=tables[i].getElementsByTagName('tr');
				for(var j=0;j<trs.length;j++){
					if(trs[j].parentNode.nodeName=='TBODY' && trs[j].parentNode.nodeName!='TFOOT'){					
						trs[j].onmouseover=function(){
							this.className=classToApply;return false
						}
						trs[j].onmouseout=function(){
							this.className='';return false
						}
					}
				}
			}
		}
	}
}

/* FORM FIELD VALIDATION
onSubmit="return check_required_fields();"

function check_required_fields() {
	var errorMessage = new String();
	if(noneWithCheck(document.daForm.checkOne)){ errorMessage += "\nPlease check one or more check boxes of the set of three."; }
	if(withoutCheck(document.daForm.checkLoner)){ errorMessage += "\nThe \"Loner\" check box must be checked."; }
	if(withoutContent(document.daForm.sometext.value)){ errorMessage += "\n\"Some text\" is a required field."; }
	if(noneWithContent(document.daForm.oneOrTheOther)){ errorMessage += "\nSomething must be typed in one or both of the set of form text fields."; }
	if(isValidEmail(document.daForm.areaName.value)){ errorMessage += "\nThe email address you entered is not valid."; }
	if(withoutSelectionValue(document.daForm.dropname)){ errorMessage += "\nPlease select something from the dropdown list."; }
	if(errorMessage.length > 2) {
		displayEM(errorMessage);
		return false;
	}
	return true;
}
---------------------------------------- */

function displayEM(errorMessage){
	var beforeErrorMessage = new String();
	beforeErrorMessage = "You man not have noticed but:\n";
	var afterErrorMessage = new String();
	afterErrorMessage = "\n\nPlease make the above changes.";
	alert(beforeErrorMessage + errorMessage + afterErrorMessage);
}

function withoutContent(ss) {
	if(ss.length > 0) { return false; }
	return true;
}

function isValidEmail(ss) {
	if(ss.length > 0) {
		if((ss.indexOf(".") > 0) && (ss.indexOf("@") > 0)) { return false; }
		return true;
	}
}

function isValidURL(ss) {
	if(ss.length > 0) {
		if((ss.substring(0,7) == "http://") && (ss.indexOf(".") > 0)) { return false; }
		return true;
	}
}

function noneWithContent(ss) {
	for(var i = 0; i < ss.length; i++) {
		if(ss[i].value.length > 0) { return false; }
	}
	return true;
}

function noneWithCheck(ss) {
	if(ss.length){
		for(var i = 0; i < ss.length; i++) {
			if(ss[i].checked) { return false; }
		}
	}else{
		if(ss.checked) { return false; }
	}
	return true;
}

function withoutCheck(ss) {
	if(ss.checked) { return false; }
	return true;
}

function withoutSelectionValue(ss) {
	for(var i = 0; i < ss.length; i++) {
		if(ss[i].selected) {
			if(ss[i].value.length) { return false; }
		}
	}
return true;
}


/* ONLOAD
---------------------------------------- */
window.onload=function(){
	color_rows();
	table_ruler();
}