function popup(url, width, height, resizable, scrollbars) 
	{
	var append = "";
	if (resizable) append = append + ",resizable";
	if (scrollbars) append = append + ",scrollbars";
	window.open(url, null, 'width=' + width + ',height=' + height + append);
	}

function closeParentWin()
	{
	parent.close();
	}

function closeWin()
	{
	window.close();
	}
function closeNewWin(RefreshPage)
	{
	if (window.opener && !window.opener.closed) window.opener.parent.top.document.location.href = RefreshPage;
	window.close();
	}

function closePopWin(RefreshPage)
	{
	if (window.opener && !window.opener.closed) window.opener.document.location.href = RefreshPage;
	window.close();
	}

function showStatus(text) 
	{
	window.status = text;
	}

function autotab(curr_field, char_count)
{
   var ele_len = document.forms[0].elements.length;  
   var field_legnth = curr_field.value.length;       
                                                     

   for (var z=0; z<ele_len; z++)
       document.forms[0].elements[z].name;

   if (char_count == field_legnth)
   {
      for(var k=0; k<ele_len; k++)
         if(curr_field.name == document.forms[0].elements[k].name)
         {
            document.forms[0].elements[k+1].focus();
            return;
         }
   }
}


function clearBox(box) {
	if(box.value==box.defaultValue) {
		box.value = "";
	}
}

function fixBox(box) {
	if(box.value=="") {
		box.value = box.defaultValue
	}
}

function Left(str, n)
/***
        IN: str - the string we are LEFTing
            n - the number of characters we want to return

        RETVAL: n characters from the left side of the string
***/
{
        if (n <= 0)     
                return "";
        else if (n > String(str).length)   
                return str;                
        else 
                return String(str).substring(0,n);
}

function Len(str)
/***
IN: str - the string whose length we are interested in
RETVAL: The number of characters in the string
***/
	{  
	return String(str).length;  
	}

function FormatDateTime(datetime, FormatType)
/*
	 FomatType takes the following values
		1 - General Date = Friday, October 30, 1998
		2 - Typical Date = 10/30/98
		3 - Standard Time = 6:31 PM
		4 - Military Time = 18:31
*/
{
	var strDate = new String(datetime);

	if (strDate.toUpperCase() == "NOW") {
		var myDate = new Date();
		strDate = String(myDate);
	} else {
		var myDate = new Date(datetime);
		strDate = String(myDate);
	}


	
	var Day = new String(strDate.substring(0,3));
	if (Day == "Sun") Day = "Sunday";
	if (Day == "Mon") Day = "Monday";
	if (Day == "Tue") Day = "Tuesday";
	if (Day == "Wed") Day = "Wednesday";
	if (Day == "Thu") Day = "Thursday";
	if (Day == "Fri") Day = "Friday";
	if (Day == "Sat") Day = "Saturday";	
	
	var Month = new String(strDate.substring(4,7)), MonthNumber = 0;
	if (Month == "Jan") { Month = "January"; MonthNumber = 1; }
	if (Month == "Feb") { Month = "February"; MonthNumber = 2; }
	if (Month == "Mar") { Month = "March"; MonthNumber = 3; }
	if (Month == "Apr") { Month = "April"; MonthNumber = 4; }
	if (Month == "May") { Month = "May"; MonthNumber = 5; }
	if (Month == "Jun") { Month = "June"; MonthNumber = 6; }
	if (Month == "Jul") { Month = "July"; MonthNumber = 7; }
	if (Month == "Aug") { Month = "August"; MonthNumber = 8; }
	if (Month == "Sep") { Month = "September"; MonthNumber = 9; }
	if (Month == "Oct") { Month = "October"; MonthNumber = 10; }
	if (Month == "Nov") { Month = "November"; MonthNumber = 11; }
	if (Month == "Dec") { Month = "December"; MonthNumber = 12; }
	
	var curPos = 11;
	var MonthDay = new String(strDate.substring(8,10));
	if (MonthDay.charAt(1) == " ") {
		MonthDay = "0" + MonthDay.charAt(0);
		curPos--;
	}	
	
	var MilitaryTime = new String(strDate.substring(curPos,curPos + 5));
	
	var Year = new String(strDate.substring(strDate.length - 4, strDate.length));	
	
	document.write(strDate + "");	

	
	if (FormatType == 1)
		strDate = Day + ", " + Month + " " + MonthDay + ", " + Year;
	else if (FormatType == 2)
		strDate = MonthNumber + "/" + MonthDay + "/" + Year.substring(2,4);
	else if (FormatType == 3) {
		var AMPM = MilitaryTime.substring(0,2) >= 12 && MilitaryTime.substring(0,2) != "24" ? " PM" : " AM";
		if (MilitaryTime.substring(0,2) > 12)
			strDate = (MilitaryTime.substring(0,2) - 12) + ":" + MilitaryTime.substring(3,MilitaryTime.length) + AMPM;
		else {
			if (MilitaryTime.substring(0,2) < 10)
				strDate = MilitaryTime.substring(1,MilitaryTime.length) + AMPM;
			else
				strDate = MilitaryTime + AMPM;
		}
	}	
	else if (FormatType == 4)
		strDate = MilitaryTime;


	return strDate;
}


 function LTrim(str)
        /***
                PURPOSE: Remove leading blanks from our string.
                IN: str - the string we want to LTrim

                RETVAL: An LTrimmed string!
        ***/
        {
                var whitespace = new String(" \t\n\r");

                var s = new String(str);

                if (whitespace.indexOf(s.charAt(0)) != -1) {
                    

                    var j=0, i = s.length;

                    
                    while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
                        j++;


                    
                    s = s.substring(j, i);
                }

                return s;
        }

function RTrim(str)
        /***
                PURPOSE: Remove trailing blanks from our string.
                IN: str - the string we want to RTrim

                RETVAL: An RTrimmed string!
        ***/
        {
                
                var whitespace = new String(" \t\n\r");

                var s = new String(str);

                if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
                    
                    var i = s.length - 1;       

                    while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
                        i--;

                    s = s.substring(0, i+1);
                }

                return s;
        }

function Trim(str)
        /***
                PURPOSE: Remove trailing and leading blanks from our string.
                IN: str - the string we want to Trim

                RETVAL: A Trimmed string!
        ***/
        {
                return RTrim(LTrim(str));
        }

function Right(str, n)
        /***
                IN: str - the string we are RIGHTing
                    n - the number of characters we want to return

                RETVAL: n characters from the right side of the string
        ***/
        {
                if (n <= 0)     
                   return "";
                else if (n > String(str).length)   
                   return str;                     
                else { 
                   var iLen = String(str).length;
                   return String(str).substring(iLen, iLen - n);
                }
        }

function Mid(str, start, len)
        /***
                IN: str - the string we are LEFTing
                    start - our string's starting position (0 based!!)
                    len - how many characters from start we want to get

                RETVAL: The substring from start to start+len
        ***/
        {
                
                if (start < 0 || len < 0) return "";

                var iEnd, iLen = String(str).length;
                if (start + len > iLen)
                        iEnd = iLen;
                else
                        iEnd = start + len;

                return String(str).substring(start,iEnd);
        }


/* Keep in mind that strings in JavaScript are zero-based, so if you ask
 for Mid("Hello",1,1), you will get "e", not "H".  To get "H", you would
 simply type in Mid("Hello",0,1)

 You can alter the above function so that the string is one-based.  Just
 check to make sure start is not <= 0, alter the iEnd = start + len to
 iEnd = (start - 1) + len, and in your final return statement, just
 return ...substring(start-1,iEnd)*/

function InStr(strSearch, charSearchFor)
/*
InStr(strSearch, charSearchFor) : Returns the first location a substring (SearchForStr)
                           was found in the string str.  (If the character is not
                           found, -1 is returned.)
                           
Requires use of:
	Mid function
	Len function
*/
{
	for (i=0; i < Len(strSearch); i++)
	{
	    if (charSearchFor == Mid(strSearch, i, 1))
	    {
			return i;
	    }
	}
	return -1;
}


function UCase(string)
{
	return string.toUpperCase();
}

function LCase(string)
{
	return string.toLowerCase();
}


function clearBox(box) {
	if(box.value==box.defaultValue) {
		box.value = "";
	}
}

function fixBox(box) {
	if(box.value=="") {
		box.value = box.defaultValue;
	}
	else {
		fixfirst(box);
	}
	
}

function fix(box)
{
	box.value = fixfirst(box.value);
}

function fixfirst(box)
{
	theWord = box;
	theWord = Trim(theWord);
	
	// Smith-Jones 
	if (theWord.indexOf(' ') > -1)
	{
		var TheWords = theWord.split(" ");
		var theRest;
		theRest = "";
		for (i = 0;i < TheWords.length;i++)
		{
			theRest = theRest + ' ' + fixfirst(TheWords[i]);
		}
		box = theRest;
	}
	else if (theWord.indexOf('-') > -1)
	{
		var TheWords = theWord.split("-");
		var theRest;
		theRest = "";
		for (i = 0;i < TheWords.length;i++)
		{
			theRest = theRest + '-' + fixfirst(TheWords[i]);
		}
		theRest = Mid(theRest, 1, Len(theRest)-1);
		box = theRest;
	}
	else
	{
		var theStartPos = 1;
		var shouldUCase = true;
		var theFirstThree = Left(theWord, 3);
		if (theFirstThree == "McM" || theFirstThree == "McC" || theFirstThree == "McN" || theFirstThree == "O\'B") // || Left(theWord, 3) == 'O\'B'
		{
			theStartPos = 3;
			shouldUCase = false;
		}
		
		theFirstLetter = Left(theWord, theStartPos);
		
		if (shouldUCase == true)
		{
			theFirstLetter = UCase(theFirstLetter);
		}
		
		theRest = Mid(theWord, theStartPos, Len(theWord));
		theRest = LCase(theRest);
	
		box = theFirstLetter + theRest;
	}

	
	box = Trim(box);
	return box;
}


function Show(WhichBox)
{
	var theElement = document.getElementById(WhichBox);
	theElement.style.visibility = "visible";
	theElement.style.display = "block";
}

function Hide(WhichBox)
{
	var theElement = document.getElementById(WhichBox);
	theElement.style.visibility = "hidden";
	theElement.style.display = "none";
}

function ShowTheDiv(WhichBox)
{
	Show(WhichBox);
}

function HideTheDiv(WhichBox)
{
	
	Hide(WhichBox);
}

function serializeData(theFormName)
{
   wddxSerializer = new WddxSerializer();

	col0 = new Array();
	WDDXQuery = new WddxRecordset();

	var theForm = eval('document.' + theFormName); 

	
	for(i=0; i<theForm.elements.length; i++)
	{
		
		var elementType = theForm.elements[i].type;
		if(elementType == "radio") 
		{ 
			if (theForm.elements[i].checked)
			{
			col0 = new Array();
			col0[0] = theForm.elements[i].value;
			WDDXQuery[theForm.elements[i].name] = col0;
			}
		}
		else
		{
			col0 = new Array();
			col0[0] = theForm.elements[i].value;
			WDDXQuery[theForm.elements[i].name] = col0;
		} 
	}	

   wddxPacket = wddxSerializer.serialize(WDDXQuery);

   if (wddxPacket != null)
   {
		return wddxPacket
   }
   else
   {
      alert("Couldn't serialize data");
   }
}

function OW(strName,iW,iH,TOP,LEFT,R,S,SC,T,TB,URL,TYPE,dArg)
{
	if (TYPE=="modal" || TYPE=="modalIframe")
	{
	var sF=""
	var _rv
	sF+=T?'unadorned:'+T+';':'';
	sF+=TB?'help:'+TB+';':'';
	sF+=S?'status:'+S+';':'';
	sF+=SC?'scroll:'+SC+';':'';
	sF+=R?'resizable:'+R+';':'';
	sF+=iW?'dialogWidth:'+iW+'px;':'';
	sF+=iH?'dialogHeight:'+(parseInt(iH)+(S?42:0))+'px;':'';
	sF+=TOP?'dialogTop:'+TOP+'px;':'';
	sF+=LEFT?'dialogLeft:'+LEFT+'px;':'';
	
	
	document.getElementById("thepage").style.filter = "alpha(opacity=30)";

	
	if (TYPE=="modal")
		_rv=window.showModalDialog(URL+"&r="+Math.round(Math.random()*1000000),dArg?dArg:"",sF);
	else
	{
		var da=new Object()
		da.w=iW;
		da.h=iH;
		da.url=URL;
		_rv=window.showModalDialog("/cgi-bin/dasp/ModalIframe.asp?r="+Math.round(Math.random()*1000000),da,sF);
	}

	if ("undefined" != typeof(_rv) )
		return _rv;
	}
	else
	{
		var sF=""
		sF+=iW?'width='+iW+',':'';
		sF+=iH?'height='+iH+',':'';
		sF+=R?'resizable='+R+',':'';
		sF+=S?'status='+S+',':'';
		sF+=SC?'scrollbars='+SC+',':'';
		sF+=T?'titlebar='+T+',':'';
		sF+=TB?'toolbar='+TB+',':'';
		sF+=TB?'menubar='+TB+',':'';
		sF+=TOP?'top='+TOP+',':'';
		sF+=LEFT?'left='+LEFT+',':'';
		return window.open(URL?URL:'about:blank',strName?strName:'',sF).focus()
	}
}

function selectRadio(theRadio, theValue)
{
	radios = theRadio;

	for (i = 0; i < radios.length; i++) {
		if (radios[i].value == theValue) 
		{
			radios[i].checked = true;
		}
		else
		{
			radios[i].checked = false;
		}
	}
}