function editstudent_onclick()
{
	document.theForm.target = 'info'
	document.theForm.action = 'leader.student.info.asp'
	document.theForm.submit()
	document.theForm.target = ''
	document.theForm.action = ''
}


function editLeader_onclick()
{
	document.theForm.target = 'info'
	document.theForm.action = 'leader.leaders.info.asp'
	document.theForm.submit()
	document.theForm.target = ''
	document.theForm.action = ''
}

function editsmallgroups_onclick()
{
	document.theForm.target = 'info'
	document.theForm.action = 'leader.smallgroups.info.asp'
	document.theForm.submit()
	document.theForm.target = ''
	document.theForm.action = ''
}

function newStudent()
{
	window.open('leader.student.form.asp?userid=0', "newstudent","height=500,width=400,left=100, top=100, toolbar=no,menubar=no,scrollbars=yes,resizable=no");
}

function deleteStudent()
{
	document.theForm.target = '';
	document.theForm.action = 'leader.student.submit.asp?submit_type=delete';
	document.theForm.submit();
}

function inactiveStudent()
{
	document.theForm.target = '';
	document.theForm.action = 'leader.student.submit.asp?submit_type=inactive';
	document.theForm.submit();
}

function activeStudent()
{
	document.theForm.target = '';
	document.theForm.action = 'leader.student.submit.asp?submit_type=active';
	document.theForm.submit();
}

function editStudent()
{
	var place;
	place = 'leader.student.form.asp?userid=' + document.theForm.userid.value;
	window.open(place, "newstudent","height=500,width=400,left=100, top=100, toolbar=no,menubar=no,scrollbars=yes,resizable=no");
}

function closeStudentForm()
{
	window.close()
}

function newLeader()
{
	window.open('leader.leaders.form.asp?userid=0', "newleader","height=500,width=400,left=100, top=100, toolbar=no,menubar=no,scrollbars=yes,resizable=no");
}

function deleteLeader()
{
	document.theForm.target = '';
	document.theForm.action = 'leader.leaders.submit.asp?submit_type=delete';
	document.theForm.submit();
}

function inactiveLeader()
{
	document.theForm.target = '';
	document.theForm.action = 'leader.leaders.submit.asp?submit_type=inactive';
	document.theForm.submit();
}

function activeLeader()
{
	document.theForm.target = '';
	document.theForm.action = 'leader.leaders.submit.asp?submit_type=active';
	document.theForm.submit();
}

function editLeader()
{
	var place;
	place = 'leader.leaders.form.asp?userid=' + document.theForm.userid.value;
	window.open(place, "newleader","height=500,width=400,left=100, top=100, toolbar=no,menubar=no,scrollbars=yes,resizable=no");
}


function closeLeaderForm()
{
	window.close();
}




function openCalendarInfo(url)
{
	window.name = 'calendar';
 	remote = open(url, "EventInfo", "scrollbars,width=500,height=400,left=100,top=100");
}

function newEventWindow(thisDate)
{
	window.name = 'calendar';
	var place;
	place = "leader.calendar.form.asp?submit_type=new&thedate=" + thisDate;
	window.open(place, "newcalendar","height=500,width=350,left=100, top=100, toolbar=no,menubar=no,scrollbars=yes,resizable=no");

}

function editEventWindow(eventID)
{
	var place;
	place = "leader.calendar.form.asp?submit_type=edit&eventID=" + eventID;
	window.open(place, "editcalendar","height=500,width=350,left=100, top=100, toolbar=no,menubar=no,scrollbars=yes,resizable=no");
	//window.close();

}

function occurChange()
{
	if (document.theForm.reoccurs.checked == true)
	{
		document.theForm.end_date.disabled = true;
		document.theForm.occurs.disabled = false;
		document.theForm.occur_end.disabled = false;
		document.theForm.occurID.disabled = false;
	}
	else
	{
		document.theForm.end_date.disabled = false;
		document.theForm.occurs.disabled = true;
		document.theForm.occur_end.disabled = true;
		document.theForm.occurID.disabled = true;		
		
	}
}


var SECOND = 1000; // the number of milliseconds in a second
var MINUTE = SECOND * 60; // the number of milliseconds in a minute
var HOUR = MINUTE * 60; // the number of milliseconds in an hour
var DAY = HOUR * 24; // the number of milliseconds in a day
var WEEK = DAY * 7; // the number of milliseconds in a week


function daysBetween(year1, month1, day1, year2, month2, day2) {
	var Date1 = Date.UTC(year1, month1 - 1, day1);
	var Date2 = Date.UTC(year2, month2 - 1, day2);
	var bTime = Math.abs(Date1 - Date2)  // time difference
	return Math.round(bTime / DAY);
}




function calculateEndDate()
{
	//adds weeks to occur_end
	var daysTilNext;
	var occur_end;
	
	daysTilNext 	= document.theForm.occurs.value * 7;
	occur_end 	= document.theForm.occur_end.value
	
	document.theForm.occur_end.value = dateAdd(dd, daysTilNext, occur_end);
	
	
}


function calculateOccurs()
{
	//date difference and gets weeks

}

function closeAndReloadCalendar()
{
	Calendar.reload();
	window.close();
}
