var divToUpdateName = null;


function loadNeoCalendar(divToUpdateName2) {

	divToUpdateName = divToUpdateName2;
	var divToUpdate = document.getElementById(divToUpdateName);
	
	
	divToUpdate.innerHTML = '<br/><br/><center><br/><img src="img/ajax/lc-loader.gif"/><br/><br/><h1>Loading My Calendar</h1><br/><h2>Please wait</h2></center><br/><br/><br/><br/>';
	
	var url = "neoCalendarAction.action";
	neoAjax.updateNoCache(url,divToUpdateName);		
	
}

function loadUpcomingAppointments(divToUpdateName2) {

	divToUpdateName = divToUpdateName2;
	var divToUpdate = document.getElementById(divToUpdateName);
	
	divToUpdate.innerHTML = '<br/><br/><center><br/><img src="img/ajax/lc-loader.gif"/><br/><br/><h1>Loading</h1><br/><h2>Please wait</h2></center><br/><br/><br/><br/>';
	
	var url = "publicAccountCareersAdvisorAction-upcomingAppointments.action";
	neoAjax.updateNoCache(url,divToUpdateName);		
	
}

function changeMonth(month,year) {

	var divToUpdate = document.getElementById("updatedNeoCalendarInner");
	var dayDetailsDiv = document.getElementById("dayDetailsDiv");
	
	divToUpdate.innerHTML = '<br/><br/><center><br/><img src="img/ajax/lc-loader.gif"/><br/><br/><h1>Loading My Calendar</h1><br/><h2>Please wait</h2></center><br/><br/><br/><br/>';
	dayDetailsDiv.innerHTML = "";
	dayDetailsDiv.style.display = "none";
	
	var url = "neoCalendarAction.action?month=" + month + "&year=" + year;
	neoAjax.updateNoCache(url,"updatedNeoCalendarInner");		
	
}


function loadDayDetails(clickedCell, day, month, year) {

	var dayDetailsDiv = document.getElementById("dayDetailsDiv");
	dayDetailsDiv.innerHTML = '<center><br/><img src="img/ajax/lc-loader.gif"/><br/><br/><h1>Loading Selected Day</h1><br/><h2>Please wait</h2></center><br/>';
	dayDetailsDiv.style.display = "block";
	
	var url = "neoCalendarAction.action?day=" + day + "&month=" + month + "&year=" + year;
	neoAjax.updateNoCache(url,dayDetailsDiv);
	
}


function addAppointment(save) {
//	var dayDetailsList = document.getElementById("dayDetailsList");
//	var addAppointment = document.getElementById("addAppointment");
//	if (on == true)
//	{
//		dayDetailsList.style.display = "none";
//		addAppointment.style.display = "block";
//	}
//	else
//	{
//		dayDetailsList.style.display = "block";
//		addAppointment.style.display = "none";
//	}

	var dayDetailsDiv = document.getElementById("dayDetailsDiv");
//	dayDetailsDiv.innerHTML = '<center><br/><img src="img/ajax/lc-loader.gif"/><br/><br/><h1>Loading Selected Day</h1><br/><h2>Please wait</h2></center><br/>';
//	dayDetailsDiv.style.display = "block";
	
	
	var url = "neoCalendarAction-addAppointment.action?save=" + save + "&day=" + escape(document.getElementById("theday").value) + "&month=" + escape(document.getElementById("themonth").value) + "&year=" + escape(document.getElementById("theyear").value);
	neoAjax.updateNoCache(url,dayDetailsDiv);
}


function submitAppointment() {
//	neoAjax.submitNoCache("neoCalendarAction-addAppointment.action","dayDetailsDiv",document.addAppointmentForm);
	var day = escape(document.getElementById("startDay").value);
	var month = escape(document.getElementById("startMonth").value);
	var year = escape(document.getElementById("startYear").value);
	
	var url = "neoCalendarAction-addAppointment.action?save=true&" + neoAjax.serialize(document.addAppointmentForm);
	refreshDayDetailstDiv = function() {
		loadDayDetails(null, day, month, year);
		loadUpcomingAppointments("upcomingAppointmentsDiv");
	};
	neoAjax.loadDivOnComplete("updatedNeoCalendarInner",url,refreshDayDetailstDiv);
}


function rescheduleAppointment(save, appointmentId) {
	var dayDetailsDiv = document.getElementById("dayDetailsDiv");

	var url = "neoCalendarAction-rescheduleAppointment.action?save=" + save + "&appointmentId=" + appointmentId;
	neoAjax.updateNoCache(url,dayDetailsDiv);
}

function submitRescheduleAppointment() {

	var day = escape(document.getElementById("startDay").value);
	var month = escape(document.getElementById("startMonth").value);
	var year = escape(document.getElementById("startYear").value);

	var url = "neoCalendarAction-rescheduleAppointment.action?save=true&" + neoAjax.serialize(document.rescheduleAppointmentForm);
	refreshDayDetailstDiv = function() {
		loadDayDetails(null, day, month, year);
		loadUpcomingAppointments("upcomingAppointmentsDiv");
	};
	neoAjax.loadDivOnComplete("updatedNeoCalendarInner",url,refreshDayDetailstDiv);
}
	
function declineAppointment(save, appointmentId) {
	var dayDetailsDiv = document.getElementById("dayDetailsDiv");

	var url = "neoCalendarAction-declineAppointment.action?save=" + save + "&appointmentId=" + appointmentId;
	neoAjax.updateNoCache(url,dayDetailsDiv);
}

function submitDeclineAppointment() {

	var day = escape(document.getElementById("startDay").value);
	var month = escape(document.getElementById("startMonth").value);
	var year = escape(document.getElementById("startYear").value);

	var url = "neoCalendarAction-declineAppointment.action?save=true&" + neoAjax.serialize(document.declineAppointmentForm);
	refreshDayDetailstDiv = function() {
		loadDayDetails(null, day, month, year);
		loadUpcomingAppointments("upcomingAppointmentsDiv");
	};
	neoAjax.loadDivOnComplete("updatedNeoCalendarInner",url,refreshDayDetailstDiv);
}

	
function cancelAppointment(appointmentId,  day, month, year) {
	var dayDetailsDiv = document.getElementById("dayDetailsDiv");
	var url = "neoCalendarAction-cancelAppointment.action?appointmentId=" + appointmentId + "&day=" + day + "&month=" + month + "&year=" + year;
	neoAjax.updateNoCache(url,dayDetailsDiv);
}

function acceptAppointment(appointmentId,  day, month, year) {
	var dayDetailsDiv = document.getElementById("dayDetailsDiv");
	var url = "neoCalendarAction-acceptAppointment.action?appointmentId=" + appointmentId + "&day=" + day + "&month=" + month + "&year=" + year;
	
	refreshDayDetailstDiv = function() {
		loadUpcomingAppointments("upcomingAppointmentsDiv");
	};
	neoAjax.loadDivOnComplete(dayDetailsDiv,url,refreshDayDetailstDiv);
}


function loadAutoSuggest()
{
	var options = {
		script: "neoCalendarAction-findRecipient.action?",
		varname: "recipient",
		maxresults: 35,
		callback: function (obj) { document.getElementById('recipient').value = obj.id; }
		
	};
	var as = new _bsn.AutoSuggest('recipientName', options);
	
}

//var divToUpdateName = null;
//
//
//function loadNeoCalendar(divToUpdateName2) {
//
//	divToUpdateName = divToUpdateName2;
//	var divToUpdate = document.getElementById(divToUpdateName);
//	
//	
//	divToUpdate.innerHTML = '<br/><br/><center><br/><img src="img/ajax/lc-loader.gif"/><br/><br/><h1>Loading My Calendar</h1><br/><h2>Please wait</h2></center><br/><br/><br/><br/>';
//	
//	var url = "neoCalendarAction.action";
//	neoAjax.updateNoCache(url,divToUpdateName);		
//	
//}
//
//
//function changeMonth(month,year) {
//
//	var divToUpdate = document.getElementById(divToUpdateName);
//	var dayDetailsDiv = document.getElementById("dayDetailsDiv");
//	
//	divToUpdate.innerHTML = '<br/><br/><center><br/><img src="img/ajax/lc-loader.gif"/><br/><br/><h1>Loading My Calendar</h1><br/><h2>Please wait</h2></center><br/><br/><br/><br/>';
//	dayDetailsDiv.innerHTML = "";
//	dayDetailsDiv.style.display = "none";
//	
//	var url = "neoCalendarAction.action?month=" + month + "&year=" + year;
//	neoAjax.updateNoCache(url,divToUpdateName);		
//	
//}
//
//
//function loadDayDetails(clickedCell, day, month, year) {
//	
//	
//	var dayDetailsDiv = document.getElementById("dayDetailsDiv");
//	dayDetailsDiv.innerHTML = '<center><br/><img src="img/ajax/lc-loader.gif"/><br/><br/><h1>Loading Selected Day</h1><br/><h2>Please wait</h2></center><br/>';
//	dayDetailsDiv.style.display = "block";
//	
//	var url = "neoCalendarAction.action?day=" + day + "&month=" + month + "&year=" + year;
//	neoAjax.updateNoCache(url,dayDetailsDiv);
//	
//	
//	
//}
//
//
//function addAppointment(save) {
////	var dayDetailsList = document.getElementById("dayDetailsList");
////	var addAppointment = document.getElementById("addAppointment");
////	if (on == true)
////	{
////		dayDetailsList.style.display = "none";
////		addAppointment.style.display = "block";
////	}
////	else
////	{
////		dayDetailsList.style.display = "block";
////		addAppointment.style.display = "none";
////	}
//
//	var dayDetailsDiv = document.getElementById("dayDetailsDiv");
////	dayDetailsDiv.innerHTML = '<center><br/><img src="img/ajax/lc-loader.gif"/><br/><br/><h1>Loading Selected Day</h1><br/><h2>Please wait</h2></center><br/>';
////	dayDetailsDiv.style.display = "block";
//	
//	
//	var url = "neoCalendarAction-addAppointment.action?save=" + save + "&day=" + escape(document.getElementById("theday").value) + "&month=" + escape(document.getElementById("themonth").value) + "&year=" + escape(document.getElementById("theyear").value);
//	neoAjax.updateNoCache(url,dayDetailsDiv);
//}
//
//
//function submitAppointment() {
//	neoAjax.submitNoCache("neoCalendarAction-addAppointment.action","dayDetailsDiv",document.addAppointmentForm);
//}
//	
//function cancelAppointment(appointmentId,  day, month, year) {
//	var dayDetailsDiv = document.getElementById("dayDetailsDiv");
//	var url = "neoCalendarAction-cancelAppointment.action?appointmentId=" + appointmentId + "&day=" + day + "&month=" + month + "&year=" + year;
//	neoAjax.updateNoCache(url,dayDetailsDiv);
//}
//
//
//function acceptAppointment(appointmentId,  day, month, year) {
//	var dayDetailsDiv = document.getElementById("dayDetailsDiv");
//	var url = "neoCalendarAction-acceptAppointment.action?appointmentId=" + appointmentId + "&day=" + day + "&month=" + month + "&year=" + year;
//	neoAjax.updateNoCache(url,dayDetailsDiv);
//}
//
//
//function loadAutoSuggest()
//{
//	var options = {
//		script: "neoCalendarAction-findRecipient.action?",
//		varname: "recipient",
//		maxresults: 35,
//		callback: function (obj) { document.getElementById('recipient').value = obj.id; }
//		
//	};
//	var as = new _bsn.AutoSuggest('recipientName', options);
//	
//}
