/*
	EMERSON COLLEGE
		Checkin Javascript
		
*/

function getCheckin(search_id_lastname) {
	// This function searches ID/lastname and gets checkin info
		
		var opt_getInformationCheckin = "&id_lastname="+search_id_lastname+"&camera_direction="+$F('camera_direction');;
		var getInformationCheckin = new Ajax.Updater(
										"info_checkin", 
											ajaxurl_root, { 
											method: 'post', 
											parameters: "&id=file_getCheckin"+opt_getInformationCheckin,
											evalScripts: true,
											onFailure: function(x) {
												$("debug").innerHTML = x.responseText;
											}
										}
									);
}

function checkin_sendCheckin(display_id,event_id,action) {
	
	// Vars
		var opt_checkin_sendCheckin = 
			'&check_student_id='+$F('check_student_id')
			+'&check_event_id='+event_id
			+'&check_action='+action;
		
		if (action == 1) {
			update_div = 'checkout_field_form_'+display_id;
		} else {
			update_div = 'checkin_field_form_'+display_id;
		}
		
	// Action
		var checkin_sendCheckin_ajax = new Ajax.Updater(
			update_div,
			ajaxurl_root, {
				method: 'post',
				parameters: '&id=file_saveCheckin'+opt_checkin_sendCheckin,
				evalScripts: true,
				onSuccess: function() {
					new Effect.Highlight('checkin_field_'+display_id,{duration:4});
				},
				onFailure: function(x) {
					$('debug').innerHTML = x.responseText;
				}
			});
		
}


function getCheckout(search_id_lastname) {
	// This function searches ID/lastname and gets checkin info
		
		var opt_getInformationCheckout = "&id_lastname="+search_id_lastname;
		var getInformationCheckout = new Ajax.Updater(
										"info_checkout", 
											ajaxurl_root, { 
											method: 'post', 
											parameters: "&id=file_getCheckout"+opt_getInformationCheckout,
											evalScripts: true,
											onFailure: function(x) {
												$("debug").innerHTML = x.responseText;
											}
										}
									);
}

function checkin_sendCheckout(display_id,event_id,action) {
	
	// Vars
		var opt_checkin_sendCheckout = 
			'&check_student_id='+$F('check_student_id')
			+'&check_event_id='+event_id
			+'&check_action='+action;
		
	// Action
		var checkin_sendCheckout_ajax = new Ajax.Updater(
			'checkout_field_form_'+display_id,
			ajaxurl_root, {
				method: 'post',
				parameters: '&id=file_saveCheckout'+opt_checkin_sendCheckout,
				evalScripts: true,
				onSuccess: function() {
					new Effect.Highlight('checkout_field_'+display_id,{duration:4});
				},
				onFailure: function(x) {
					$('debug').innerHTML = x.responseText;
				}
			});
		
}

/*
	CHECK OUT FUNCTIONS
	
*/

function getCheckout(search_id_lastname) {
	// This function searches ID/lastname and gets checkin info
		
		var opt_getInformationCheckout = "&id_lastname="+search_id_lastname;
		var getInformationCheckout = new Ajax.Updater(
										"info_checkout", 
											ajaxurl_root, { 
											method: 'post', 
											parameters: "&id=file_getCheckout"+opt_getInformationCheckout,
											evalScripts: true,
											onFailure: function(x) {
												$("debug").innerHTML = x.responseText;
											}
										}
									);
}

function clearCheckout() {
	
	$('info_checkout').innerHTML = "";
	$('search_id_lastname').value = "Enter ID# or Lastname";
	
}
