//Highlight table row on hover
//usage onmouseover="mark_row(this)" onmouseout="unmark_row(this)"
function mark_row(t) {
t.style.backgroundColor = '#F6ECE2';
}
function unmark_row(t) {
t.style.backgroundColor = 'transparent';
}

//this nice javascript will open external links in a new window - http://www.sitepoint.com/article/standards-compliant-world/3
//usage rel="external"

function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rev") == "external") 
     {anchor.target = "_blank";
		 anchor.title = anchor.title+" in a new window";}
	 else
	 	 {anchor.title = anchor.title;} 
 } 
} 
window.onload = externalLinks;

// for textareas to not get too long
// the markup is: onkeyup="textLimit(this.form.fieldid, 250);"
function textLimit(field, maxlen) {
if (field.value.length > maxlen + 1)
alert('Your input has been truncated!');
if (field.value.length > maxlen)
field.value = field.value.substring(0, maxlen);
}
//also for textareas to not get too long and adds a little box showing how many characters are left
// markup - onKeyDown="textCounter(this.form.fieldname,this.form.remLen,125);" onKeyUp="textCounter(this.form.fieldname,this.form.remLen,125);
// markup for little box - <input type="readonly" type="text" name="remLen" size="3" maxlength="3" value="125" /><br /> characters left
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}

//for checking and unchecking boxes - usage <input type="checkbox" name="checkall" onclick="checkUncheckAll(this, del);"> where
// del is the name of the field to check/uncheck 
function checkUncheckAll(checkAllState, cbGroup)
{
	for (i = 0; i < cbGroup.length; i++)
	{
		cbGroup[i].checked = checkAllState.checked;
	}
}




	
//this allows all things in the list to be checked/unchecked
function checkAll(chkid)
{ 
for (i = 0; i < chkid.length; i++)
	chkid[i].checked = true ;
	
}

function uncheckAll(chkid)
{
for (i = 0; i < chkid.length; i++)
	chkid[i].checked = false ;
}

//this is probably a better version of the above
function selectAll(obj) { 
var checkBoxes = document.getElementsByTagName('input'); 
for (i = 0; i < checkBoxes.length; i++) { 
if (obj.checked == true) { 
checkBoxes[i].checked = true; // this checks all the boxes 
} else { 
checkBoxes[i].checked = false; // this unchecks all the boxes 
} 
} 
} 


