
	var weekHourDay = new Array();

	var initialShift=''; //this var lets us know which hour was pressed first w/ a shift key
	var endShift=''; //this var lets us know which hour was pressed second w/ a shift key
	
	var highHour,lowHour,highDay,lowDay,highWeek,lowWeek;

	function checkHour_init(cWeek,cDay,cHour,event1) {
		//alert('SHIFT? ' + event1.shiftKey);

		var hourDayVal = cWeek+'_'+cDay+'_'+cHour;
		
		if(event1.shiftKey) { //if the shift key is pressed:
			if(initialShift && endShift=='') { //if the first shift value was set, but not the second

				//alert('shifting done!');
				endShift=hourDayVal;
				
			  //loop through the hours and "checkHourDo(cWeek,cDay,cHour)":
				
				var splitInitialShift = initialShift.split('_');
				var splitEndShift = endShift.split('_');

			     //get the highest & lowesthours (to form the box 'height')
				if(splitEndShift[2]*1>splitInitialShift[2]*1) { highHour= splitEndShift[2]; lowHour=splitInitialShift[2]; }
				else { lowHour= splitEndShift[2]; highHour=splitInitialShift[2]; }

				//alert('highHour: ' + highHour +' lowHour: ' + lowHour);

			     //get the highest & lowest days (to form the box 'width')
				if(splitEndShift[1]*1>splitInitialShift[1]*1) { highDay= splitEndShift[1]; lowDay=splitInitialShift[1]; }
				else { lowDay= splitEndShift[1]; highDay=splitInitialShift[1]; }

			     //get the highest & lowest weeks (to form the box 'width')
				if(splitEndShift[0]*1>splitInitialShift[0]*1) { highWeek= splitEndShift[0]; lowWeek=splitInitialShift[0]; }
				else { lowWeek= splitEndShift[0]; highWeek=splitInitialShift[0]; }
		


				
				for(iWeek=lowWeek;iWeek<highWeek*1+1;iWeek++){
					//alert('iWeek: ' + iWeek);
				  for(iDay=lowDay;iDay<highDay*1+1;iDay++){
					//alert('iDay: ' + iDay);
				    for(iHour=lowHour;iHour<highHour*1+1;iHour++){
					//alert('iHour' + iHour);
					checkHourDo(iWeek,iDay,iHour);
				    }
				  }
				}
						
				initialShift='';
				endShift='';

			}
			else { 
				initialShift=hourDayVal; 
				//alert('IS only:'+initialShift);
				document.getElementById(hourDayVal).style.background="url('images/calendar_check_gray.jpg')";
				document.getElementById(hourDayVal).style.backgroundPosition='center center';
		

			 }
		}
		else { // if no shift key, just plain checking:

			if(initialShift) {

				document.getElementById(initialShift).style.background="";
				document.getElementById(initialShift).style.backgroundPosition='center center';
			initialShift='';
			}
			endShift='';
			checkHourDo(cWeek,cDay,cHour);
			
		}
	}	

	if(!Array.indexOf){
	    Array.prototype.indexOf = function(obj){
	        for(var i=0; i<this.length; i++){
	            if(this[i]==obj){
	                return i;
	            }
	        }
	        return -1;
	 }//end if
	} //end function



	function checkHourDo(cWeek,cDay,cHour,offOnOnly){

		//offOnOnly can be 'on','off', or '' (nothing), if on, all are turned on regardless
		

		//alert('W:'+cWeek+'D:'+cDay+'H:'+cHour);

		var hourDayVal = cWeek+'_'+cDay+'_'+cHour;

		foundVar = weekHourDay.indexOf(hourDayVal);
		//alert(foundVar);

		if(foundVar>-1){ //the hour is already selected, so unselect it
		
			if(offOnOnly!='on') { //dont do this if we want all values 'on':
			
				weekHourDay.splice(foundVar, 1);
		
				document.getElementById(hourDayVal).style.background="";
				document.getElementById(hourDayVal).style.backgroundColor="#DDEAF2";
			}
		}
		else {  //the hour is not selected, so select it

			if(offOnOnly!='off') { //dont do this if we want all values 'off':
				weekHourDay.push(hourDayVal);
				document.getElementById(hourDayVal).style.background="url('images/calendar_check_dark.jpg')";
				document.getElementById(hourDayVal).style.backgroundPosition='center center';
			}
		}

	}


	//check/uncheck all days for that hour (used for +Add Hour button)

	function clearHour_allDays(hour1) {  // uncheck the hour for every day
		for(i=1;i<8;i++){

			//checkHourDo(cWeek,cDay,cHour,'off')
			var cWeek=1; //this will be turned onto a for loop when we do add_week function	
			checkHourDo(cWeek,i,hour1,'off');
		}
	}

/* "+ ADD HOUR" FUNCTIONS: */

	//what hours are usually displayed (8am-8pm);
	var displayedHours =  new Array(8,9,10,11,12,13,14,15,16,17,18,19,20); 

	function showHideHour(hour1){

		var thisClassName = document.getElementById('popHour_'+hour1).className;
		var thisClassArray = thisClassName.split('_');
		if(thisClassArray[1]=='OFF'){
			document.getElementById('popHour_'+hour1).className=thisClassArray[0]+'_ON';

			for(i=1;i<globalWeekCount+1;i++){
			  document.getElementById('hour_container_'+i+'_'+(hour1*1)).style.display='';
			}

			//add hour to displayed hour array:
			displayedHours.push(hour1*1);

		}
		else { 
			document.getElementById('popHour_'+hour1).className=thisClassArray[0]+'_OFF';
			for(i=1;i<globalWeekCount+1;i++){
			  document.getElementById('hour_container_'+i+'_'+(hour1*1)).style.display='none';
			}
			//clear all checked values for that hour:
				clearHour_allDays(hour1*1);
		
			//remove hour from displayed hour:
				displayedHour = displayedHours.indexOf(hour1*1);
				displayedHours.splice(displayedHour,1);
		}
		
	}

	function toggleAddHours(){

		if(document.getElementById('popUpHourMain').style.display=='') {
			document.getElementById('popUpHourMain').style.display='none'; 
			document.getElementById('add_hour_button').style.backgroundColor='#2596BE';
		}
		else {  document.getElementById('popUpHourMain').style.display='';
			document.getElementById('add_hour_button').style.backgroundColor='#004488';
		 }
	}