window.addEvent('domready',function() {
	//Delete (selected) bookmarked actions								
	$$('a.delete_bookmarked_action').addEvent('click', function (e) {
		delete_bookmarked(this);
	});

	//bookmark favorites actions
	$$('a.addFavoritesAction').each(function(e) {
				e.addEvent('click', function (e1) {
			    var survey_id = e.getProperty('survey_id');
				var parent_survey_id = e.getProperty('parent_survey_id');
				var category_id = e.getProperty('category_id');
				var category_array = e.getProperty('category_array');
				var goal_id = e.getProperty('goal_id');
				//var goalStatus = e.getProperty('goalStatus');
				//var favCount = e.getProperty('favCount');
				var current_week = e.getProperty('current_week');
				var week_r_id = e.getProperty('week_r_id');
				var remove_icon = e.getProperty('remove_icon');
				var template = e.getProperty('template');
				var favActionBox = $('favoriteActionsBox');
				
				var actionArray = {'goal_id': goal_id,  'category_id': category_id ,  'category_array': category_array ,  'survey_id': survey_id ,  'parent_survey_id': parent_survey_id ,  'current_week': current_week ,  'week_r_id': week_r_id ,  'remove_icon': remove_icon ,  'template': template };

							//This code will send a data object via a POST request and alert the retrieved data.
							var jsonRequest = new Request.JSON({url: 'ajax/add_bookmark_action.php', onComplete: function(responseVal){
															  
										//alert(responseVal.message_div);																
										//this code will add the no selected actions label, if all favorites actions are removed
											if(responseVal.message_div != "" )
											{
												favActionBox.set("html", responseVal.message_div);
												
												//re create the events after writing the new html - feb 17, 2011 - starts
												//Delete (selected) bookmarked actions								
												$$('a.delete_bookmarked_action').addEvent('click', function (e) {
													delete_bookmarked(this);
												});
												//save favorite actions	
												$$('#save_favorite_actions').addEvent('click', function (e1) {
			
													var jsonRequest = new Request.JSON({
													url: "ajax/get_label.php",
													onComplete: function(result) {
														Sexy.confirm(result.label1, {
														textBoxBtnOk: result.label2,
														textBoxBtnCancel: result.label3,
														onComplete: function(returnvalue) 
														{
															if (returnvalue) 
															{
																save_favorite_action_plans_box();
															}
														}
														});
														}
													}).get({label1: 'LBL_VALIDATE_ACTION_MESSAGE', label2: 'LBL_BTN_VALIDATE', label3: 'LBL_BTN_CANCEL'});
												});
												//re create the events after writing the new html - feb 17, 2011 - ends
												
											}
										
							}}).post(actionArray);

				});
	});
	//Select for next action plan
	$$('#select_bookmark_btn').addEvent('click', function (e1) {
		$$('.bookmark_chkbox').each(function(e) {
			if(e.checked) {
				var action_container = $('selected_action_list');
				var chkbox_id = e.get('id').replace('chkbox_','');
				var survey_id = e.getProperty('chk_survey_id');
				var parent_survey_id = e.getProperty('chk_parent_survey_id');
				var goal_id = e.getProperty('chk_goal_id');
				var week_r_id = e.getProperty('chk_week_r_id');
				var chk_user_id = e.getProperty('chk_user_id');
				var title = e.getProperty('title');
				var chk_current_week = e.getProperty('chk_current_week');
				var chk_template = e.getProperty('chk_template');
				var chk_image_remove_icon = e.getProperty('chk_image_remove_icon');
				//alert(chk_user_id);
				var div_data = '<div class="div_selected_action" align="left"  id="'+chkbox_id+'" parent_survey_id="'+parent_survey_id+'" survey_id="'+survey_id+'" goal_id="'+goal_id+'" week_r_id="'+week_r_id+'" user_id="'+chk_user_id+'" current_week="'+chk_current_week+'" template="'+chk_template+'"  title="'+title+'" image_remove_icon="'+chk_image_remove_icon+'" >'+title+
				'<div class=" remove_selected_action fright"><a action_survey_id="'+survey_id+'" action_goal_id="" action_user_id="'+chk_user_id+'" class="remove_selected_action" href="Javascript:void(0);" title="remove"><img border="0" src="'+chk_image_remove_icon+'" style="vertical-align:middle;" /></a></div></div>';
				$('div_'+chkbox_id).dispose();

				action_container.set("html", action_container.get("html") + div_data);
			}
		});
		//Removing a selected action  back to bookmarked action list
		$$('a.remove_selected_action').each(function(e) {
				e.addEvent('click', function (e1) {
					var parent = e.getParent('div').getParent('div');
					var action_user_id = e.getProperty('action_user_id');
					var parent_id = parent.getProperty('id');
					var div_title = parent.getProperty('title');
					var div_survey_id = parent.getProperty('survey_id');
					var div_parent_survey_id = parent.getProperty('parent_survey_id');
					var div_goal_id = parent.getProperty('goal_id');
					var div_week_r_id = parent.getProperty('week_r_id');
					var div_current_week = parent.getProperty('current_week');
					var div_template = parent.getProperty('template');
					var image_remove_icon = parent.getProperty('image_remove_icon');
					//alert(action_user_id);
					parent.dispose();
					var parent_action_container = $('bookmarked_list');
					var parent_div_data ='<div id="div_'+parent_id+'" style="margin-top: 2px;"><div class=" bookmark_chkbox_div fleft"><input type="checkbox" id="chkbox_'+parent_id+'" title="'+div_title+'" id="chkid" value="1" class="bookmark_chkbox" chk_survey_id="'+div_survey_id+'" chk_week_r_id="'+div_week_r_id+'" chk_parent_survey_id="'+div_parent_survey_id+'" chk_goal_id="'+div_goal_id+'" chk_user_id="'+action_user_id+'" chk_current_week="'+div_current_week+'" chk_template="'+div_template+'" chk_image_remove_icon="'+image_remove_icon+'" /></div><div class=" box_370 fleft">'+div_title+'</div><div class=" remove_bookmark fright"><a href="Javascript:void(0);" class="delete_bookmarked_action" object_name="'+div_title+'" bookmark_id="'+parent_id+'" user_id="'+action_user_id+'" title="remove"><img border="0" src="'+image_remove_icon+'" style="vertical-align:middle;" /></a></div></div><div class="clear"></div>'
					parent_action_container.set("html", parent_action_container.get("html") + parent_div_data);
					$$('a.delete_bookmarked_action').addEvent('click', function (e) {
						delete_bookmarked(this);
					})
				});
		});
	});
	//Save the selected boomarks to next action plan
	$$('#save_action_plan').addEvent('click', function (e1) {
		var action_exists =$(document.body).getElements('.div_selected_action');
		var action_survey_id = $$('#save_action_plan').getProperty('action_survey_id');
		var parent_survey_id = $$('#save_action_plan').getProperty('parent_survey_id');
		var action_week_range_id = $$('#save_action_plan').getProperty('action_week_range_id');
		var my_plan_count = 0;
		var more_add_count = 0;
		//alert(action_survey_id);
		//alert(action_week_range_id);
		//Checking the number of action plans selected. Show an alert message if more than 5 action plans are selected for validation.
		var action_count = action_exists.length;
		//alert(action_count);
		if(action_count > 0) {
			var jsonRequest = new Request.JSON({
				url: "ajax/get_action_count.php",
				onComplete: function(result) {
					my_plan_count = result.length;
					if(my_plan_count >=5) {
						var jsonRequest = new Request.JSON({
							url: "ajax/get_label.php",
							onComplete: function(result) {
								Sexy.alert('<h1>'+result.label+'</h1></br></br>');
							}
						}).get({label: 'YOU_ALREADY_HAVE_5_SELECTED_ACTIONS'});
					} else if((action_count + my_plan_count) > 5 ) {
							more_add_count = 5-my_plan_count;
							var jsonRequest = new Request.JSON({
								url: "ajax/get_label.php",
								onComplete: function(result) {
									Sexy.alert(result.label1+'&nbsp;'+my_plan_count+'&nbsp;<br/>'+result.label2+'&nbsp;'+more_add_count+'&nbsp;'+result.label3+'&nbsp;</h1></br></br>');
								}
							}).get({label1: 'LBL_YOU_ALREADY_HAVE', label2: 'LBL_SELECTED_ACTION_PLAN_(S)_YOU CAN_ADD_ONLY', label3: 'LBL_MORE'});	
					} else {
						save_action_plans();
					}
				}
			}).get({week_range_id: action_week_range_id, survey_id: action_survey_id, parent_survey_id: parent_survey_id});
			//check_action_plan_exists();
			
			
			/*if(action_count > 5) {
				var jsonRequest = new Request.JSON({
					url: "ajax/get_label.php",
					onComplete: function(result) {
						Sexy.alert('<h1>'+result.label+'</h1></br></br>');
					}
				}).get({label: 'LBL_SELECT_MAXIMUM_5_ACTION_PLANS_MESSAGE'});
			} else {
				save_action_plans();
			}*/
		}
	});
	//Selected actions: week range header 
	$$('a.week_range_action_plans').each(function(e) {
				e.addEvent('click', function (e1) {
					get_week_action_plans(e);						  
				});
	});
	//My action plan: week range header
	$$('a.my_action_plan_week_range').each(function(e) {
        e.addEvent('click', function (e1) {
			Site.myActionSubTabsMenu();
			var week_range_id = e.getProperty('week_range_id');	
			$(document.body).getElements('.my_actions_block').setStyle('display', 'none');
			$('div_my_action_'+week_range_id).setStyle('display', 'block');
			var block_id = $$('#block_'+week_range_id).getProperty('week_rangeindex');
			$$('#tab'+block_id).setStyle('display', 'block');
		});
	});

	//new function for favorite actions validation - Feb 09, 2011- starts
	$$('#save_favorite_actions').addEvent('click', function (e1) {
		var bodyVar = document.body,
		htmlVar = document.documentElement;
	
		var heightVar = Math.max( bodyVar.scrollHeight, bodyVar.offsetHeight, 
						   htmlVar.clientHeight, htmlVar.scrollHeight, htmlVar.offsetHeight );
		
		var jsonRequest = new Request.JSON({
		url: "ajax/get_label.php",
		onComplete: function(result) {
			Sexy.confirm(result.label1, {
			textBoxBtnOk: result.label2,
			textBoxBtnCancel: result.label3,
			onComplete: function(returnvalue) 
			{
				if (returnvalue) 
				{
					save_favorite_action_plans_box();
					/*$$('#red_box_clicked1').dispose();
					$$('#red_box_clicked2').dispose();
					var dash_container = $$('#dash_menu_box');
					var image_c = dash_container.getProperty('image_c');
					var parent_survey_id = dash_container.getProperty('parent_survey_id');
					var url = 'quizz_results.php?survey='+parent_survey_id+'&rtype=6';
					var dash_data = '<div class="dashboardSeperator fleft"><img src="'+image_c+'" border="0"/></div><div class="fleft dashboardButton" ><a href="'+url+'" class="dashBoardButton">Action Plan</a></div>';
					dash_container.set("html", dash_container.get("html") + dash_data);*/
					
					
				}
			}
			},heightVar);
			}
		}).get({label1: 'LBL_VALIDATE_ACTION_MESSAGE', label2: 'LBL_BTN_VALIDATE', label3: 'LBL_BTN_CANCEL'});
	});
	
	//finished red button	
	$$('#finished_actions').addEvent('click', function (e) {
		process_finished_actions(this);
	});
});	

function delete_bookmarked(obj) {
	var bodyVar = document.body,
    htmlVar = document.documentElement;

	var heightVar = Math.max( bodyVar.scrollHeight, bodyVar.offsetHeight, 
                       htmlVar.clientHeight, htmlVar.scrollHeight, htmlVar.offsetHeight );

	var object_name = obj.getProperty('object_name');
	var bookmark_id = obj.getProperty('bookmark_id');
	var user_id = obj.getProperty('user_id');
	var category_id = obj.getProperty('category_id');
	var survey_id = obj.getProperty('survey_id');
	//alert(user_id);
	//var deleteMessage= '<br><br><strong>Delete bookmark action: </strong><br><br>' + object_name + '<br><br><br>';
	var deleteArray = {'object_delete': 'BOOKMARK', 'bookmark_id': bookmark_id, 'user_id': user_id,  'category_id': category_id ,  'survey_id': survey_id };
	var parent = obj.getParent('div').getParent('div');
	var favCatTitle = $('favCatTitle'+category_id);
	var favActionBox = $('favoriteActionsBox');
	var jsonRequest = new Request.JSON({
		url: "ajax/get_label.php",
		onComplete: function(result) {
			Sexy.confirm(result.label1, {
				textBoxBtnOk: result.label2,
				textBoxBtnCancel: result.label3,
				onComplete: function(returnvalue) {
						if (returnvalue) {
							//This code will send a data object via a POST request and alert the retrieved data.
							var jsonRequest = new Request.JSON({url: 'ajax/delete_bookmarked_action.php', onComplete: function(responseVal){
															  
										new Fx.Tween(parent,{ duration:300 }).start('background-color', '#CCCCCC');
										new Fx.Slide(parent,{
													 duration:300, 
													 onComplete: function() {
														 parent.dispose(); 
														
													} 
														 }).slideOut(); 
										//this code will remove the category title from the list
								 		if(responseVal.data == true)
										favCatTitle.dispose(); 
										
										//this code will add the no selected actions label, if all favorites actions are removed
										if(responseVal.dataLabel == true)
										{
											var noSelActMessage = responseVal.messageLabel;
											var favActionData = '<div class="box_210">' + noSelActMessage + '</div>';
											favActionBox.set("html",  favActionData);
										}
							}}).post(deleteArray);
						}
				}
			},heightVar);
		}
	}).get({label1: 'LBL_DELETE_BOOKMARK_MESSAGE', label2: 'LBL_BTN_YES', label3: 'LBL_BTN_CANCEL'});
}

function save_action_plans() {
	//var insertMessage= '<br><br><strong>Validate your action plan ?</strong> <br><br>Are you sure you want to validate these action plans in your next action plan. This cannot be undone.<br><br><br>';
	var existing_list = '';
	var jsonRequest = new Request.JSON({
		url: "ajax/get_label.php",
		onComplete: function(result) {
			Sexy.confirm(result.label1, {
				textBoxBtnOk: result.label2,
				textBoxBtnCancel: result.label3,
				onComplete: function(returnvalue) {
						if (returnvalue) {
							$('ajax_loading').setStyle('visibility', 'visible');
							$$('.div_selected_action').each(function(e) {
								var parent_survey_id = e.getProperty('parent_survey_id');
								var survey_id = e.getProperty('survey_id');
								var goal_id = e.getProperty('goal_id');
								var user_id = e.getProperty('user_id');
								var week_r_id = e.getProperty('week_r_id');
								var current_week = e.getProperty('current_week');
								var template = e.getProperty('template');
								var insertArray = {'survey_id': survey_id, 'parent_survey_id':parent_survey_id, 'goal_id': goal_id , 'user_id': user_id, 'week_r_id': week_r_id, 'current_week': current_week, 'template': template};
								var checkArray = {'survey_id': survey_id, 'goal_id': goal_id , 'week_r_id': week_r_id};
								//This code will send a data object via a POST request and alert the retrieved data.
								
								//Block 1 -----STARTS:  IMPORTANT:  If needs to check whether a bookmarked action is already selected, comment(disable) this 'Block 1' and uncomment(enable) the 'Block 1A' given below.
								var jsonRequest = new Request.JSON({url: 'ajax/save_selected_action.php', onComplete: function(result){
									//$('ajax_loading').setStyle('visibility', 'hidden');																						   
									document.location.href='quizz_results.php?survey='+parent_survey_id+'&rtype=6';																							
								}}).post(insertArray);
								//Block 1 -----ENDS
								
								//Block 1A ------STARTS
								/*var jsonRequest = new Request.JSON({
									url: 'ajax/check_action_plan_exists.php',
									onComplete: function(action_result){
										if(action_result.length > 0) {
											//for(i=0; i <action_result.length; i++) {
												//var existing_plans  = existing_plans + action_result[i].title + '<br/>'
												existing_list = existing_list + action_result[0].title;
												var jsonRequest = new Request.JSON({
													url: "ajax/get_label.php",
													onComplete: function(result) {
														Sexy.alert('<h4>'+result.label+'<br/><br/>'+action_result[0].title+'<br/><br/></h4>');
													}
												}).get({label: 'LBL_ACTION_PLAN_ALREADY_EXISTS'});
												$('ajax_loading').setStyle('visibility', 'hidden');
												//document.location.href='quizz_results.php?survey='+survey_id+'&rtype=3';
											//}
										} else {
											var jsonRequest = new Request.JSON({url: 'ajax/save_selected_action.php', onComplete: function(result){
												$('ajax_loading').setStyle('visibility', 'hidden');																						   
												document.location.href='quizz_results.php?survey='+parent_survey_id+'&rtype=3';																							   
											}}).post(insertArray);
											
										}
									}
								}).post(checkArray);*/
								//Block 1A ------ENDS
								
							});
						}
				}
			});
		}
	}).get({label1: 'LBL_VALIDATE_ACTION_MESSAGE', label2: 'LBL_BTN_VALIDATE', label3: 'LBL_BTN_CANCEL'});	
}

function check_action_plan_exists() {
	var exists = false;
	$$('.div_selected_action').each(function(e) {
		var survey_id = e.getProperty('survey_id');
		var goal_id = e.getProperty('goal_id');
		var week_r_id = e.getProperty('week_r_id');
		var user_id = e.getProperty('user_id');
		var existing_plans='';
		var postArray = {'survey_id': survey_id, 'goal_id': goal_id, 'week_r_id': week_r_id};
		//This code will send a data object via a POST request and alert the retrieved data.
		var jsonRequest = new Request.JSON({
			url: 'ajax/check_action_plan_exists.php',
			onComplete: function(action_result){
				if(action_result.length > 0) {
					exists = true;
					for(i=0; i <action_result.length; i++) {
						existing_plans  = existing_plans + action_result[i].title + '<br/>'
						//Sexy.alert(action_result[i].title);
						//existing_plans.set("html", existing_plans_set.get("html") + existing_plan);
					}
					Sexy.alert('<h3>The following action plan(s) already exists.<br/><br/>'+existing_plans+'</h3>');
				}
			}
		}).post(postArray);
	});
}

function get_week_action_plans(obj) {
	
	var week_range_id = obj.getProperty('week_range_id');
	var week_range_title = obj.getProperty('week_range_title');
	var survey_id = obj.getProperty('survey_id');
	var parent_survey_id = obj.getProperty('parent_survey_id');
	var current_weekrange_action_plan = obj.getProperty('current_weekrange_action_plan');
	var lbl_current = obj.getProperty('lbl_current');
	var week_range_min = obj.getProperty('week_range_min');
	var week_range_max = obj.getProperty('week_range_max');
	var i;
	var container = $('week_action_list');
	container.set("html", '');
	var jsonRequest = new Request.JSON({
		url: "ajax/get_label.php",
		onComplete: function(result) {
			if(current_weekrange_action_plan == week_range_id) {
				$('week_title').set("html", lbl_current);
			}
			else {
				$('week_title').set("html", result.label+'&nbsp;'+week_range_min+'-'+week_range_max);
			}
		}
	}).get({label: 'LBL_WEEK'});
	var jsonRequest = new Request.JSON({
		url: "ajax/get_week_action_plans.php",
		onComplete: function(result) {
			if(result.length > 0) {
				for(i=0; i <result.length; i++) {
					//alert(result[i].action_plan_id);
					var action_plan_data = '<div class="my_selected_actions_block_item" align="left">'+result[i].title+'</div>'
					container.set("html", container.get("html") + action_plan_data);
				}
			} else {
				container.set("html", '<h4>No action plans for '+week_range_title+'</h4>');
			}
			
		}
	}).get({week_range_id: week_range_id, survey_id: survey_id, parent_survey_id: parent_survey_id});	
}

//new function to save favorites actions - Feb 10, 2011 - starts
function save_favorite_action_plans() {

	var existing_list = '';
	var jsonRequest = new Request.JSON({
		url: "ajax/get_label.php",
		onComplete: function(result) {
			Sexy.confirm(result.label1, {
				textBoxBtnOk: result.label2,
				textBoxBtnCancel: result.label3,
				onComplete: function(returnvalue) {
						if (returnvalue) {
							$('ajax_loading').setStyle('visibility', 'visible');
							$$('.bookmark_chkbox').each(function(e) {
								if(e.checked) {	
								
								var parent_survey_id = e.getProperty('chk_parent_survey_id');
								var survey_id = e.getProperty('chk_survey_id');
								var goal_id = e.getProperty('chk_goal_id');
								var category_id = e.getProperty('chk_category_id');
								var user_id = e.getProperty('chk_user_id');
								var week_r_id = e.getProperty('chk_week_r_id');
								var current_week = e.getProperty('chk_current_week');
								var template = e.getProperty('chk_template');
								var insertArray = {'survey_id': survey_id, 'parent_survey_id':parent_survey_id, 'goal_id': goal_id , 'category_id': category_id , 'user_id': user_id, 'week_r_id': week_r_id, 'current_week': current_week, 'template': template};
								var checkArray = {'survey_id': survey_id, 'goal_id': goal_id , 'week_r_id': week_r_id};
								//This code will send a data object via a POST request and alert the retrieved data.
								
								//Block 1 -----STARTS:  IMPORTANT:  If needs to check whether a bookmarked action is already selected, comment(disable) this 'Block 1' and uncomment(enable) the 'Block 1A' given below.
								var jsonRequest = new Request.JSON({url: 'ajax/save_selected_action.php', onComplete: function(result){
									//$('ajax_loading').setStyle('visibility', 'hidden');																						   
									document.location.href='quizz_results.php?survey='+parent_survey_id+'&rtype=6';																							
								}}).post(insertArray);
								//Block 1 -----ENDS
								
													
							}
							});
						}
				}
			});
		}
	}).get({label1: 'LBL_VALIDATE_ACTION_MESSAGE', label2: 'LBL_BTN_VALIDATE', label3: 'LBL_BTN_CANCEL'});	
}
//new function to save favorites actions - Feb 10, 2011 - ends
//new function to save favorites actions from box - Feb 17, 2011 - starts
function save_favorite_action_plans_box() {

	var existing_list = '';
	$('ajax_loading').setStyle('visibility', 'visible');
	$$('.bookmark_chkbox').each(function(e) {
		if(e.checked) {	
		
		var parent_survey_id = e.getProperty('chk_parent_survey_id');
		var survey_id = e.getProperty('chk_survey_id');
		var goal_id = e.getProperty('chk_goal_id');
		var category_id = e.getProperty('chk_category_id');
		var user_id = e.getProperty('chk_user_id');
		var week_r_id = e.getProperty('chk_week_r_id');
		var current_week = e.getProperty('chk_current_week');
		var template = e.getProperty('chk_template');
		var insertArray = {'survey_id': survey_id, 'parent_survey_id':parent_survey_id, 'goal_id': goal_id , 'category_id': category_id , 'user_id': user_id, 'week_r_id': week_r_id, 'current_week': current_week, 'template': template};
		var checkArray = {'survey_id': survey_id, 'goal_id': goal_id , 'week_r_id': week_r_id};
		//This code will send a data object via a POST request and alert the retrieved data.
		
		//Block 1 -----STARTS:  IMPORTANT:  If needs to check whether a bookmarked action is already selected, comment(disable) this 'Block 1' and uncomment(enable) the 'Block 1A' given below.
		var jsonRequest = new Request.JSON({url: 'ajax/save_selected_action.php', onComplete: function(result){
			//$('ajax_loading').setStyle('visibility', 'hidden');																						   
			document.location.href='quizz_results.php?survey='+parent_survey_id+'&rtype=6';																							
		}}).post(insertArray);
		//Block 1 -----ENDS
		
							
	}
	});
}
//new function to save favorites actions from box - Feb 17, 2011 - ends

//new function for enable/disable  the savefavoriteaction button on checkbox enable/disable - Feb 17,2011 - starts
function processValidateButton(checkid)
{
	//$$('#save_favorite_actions').setProperty('disabled','false');
	//var action_survey_id = $$('#save_favorite_actions').getProperty('action_survey_id');
	//var parent_survey_id = $$('#save_favorite_actions').getProperty('parent_survey_id');
	//var action_week_range_id = $$('#save_favorite_actions').getProperty('action_week_range_id');
	//alert('survey = '+action_survey_id + 'psurvey = ' + parent_survey_id + 'wr = '+action_week_range_id);
	var checkCounter =0;
	$$('.bookmark_chkbox').each(function(e) {
										 
		if(e.checked) {	
			checkCounter = checkCounter + 1;
			$$('#finished_actions').hide();
			if(checkCounter > 5)
			{
				var jsonRequest = new Request.JSON({
				url: "ajax/get_label.php",
				onComplete: function(result) {
					alert(result.label);
					checkid.setProperty('checked', false);
				}
				}).get({label: 'LBL_ACTION_PLAN_MAXIMUM_VALIDATION'});
			}
		}
	});
	if(checkCounter >= 1 && checkCounter <= 5)
	{
		$$('#save_favorite_actions').setProperty('class','menu button');
		$$('#save_favorite_actions').setProperty('disabled',false);
	}
	if(checkCounter < 1 )
	{ 
		$$('#save_favorite_actions').setProperty('class','menu button inactiveButton');
		$$('#save_favorite_actions').setProperty('disabled','disabled');
	}
}
//new function for enable/disable save favorite action button on checkbox enable/disable - Feb 17,2011 - ends

//new function for process finished actions button - Apr 18,2011 - starts
function process_finished_actions()
{
	//$$('#finished_actions').setProperty('class','hiddenButton');
	$$('#action_box_clicked').setProperty('value', 1);
	$$('#finished_actions').hide();
	$$('#save_favorite_actions').setProperty('class','menu button inactiveButton shownButton');
	$$('#save_favorite_actions').setProperty('disabled','disabled');
	//Function to update the 'video viewed' status(=1)
	update_video_view_status();
	//Show a disabled 'Action plan' button on the dashboard menu when the red colored'Finished Adding Actions' button is clicked
	var timeline_container = $$('#dash_menu_box');
	var image_ct = $$('#timeline_button').getProperty('image_ct');
	var container_data ='';
	var jsonRequest = new Request.JSON({
		url: "ajax/get_label.php",
		onComplete: function(result) {
			container_data = '<div class="dashboardSeperator fleft" id="red_box_clicked1"><img src="'+image_ct+'" border="0"/></div><div class="fleft dashboardButtonDisabled" id="red_box_clicked2"><a href="javascript:void(0);" class="dashBoardButton">'+result.label+'</a></div>';
		$$('#dashboard_timeline_block').dispose();
		timeline_container.set("html", timeline_container.get("html") + container_data);
		}
	}).get({label: 'LBL_ACTION_PLAN_BUTTON'});
}
//new function for process finished actions button - Apr 18,2011  - ends

//Function to update the 'video viewed' status of a survey - May 02, 2011  -starts
function update_video_view_status()
{
	survey_id = $$('#save_favorite_actions').getProperty('parent_survey_id');
	insertData = {'survey_id': survey_id};
	var jsonRequest = new Request.JSON({url: 'ajax/update_video_view.php', onComplete: function(result){
			$$('.bookmark_chkbox').each(function(e) {
				e.setProperty('onclick', 'processValidateButton(this);');									 
			});
		}}).post(insertData);
}
//Function to update the 'video viewed' status of a survey - May 02, 2011  -ends

