	function returnwdStartEvn()
	{
		var intStartEvn
		
		intStartEvn = Number(document.PowerConnForm.wdStartEvn.value) + Number(document.PowerConnForm.wdStartEvnHalf.value);
		if ((document.PowerConnForm.wdStartEvnAmPm.selectedIndex == 1) && (document.PowerConnForm.wdStartEvn.selectedIndex != 12))
				intStartEvn += 12;
		else if ((document.PowerConnForm.wdStartEvnAmPm.selectedIndex == 0) && (document.PowerConnForm.wdStartEvn.selectedIndex == 12))
				intStartEvn -= 12;
		
		if (document.PowerConnForm.wdStartEvn.selectedIndex == 0)
				intStartEvn = -1
				
		return intStartEvn
	}
	
	function returnwdEndEvn()
	{
		var intEndEvn
		
		intEndEvn = Number(document.PowerConnForm.wdEndEvn.value) + Number(document.PowerConnForm.wdEndEvnHalf.value);
		if (((document.PowerConnForm.wdEndEvnAmPm.selectedIndex == 1) && (document.PowerConnForm.wdEndEvn.selectedIndex != 12)) || ((document.PowerConnForm.wdEndEvnAmPm.selectedIndex == 0) && (document.PowerConnForm.wdEndEvn.selectedIndex == 12) && (document.PowerConnForm.wdEndEvnHalf.selectedIndex == 0)))
				intEndEvn += 12;
		else if ((document.PowerConnForm.wdEndEvnAmPm.selectedIndex == 0) && (document.PowerConnForm.wdEndEvn.selectedIndex == 12) && (document.PowerConnForm.wdEndEvnHalf.selectedIndex == 1))
				intEndEvn -= 12;
		
		if (document.PowerConnForm.wdEndEvn.selectedIndex == 0)
				intEndEvn = -1

		return intEndEvn
	}
	
		function roundwdStartEvn()
	{
		var intStartEvn
		
		intStartEvn = Number(document.PowerConnForm.wdStartEvn.value);
		if ((document.PowerConnForm.wdStartEvnAmPm.selectedIndex == 1) && (document.PowerConnForm.wdStartEvn.selectedIndex != 12))
				intStartEvn += 12;
		else if ((document.PowerConnForm.wdStartEvnAmPm.selectedIndex == 0) && (document.PowerConnForm.wdStartEvn.selectedIndex == 12))
				intStartEvn -= 12;
		
		if (document.PowerConnForm.wdStartEvn.selectedIndex == 0)
				intStartEvn = -1
				
		return intStartEvn
	}
	
	function roundwdEndEvn()
	{
		var intEndEvn
		
		intEndEvn = Number(document.PowerConnForm.wdEndEvn.value);
		if (((document.PowerConnForm.wdEndEvnAmPm.selectedIndex == 1) && (document.PowerConnForm.wdEndEvn.selectedIndex != 12)) || ((document.PowerConnForm.wdEndEvnAmPm.selectedIndex == 0) && (document.PowerConnForm.wdEndEvn.selectedIndex == 12) && (document.PowerConnForm.wdEndEvnHalf.selectedIndex == 0)))
				intEndEvn += 12;
		else if ((document.PowerConnForm.wdEndEvnAmPm.selectedIndex == 0) && (document.PowerConnForm.wdEndEvn.selectedIndex == 12) && (document.PowerConnForm.wdEndEvnHalf.selectedIndex == 1))
				intEndEvn -= 12;
		
		if (document.PowerConnForm.wdEndEvn.selectedIndex == 0)
				intEndEvn = -1

		return intEndEvn
	}
	
	
// ********************************************** START EVENING *********************************************
		
function wdStartEvn_OnChange()
{
	wdStartEvn();
	mrn2evn_check();
	wdStartEvn();
	wdEndEvn();
	changeImageWD();
}


function wdStartEvn()
{
	var myMorning, myStart, myEnd
	
	if (document.PowerConnForm.wdStartEvn.selectedIndex == 0)
	{
		//dont' do nothing.. just make sure all related dropdowns are set to 0
		document.PowerConnForm.wdStartEvnHalf.selectedIndex = 0;
		document.PowerConnForm.wdStartEvnAmPm.selectedIndex = 0;
	}
	else
	{
	// before wd calculate the time first make sure end is not am when start is pm
			if (document.PowerConnForm.wdStartEvnAmPm.selectedIndex == 1)
			{
				if ((document.PowerConnForm.wdEndEvn.selectedIndex == 12) && (document.PowerConnForm.wdEndEvnHalf.selectedIndex != 1))
				{
					document.PowerConnForm.wdEndEvnAmPm.selectedIndex = 0
				}
				else
				{

					document.PowerConnForm.wdEndEvnAmPm.selectedIndex = 1
				}
			}
	

		myMorning = returnwdEndMrn();
		myStart = returnwdStartEvn();
		myEnd = returnwdEndEvn();
		
		if (myStart <= myMorning) //determine whether start evening time is less then end morning time.
		{
				if (document.PowerConnForm.wdEndMrnAmPm.selectedIndex == 0)
					document.PowerConnForm.wdStartEvnAmPm.selectedIndex = 1; // changes start evening time to pm if less then end morning time.
		}
		
		if (myStart >= myEnd)
		{
				//reset evening end time if it was set to -1
				if (document.PowerConnForm.wdEndEvn.selectedIndex == -1)
					{
						document.PowerConnForm.wdEndEvn.selectedIndex = document.PowerConnForm.wdStartEvn.selectedIndex;
						document.PowerConnForm.wdEndEvnHalf.selectedIndex = document.PowerConnForm.wdStartEvnHalf.selectedIndex;
						document.PowerConnForm.wdEndEvnAmPm.selectedIndex = document.PowerConnForm.wdStartEvnAmPm.selectedIndex;
					}
						
				document.PowerConnForm.wdEndEvnHalf.selectedIndex = document.PowerConnForm.wdStartEvnHalf.selectedIndex;
	
				switch(myStart)	
				{
					case 0:
					case 0.5:
					case 12.5:
					case 12:
						document.PowerConnForm.wdEndEvn.selectedIndex = 1;
						document.PowerConnForm.wdEndEvnAmPm.selectedIndex = 1;
						break
					case 23:
					case 23.5:
						document.PowerConnForm.wdEndEvnAmPm.selectedIndex = 0;
						document.PowerConnForm.wdEndEvnHalf.selectedIndex = 0;
						document.PowerConnForm.wdEndEvn.selectedIndex = (document.PowerConnForm.wdStartEvn.selectedIndex + 1);
						break
					case 11.5:
					case 11:
						document.PowerConnForm.wdEndEvnAmPm.selectedIndex = 1;
					default:
						document.PowerConnForm.wdEndEvn.selectedIndex = (document.PowerConnForm.wdStartEvn.selectedIndex + 1);	
						break
				}
		
		}
	}
}


// ***************************************** END EVENING ************************************************************

function wdEndEvn_OnChange()
{
	wdEndEvn();
	wdStartEvn();
	mrn2evn_check();
	changeImageWD();
}


function wdEndEvn()
{

	//formatwdEndTime();
	
	var myStart, myEnd
	myStart = returnwdStartEvn();
	myEnd = returnwdEndEvn();
	
	
	//alert('wdEndEvn - start:' + myStart + ' end:' + myEnd);	
	if (document.PowerConnForm.wdEndEvn.selectedIndex == 0)
	{
		//dont' do nothing.. just make sure all related dropdowns are set to 0
		document.PowerConnForm.wdEndEvnHalf.selectedIndex = 0;
		document.PowerConnForm.wdEndEvnAmPm.selectedIndex = 0;
	}
	else
	{
		//Checks to see if the times are the same.
		if ((myStart == myEnd) && (document.PowerConnForm.wdStartEvnAmPm.selectedIndex == document.PowerConnForm.wdEndEvnAmPm.selectedIndex))
			{
				if (document.PowerConnForm.wdStartEvnHalf.selectedIndex == 0)
				{
						document.PowerConnForm.wdEndEvnHalf.selectedIndex = 1;
				}
				else
				{
						document.PowerConnForm.wdEndEvnHalf.selectedIndex = 0;
						document.PowerConnForm.wdEndEvn.selectedIndex = (document.PowerConnForm.wdStartEvn.selectedIndex + 1);
				}
			}	
	}
	
	//Checks to see if start is pm and greater than end
	if ((myStart > myEnd) && (document.PowerConnForm.wdStartEvnAmPm.selectedIndex == 0))
		document.PowerConnForm.wdEndEvnAmPm.selectedIndex = 1
	
}




// ***************************************** MORNING TO EVENING ************************************************************

function mrn2evn_check()	//Checks the weekday end morning time to see if it is at the midnight and nulls out the evening clocks
{
	if (returnwdEndMrn() >= 24)
	{
		document.PowerConnForm.wdStartEvn.selectedIndex = 0;
		document.PowerConnForm.wdStartEvnHalf.selectedIndex = 0;
		document.PowerConnForm.wdStartEvnAmPm.selectedIndex = 0;
		document.PowerConnForm.wdEndEvn.selectedIndex = 0;
		document.PowerConnForm.wdEndEvnHalf.selectedIndex = 0;
		document.PowerConnForm.wdEndEvnAmPm.selectedIndex = 0;
	}
	else if ((document.PowerConnForm.wdStartEvn.selectedIndex != 0) && (returnwdEndMrn() > returnwdStartEvn()))
	{
		document.PowerConnForm.wdStartEvn.selectedIndex = document.PowerConnForm.wdEndMrn.selectedIndex;
		document.PowerConnForm.wdStartEvnAmPm.selectedIndex = document.PowerConnForm.wdEndMrnAmPm.selectedIndex;
		document.PowerConnForm.wdStartEvnHalf.selectedIndex = document.PowerConnForm.wdEndMrnHalf.selectedIndex;
	}
	
}

