function confStep(){
	return true;
	//return confirm("You will lose the changes you made after the last Submit, proceed?");	
}
/* detect browser */
var ie;
document.getElementById && !document.all ?	ie = false : ie = true;
function eventsource(e){
	return ie ? event.srcElement : e.target	
}
function fixevent(e){
	if (!e && window.event)
		return window.event;
	return e;
}
function isTag(o, tag){
	return o != null && o.tagName != null && tag != null && o.tagName.toLowerCase() == tag.toLowerCase();
}
function getTagAncestor(o, tag){
	if (!o)
		return null;
	var p=ie? o.parentElement : o.parentNode	
	while (p && !isTag(p, tag))
		p=ie? p.parentElement : p.parentNode
	return p;	
}
function toURI(s){	
	if (!s)
		return '';
	return encodeURIComponent(s.toString());
}
function absolutePosition(o)
{
	var x = o.offsetLeft;
	var y = o.offsetTop;
	var p = o.offsetParent;
	while (p)
	{
		x += p.offsetLeft;
		y += p.offsetTop;
		if (p.tagName.toLowerCase() == 'div')
		{
			y -= p.scrollTop;
			x -= p.scrollLeft;
		}		
		p = p.offsetParent;
	}

	this.x = x;
	this.y = y;
}
function getFirstElementTag(o, tag)
{
	if (!o)
		return null;
	for (var i = 0; i < o.childNodes.length; i++)
	{
		var node = o.childNodes.item(i);
		if (isTag(node, tag))
			return node;
	}
	return null;
}
/* this actually fetches the n'th span of a row, whether it's hidden or not */
function getRowHiddenSpan(row, index)
{
	if (!isTag(row, 'tr'))
		return null;
		
	var cell = row.cells[0];
	if (!cell)
		return null;
	var cnt = 0;
	for (var i = 0; i < cell.childNodes.length; i++)
	{
		var c = cell.childNodes[i];
		if (!isTag(c, 'span'))
			continue;
		if (cnt >= index)
			return c;
		cnt++;
	}
	
	return null;
}

function getRowHiddenSpanValue(row, index)
{
	var span = getRowHiddenSpan(row, index);
	if (!span)
		return '';
	return span.innerHTML;
}
/* fixme: the name is misleading (actually gets innerHTML due to firefox not havin innerText) */
/* this should not be a problem, as it's used only for spans containing text */
function getRowSpanText(row, iSpan)
{
	var span = getRowHiddenSpan(row, iSpan);
	if (!span)
		return '';
	return span.innerHTML;
}

function TrimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}

/* disables form submission on enter */
function noenter(e) {
	return !(e && e.keyCode == 13); 
}

/* common char sets */
var nonzero 	  = "123456789";
var digits 		  = "0123456789";
var alphasWSpace  = "abcdefghijklmnopqrstuvwxyz";
var alphas  	  = " abcdefghijklmnopqrstuvwxyz";

/* gets the keyCode typed*/
function getTypedKeyCode(e){
	var key = false;
	if (window.event) key = window.event.keyCode;
	else if (e) key = e.which;
	return key;	
}

/* allows only characters in the chars array */
function filter(e, chars){
	var key = getTypedKeyCode(e);
	if(!key) return true;
	/* allow upper case */
	var keychar = String.fromCharCode(key).toLowerCase();
	/* allow control keys */
	if ((key==null) || (key==0) || (key==8) ||  (key==9) || (key==13) || (key==27)) return true;
	/* allow chars in arg string */
	else if (((chars).indexOf(keychar) > -1)) return true;
	else return false;
}
function filter_noenter(s,e){	
	return ( filter(e, s) && noenter(e) );
}
/* assures correct min-max range */
function range(o,vmin,vmax){
	if(!vmin)
		vmin = o.value;
	if(!vmax)
		vmax = o.value;
	var l = o.id.length;
	var minmax = o.id.substr(l-3,l);
	if(minmax == 'min'){
		var o2 = document.getElementById(o.id.substr(0,l-3)+'max');
		if(!o2)	return;
		if(o2.value=="") return;		
		if(o2.value < o.value)	o2.value = vmax;
		
	}
	else
	if(minmax == 'max'){
		var o2 = document.getElementById(o.id.substr(0,l-3)+'min');
		if(!o2)	return;
		if(o2.value=="") return;		
		if(o2.value > o.value)	o2.value = vmin;
	}
	return;
}
function rangeSel(o,vmin,vmax){
	if(!vmin && vmin!=0)
		vmin = o.options[o.selectedIndex].value;
	if(!vmax)
		vmax =  o.options[o.selectedIndex].value;
	var l = o.id.length;
	var minmax = o.id.substr(l-3,l);
	if(minmax == 'min'){
		var o2 = document.getElementById(o.id.substr(0,l-3)+'max');
		if(!o2)	return;	
		if(parseInt(o2.options[o2.selectedIndex].value) < parseInt(o.options[o.selectedIndex].value)) comboSelectByValue(o2,vmax);
		
	}
	else
	if(minmax == 'max'){
		var o2 = document.getElementById(o.id.substr(0,l-3)+'min');
		if(!o2)	return;	
		if(parseInt(o2.options[o2.selectedIndex].value) > parseInt(o.options[o.selectedIndex].value))	comboSelectByValue(o2,vmin);
	}	
	return;
}

function comboSelectByValue(combo, value){	
	for (var i = 0; i < combo.options.length; i++){
		var c = combo.options[i];
		if (!isTag(c, 'option'))
			continue;						
		if (c.text == value || c.value == value){
			combo.options[i].selected=true;
			return;
		}
	}	
}

/* allows date only if valid, else resets obj to val*/
function filterDate(obj) {
	var strDate = obj.value;
	var dPart = strDate.split("/");
	if(dPart.length==3){
		if(dPart[2].length<4){
				obj.value = 'mm/dd/yyyy';
				return false;				
			}

		dPart[0] == 1 ? dPart[0] = 11 : dPart[0] -= 1;
		var aDate = new Date(dPart[2],dPart[0],dPart[1]) 
		if( aDate.getDate()==dPart[1] && (aDate.getFullYear()==dPart[2] || (!document.all && aDate.getFullYear()==dPart[2]+1900) )  ){ 
			if(aDate) 
				return true;	
		}
	}	
	
	obj.value = 'mm/dd/yyyy';
	return false;	
}
