/**
 * DHTML textbox character counter (IE4+) script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
function addEvent(elm, evType, fn, useCapture)
{
if(elm.addEventListener)
  {
  elm.addEventListener(evType, fn, useCapture);
  return true;
  }
else if (elm.attachEvent)
  {
  var r = elm.attachEvent('on' + evType, fn);
  return r;
  }
else
  {
  elm['on' + evType] = fn;
  }
}
function checkAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = true ;
}
function checktop(field,num) {
	var lengthoffield = 0;
	lengthoffield = Math.min(num,field.length);
	for (i = 0; i < lengthoffield; i++)
		field[i].checked = true ;
}
function uncheckAll(field)
{
 
	for (i = 0; i < field.length; i++)
		field[i].checked = false ;
	 
	}
function formSubmit(thisform,newaction) {       
	thisform.action = newaction;       
} 

// removes the square border that IE
// insists on adding to checkboxes and radio
function removeCheckBoxBorders()
{
var el = document.getElementsByTagName("input");
for (i=0;i<el.length;i++)
  {
  var type = el[i].getAttribute("type");
  if((type=="checkbox")||(type=="radio"))
    {
   el[i].style.border = "none";
    }
  }
}
addEvent(window, 'load', removeCheckBoxBorders, false);
function taLimit() {
	var taObj=event.srcElement;
	if (taObj.value.length==taObj.maxLength*1) return false;
}
function taCount(visCnt) { 
	var taObj=event.srcElement;
	if (taObj.value.length>taObj.maxLength*1) taObj.value=taObj.value.substring(0,taObj.maxLength*1);
	if (visCnt) visCnt.innerText=taObj.maxLength-taObj.value.length;
}
function textCounter(field, maxlimit) {
	if (field.value.length > maxlimit) {
		field.value = field.value.substring(0, maxlimit);
		alert("This field cannot contain more than " + maxlimit + " characters");
	}
}
function hideShow(div,icon,swaptext,title)
{ 
	if(document.getElementById(div).style.display == 'none')
	{ 
		document.getElementById(div).style.display = '';
		document.images[icon].src = '/_resources/images/xtree/hide.gif';
		document.getElementById(swaptext).innerText = 'Hide ' + title;	
	}
	else
	{
		document.getElementById(div).style.display = 'none';
		document.images[icon].src = '/_resources/images/xtree/show.gif';
		document.getElementById(swaptext).innerText = 'Show ' + title;	
	}
} 
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 cancel() {
	 history.go(-1);
}
function gohere(gotoURL) {
	 window.location = gotoURL;	
}
function hov(loc,cls){
   if(loc.className)
      loc.className=cls;
}
function del(gotoURL) {
	if(confirm('Are you sure want to delete this?')) 		
		{
		location = gotoURL;
		}
	return;
	}
function archive(gotoURL) {
	if(confirm('Are you sure want to archive this?')) 		
		{
		location = gotoURL;
		}
	return;
}
