function validate() {
var thisf; 
var errstr = "";
	if (typeof cvld != 'undefined') {
	for(i = 0; i < document.frm.length; i++) {
	thisf = document.frm[i];

	  if (thisf.type == 'file' && thisf.value.length > 1){
		//	alert(thisf.type+" is type for fld with value of "+thisf.value+" and name is "+thisf.name); 
	  show_patient_flag = 1;
	  } 

	  if(cvld[i] != null && cvld[i] != ''){  
		// N   is this variable not supposed to be left blank? 
		if (cvld[i] == 'N' && (thisf.value == '' || isNaN(thisf.value))){ 
		errstr += "* "+cvldmsg[i]+" (Valid Number)\r";
		rowbg(cvldrow[i],i);
		}
		
		// B   is this variable not supposed to be left blank? 
		if (cvld[i] == 'b' && (thisf.value == '' || thisf.type == 'checkbox' && thisf.checked != true)){ 
		errstr += "* "+cvldmsg[i]+"\r";
		rowbg(cvldrow[i],i);
		}				
		// F  is this FILE variable not supposed to be left blank? (works for file filds too)
		if (cvld[i] == 'f' && thisf.value == ''){ 
//		alert(i+"* "+cvldmsg[i]);
		var nextf = i+1; 
			if(document.frm[nextf].type != 'hidden'){
			errstr += "* "+cvldmsg[i]+"\r";
			rowbg(cvldrow[i],i);
			}
		}				
		// SB    is this DD list variable not supposed to be left blank? 
		else if (cvld[i] == 'sb' && thisf.options[thisf.options.selectedIndex].value == ''){ 
		errstr += "* "+cvldmsg[i]+"\r";
		rowbg(cvldrow[i],i);
		}
		// EE    is this variable supposed to be in email format
		else if (cvld[i] == 'ee'){
			if (thisf.value.indexOf("@") == -1 || thisf.value.indexOf(".") == -1 || thisf.value.indexOf(" ") != -1){ 
			errstr += "* "+cvldmsg[i]+" (ex. yourname@somedomain.com)\r";
			rowbg(cvldrow[i],i);
			}
		}
		// is this variable supposed to be an EXACT length?
		else if (cvld[i].indexOf("el") != -1) {
		len = cvld[i].substr(cvld[i].indexOf("l")+1, cvld[i].length);
			if(parseInt(len) != thisf.value.length){
			errstr += "* "+cvldmsg[i]+"\r";
			rowbg(cvldrow[i],i);
			}
		}
		// is this variable supposed to be at least a certain length?
		else if (cvld[i].indexOf("l") != -1) {
		len = cvld[i].substr(cvld[i].indexOf("l")+1, cvld[i].length);
			if(parseInt(len) > thisf.value.length){
			errstr += "* "+cvldmsg[i]+"\r";
			rowbg(cvldrow[i],i);
			}
		}
	  }
	}
	}
 if(errstr != ""){
 alert("Please complete the required fields now before proceeding\n\n"+errstr);
// window.status = getfocus;
 eval(getfocus);
 getfocus = '';
 recolor = '';
 nohilite = 1;
 return false;
 }
 else{
   if(show_patient_flag == 1){
   show_patient_div();
   }
 return true;
 }
}

var getfocus = '';
var nohilite = 0;
var show_patient_flag = 0;
var outrowid = '';
var recolor = '';
rowcbg = new Array(); 
 
function rowbg(rowid,onoff){
var table = 'formtab'; 
var r=document.getElementById(table).getElementsByTagName( "tr" )[rowid]; 

//alert(rowid+rowcbg[rowid]+" onoff= "+onoff);
	if(rowcbg[rowid] == null || rowcbg[rowid].length < 5){
	rowcbg[rowid] = r.getAttribute('bgcolor'); //r.style["backgroundColor"];
//	alert(rowid+rowcbg[rowid]+" => "+r.style["backgroundColor"]);
	}
	// do color
	if(onoff == 'off'){
	r.style["backgroundColor"]=rowcbg[rowid];
	}
	else if(onoff == 'on' &&  nohilite == 0){
//	r.style["backgroundColor"]='#FFFFCC';
	r.style["backgroundColor"]='#FFF5C3'; // Color Modified as you instructed 
	}
	else if(onoff != 'on' && onoff != 'off')  { // turn red and punish the infidel
	r.style["backgroundColor"]='#FFBBBB';
		if(getfocus == '' && recolor == ''){
// alert(onoff+" != 'on'");
		getfocus = "document.frm["+onoff+"].focus();"; //document.frm["+onoff+"].select();";
		}
		if(outrowid == rowid && recolor == ''){
//alert(rowid+rowcbg[rowid]+" onoff= "+onoff);
		getfocus += " rowbg("+rowid+",3000);";
		recolor = 'done';
		}
	}
		if(onoff == 'on')	outrowid = rowid;

nohilite = 0;
}

function show_patient_div() {
	if(document.all.loading.style){
	document.all.loading.style.bottom = screen.height/2-150;
	document.all.loading.style.left = screen.width/2-150;
	document.all.loading.style.visibility ="visible";
	}
	else if(document.layers){
	document.layers.loading.bottom = screen.height/2-150;
	document.layers.loading.left = screen.width/2-150;
	document.layers.loading.visibility = "visible";
	}
	 
}

// i kept this here to check out the diff later...
function FormatAmount(amt,CommaDelimiter){
if (amt.indexOf(".")){
splt_amt=amt.split(".");
amt=splt_amt[0];
}
amt = amt.replace(/\D/g,""); 
 var samt = new String(amt);
 if (samt.length < 3) { return samt; } 
 for (var i = 0; i < Math.floor((samt.length-(1+i))/3); i++)
 {
   samt = samt.substring(0,samt.length-(4*i+3)) + CommaDelimiter + samt.substring(samt.length-(4*i+3));
 }
 return samt;
}


function go2url(thiss,urlA,conf){
	var id = thiss.options[thiss.options.selectedIndex].value;
	var url = urlA+id;
	if(conf == 1){
		var upd= confirm ('Go to new record '+id+' ?');
		if(upd)
			window.location.href(url);
		else
			alert('Cancelled move');
	}
	else
		window.location.href(url);
}	

		
function confirmdelete(url,msg){
	window.status = 'Delete';
	var del= confirm (msg);

	if(del){
		window.location.href(url);
	}
	else{
//		alert('User Deletion Cancelled');
	}
}	


function banner_frame(){
 if (self != top){
 location = '/';
 }
}
        function txt_front(sflag){
                if (document.frm.front_head != null){
                 if (document.frm.front_head.value == "Front Headline"){
                 document.frm.front_head.value = "";
                 }
                }
         if(sflag == 'submit'){
         window.blur();
         }
        }

function ccon(oTd) {if (!oTd.contains(event.fromElement)) {oTd.bgColor="FFFFFF";}}
function ccoff(oTd) {if (!oTd.contains(event.toElement)) {oTd.bgColor="E9F8FC";}}
		
// dblue = "#1b81c8" Lblue="#daf5f1" turq="#138b91" lturq="#cff2f1" >
		
		
function AppWin(url, wname, pl, pt) {

location=url;
return;


var w = 780;
var h = 550;
pt = pt - 5; // height tweak
 // Nav 4 gives true screen pos %, while default assumes % on 640X480
 if (parseInt(navigator.appVersion) >= 4) {
   if((screen.availWidth * .85) > w) { w = screen.availWidth * .85;  }
   if((screen.availHeight * .85) > h) { h = screen.availHeight * .85; }
 winX = (screen.availWidth - w)*pl*.01;
 winY = (screen.availHeight - h)*pt*.01;
 }
aWin = window.open(url, wname,'scrollbars=yes,status=yes,resizable=yes,width=' + w + ',height=' + h + ',left=' + winX + ',top=' + winY);
 if (aWin.focus) {
 aWin.focus();
 }
}

function PopWin(url, wname, w, h, pl, pt) {
var winX = pl;
var winY = pt;
 // Nav 4 gives true screen pos %, while default assumes % on 640X480
 if (parseInt(navigator.appVersion) >= 4) {
 winX = (screen.availWidth - w)*pl*.01;
 winY = (screen.availHeight - h)*pt*.01;
 }
pWin = window.open(url, wname,'scrollbars=yes,status=no,dependent,resizable=yes,width=' + w + ',height=' + h + ',left=' + winX + ',top=' + winY);
 if (pWin.focus) {
 pWin.focus();
 }
}

function popDesc(menuName,on,l,t) {
var DL_bNS4=(document.layers);
var DL_bNS6 = (navigator.vendor == ("Netscape6") || navigator.product == ("Gecko"));
var DL_bDOM=(document.getElementById);
var DL_bIE=(document.all);
var DL_bIE4=(DL_bIE && !DL_bDOM);
var DL_bMac = (navigator.appVersion.indexOf("Mac") != -1);
var DL_bIEMac=(DL_bIE && DL_bMac);
var DL_bIE4Mac=(DL_bIE4 && DL_bMac);
var DL_bNS =(DL_bNS4 || DL_bNS6);

                if (on) {
                        if (DL_bNS4) {
                        document.layers[menuName].left = l;
                        document.layers[menuName].top = t;
                        document.layers[menuName].visibility = "show";
                        } 
					    else {
						   if(DL_bDOM)
		                   DL_oLayer=document.getElementById(menuName);
					       else
					       DL_oLayer = window[menuName];
                        DL_oLayer.style.left = l;
                        DL_oLayer.style.top = t;
                        DL_oLayer.style.visibility="visible";
                        }
                } else {
                        if (DL_bNS4) {
                        document.layers[menuName].visibility = "hide";
                        } 
						else {
						   if(DL_bDOM)
		                   DL_oLayer=document.getElementById(menuName);
					       else
					       DL_oLayer = window[menuName];
                        DL_oLayer.style.visibility="hidden";
                        }
                }

}

// php_admin row highlighter //

/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   interger  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 * <tr onmouseover="setPointer(this, 1, 'over', '#CCCCCC', '#CCFFCC', '#FFCC99');" onmouseout="setPointer(this, 1, 'out', '#CCCCCC', '#CCFFCC', '#FFCC99');" onmousedown="setPointer(this, 1, 'click', '#CCCCCC', '#CCFFCC', '#FFCC99');">
*/	

var marked_row = new Array;
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

	if(!currentColor)
		currentColor = '';
    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == '' || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function




/*
Pungo Spell Copyright (c) 2003 Billy Cook, Barry Johnson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


// Public functions --------------------------------

// spellCheck - spell check a field
function spellCheck( formName, fieldName, spelltext ) {

   var h_spellform = document.forms['spell_form'];
   h_spellform.spell_formname.value = formName;
   h_spellform.spell_fieldname.value = fieldName;
   h_spellform.spellstring.value = document.forms[formName][fieldName].value;
   openSpellWin(640, 480);
   h_spellform.submit();
   return true;
}

// Private functions -------------------------------

// globals
var wordindex = -1;
var offsetindex = 0;
var ignoredWords = Array();

// mispelled word object
//
function misp(word, start, end, suggestions) {
   this.word = word;               // the word
   this.start = start;             // start index
   this.end = end;                 // end index
   this.suggestions = suggestions; // array of suggestions
}

// replace the word in the misps array at the "wordindex" index.  The
// misps array is generated by a PHP script after the string to be spell
// checked is evaluated with pspell
//
function replaceWord() {
   var frm = document.fm1;
   var strstart = '';
   var strend;

   // if this isn't the beginning of the string then get all of the string
   // that is before the word we are replacing
   if ( misps[ wordindex ].start != 0 )
       strstart = mispstr.slice( 0, misps[ wordindex ].start + offsetindex);

   // get the end of the string after the word we are replacing
   strend = mispstr.slice( misps[ wordindex ].end + 1 + offsetindex);
  
   // rebuild the string with the new word
   mispstr = strstart +  frm.changeto.value  + strend;

   // update offsetindex to compensate for replacing a word with a word
   // of a different length.
   offsetindex += frm.changeto.value.length - misps[ wordindex ].word.length;

   // update the word so future replaceAll calls don't change it
   misps[ wordindex ].word = frm.changeto.value;

   nextWord(false);
}

// replaces all instances of currently selected word with contents chosen by user. 
// note: currently only replaces words after hilighted word.  I think we can re-index
// all words at replacement or ignore time to have it wrap to the beginning if we want
// to.
//
function replaceAll() {
   var frm = document.fm1;
   var strstart = '';
   var strend;
   var idx;
   var origword;
   var localoffsetindex = offsetindex;

   origword = misps[ wordindex ].word;

   // reindex everything past the current word
   for (idx = wordindex; idx < misps.length; idx++) {
      misps[ idx ].start += localoffsetindex;
      misps[ idx ].end += localoffsetindex;
   }

   // testing
   localoffsetindex = 0;

   for (idx = 0; idx < misps.length; idx++) {

      if (misps[ idx ].word == origword) {
         if ( misps[ idx ].start != 0 )
            strstart = mispstr.slice( 0, misps[ idx ].start + localoffsetindex);
   
   
         // get the end of the string after the word we are replacing
         strend = mispstr.slice( misps[ idx ].end + 1 + localoffsetindex);
        
         // rebuild the string with the new word
         mispstr = strstart +  frm.changeto.value  + strend;
      
         // update offsetindex to compensate for replacing a word with a word
         // of a different length.
         localoffsetindex += frm.changeto.value.length - misps[ idx ].word.length;

      }
      // we have to re-index everything after replacements
      misps[ idx ].start += localoffsetindex;
      misps[ idx ].end += localoffsetindex;
   }

   // add the word to the ignore array
   ignoredWords[ origword ] = 1;

   // reset offsetindex since we reindexed
   offsetindex = 0;

   nextWord(false);
}

// hilight the word that was selected using the nextWord function
//
function hilightWord() {
   var strstart = '';
   var strend;

   // if this isn't the beginning of the string then get all of the string
   // that is before the word we are replacing

   if ( misps[ wordindex ].start != 0 )
       strstart = mispstr.slice( 0, misps[ wordindex ].start + offsetindex);

   // get the end of the string after the word we are replacing

   strend = mispstr.slice( misps[ wordindex ].end + 1 + offsetindex);

   // rebuild the string with a span wrapped around the misspelled word 
   // so we can hilight it in the div the user is viewing the string in


   //var divptr = document.getElementById("strview");
   var divptr = iFrameBody;

   divptr.innerHTML = '';
   divptr.innerHTML = strstart;

   divptr.innerHTML +=  "<span class='hilight' id='h1'>" + misps[ wordindex ].word + "</span>" + htmlToText(strend);
   
   //if (document.getElementById("h1").scrollIntoView)
      //document.getElementById("h1").scrollIntoView();

   divptr.innerHTML = divptr.innerHTML.replace(/_\|_/g, "<br>");
}


// called by onLoad handler to start the process of evaluating misspelled
// words
//
function startsp() {
   nextWord(false);
}

function getCorrectedText() {
   return mispstr;
}

// display the next misspelled word to the user and populate the suggested
// spellings box
//
function nextWord(ignoreall) {
   var frm = document.fm1;
   var sug = document.fm1.suggestions;
   var sugidx = 0;
   var newopt;
   var isselected = 0;

   // push ignored word onto ingoredWords array
   if (ignoreall)
      ignoredWords[ misps[ wordindex ].word ] = 1;

   // update the index of all words we have processed
   // This must be done to accomodate the replaceAll function.
   if (wordindex >= 0) {
      misps[ wordindex ].start += offsetindex;
      misps[ wordindex ].end += offsetindex;
   }

   // increment the counter for the array of misspelled words
   wordindex++;

 

   // draw it and quit if there are no more misspelled words to evaluate
   if (misps.length <= wordindex) {
      iFrameBody.innerHTML = mispstr;
      iFrameBody.innerHTML = iFrameBody.innerHTML.replace(/_\|_/g, "<br>");
      
      clearBox( sug );
      alert('Spell checking complete.');
      frm.change.disabled = true;
      frm.changeall.disabled = true;
      frm.ignore.disabled = true;
      frm.ignoreall.disabled = true;

      // put line feeds back
      mispstr = mispstr.replace(/_\|_/g, "\n");

      // get a handle to the field we need to re-populate
      window.opener.document.forms[spell_formname][spell_fieldname].value = mispstr;
      window.close();
      return true;
   }


   // check to see if word is supposed to be ignored
   if (ignoredWords[ misps[ wordindex ].word ] == 1) {
       nextWord(false);
       return;
   }

   // clear out the suggestions box
   clearBox( sug );

   // re-populate the suggestions box if there are any suggested spellings for the word
   if (misps[ wordindex ].suggestions.length) {
      for (sugidx = 0; sugidx < misps[ wordindex ].suggestions.length; sugidx++) {
         if (sugidx == 0)
            isselected = 1;
         else
            isselected = 0;
         newopt = new Option(misps[ wordindex ].suggestions[sugidx], misps[ wordindex ].suggestions[sugidx], 0, isselected); 
         sug.options[ sugidx ] = newopt;

         if (isselected) {
            frm.changeto.value = misps[ wordindex ].suggestions[sugidx];
            frm.changeto.select();
         }
      }
   }
   hilightWord();
}

function htmlToText(thetext) {
   // disable for now
   return thetext;

   var re = /\</g;
   var re2 = /\>/g;
   var re3 = /\n/g;
   var re4 = /\ /g;
   
   thetext = thetext.replace(re, "&lt;");                          
   thetext = thetext.replace(re2, "&gt;");
   thetext = thetext.replace(re3, "<br>");
   thetext = thetext.replace(re4, "&nbsp;");

   return thetext;
}

// remove all items from the suggested spelling box
// 
function clearBox( box ) {
  var length = box.length;

  // delete old options -- rememeber that select
  //                       boxes automatically re-index
  for (i = 0; i < length; i++) {
     box.options[0] = null;
  }
}

function openSpellWin(width, height) {
  window.open("", "spellWindow", 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+width+',height='+height+'\'');
}

/************** Custom Functions for TASK LOG **************/
function format(num) {
	if(num.length >= 2)	return num;
	return (num < 10) ? '0' + num : num; 
}

function time_diff(t1, t2, format) {
	var timedifference = t1 - t2;
	
	hourtime = parseInt(timedifference / 3600);
	leftoverhours = (timedifference % 3600);
	minutetime = parseInt(leftoverhours / 60);
	leftoverminutes = (leftoverhours % 60);
	secondtime = parseInt(leftoverminutes);
	
	if(!format)
		return new Array(hourtime, minutetime, secondtime);
	else	
		return format(hourtime) + ":" + format(minutetime) + ":" + format(secondtime);
}

function timeobj(target, h, m, s, ampm, objtype) {
	this.target = target;
	this.objtype = 'div';
	this.hours = 0;
	this.mins = 0;
	this.secs = 0;
	this.ampm = 0;
	this.pausetime = 0;
	
	if(h)
		this.hours = h;
	if(m)
		this.mins = m;
	if(s)
		this.secs = s;
	if(ampm)
		this.ampm = 1;
	if(objtype)
		this.objtype = objtype;
		
	this.start = starttimer;
	this.pause = function() {
		this.pausetime = 1;
	};
	this.resume = function() {
		this.pausetime = 0;
	};
	
	this.getcurtime = function(aors) {
		if(!aors)
			return format(this.hours) + ":" + format(this.mins) + ":" + format(this.secs);
		else
			return new Array(this.hours, this.mins, this.secs);	
	};
}

function starttimer() {	
	var funref = tick(this);
	if (document.all || document.getElementById)
		setInterval(funref, 1000);
}

function tick(tobj) {	
	return (function() {
		if( tobj.pausetime )
			return;
			
		tobj.secs++;
		if(tobj.secs > 59) {
			tobj.mins++;
			tobj.secs = 0;
		}	
		
		if(tobj.mins > 59) {
			tobj.hours++;
			tobj.mins = 0;
		}

		var amOrPm = "AM";
		var hrs = tobj.hours;
		if( tobj.ampm ) {
			if(tobj.hours >= 24) {
				tobj.hours = tobj.hours - 24;
				hrs = tobj.hours;
			}
			
			if (tobj.hours > 11) amOrPm = "PM";
			if (tobj.hours > 12) hrs = tobj.hours - 12;
			if (hrs == 0) hrs = 12;
		}
		
		var dispTime = format(hrs) + ":" + format(tobj.mins) + ":" + format(tobj.secs);
		if( tobj.ampm )
			dispTime += " " + amOrPm;
	
		if( tobj.objtype.toLowerCase() == 'text' ) {
			if( tobj.target )
				tobj.target.value = dispTime;
	
		}
		else {	// Default to DIV Tag
			if (document.getElementById && document.getElementById(tobj.target))
				document.getElementById(tobj.target).innerHTML = dispTime;	
		}	
	});
}
	
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "; path=/") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(ckName) 
{ 
	var search = ckName + "=";
	var ckValue = "";
	if (document.cookie.length > 0) 
	{
		offset = document.cookie.indexOf(search);
		if (offset != -1) 
		{ 
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1) 
				end = document.cookie.length;
			ckValue = unescape(document.cookie.substring(offset, end));
		}
	}
	return ckValue;
}

function clearCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "; path=/") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

function togglediv(id) {
	var divtag;
	if(document.getElementById && document.getElementById(id)) {
		divtag = document.getElementById(id);
	}
		
	if(divtag && divtag.style){
		if(divtag.style.display == 'block')
			divtag.style.display = 'none';
		else
			divtag.style.display = 'block';
	}
}

function showdiv(id) {
	var divtag;
	if(document.getElementById && document.getElementById(id)) {
		divtag = document.getElementById(id);
	}
		
	if(divtag && divtag.style){
		divtag.style.display = 'block';
	}
}

function hidediv(id) {
	var divtag;
	if(document.getElementById && document.getElementById(id)) {
		divtag = document.getElementById(id);
	}
		
	if(divtag && divtag.style){
		divtag.style.display = 'none';
	}
}

function writediv(id, content, append) {
	var divtag;
	if(document.getElementById && document.getElementById(id)) {
		divtag = document.getElementById(id);
	}
		
	if(divtag && divtag.innerHTML){
		if( append == 1 )
			divtag.innerHTML += content;
		else
			divtag.innerHTML = content;
	}
}

function readdiv(id) {
	var divtag;
	if(document.getElementById && document.getElementById(id)) {
		divtag = document.getElementById(id);
	}
		
	if(divtag && divtag.innerHTML){
		return divtag.innerHTML;
	}
	
	return '';
}
