var popWin = null    // use this when referring to pop-up window
var winCount = 0
var winName = "popWin"

/* NUMBER CHECKING ROUTINES **************************************************/
function setCFDate(cfyear, cfmonth, cfday, newdate, numberofdays) {
	oDate = new Date(newdate);
	var milliseconds = Date.UTC(oDate.getFullYear(),oDate.getMonth(),oDate.getDate());
    milliseconds += (86400000 * numberofdays);
	oDate = new Date(milliseconds);
	var dYear = oDate.getFullYear();
	var dDay = oDate.getDate();
	var dMonth = oDate.getMonth() + 1;
	if (dMonth < 10) {
		dMonth = '0' + dMonth;
	}
	if (dDay < 10) {
		dDay = '0' + dDay;
	}
	if (cfyear) {
		cfyear.value = dYear;
	}
	if (cfmonth) {
		cfmonth.value = dMonth;
	}
	if (cfday) {
		cfday.value = dDay;
	}
}

function CFDateChange(nMonth, nDay, nYear, cMonth, cDay, cYear, numberofdays) {
	var cDate = nMonth.value + '/' + nDay.value + '/' + nYear.value;
	setCFDate(cYear, cMonth, cDay, cDate, numberofdays);
}

function numberOnlywithDecimal(num, msg) {
	var origvalue = num.value;
	var newvalue = num.value;

	newvalue = origvalue.replace(/[^0-9\.]/gi, "").replace(/([0-9]*)(\.?)([0-9]*)(\.?)([0-9]*)?/gi, "$1$2$3");
	if (newvalue != origvalue) {
		num.value = newvalue;
		if (msg) {
			alert(msg);
		}
		return false;
	}
	return true;
}

function numberOnlywithoutDecimal(num, msg) {
	var origvalue = num.value;
	var newvalue = num.value;
	newvalue = origvalue.replace(/[^0-9]/gi, "");
	if (newvalue != origvalue) {
		num.value = newvalue;
		if (msg) {
			alert(msg);
		}
		return false;
	}
	return true;
}

/*  VISUAL CONTROL FUNCTIONS ****************************************************/
function swapit(spanname) {
	document.all(spanname).style.visibility = ("hidden" == document.all(spanname).style.visibility ? "visible" : "hidden");
}

/*  TABLE HANDLERS FOR QUICK CHANGES AND CLICK EVENTS **************************/
function trmouseover(tr, color, cursor) {
	if (color != null) tr.style.backgroundColor = color;
	if (cursor == null) {cursor = 'default'};
	tr.style.cursor = cursor;
}
function trmouseout(tr, color) {
	if (color != null) tr.style.backgroundColor = color;
	tr.style.cursor = 'default';
}
function trclick(loc) {
	document.location=loc;
}

/* quick swap for highlighting a link with an underscore */
function linkglow(linkobj) {
	linkobj.style.textDecoration = ("underline" == linkobj.style.textDecoration ? "none" : "underline");
	/*if (linkobj.style.textDecoration) == 'none':linkobj.style.textDecoration='underline':linkobj.style.textDecoration='none';*/
	
}

/*  Function for highlighting TOC items ****************************************/
function highlightRow(row,toggle){
    if(document.all){

        toggle == 1 ? row.style.background = "#9CB4EB" : row.style.background = "#C2D1F3";
		//toggle == 1 ? row.style.background = "5396C3" : row.style.background = "CBDFED";
        //toggle == 1 ? row.style.background = "7a8cad" : row.style.background = "43527a";
    }
}

function highlightContentRow(row,toggle){
    if(document.all){

        toggle == 1 ? row.style.background = "CBDFED" : row.style.background = "5396C3";
        //toggle == 1 ? row.style.background = "7a8cad" : row.style.background = "43527a";
    }
}
/*  Funciton for toggling TOC items *******************************************/
function toggle(elem)
{   
	if(elem!=null)//Temp: added 12-12-00; MLWardrick; error-handling for null objects
	{
		if(elem.nextSibling!=null) {
			elem.nextSibling.style.display = ("" == elem.nextSibling.style.display ? "none" : "");
	    	elem.children[0].children[0].innerHTML = ("6" == elem.children[0].children[0].innerHTML ? "4" : "6");
		};
	}
}


/*  Function used by CF_COLLAPSABLE to collapse and expand table rows *********/
function spancollapse(spantagid, arrowtagid, fieldtoupdate, formname) {
	document.all(spantagid).style.display = ("none" == document.all(spantagid).style.display ? "block" : "none");
	document.all(arrowtagid).innerHTML = ("block" == document.all(spantagid).style.display ? "6" : "4");
	if (fieldtoupdate) {
		if (document.all(spantagid).style.display == "none") {
			document.forms(formname).elements(fieldtoupdate).value = "true";
		}
		else
		{
			document.forms(formname).elements(fieldtoupdate).value = "false";
		};
		document.forms(formname).submit();
	}
}

function gotoobject(obj) {
	obj.focus();
}
	
function pfwindow(fulllink) {
	var newWin = window.open(fulllink + '&pf=true', '', '');
}

function openPopWin(winURL, winWidth, winHeight, winFeatures, winLeft, winTop){
  var d_winLeft = 20  // default, pixels from screen left to window left
  var d_winTop = 20   // default, pixels from screen top to window top
  winName = "popWin" + winCount++ //unique name for each pop-up window
  closePopWin()           // close any previously opened pop-up window
  if (openPopWin.arguments.length >= 4)  // any additional features? 
    winFeatures = "," + winFeatures
  else 
    winFeatures = "" 
  if (openPopWin.arguments.length == 6)  // location specified
    winFeatures += ",left=" + winLeft + ",top=" + winTop
  winURL += "&pop=true"
  popWin = window.open(winURL, winName, "width=" + winWidth 
           + ",height=" + winHeight + winFeatures)
}

function closePopWin(){    // close pop-up window if it is open 
  if (navigator.appName != "Microsoft Internet Explorer" 
      || parseInt(navigator.appVersion) >=4) //do not close if early IE
    if(popWin != null) if(!popWin.closed) popWin.close() 
}

function getLocation(winWidth, winHeight, winLeft, winTop){
  return ""
}

