// *************************************
// schedule.js Version 6.0 (IscheduerPlus) 
// October 31,2011
//
// Develped exclusively for 
//     Rodriguez Funeral Home
//     by Jay Grubb dba Grubb Consulting Service (GCS) 
//

function SetDeceased(nIndex)
// Saves a cookie with the selected client
{
 		++nIndex ;
 		setCookie("RFHSel","" + nIndex + "",1) ;
}

// Address of guestbook
function OpenGuestBook()
{
		window.open("../guestbook/guestbook.html","_blank","menubar=1,toolbar=1,resizable=1,scrollbars=1,titlebar=1,location=0") ;
}

function setFontSize()
// Adjust the size of the base font given the user's screen resolution
{
 		
		try {
		 		var xs = screen.availWidth ;
				var ys = screen.availHeight ;	 
				if((xs <= 1000) && (ys <= 800)) { 
						document.body.style.fontSize = "11pt" ;
				}
				else if ((xs <= 1150)  && (ys <= 900)) { 
						document.body.style.fontSize = "12pt" ;
				}
				else if ((xs <= 1280)  && (ys <= 960)) { 
						document.body.style.fontSize = "13pt" ;
				}
				else if ((xs <= 1600)  && (ys <= 1100)) { 
						document.body.style.fontSize = "14pt" ;
				}
				else {
						document.body.style.fontSize = "15pt" ;
				}
		}
		catch(error) {
		}
}

function setPrtFontSize()
// Adjust the size of the base font given the user's screen resolution
{
 		
		try {
			document.body.style.fontSize = "12pt" ;
		}
		catch(error) {
		}
}

function WriteSchedHeader(stSort)
{
		document.write('Click on a name to view the <span class="empInstr">service schedule</span>') ;
		if (bCondolences != 0) 
			  document.write(', <span class="empInstr">obituary</span> and <span class="empInstr">send&nbsp;a&nbsp;condolence</span>.') ; 
  	else
				document.write(' and <span class="empInstr">obituary</span>.') ; 
		document.write(' Re-sort the list by clicking on "' + stSort + '"') ;	
}

function WriteSchedList(bOrderByName)
{
 		// declare local variables
 		var dtToday = new Date ;	 // todays date
    var i,  j ;								 // index variable

		// write the name of the deceased							
		for( j=0 ; j<nMaxRec ; j++) 	// repeat for all records imported from the database
  	{
				i = bOrderByName == 0 ? j : aNameOrder[j] ;
		
				var dtRec = new Date(aDateOfService[i] + " 23:59:59") ; // get the date of the last schedule service for this item
					
				if(dtRec < dtToday) // display the record if the schedule service has not already passed
						continue ;		 			
				// write row	
				document.write("<div class='schRows'>") ;
						// write name
						document.write("<div class='schName'>") ;
						document.write("<a class='schName' href='schedfrm.html' ") ;
								document.write("onclick='SetDeceased(" + i + ");'>") ;
						document.write(aDeceased[i][fldLFName] + "</a></div>") ;
		 				// write date of passing
						document.write("<div class='schDate'>" + aDeceased[i][fldPassing]+ "</div>") ;		
						// indicate a service has been scheduled if a service is scheduled
						if ((aIsService3[i] + aIsService2[i] + aIsService1[i] + aIsService4[i]) != 0) 
							 document.write("<div class='schSrvSched'>Services Scheduled</div>") ;
						else
								document.write("<div class='schSrvSched'>Call</div>") ;
				document.write("</div>") ;
		}
}

function WriteSchedEnd()
{
 		var sTop ="schTop" ;
		var sDir ="../guestbook" ;
	
		if (bCondolences!=0) 
	 	   	cTop = "schTop"
  	else
				cTop = "schTopC"
		document.write("<p class='" + cTop + " TimesFont'>") ;
		document.write("&lt;<a href='#PTop' class='alwaysblue' title='Go to the top of this page'>top</a>&gt;") ;
		document.write("</p>") ;
		if (bCondolences!=0)
		{
			 	document.write("<p class='schOther'>To send a condolence to us for someone not listed above, click here: ") ;
		 		document.write("<a href='#' title='Send Condolences' onclick='OpenGuestBook();return false;'>Condolence</a>.") ;
				document.write("</p>") ;
		}
		return true ;
}


