﻿	var gSessionType = 0; //0=SessionID, 1=SessionGroupID
	var gSessionID = 0;
	
	function AddCourseToBag(inSessionID) {
		gSessionType = 0;
		gSessionID = inSessionID;
	}
	
	function AddSessionGroupToBag(inSessionGroupID) {
		gSessionType = 1;
		gSessionID = inSessionGroupID;
	}		
	
	function SaveCourseToSchoolBag() {
		var aChecked = jQuery("input[name=inSessionID]:checked");
		
		if ((aChecked.length > 0) && (gSessionID > 0)) {		
			 //Are you sure you want to add this course?
			if (confirm(jQuery.i18n._(7396))) {
				var cFuseaction = (gSessionType == 0) ? "ProgramsFrontMod.AddCourseToBag" : "ProgramsFrontMod.AddSessionGroupToBag";
				var cParam = (gSessionType == 0) ? "inSessionID" : "inSessionGroupID";
				LoadDiv("divAddResult", cFuseaction, "&" + cParam + "=" + gSessionID);
				jQuery("input[name=inSessionID]:checked").attr('checked','');
			}
		} else {
			alert(jQuery.i18n._(8428));			
			jQuery("input[name=inSessionID]:checked").attr('checked','');
		}							
	}
	
	function AddCourseWaitingList() {
		 //Are you sure you want to add this course?
		if (confirm(jQuery.i18n._(7396))) {
			document.getElementById('frmWaiting').submit();
		}							
	}	

	function AddCoursesWaitingList() {
		var aChecked = jQuery("input[name=inCourseID]:checked");
		
		if ((aChecked.length > 0)) {		
			 //Are you sure you want to add this course?
			if (confirm(jQuery.i18n._(7396))) {
				document.getElementById('frmWaiting').submit();
			}
		} else {
			alert(jQuery.i18n._(8428));			
			jQuery("input[name=inCourseID]:checked").attr('checked','');
		}							
	}	
	
	
	function SaveShortCourseToSchoolBag() {
		var aChecked = jQuery("input[name=inSessionID]:checked");
		
		if (aChecked.length > 0) {
			//Are you sure you want to add this course?
			if (confirm(jQuery.i18n._(7396))) {
								
				var aValues = [];
				
				// Put every checked checkbox to the values Array
				aChecked.each(function(){
				    aValues.push(this.value);
				});
				
				// Call to the server
				LoadDiv("divAddResult", "ProgramsFrontMod.AddCourseToBag", "&inSessionID=" + aValues.join(','));
			}
		} else {
			alert(jQuery.i18n._(8428));			
		}
	}	

	function ShowYearTabs(iYear) {
		jQuery('.divSessionContent').css('display','none');
		jQuery('.divSessionContent_' + iYear).css('display','block');
		return false;
	}	
