
// Begin

/////////////////////////////////////////////////////////////////////////////
//
// DATE:  Template
//
// PURPOSE:
//
// PARAMETERS:
//
// RETURNS: none
//
// Last modified:
//
// Notes:
//
//////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////
//
// DATE: 8-13-03
//
// PURPOSE: Change the priority image per the user's selection
//
// PARAMETERS:  Priority List Box
//
// RETURNS: none
//
// Last modified: 8-13-03
//
// Notes: 
//
// 8-13-03  Note that the selection order is reversed, due to the 
// way the List Box control operates, e.g., the first selection 
// (top most in the box) is 0, the next is 1, etc. But I have chosen
// the priority list (per the DB table) as 3 indicating the highest
// priority for a person. This seemed only natural (but it could be
// reversed to follow the List Box object).
//
//
////////////////////////////////////////////////////////////////

function ChangePriorityImg(PostIt)
{
 var Mesg = "Inside JS Function Cal Demo Change Priority"
// alert (Mesg)

var SelIndex = PostIt.selectedIndex
// alert (SelIndex)

if (SelIndex == 0)
	{
//	document.images[0].src = "../Images/reddot.gif";			
	document.images[0].src = "../CalIncludes/Images/reddot.gif";			
//	document.images[0].src = ImagePath + "reddot.gif";			
	document.images["image1"].width = 10;					// 10;
	document.images["image1"].height = 11;				// 11;
	document.images["image1"].hspace = 10;
	document.images["image1"].vspace = 0;
	}

else if (SelIndex == 1)
	{
//	document.images["image1"].src = "../CalIncludes/Images/c3.jpg";
	document.images[0].src = "../CalIncludes/Images/yellowdot.gif";			
	document.images["image1"].width = 12;
	document.images["image1"].height = 12;
	document.images["image1"].hspace = 10;
	document.images["image1"].vspace = 0;
	}

else if (SelIndex == 2)
	{
//	document.images["image1"].src = "../CalIncludes/Images/c5.jpg";
	document.images[0].src = "../CalIncludes/Images/greendot.gif";			
	document.images["image1"].width = 12;
	document.images["image1"].height = 12;
	document.images["image1"].hspace = 10;
	document.images["image1"].vspace = 0;
	}


// dummy pix, has no width or height - shows blank
else if (SelIndex == 3)
	{
	document.images["image1"].src = "../CalIncludes/Images/c5.jpg";
	document.images["image1"].width = 0;
	document.images["image1"].height = 0;
	}
else;
}


////////////////////////////////////////////////////////////////
//
// DATE: 8-3-02
//
// PURPOSE: Change the SortBy List Box per the user's selection
//
// PARAMETERS:  Directory List Box, Sort By List Box
//
// RETURNS: none
//
// Last modified: 8-3-02
//
// Notes: We could replace the PHP code with this code to build 
//        the List Boxes, but if the user has JS turned off, no
//        boxes will get built.  This way, if JS is turned off then
//        the Sort By list box remains the same (all 7 options).
//
//
////////////////////////////////////////////////////////////////

function DisplaySelected(DirList, SortList)
{
// var Mesg = "Inside Function"
// alert (Mesg)

// var SelIndex = document.MainMenu.DirList.selectedIndex
var SelIndex = DirList.selectedIndex

// alert (SelIndex)

// var Sel = document.MainMenu.Directory.options[document.MainMenu.Directory.selectedIndex]
// var Sel = document.MainMenu.Directory.options[SelIndex]
// var Sel = document.MainMenu.Directory.options.SelIndex
// var Sel = DirList.SelIndex
// var Sel = DirList.selectedIndex.text

var Sel = DirList.options[SelIndex].text

// var Msg = "You chose " + Sel;
// alert(Msg);
// history.go(0)


if (Sel == "Agencies")
	{
	SortList.length = 0
	SortList.options[0] = new Option("Name", "Name")
	SortList.options[1] = new Option("City & State", "City")
	SortList.options[2] = new Option("Phone Number", "Phone")
	SortList.options[3] = new Option("Priority", "Priority")
	SortList.options[4] = new Option("Latest Notes", "Notes")
	SortList.options[5] = new Option("Latest Resume", "Resume")
	SortList.options[6] = new Option("Last Updated", "Updated")
	}

else if (Sel == "Businesses")
	{
	SortList.length = 0
/*
	SortList.options[0] = new Option("Name", "Name")
	SortList.options[1] = new Option("City & State", "City")
	SortList.options[2] = new Option("State", "State")
	SortList.options[3] = new Option("Phone Number", "Phone")
	SortList.options[4] = new Option("Latest Notes", "Notes")
	SortList.options[5] = new Option("Priority", "Priority")
*/
	with (SortList) {
		options[0] = new Option("Name", "Name")
		options[1] = new Option("City & State", "City")
		options[2] = new Option("Phone Number", "Phone")
		options[3] = new Option("Priority", "Priority")
		options[4] = new Option("Latest Notes", "Notes")
		options[5] = new Option("Last Updated", "Updated")
		}
	}

else if (Sel == "Customers")
	{
	SortList.length = 0
/*
	SortList.options[4] = null
	SortList.options[4] = null
	SortList.options[4] = null
*/
	SortList.options[0] = new Option("Name", "Name")
	SortList.options[1] = new Option("City & State", "City")
	SortList.options[2] = new Option("Phone Number", "Phone")
	SortList.options[3] = new Option("Priority", "Priority")
	SortList.options[4] = new Option("Last Updated", "Updated")
	SortList.options[5] = new Option("Birthdays, this month", "Birthday")
	SortList.options[6] = new Option("Birthdays, next month", "BirthdayNext")
	}

else if (Sel == "Persons")
	{
	SortList.length = 0
/*
	SortList.options[4] = null
	SortList.options[4] = null
	SortList.options[4] = null
*/
	SortList.options[0] = new Option("Name", "Name")
	SortList.options[1] = new Option("City & State", "City")
	SortList.options[2] = new Option("Phone Number", "Phone")
	SortList.options[3] = new Option("Priority", "Priority")
	SortList.options[4] = new Option("Last Updated", "Updated")
	SortList.options[5] = new Option("Birthdays, this month", "Birthday")
	SortList.options[6] = new Option("Birthdays, next month", "BirthdayNext")
	}

else {}
}



/////////////////////////////////////////////////////////////////////////////
//
// DATE:
//
// PURPOSE:
//
// PARAMETERS:
//
// RETURNS: none
//
// Last modified:
//
// Notes:
//
//////////////////////////////////////////////////////////////////////////////


function doColor(bizindex, color, bg) {
bizindex.style.color = color; 		// changes text color
bizindex.style.backgroundColor = bg; 	// changes background color
}

function undoColor(bizindex) {
bizindex.style.color = ""; 			// sets color back to default
bizindex.style.backgroundColor = ""; 	// sets background to default
}



// Run this function each time the interval ends
function countdown()
	{

	// Display the countdown and decrement the counter
	status = counter--
    
	// Cancel the interval when we hit 0
	if (counter < 0)
		{
	        clearTimeout(timeout_id)
        	status = ""
		window.open()
		alert ("Timer Completed")
		}
	    else
		{
	        // Otherwise, set the timeout again
        	timeout_id = setTimeout("countdown()", 1000)
		}
	}





var up, down;
var min1, sec1;
var cmin1, csec1, cmin2, csec2;



/////////////////////////////////////////////////////////////////////////////
//
// DATE:  Template
//
// PURPOSE:
//
// PARAMETERS:
//
// RETURNS: none
//
// Last modified:
//
// Notes:
//
//////////////////////////////////////////////////////////////////////////////

function Minutes(data)
	{
	for(var i=0; i< data.length; i++)
		if(data.substring(i, i+1) == ":")
			break;
	return(data.substring(0,i));
	}



/////////////////////////////////////////////////////////////////////////////
//
// DATE:  Template
//
// PURPOSE:
//
// PARAMETERS:
//
// RETURNS: none
//
// Last modified:
//
// Notes:
//
//////////////////////////////////////////////////////////////////////////////

function Seconds(data)
	{
	for(var i=0; i<data.length; i++)
		if(data.substring(i, i+1) == ":")
			break;
	return(data.substring(i+1, data.length));
	}



/////////////////////////////////////////////////////////////////////////////
//
// DATE:  Template
//
// PURPOSE:
//
// PARAMETERS:
//
// RETURNS: none
//
// Last modified:
//
// Notes:
//
//////////////////////////////////////////////////////////////////////////////

function Display(min, sec)
	{
	var disp;

	if(min <= 9)
		disp = " 0";
	else disp = " ";

	disp += min + ":";

	if(sec<=9)
		disp += "0" + sec;
	else
		disp += sec;

	return(disp);
	}



/////////////////////////////////////////////////////////////////////////////
//
// DATE:  Template
//
// PURPOSE:
//
// PARAMETERS:
//
// RETURNS: none
//
// Last modified:
//
// Notes:
//
//////////////////////////////////////////////////////////////////////////////

function CountUp()
	{
	cmin1 = 0;
	csec1 = 0;
	min1 = 0 + Minutes(document.MyTimer.begin1.value);
	sec1 = 0 + Seconds(document.MyTimer.begin1.value);

	UpRepeat();
	}



/////////////////////////////////////////////////////////////////////////////
//
// DATE:  Template
//
// PURPOSE:
//
// PARAMETERS:
//
// RETURNS: none
//
// Last modified:
//
// Notes:
//
//////////////////////////////////////////////////////////////////////////////

function UpRepeat()
	{
	csec1++;

	if(csec1 == 60)
		{
		csec1 = 0; cmin1++;
		}

	document.MyTimer.disp1.value = Display(cmin1,csec1);

	if((cmin1 == min1) && (csec1 == sec1))
		alert("Timer-CountUp Stopped");
	else
		up = setTimeout("UpRepeat()", 1000);
	}



/////////////////////////////////////////////////////////////////////////////
//
// DATE:  Template
//
// PURPOSE:
//
// PARAMETERS:
//
// RETURNS: none
//
// Last modified:
//
// Notes:
//
//////////////////////////////////////////////////////////////////////////////

function CountDown()
	{
	cmin2 = 1 * Minutes(document.MyTimer.begin2.value);
	csec2 = 0 + Seconds(document.MyTimer.begin2.value);
	DownRepeat();
	}



/////////////////////////////////////////////////////////////////////////////
//
// DATE:  Template
//
// PURPOSE:
//
// PARAMETERS:
//
// RETURNS: none
//
// Last modified:
//
// Notes:
//
//////////////////////////////////////////////////////////////////////////////

function DownRepeat()
	{
	csec2--;

	if(csec2 == -1)
		{
		csec2 = 59;
		cmin2--;
		}

	document.MyTimer.disp2.value = Display(cmin2, csec2);

	if((cmin2 == 0) && (csec2 == 0))
		alert("Timer-CountDown Stopped");
	else
		down = setTimeout("DownRepeat()", 1000);
	}





/////////////////////////////////////////////////////////////////////////////
//
// DATE:  Template
//
// PURPOSE:
//
// PARAMETERS:
//
// RETURNS: none
//
// Last modified:
//
// Notes:
//
//////////////////////////////////////////////////////////////////////////////

function get_cookie(name_to_get)
{

    var cookie_pair
    var cookie_name
    var cookie_value

// document.writeln("<BR>Inside function get_cookie")
    
    // Split all the cookies into an array
    var cookie_array = document.cookie.split("; ")
    
    // Run through the cookies
    for (counter = 0; counter < cookie_array.length; counter++) {
    
        // Split the cookie into a name/value pair
        cookie_pair = cookie_array[counter].split("=")
        cookie_name = cookie_pair[0]
// document.writeln("<BR>" + cookie_name)
        cookie_value = cookie_pair[1]
// document.writeln("<BR>" + cookie_value)
// document.writeln("<BR>")
        
        // Compare the name with the name we want
        if (cookie_name == name_to_get) {
        
            // If this is the one, return the value
            return unescape(cookie_value)
        }
    }
    
    // If the cookie doesn't exist, return null
    return null
}



/////////////////////////////////////////////////////////////////////////////
//
// DATE:  Template
//
// PURPOSE:
//
// PARAMETERS:
//
// RETURNS: none
//
// Last modified:
//
// Notes:
//
//////////////////////////////////////////////////////////////////////////////

function set_cookie(cookie_name, cookie_value, cookie_expire, cookie_path, cookie_domain, cookie_secure)
{

    // Begin the cookie parameter string
    var cookie_string = cookie_name + "=" + cookie_value
    
    // Add the expiration date, if it was specified
    if (cookie_expire) {
        var expire_date = new Date()
//        var ms_from_now = cookie_expire * 60 * 1000
        var ms_from_now = cookie_expire * 1000
        expire_date.setTime(expire_date.getTime() + ms_from_now)
        var expire_string = expire_date.toGMTString()
        cookie_string += "; expires=" + expire_string
document.writeln("<BR>Expires : " + expire_string)
    }
    
    // Add the path, if it was specified
    if (cookie_path) {
        cookie_string += "; path=" + cookie_path
    }

    // Add the domain, if it was specified
    if (cookie_domain) {
        cookie_string += "; domain=" + cookie_domain
    }
    
    // Add the secure Boolean, if it's true
    if (cookie_secure) {
        cookie_string += "; true"
    }
    
    // Set the cookie
    document.cookie = cookie_string

}



/////////////////////////////////////////////////////////////////////////////
//
// DATE:  Template
//
// PURPOSE:
//
// PARAMETERS:
//
// RETURNS: none
//
// Last modified:
//
// Notes:
//
//////////////////////////////////////////////////////////////////////////////

function its_empty(string_value) {

    // Check for the empty string and null
    if (string_value == "" || string_value == null) {
    
        // If either, it's empty so return true
        return true
    }
    
    // Otherwise, it's not empty so return false
    return false
}



/////////////////////////////////////////////////////////////////////////////
//
// DATE:  Template
//
// PURPOSE:
//
// PARAMETERS:
//
// RETURNS: none
//
// Last modified:
//
// Notes:
//
//////////////////////////////////////////////////////////////////////////////

function its_whitespace(string_value) {

    // These are the whitespace characters
    var whitespace = " \n\r\t"

    // Run through each character in the string
    for (var counter = 0; counter < string_value.length; counter++) {
        
        // Get the current character
        current_char = string_value.charAt(counter)
        
        // If it's not in the whitespace characters string,
        // return false because we found a non-whitespace character
        if (whitespace.indexOf(current_char) == -1) {
            return false
        }
    }
    
    // Otherwise, the string has nothing but
    // whitespace characters, so return true
    return true
}

// End -->


