	function business_container(){
		if(is_business==1){
			all_staff();
			opening_hours();
			description();
			services();
			staff_members();
			business_detalis();
		}
	}

	function create_help_event(){
		$('.title_help').click(function(){
			var old=0;
			var hr=$(this).attr('id');
			$('.desc_hide').each(function(){
				if($(this).css('display')=='block'){
					old++;
					$(this).prev().children('h3').removeClass('faq2');
					$(this).slideUp('fast',function(){
						old--;
						if(old==0)
							document.location.hash=hr;
					});					
				}
			});
			var w=$(this).attr('rel');
			if($('.desc_help_'+w).css('display')=='none'){
				old++;
				$(this).children('h3').addClass('faq2');
				$('.desc_help_'+w).slideDown('fast',function(){
					old--;
					if(old==0)
						document.location.hash=hr;	
				});
			}else{				
				$(this).css('background-position','0px -15px');
				$(this).children('h3').removeClass('faq2');
			}
			
				
		});
	}


	function business_profil_box(){
		

		$('.business_des .add_to_contacts, .business_buttons .add_to_contacts').click(function(e){
			e.preventDefault();
			if($('.business_des h3').length){
				thetitle = $('.business_des h3').text();
			} else {
				thetitle = $(this).attr('rel');
			}
			
			$('body').prepend('<div id="dark"></div>');
			$('#dark').css({'left':'0px','right':'0px','opacity':'0.4','background':'#000','width':$('body').width()+'px','height':$(document).height()+'px','z-index':'10','position':'absolute'});
				
			var baner='<div id="JSjoin_network" style="background:url(\''+STATIC_IMG_DIR+'plans/content_message.gif\') repeat-x #d0d0d0;left:'+($('body').width()/2-189)+'px;position:absolute;top:'+($(window).height()/2+$(document).scrollTop()-111)+'px;width:378px;z-index:11">';
				baner+='<div style="color:#fff;font-size:16px;font-weight:bold;padding:6px 0 6px 14px;cursor:move">Add Contact</div>';
				baner+='<div style="background:#fff;margin:14px;padding:19px 10px 21px 15px;width:324px">';
				baner+='<div id="join_network_div"><b style="display:block;padding-bottom:17px">Are you sure you want to add \''+thetitle+'\' as a contact?</b></div>';
				baner+='<a id="JSadd" href="" style="margin-right:10px;"></a>';
				baner+='<a id="JSlong_ok" href="" style="margin-right:10px;display:none;"></a>';
				baner+='<a id="JScancel" href=""></a>';
				baner+='<div class="clear"></div></div></div>';			
			$('body').prepend(baner);
			$('#JSjoin_network').draggable();
			var href=$(this).attr('href');
			
			
			$('#JSadd').click(function(e){
				e.preventDefault();
				business_add_to_contact(href);
			});

			$('#JScancel, #JSlong_ok').click(function(e){
				e.preventDefault();
				$('#dark').remove();
				$(this).unbind('click');				
				$('#JSjoin_network').remove();
			});
			
		});

		$('.business_des .send_a_message').click(function(e){
			e.preventDefault();
			
			$('body').prepend('<div id="dark"></div>');
			$('#dark').css({'left':'0px','right':'0px','opacity':'0.4','background':'#000','width':$('body').width()+'px','height':$(document).height()+'px','z-index':'10','position':'absolute'});

			var style='left:'+($('body').width()/2-189)+'px;position:absolute;top:'+($(window).height()/2+$(document).scrollTop()-150)+'px;';
			var baner='<div id="JSsend_message" style="background:url(\''+STATIC_IMG_DIR+'plans/content_message.gif\') repeat-x #d0d0d0;'+style+';width:404px;z-index:11">';
				baner+='<div style="color:#fff;font-size:16px;font-weight:bold;padding:6px 0 6px 14px;cursor:move">Send A Message</div>';
				baner+='<div style="background:#fff;margin:14px;padding:19px 10px 21px 15px;width:350px">';
				baner+='<div id="send_div">';
				baner+='<form name="send" id="send_form">';	
				baner+='<table cellpadding="0" cellspacing="6">';
				baner+='<tr><td align="right"><b>To:</b></td><td>'+$('.business_des h3').text()+'</td></tr>';
				baner+='<tr><td align="right" ><b>Subject:</b></td><td><input tyle="text" value="" name="data[message][subject]" style="border:1px solid #9da7b5;padding-left:0px;padding-right:0px;width:274px;" /></td></tr>';
				baner+='<tr><td align="right" valign="top" style="padding-top:4px;"><b>Message:</b></td><td style="padding-top:4px;"><textarea  name="data[message][message]"  style="border:1px solid #9da7b5;height:184px;width:274px;" ></textarea></td></tr>';
				baner+='</table>';
				baner+='</form>';
				baner+='</div>';
				baner+='<div style="float:right;padding:10px 6px 0 0;width:116px">';
		
				baner+='<a id="JSsend" href="" style="margin-right:10px;"></a>';
				baner+='<a id="JSlong_ok" href="" style="margin-right:10px;display:none;"></a>';
				baner+='<a id="JScancel" href=""></a>';		
				baner+='<div class="clear"></div></div><div class="clear"></div></div></div>';			
			$('body').prepend(baner);
			$('#JSsend_message').draggable();
			
			var href=$(this).attr('href');
			
			$('#JSsend').click(function(e){
				e.preventDefault();
				form_data2=$("#send_form").serialize();
				business_send_small(href,form_data2);
			});
			
			
			$('#JScancel, #JSlong_ok').click(function(e){
				e.preventDefault();
				$('#dark').remove();
				$('#JSsend_message a').unbind('click');				
				$('#JSsend_message').remove();
			});			
		});
	}


	function business_add_to_contact(path){
		
		
		$.ajax({
			type:"POST",
			url: path,
			timeout:25000,
			beforeSend: function(){
				$('#JSadd').unbind('click').remove();
				$('#JSremove').unbind('click').remove();
				$('#JScancel').unbind('click').remove();
				$('#JSlong_ok').show();
				$('#join_network_div').html('<div style="text-align:center"><img src="'+STATIC_IMG_DIR+'spinner.gif" alt="" style="padding:8px 0 9px 0" /></div>');
			},
			success: function(msg){				
				$('#join_network_div').html(msg);										
			},
			error: function(){					
				$('#join_network_div').html('<div style="text-align:center;color:red;padding:10px 0 10px 0;">Error. <br /> Please refresh the page</div>');
			}
		});
	}
	
	function business_send_small(path,data){	
		if(data==null)
		data='start=1';
		
		$.ajax({
			type:"POST",
			url: path,
			timeout:25000,
			data:data,
			beforeSend: function(){
				$('#JSsend').unbind('click').remove();
				$('#JScancel').unbind('click').remove();
				$('#JSlong_ok').css({'float':'right'}).show();
				$('#send_div').html('<div style="text-align:center"><img src="'+STATIC_IMG_DIR+'spinner.gif" alt="" style="padding:70px 0 70px 0" /></div>');
			},
			success: function(msg){				
				$('#send_div').html(msg);
			},
			error: function(){
				$('#send_div').html('<div style="text-align:center;color:red;padding:62px 0 62px 0;">Error. <br /> Please refresh the page</div>');
			}
		});
	}



	function all_staff(){
		
		
		$('#all_staff').click(function(e){
			e.preventDefault();

			var style='left:'+($('body').width()/2-365)+'px;position:absolute;top:'+($(window).height()/2+$(document).scrollTop()-190)+'px;';		
			
			$('body').prepend('<div id="dark"></div>');
			if($.browser.msie && $.browser.version=='6.0')
				$('select').css({'visibility':'hidden'});
			$('#dark').css({'left':'0px','right':'0px','opacity':'0.4','background':'#000','width':$('body').width()+'px','height':$(document).height()+'px','z-index':'10','position':'absolute'});
			var baner='<div id="staff_container" style="background:url(\''+STATIC_IMG_DIR+'plans/content_message.gif\') repeat-x #d0d0d0;'+style+';width:730px;z-index:11">';
				baner+='<div style="background:url(\''+STATIC_IMG_DIR+'plans/content_message.gif\') repeat-x 0px 100% #e98680;color:#fff;font-size:16px;font-weight:bold;padding:6px 14px 13px 14px;width:702px;overflow:hidden"><span style="display:block;float:left;width:360px;">All Staff Members</span> <a href="" class="close_box" style="background:url(\''+STATIC_IMG_DIR+'plans/close_content_message.gif\') no-repeat;display:block;float:right;height:14px;margin:1px 0 0 0;width:14px;"/></a></div>';
				baner+='<div style="background:#fff;margin: 7px 14px 14px 14px;padding:3px 5px 5px 5px;width:692px">';
				baner+='<div id="staff_content" >fgh dfgh dfg </div>';
				baner+='<div class="clear"></div></div></div>';			
			$('body').prepend(baner);
			$('.close_box').click(function(e){
					e.preventDefault();
					$('#staff_container a').unbind('click');
					$('#dark, #staff_container').remove();
					if($.browser.msie && $.browser.version=='6.0')
						$('select').css({'visibility':''});
				});

			$.ajax({
				type:"POST",
				url: URL_A + 'networks/business_all_staff/'+session_id+'/'+user_id+'/'+network_id,
				timeout:25000,
				data:'start=1',
				beforeSend: function(){
					$('#staff_content').html('<table cellpadding="0" cellspacing="0" border="0" width="100%" style="height:'+$('#events_my_reminders').height()+'px"><tr><td style="text-align:center"><img src="'+STATIC_IMG_DIR+'spinner.gif" alt="" style="padding:150px 0 149px 0"/></td></tr></table>');
				},
				success: function(msg){
					$('#staff_content').html(msg);
				},
				error: function(){				
					$('#staff_content').html('<div style="text-align:center;color:red;padding:100px 0 100px 0;">Error. <br /> Please refresh the page</div>');
				}
			});				
			
			
		});
	}




/*////////////////////////////////*/
/* begin section Contact Details*/
/*////////////////////////////////*/
	var path_contact_detail='';
	function business_detalis(){
		$('#edit_business_des').click(function(e){
			e.preventDefault();
			$('body').prepend('<div id="dark"></div>');
			$('#dark').css({'left':'0px','right':'0px','opacity':'0.4','background':'#000','width':$('body').width()+'px','height':$(document).height()+'px','z-index':'10','position':'absolute'});
			var baner='<div id="JScontact_detail" style="background:url(\''+STATIC_IMG_DIR+'plans/content_message.gif\') repeat-x #d0d0d0;left:'+($(window).width()/2-250)+'px;position:absolute;top:'+($(document).scrollTop()+100)+'px;width:500px;z-index:11">';
				baner+='<div style="cursor:move;color:#fff;font-size:16px;font-weight:bold;padding:6px 0 6px 14px;">Contact Details</div>';
				baner+='<div style="background:#fff;margin:14px;padding:10px 10px 21px 15px;width:447px">';
				baner+='<div id="contact_detail">';
				baner+='</div>';
				baner+='<div style="float:right;padding:10px 3px 0 0;width:116px">';	
				baner+='<a id="JSsave" href="" style="display:none"></a>';
				baner+='<a id="JSclose" href="'+URL_A+'networks/business_view/'+network_id+'" style="float:right;display:none"></a>';
				baner+='<div class="clear"></div></div><div class="clear"></div></div></div>';			
			$('body').prepend(baner);
			$('#JSclose').click(function(e){
				e.preventDefault();
				$(this).unbind('click');
				$('#JScontact_detail, #JScontact_detail a').unbind();
				$('#JScontact_detail, #dark').remove();			
			});
			$('#JSsave').click(function(e){
				e.preventDefault();
				if($('#fileToUploadPhoto').val()!='' && !$('#checkboxPhoto').is(':checked')){
					alert('Please confirm that you have the right to this picture and that you agree with our Terms and Conditions')
				}else{
					$('#JSsave').remove();
					$('#JSclose').css({'display':'none'});
					if($('#fileToUploadPhoto').val()!=''){
						$('#ENhas_image').val(1);
						ajaxFileUploadPhotoBusiness2();
					}else{
						contact_detail(path_contact_detail,$('#EditNetwork').serialize());
					}
				}
			});
			$('#JScontact_detail').draggable();				
			contact_detail($(this).attr('rel'),false);	
		});
		
		$('a.enlarge_map').click(function(e){
				e.preventDefault();
				get_large_map(e, this);
		});
	}
	function contact_detail(path,form){
		path_contact_detail=path;
		if(form==false)
			var form_data="start=1";
		else
			form_data=form;
		$.ajax({
			type:"POST",
			url: URL_A+path,
			data: form_data,
			timeout:25000,
			beforeSend: function(){
				$('#contact_detail').html('<div style="text-align:center;padding:30px 0 20px 0"><img src="'+STATIC_IMG_DIR+'spinner.gif" alt=""/></div>');
			},
			success: function(msg){				
				$('#contact_detail').html('<div style="text-align:center;padding:0 0 10px 0">'+msg+'</div>');
				if(form==false){
					$('#JSsave,#JSclose').css({'display':''});
				}else{
					$('#JSclose').css({'display':''}).unbind();
				}
			},
			error: function(){
				$('#contact_detail').html('<div style="color:red;text-align:center"><b>Error. <br />Please refresh the page</b></div>');
			}
		});
	}
	
	function ajaxFileUploadPhotoBusiness2(){
		$('#EditNetwork').css({'display':'none'});
		$('#contact_detail').append('<div style="text-align:center;padding:20px 0 20px 0"><img src="'+STATIC_IMG_DIR+'spinner.gif" alt=""/></div>');
		$.ajaxFileUpload
		(
			{
				url:URL_A+'photos/uploadfilePhotoBusiness/'+$('#key_for_event').val()+'/'+network_id,
				secureuri:false,
				fileElementId:'fileToUploadPhoto',
				dataType: 'json',
				success: function (data, status)
				{					
					if(typeof(data.error) != 'undefined')
					{
						if(data.error != '')
						{       
							$("#contact_detail").html('<div style="text-align:center;padding:30px 0 20px 0">'+data.error+'<div>');
							$('#JSclose').css({'display':''});
						}else
						{
							contact_detail(path_contact_detail,$('#EditNetwork').serialize());
						}
					};
				},
				error: function (data, status, e){
					$("#contact_detail").html('<div style="text-align:center;padding:30px 0 20px 0">Error. Please try again</div>');
					$('#JSclose').css({'display':''});
				}
			}
		);
	}	
	
/*////////////////////////////////*/
/*  end position Contact Details*/
/*////////////////////////////////*/



/*////////////////////////////////*/
/* begin section Staff Members*/
/*////////////////////////////////*/

	function staff_members(){
		if($('#staff_list').length){
			$("#staff_list a:contains('Delete Profile')").click(function(e){
				delete_profile(e,this);				
			});
			$(".business_staff_members a:contains('Add new staff')").click(function(e){
				add_profile(e,this,'Add new staff member',false);				
			});
			
			$("#staff_list a:contains('Edit Profile')").click(function(e){
				add_profile(e,this,'Edit staff member','#'+$(this).parent().parent().attr('id'));				
			});
		}
	}
	
	function add_profile(e,event,title,parent_event){
		if(e!=false)
		e.preventDefault();

		$('body').prepend('<div id="dark"></div>');
		$('#dark').css({'left':'0px','right':'0px','opacity':'0.4','background':'#000','width':$('body').width()+'px','height':$(document).height()+'px','z-index':'10','position':'absolute'});
		var baner='<div id="JSadd_worker" style="background:url(\''+STATIC_IMG_DIR+'plans/content_message.gif\') repeat-x #d0d0d0;left:'+($(window).width()/2-300)+'px;position:absolute;top:'+($(document).scrollTop()+100)+'px;width:600px;z-index:11">';
			baner+='<div style="cursor:move;color:#fff;font-size:16px;font-weight:bold;padding:6px 0 6px 14px;">'+title+'</div>';
			baner+='<div style="background:#fff;margin:14px;padding:10px 10px 21px 15px;width:547px">';
			baner+='<div id="add_worker_con">';
			baner+='</div>';
			baner+='<div style="float:right;padding:10px 3px 0 0;width:116px">';	
			baner+='<a id="JSsave" href=""></a>';
			baner+='<a id="JSclose" href="" style="float:right"></a>';
			baner+='<div class="clear"></div></div><div class="clear"></div></div></div>';			
		$('body').prepend(baner);
		form_to_add_staff($(event).attr('href'),'',parent_event);
		$('#JSclose').click(function(e){
			e.preventDefault();
			$(this).unbind('click');
			$('#JSadd_worker, #JSadd_worker a').unbind();
			$('#JSadd_worker, #dark').remove();			
		});
		$('#JSsave').click(function(e){
			e.preventDefault();
			var error=0;
			var message_error='';
			if($('#A_s_first_name').val()=='' && $('#A_s_first_name').length){
				message_error+="Please provide worker first name. \n";
				error=1;
			}
			if($('#A_s_last_name').val()==''  && $('#A_s_first_name').length){
				message_error+="Please provide worker last name. \n";
				error=1;
			}
			if ( !isValidEmail($('#A_s_email').val()) && $('#A_s_email').length ) {
				message_error+="The e-mail does not seem to be valid. \n";
				error=1;
			}
			var day=Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
			var are_opening_hours=false;
			for(i=0;i<=6;i++){ 
				if($('#dayfromday_'+i).val()!='--'){
					are_opening_hours=true;
					var a=$('#dayfromday_'+i).val()+':'+$('#dayfrommin_'+i).val()+':00';
					var b=$('#daytoday_'+i).val()+':'+$('#daytomin_'+i).val()+':00';

					if(strtotime('2010-01-01 '+a)>=strtotime('2010-01-01 '+b)){
						message_error+=day[i]+": Ending time cannot be before the starting time. \n";
						error=1;
					}
				}
			}
			if(are_opening_hours==false){
				message_error+="Please select hours for this worker. \n";
				error=1;				
			}
			
			if(error==1)
				alert(message_error);
			else{
				$(this).unbind().remove();
				$('#JSadd_worker').css({'top':($(document).scrollTop()+($(window).height()/2-100))+'px'});
				form_to_add_staff($(event).attr('href'),$('#form_add_staff').serialize(),parent_event);		
			}
		});
		$('#JSadd_worker').draggable();
	}


	function form_to_add_staff(path,form,parent_event){
		if(form=='')
			var form_data='start=1';
		else
			var form_data=form;
		
		var new_data_for_user=Array();
		if(form!='' && parent_event!=false){
			new_data_for_user['job_title']=$('#A_s_job_title').val();
			if($('#permissions1').is(':checked'))
				new_data_for_user['is_admin']=1;
			else
				new_data_for_user['is_admin']=0;			
		}
		
		$.ajax({
			type:"POST",
			url: path,
			data: form_data,
			timeout:25000,
			beforeSend: function(){
				$('#add_worker_con').html('<div style="text-align:center;padding:30px 0 20px 0"><img src="'+STATIC_IMG_DIR+'spinner.gif" alt=""/></div>');
			},
			success: function(msg){				
				$('#add_worker_con').html('<div style="text-align:center;padding:0 0 10px 0">'+msg+'</div>');
				if($('.ow').length==1){
					$('#JSclose').unbind();
				}
				if(parent_event!=false){
					$('#form_add_staff div:first').text('Edit profile for '+$(parent_event+' p a:first').text());
				}else{
					$('#form_add_staff div:first').text('Profile');
				}
				if($('#no_changeOH').length==0 && form!='' && parent_event!=false){
					$(parent_event+' p b:first').text(new_data_for_user['job_title']);
					var a=parent_event.split('_');
					$('#staff_'+a[1]+' p b:first').text(new_data_for_user['job_title']);
					
					if($('.noad').length==0){
						if(new_data_for_user['is_admin']==1){
							$(parent_event+' p span').remove();
							$(parent_event+' p').append('<span></span>');
						}else{
							$(parent_event+' p span').remove();
						}
					}
				}
				$('.fr_link #my_friends').click(function(e){					
					e.preventDefault();
		
					var style='left:'+($('body').width()/2-300)+'px;position:absolute;top:'+($(window).height()/2+$(document).scrollTop()-190)+'px;';		
					
					if($.browser.msie && $.browser.version=='6.0')
						$('select').css({'visibility':'hidden'});
					var baner='<div id="my_friends_con" style="background:url(\''+STATIC_IMG_DIR+'plans/content_message.gif\') repeat-x #d0d0d0;'+style+';width:600px;z-index:14">';
						baner+='<div style="background:url(\''+STATIC_IMG_DIR+'plans/content_message.gif\') repeat-x 0px 100% #e98680;color:#fff;font-size:16px;font-weight:bold;padding:6px 14px 13px 14px;width:572px;overflow:hidden;cursor:move">';
						baner+='<span style="display:block;float:left;width:330px;">My friends</span> <a href="" class="close_box" style="background:url(\''+STATIC_IMG_DIR+'plans/close_content_message.gif\') no-repeat;display:block;float:right;height:14px;margin:1px 0 0 0;width:14px;"/></a></div>';
						baner+='<div style="background:#fff;margin: 7px 14px 14px 14px;padding:3px 5px 5px 5px;width:561px">';
						baner+='<div id="my_friends" ></div>';
						baner+='<div class="clear"></div></div></div>';			
					$('body').prepend(baner);
					$('.close_box').click(function(e){
							e.preventDefault();
							$('#my_friends_con, #my_friends_con a, #my_friends_con img').unbind();
							$('#my_friends_con').remove();
							if($.browser.msie && $.browser.version=='6.0')
								$('select').css({'visibility':''});
						});
					$('#my_friends_con').draggable();
					show_my_firends();
					
				});
				$('#clear_data_friend').click(function(e){
					e.preventDefault();
					$('#A_s_first_name, #A_s_last_name, #A_s_email').val('');
					$('.hi').show();
					$(this).css({'visibility':'hidden'});
				});
				$('#dark').css({'height':$(document).height()+'px'});
			},
			error: function(){
				$('#add_worker_con').html('<div style="color:red;text-align:center"><b>Error. <br />Please refresh the page</b></div>');
			}
		});		
	}
	
	function show_my_firends(){
		$.ajax({
			type:"POST",
			url: URL_A+'users/my_friends_for_business/'+network_id,
			data: 'start=1',
			timeout:25000,
			beforeSend: function(){
				$('#my_friends').html('<div style="text-align:center;padding:177px 0 177px 0"><img src="'+STATIC_IMG_DIR+'spinner.gif" alt="" /></div>');
			},
			success: function(msg){
				$('#my_friends').html(msg);
				$('.fr_con').mousedown(function(e){
					e.stopPropagation();
				});
				$('.fr_con img, .fr_con a').click(function(e){
					e.preventDefault();
					e.stopPropagation();
					if($(this).parent().attr('class')=='is'){
						if($(this).attr('title')=='')
							alert($(this).prev().attr('title'));
						else
							alert($(this).attr('title'));
					}else{
						$('#A_s_first_name').val($(this).parent().attr('fn'));
						$('#A_s_last_name').val($(this).parent().attr('sn'));
						$('#A_s_email').val($(this).parent().attr('email'));
						if($(this).parent().attr('is_self')==1){
							$('#A_is_self').val('1');
						} else {
							$('#A_is_self').val('0');
						}
						$('#my_friends_con, #my_friends_con a, #my_friends_con img').unbind();
						$('#my_friends_con').remove();
						if($.browser.msie && $.browser.version=='6.0')
							$('select').css({'visibility':''});
					}
					$('.hi').hide();
					$('#clear_data_friend').css({'visibility':'visible'});
				});
				
			},
			error: function(){
				$('#my_friends').html('<div style="color:red;text-align:center"><b>Error. <br />Please refresh the page</b></div>');
			}
		}); 		
	}
	
	var old_from_minute=[];
	var old_to_minute=[];
	function make_select_business(){
		for(z=0;z<=6;z++){
			if($('#adminday_'+z).val()=='-'){
				$('#dayfromday_'+z+', #daytoday_'+z+', #dayfrommin_'+z+', #daytomin_'+z).append('<option value="--">----</option>').attr('disabled','disabled');
				$('#daytomin_'+z).parent().next().after('&#160; Business is closed');				
			}else{
				$('#daytomin_'+z).parent().next().after('&#160; <input type="hidden" value="0" name="data[Add_staff][doesNotWork_'+z+']" \/><input type="checkbox" value="1" id="doesNotWork_'+z+'" name="data[Add_staff][doesNotWork_'+z+']" onClick="what_a_grey_day('+z+');" style="margin:3px 7px 0 0;height:auto" \/><label for="doesNotWork_'+z+'">Does not work<\/label>');
			
				aa=$('#adminday_'+z).val().split('-');
				bb=aa[0].split(':');
				cc=aa[1].split(':');
				bb[0]=parseInt(bb[0],10);
				bb[1]=parseInt(bb[1],10);
				cc[0]=parseInt(cc[0],10);
				cc[1]=parseInt(cc[1],10);
				d=bb[0];
				
				if(calendar_date=='12Hr'){
					
					if(bb[0]==0){
						$('#dayfromday_'+z).append('<option value="00">12am</option>');
						d=d+1;
					}					
					if(cc[0]==0){
						$('#daytoday_'+z).append('<option value="00">12am</option>');
					}					
					for(i=d;i<=cc[0];i++){
						if(i<10)
							$('#dayfromday_'+z+', #daytoday_'+z).append('<option value="0'+i+'">'+i+'am</option>');
						else if(i<12)
							$('#dayfromday_'+z+', #daytoday_'+z).append('<option value="'+i+'">'+i+'am</option>');
						else if(i==12){
							$('#dayfromday_'+z+', #daytoday_'+z).append('<option value="12">12pm</option>');
						}else
							$('#dayfromday_'+z+', #daytoday_'+z).append('<option value="'+i+'">'+(i-12)+'pm</option>');                                                            
					}			
				}else{
					for(i=bb[0];i<=cc[0];i++){
						if(i<10)
							$('#dayfromday_'+z+', #daytoday_'+z).append('<option value="0'+i+'">0'+i+'</option>');
						else
							$('#dayfromday_'+z+', #daytoday_'+z).append('<option value="'+i+'">'+i+'</option>');
					}
				}		
				for(i=0;i<=59;i++){
					if(i<10){
						$('#dayfrommin_'+z+', #daytomin_'+z).append('<option value="0'+i+'">0'+i+'</option>');
					}else{
						$('#dayfrommin_'+z+', #daytomin_'+z).append('<option value="'+i+'">'+i+'</option>');                                                            
					}
				}
				
				if($('#editadminday_'+z).length){
					if(cc[0]<10)
						cc[0]='0'+cc[0];
					if(bb[1]<10)
						bb[1]='0'+bb[1];
					if(cc[1]<10)
						cc[1]='0'+cc[1];
					$('#dayfrommin_hidden_'+z).val(bb[1]);
					$('#daytomin_hidden_'+z).val(cc[1]);
					aa=$('#editadminday_'+z).val().split('-');
					bb=aa[0].split(':');
					cc=aa[1].split(':');
					old_from_minute[z]=bb[1];
					old_to_minute[z]=cc[1];
					$('#dayfromday_'+z+" option[value='"+bb[0]+"']").attr('selected','selected');
					$('#dayfrommin_'+z+" option[value='"+bb[1]+"']").attr('selected','selected');						
					$('#daytoday_'+z+" option[value='"+cc[0]+"']").attr('selected','selected');
					$('#daytomin_'+z+" option[value='"+cc[1]+"']").attr('selected','selected');						
				}else{				
					if(cc[0]<10)
						cc[0]='0'+cc[0];
					if(bb[1]<10)
						bb[1]='0'+bb[1];
					if(cc[1]<10)
						cc[1]='0'+cc[1];
					
					$('#dayfrommin_hidden_'+z).val(bb[1]);
						old_from_minute[z]=bb[1];
					$('#daytomin_hidden_'+z).val(cc[1]);
						old_to_minute[z]=cc[1];
					$('#dayfrommin_'+z+" option[value='"+bb[1]+"']").attr('selected','selected');
					$('#daytomin_'+z+" option[value='"+cc[1]+"']").attr('selected','selected');
					$('#daytoday_'+z+" option[value='"+cc[0]+"']").attr('selected','selected');
				}
				
				if($('#edit_user_account').length){
					if($('#adminday_'+z).length==1 && $('#editadminday_'+z).length!=1){
						$('#doesNotWork_'+z).attr('checked','checked');
						$('#dayfromday_'+z+', #daytoday_'+z+', #dayfrommin_'+z+', #daytomin_'+z).attr('disabled','disabled');
					}
				}
				
			}
		}
		$('#dayfromday_0, #dayfromday_1, #dayfromday_2, #dayfromday_3, #dayfromday_4, #dayfromday_5, #dayfromday_6').change(function(){
			var a=$(this).attr('id').split('_');			
			if($('#'+$(this).attr('id')+' option:first').attr('value')==$(this).val() && $('#dayfrommin_'+a[1]).val()<$('#dayfrommin_hidden_'+a[1]).val()){
				$('#dayfrommin_'+a[1]+' option').removeAttr('selected');
				$('#dayfrommin_'+a[1]+" option[value='"+$('#dayfrommin_hidden_'+a[1]).val()+"']").attr('selected','selected');
				old_from_minute[a[1]]=$('#dayfrommin_hidden_'+a[1]).val();
			}
		});
		$('#daytoday_0, #daytoday_1, #daytoday_2, #daytoday_3, #daytoday_4, #daytoday_5, #daytoday_6').change(function(){
			var a=$(this).attr('id').split('_');			
			if($('#'+$(this).attr('id')+' option:last').attr('value')==$(this).val() && $('#daytomin_'+a[1]).val()>$('#daytomin_hidden_'+a[1]).val()){
				$('#daytomin_'+a[1]+' option').removeAttr('selected');
				$('#daytomin_'+a[1]+" option[value='"+$('#daytomin_hidden_'+a[1]).val()+"']").attr('selected','selected');
				old_to_minute[a[1]]=$('#daytomin_hidden_'+a[1]).val();
			}
		});
		
		$('#daytomin_0, #daytomin_1, #daytomin_2, #daytomin_3, #daytomin_4, #daytomin_5, #daytomin_6').mouseover(function(){
			var a=$(this).attr('id').split('_');
			if($('#daytoday_'+a[1]+' option:last').attr('value')==$('#daytoday_'+a[1]).val()){
				$("#daytomin_"+a[1]+" option:gt("+parseInt($('#daytomin_hidden_'+a[1]).val(),10)+")").addClass('noclick');
			}else{				
				$("#daytomin_"+a[1]+" option").removeClass('noclick');
			}
		}).change(function(){
			var a=$(this).attr('id').split('_');
				a[1]=parseInt(a[1],10);
			if($("#"+$(this).attr('id')+" option[value='"+$(this).val()+"']").attr('class')=='noclick'){            
				$("#"+$(this).attr('id')+" option[value='"+$(this).val()+"']").removeAttr('selected');
				$("#"+$(this).attr('id')+" option[value='"+old_to_minute[a[1]]+"']").attr('selected','selected');            
			}else{				
				old_to_minute[a[1]]=$(this).val();
			}
		});

		$('#dayfrommin_0, #dayfrommin_1, #dayfrommin_2, #dayfrommin_3, #dayfrommin_4, #dayfrommin_5, #dayfrommin_6').mouseover(function(){
			var a=$(this).attr('id').split('_');
			if($('#dayfromday_'+a[1]+' option:first').attr('value')==$('#dayfromday_'+a[1]).val()){
				$("#dayfrommin_"+a[1]+" option:lt("+parseInt($('#dayfrommin_hidden_'+a[1]).val(),10)+")").addClass('noclick');
			}else{				
				$("#dayfrommin_"+a[1]+" option").removeClass('noclick');
			}
		}).change(function(){
			var a=$(this).attr('id').split('_');
				a[1]=parseInt(a[1],10);
			if($("#"+$(this).attr('id')+" option[value='"+$(this).val()+"']").attr('class')=='noclick'){            
				$("#"+$(this).attr('id')+" option[value='"+$(this).val()+"']").removeAttr('selected');
				$("#"+$(this).attr('id')+" option[value='"+old_from_minute[a[1]]+"']").attr('selected','selected');            
			}else{				
				old_from_minute[a[1]]=$(this).val();
			}
		});
		
	}

	
	function delete_profile(e,event){
		e.preventDefault();
		if(confirm('Are you sure that you want to remove this worker')){
			$.ajax({
				type:"POST",
				url: $(event).attr('href'),
				data: 'start=1',
				timeout:25000,
				beforeSend: function(){
					$('#staff_list').before('<div id="remove_worker_spiner" style="display:none;text-align:center;padding:30px 0 20px 0"><img src="'+STATIC_IMG_DIR+'spinner.gif" alt="" /></div>');
					$('#remove_worker_spiner').slideDown();
					$('#staff_list').slideUp();
					$('#staff_list a').unbind('click'); 
				},
				success: function(msg){
					$('#staff_list').before('<div id="mess_staff" style="clear:both;padding:20px 0 20px 0;text-align:center;color:#00aa4f;font-size:16px"><b>'+msg+'</b></div>');
					$('#remove_worker_spiner').slideUp('fast',function(){$(this).remove()});
					var worker_array=Array();
					var worker_arrayid=Array();

					var i=0;
					var allworkers='';
					var href=$(event).attr('href').split('/');
					href=href[href.length-1];
					
					if($('#business_details #no_changeOH').length==0){						
						$('#staff_list .con').each(function(){
							if($(this).attr('id')!='work_'+href){
								worker_array[i]=$(this).html();
								worker_arrayid[i]=$(this).attr('id');								
								i++;
							}else{
								$('#staff_'+href).slideUp('fast',function(){$(this).remove()});
							}
						});						
					}else{
						$('#staff_list .con').each(function(){							
							worker_array[i]=$(this).html();
							worker_arrayid[i]=$(this).attr('id');
							i++;							
						});
					}
					var z=0;
					for(i=0;i<worker_array.length;i++){
						allworkers+='<div id="'+worker_arrayid[i]+'" class="con">'+worker_array[i]+'</div>';
						z++;
						if(z==2){
							allworkers+='<div class="cl"></div>';
							z=0;
						}
					}
					allworkers+='<div class="clear"></div>';

					$('#staff_list').html(allworkers).slideDown('fast',function(){
						$("#staff_list a:contains('Delete Profile')").click(function(e){
							delete_profile(e,this);
						});
						if($('.con').length<$('#account_type_staff').val() && $('.business_staff_members strong:first a').length==0){
							$('.business_staff_members strong:first').append('<a href="'+URL_A+'networks/add_new_workerAJAX/'+$('#key_for_event_staff').val()+'/'+network_id+'">Add new staff</a>');
							$('#moving_33 .portlet-content').append('<a href="'+URL_A+'networks/add_new_workerAJAX/'+$('#key_for_event_staff').val()+'/'+network_id+'" class="square">Add New Staff Member</a>');
							$('.business_staff_members').append('<a href="'+URL_A+'networks/add_new_workerAJAX/'+$('#key_for_event_staff').val()+'/'+network_id+'" class="square">Add new staff</a>');
							
							$(".business_staff_members a:contains('Add new staff'), #moving_33 a:contains('Add New Staff Member')").click(function(e){
								add_profile(e,this,'Add new staff member',false);				
							});
						}
					});					
					$('#mess_staff').wait('1500').slideUp('fast',function(){$(this).remove()});
					
				},
				error: function(){
					$('#staff_list').html('<div style="color:red;text-align:center"><b>Error. <br />Please refresh the page</b></div>');
				}
			}); 
		}
	}
/*////////////////////////////////*/
/*  end position Staff Members*/
/*////////////////////////////////*/

/*////////////////////////////////*/
/* begin section Business Profile*/
/*////////////////////////////////*/

	function upload_avatar_business(){
		$('.upload_logo').click(function(){
			upload_new_photo(1);
		});
	}
 
	function ajaxFileUploadPhotoBusiness(){
		

        if(change_content_photo_upload==0)
			alert('Please select photo');
		else if($('#checkboxPhoto').is(':checked')){
			change_content_photo_upload=0;
			
			$('#spinner_for_photo').html('<img src="'+STATIC_IMG_DIR+'spinner.gif" alt=""  style="padding:10px 0 10px 20px;width:auto;" />');		   
			$('#JSclose, #JSupload').css({'display':'none'});
			$.ajaxFileUpload
			(
				{
					url:URL_A+'photos/uploadfilePhotoBusiness/'+$('#key_for_event').val()+'/'+PlanID_network,
					secureuri:false,
					fileElementId:'fileToUploadPhoto',
					dataType: 'json',
					success: function (data, status)
					{
						
						if(typeof(data.error) != 'undefined')
						{
							if(data.error != '')
							{       
								$("#error_photo").html('<div style="padding:10px 0 10px 0;">'+data.error+'<div>');
								$('#spinner_for_photo').html(' ');
								$('#JSclose, #JSupload').css({'display':'block'});
								$('#checkboxPhoto').removeAttr('checked');
							}else
							{
								$('#JSclose, #JSupload').css({'display':'block'});                           
								$('#spinner_for_photo').html(data.msg);
								$('#checkboxPhoto').removeAttr('checked');
								$("#error_photo").html('<div style="padding:10px 0 10px 0;color:#656565"><b>Photo has been uploaded</b><div>');	
								$('#moving_30 .upload_logo').remove();
								$('#moving_30 .logo').html('<a href="'+URL_A+'networks/business_view/'+$('#PlanID_network_edit').val()+'">'+data.msg+'</a>');
								$('#moving_30 .logo img').removeAttr('style');
							}
						};
					},
					error: function (data, status, e)
					{
						$("#error_photo").html('<div style="padding:10px 0 10px 0;">Error. Please try again</div>');
						$('#spinner_for_photo').html(' ');
						$('#JSclose, #JSupload').css({'display':'block'});
						$('#checkboxPhoto').removeAttr('checked');
					}
				}
			);	   
		}else{
			alert('Please confirm that you have the right to this picture and that you agree with our Terms and Conditions');
		}		
		
	}
/*////////////////////////////////*/
/*  end position Business Profile*/
/*////////////////////////////////*/


/*////////////////////////////////*/
/* begin section Opening Hours*/
/*////////////////////////////////*/

	function opening_hours(){

		$('#opening_hours').click(function(e){
			opening_hoursMakeBox(e);
		});
	}

	function opening_hoursMakeBox(e){		
		e.preventDefault();	
		$('body').prepend('<div id="dark"></div>');
		$('#dark').css({'left':'0px','right':'0px','opacity':'0.4','background':'#000','width':$('body').width()+'px','height':$(document).height()+'px','z-index':'10','position':'absolute'});
		var baner='<div id="JSnew_mesage" style="background:url(\''+STATIC_IMG_DIR+'plans/content_message.gif\') repeat-x #d0d0d0;left:'+($(window).width()/2-250)+'px;position:absolute;top:'+($(document).scrollTop()+$(window).height()/2-100)+'px;width:500px;z-index:11">';
			baner+='<div style="cursor:move;color:#fff;font-size:16px;font-weight:bold;padding:6px 0 6px 14px;">Edit Opening Hours</div>';
			baner+='<div style="background:#fff;margin:14px;padding:19px 10px 21px 15px;width:447px">';
			baner+='<div id="send_opening_hours">';
			baner+='</div>';
			baner+='<div style="float:right;padding:10px 3px 0 0;width:116px">';	
			baner+='<a id="JSsave" href=""></a>';
			baner+='<a id="JSclose" href="" style="float:right"></a>';
			baner+='<div class="clear"></div></div><div class="clear"></div></div></div>';			
		$('body').prepend(baner);
		
		var days_in_week=Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
		
		var table_hours='<form name="opening_hours_form" id="opening_hours_form">';
			table_hours+='<table cellpadding="1" cellspacing="0">';				
		for(i=1;i<=6;i++){
			table_hours+='<tr>';
			table_hours+=' <td>';
			table_hours+=days_in_week[i]+'&#160;&#160;';
			table_hours+=' </td>';				
			table_hours+=' <td>from &#160;';
			table_hours+='  <select id="hour_start_'+i+'" name="data[OpeningHours][hour_start_'+i+']"></select>&#160;:';
			table_hours+='  <select id="minute_start_'+i+'" name="data[OpeningHours][minute_start_'+i+']"></select>&#160;&#160;';	
			table_hours+=' </td>';
			table_hours+=' <td>&#160;to &#160;';
			table_hours+='  <select id="hour_end_'+i+'" name="data[OpeningHours][hour_end_'+i+']"></select>&#160;:';
			table_hours+='  <select id="minute_end_'+i+'" name="data[OpeningHours][minute_end_'+i+']"></select>&#160;&#160;';	
			table_hours+=' </td>';
			table_hours+=' <td>';
			table_hours+='  <input type="hidden" id="closed_'+i+'_"   name="data[OpeningHours][closed_'+i+']" value="0" />';
			table_hours+='  <input type="checkbox" id="closed_'+i+'" name="data[OpeningHours][closed_'+i+']" value="1"  style="width:auto;height:auto;"/>&#160;';
			table_hours+='  <label for="closed_'+i+'"  id="closed_label_'+i+'" >Closed</label>';
			table_hours+=' </td>';
			table_hours+='</tr>';
		}
			table_hours+='<tr>';
			table_hours+=' <td>';
			table_hours+=days_in_week[0]+'&#160;&#160;';
			table_hours+=' </td>';				
			table_hours+=' <td>from &#160;';
			table_hours+='  <select id="hour_start_0" name="data[OpeningHours][hour_start_0]"></select>&#160;:';
			table_hours+='  <select id="minute_start_0" name="data[OpeningHours][minute_start_0]"></select>&#160;&#160;';	
			table_hours+=' </td>';
			table_hours+=' <td>&#160;to &#160;';
			table_hours+='  <select id="hour_end_0" name="data[OpeningHours][hour_end_0]"></select>&#160;:';
			table_hours+='  <select id="minute_end_0" name="data[OpeningHours][minute_end_0]"></select>&#160;&#160;';	
			table_hours+=' </td>';
			table_hours+=' <td>';
			table_hours+='  <input type="hidden" id="closed_0_"   name="data[OpeningHours][closed_0]" value="0" />';
			table_hours+='  <input type="checkbox" id="closed_0" name="data[OpeningHours][closed_0]" value="1"  style="width:auto;height:auto;"/>&#160;';
			table_hours+='  <label for="closed_0"  id="closed_label_0" >Closed</label>';
			table_hours+=' </td>';
			table_hours+='</tr>';			
		table_hours+='</table>';
		table_hours+='</form>';
		$('#send_opening_hours').html(table_hours);
		
		var select_hours='';
		var select_minutes='';
		
		if(calendar_date=='12Hr'){			
			select_hours+='<option value="00">12am</option>';
			for(i=1;i<=23;i++){
				if(i<10)
					select_hours+='<option value="0'+i+'">'+i+'am</option>';
				else if(i<12)
					select_hours+='<option value="'+i+'">'+i+'am</option>';
				else if(i==12)
					select_hours+='<option value="12">12pm</option>';
				else
					select_hours+='<option value="'+i+'">'+(i-12)+'pm</option>';                                                            
			}				
		}else{
			for(i=0;i<=23;i++){
				if(i<10)
					select_hours+='<option value="0'+i+'">0'+i+'</option>';
				else
					select_hours+='<option value="'+i+'">'+i+'</option>';
			}
		}			
		for(i=0;i<=59;i++){
			if(i<10)
				select_minutes+='<option value="0'+i+'">0'+i+'</option>';
			else
				select_minutes+='<option value="'+i+'">'+i+'</option>';                                                            
		}
		for(i=0;i<=6;i++){
			$('#hour_start_'+i+', #hour_end_'+i).html(select_hours);
			$('#minute_start_'+i+', #minute_end_'+i).html(select_minutes);
			if($('.op_hours .empty_slot').length==0){
				if($('#dotw'+i).attr('headers')=='closed'){
					$('#closed_'+i).attr('checked','checked');
				}else{
					hour_array=$('#dotw'+i).attr('headers').split(':');
					$('#hour_start_'+i+' option[value='+hour_array[0]+'], #minute_start_'+i+' option[value='+hour_array[1]+']').attr('selected','selected');
					$('#hour_end_'+i+' option[value='+hour_array[3]+'], #minute_end_'+i+' option[value='+hour_array[4]+']').attr('selected','selected');
				}
			}
			
		}
		
		$('#JSnew_mesage').draggable();
		$('#JSclose').click(function(e){
			e.preventDefault();
			$(this).unbind('click');
			$('#JSnew_mesage, #send_opening_hours select, #send_opening_hours :checkbox, #JSsave').unbind();
			$('#JSnew_mesage, #dark').remove();			
		});
		$('#JSsave').click(function(e){
			e.preventDefault();
			var error=0;
			var Messageerror='';
			var curent_date= new Date();
			var days_in_week=Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
			var new_opening_hours='';
			var admin_day_profile='';
			for(i=0;i<=6;i++){
				if(!$('#closed_'+i).is(':checked')){
					var strthour=add_zero_for_date2(curent_date.getFullYear()+'-'+(curent_date.getMonth()+1)+'-'+curent_date.getDate())+' '+$('#hour_start_'+i).val()+':'+$('#minute_start_'+i).val()+':00';
					var endhour=add_zero_for_date2(curent_date.getFullYear()+'-'+(curent_date.getMonth()+1)+'-'+curent_date.getDate())+' '+$('#hour_end_'+i).val()+':'+$('#minute_end_'+i).val()+':00';
					if(strtotime(strthour)>=strtotime(endhour)){
						Messageerror+='Incorrect date is for '+days_in_week[i]+". Please change this date \n";
						error=1;
					}
				}
			}
			if(error==1){
				alert(Messageerror);
			}else{
				if(confirm("Are you sure that you want to change opening hours? \n If the working hours for any of your workers are set outside the new opening hours for any given day, the hours for this worker will be changed to reflect your new hours automatically")){
					$(this).unbind('click').remove();
					curent_date=add_zero_for_date2(curent_date.getFullYear()+'-'+(curent_date.getMonth()+1)+'-'+curent_date.getDate())+' ';
					if(calendar_date=='12Hr'){
						var date_format='g:ia';
					}else{
						var date_format='H:i';
					}
					for(i=1;i<=6;i++){
						if($('#closed_'+i).is(':checked')){
							admin_day_profile+='<input type="hidden" id="adminday_'+i+'" value="-" />';
							new_opening_hours+='<tr><td>'+days_in_week[i]+'</td><td id="dotw'+i+'" headers="closed"> - Closed</td></tr>';
						}else{
							sh1=$('#hour_start_'+i).val()+':'+$('#minute_start_'+i).val()+':00';
							eh2=$('#hour_end_'+i).val()+':'+$('#minute_end_'+i).val()+':00';
							admin_day_profile+='<input type="hidden" id="adminday_'+i+'" value="'+sh1+'-'+eh2+'" />';
							new_opening_hours+='<tr><td>'+days_in_week[i]+'</td><td id="dotw'+i+'" headers="'+sh1+':'+eh2+'">';
							new_opening_hours+=' - '+JSdate(date_format,strtotime(curent_date+sh1))+' - '+JSdate(date_format,strtotime(curent_date+eh2))+'</td></tr>';
						}
					}
					if($('#closed_0').is(':checked')){
						admin_day_profile+='<input type="hidden" id="adminday_0" value="-" />';
						new_opening_hours+='<tr><td>'+days_in_week[0]+'</td><td id="dotw0" headers="closed"> - Closed</td></tr>';
					}else{
						sh1=$('#hour_start_0').val()+':'+$('#minute_start_0').val()+':00';
						eh2=$('#hour_end_0').val()+':'+$('#minute_end_0').val()+':00';
						admin_day_profile+='<input type="hidden" id="adminday_0" value="'+sh1+'-'+eh2+'" />';
						new_opening_hours+='<tr><td>'+days_in_week[0]+'</td><td id="dotw0" headers="'+sh1+':'+eh2+'">';
						new_opening_hours+=' - '+JSdate(date_format,strtotime(curent_date+sh1))+' - '+JSdate(date_format,strtotime(curent_date+eh2))+'</td></tr>';						
					}					
					new_opening_hours='<table cellpadding="1" cellspacing="0" summary="Opening hours">'+new_opening_hours+'</table>';
					opening_hoursAJAX($('#opening_hours').attr('rel'),new_opening_hours,admin_day_profile);
				}	
			}
		});
		$('#send_opening_hours select').change(function(e){
			var atr=$(this).attr('id').split('_');				
			$('#closed_'+atr[2]).removeAttr('checked');			
		});
		
		$('#send_opening_hours :checkbox').click(function(e){				
			if($(this).is(':checked')){
				var atr=$(this).attr('id').split('_');
				$('#hour_start_'+atr[1]+' option[value=00], #minute_start_'+atr[1]+' option[value=00], #hour_end_'+atr[1]+' option[value=00], #minute_end_'+atr[1]+' option[value=00] ').attr('selected','selected');
			}
		});
	}


	function opening_hoursAJAX(path,new_opening_hours,admin_day_profile){
		var array_path=path.split('/');
		$.ajax({
			type:"POST",
			url: URL_A+path,
			data: $('#opening_hours_form').serialize(),
			timeout:25000,
			beforeSend: function(){
				$('#send_opening_hours select, #send_opening_hours :checkbox').unbind();
				$('#send_opening_hours').html('<div style="text-align:center;padding:30px 0 20px 0"><img src="'+STATIC_IMG_DIR+'spinner.gif" alt=""/></div>');
			},
			success: function(msg){
				$('#send_opening_hours').html('<div style="text-align:center;padding:30px 0 20px 0"><b>'+msg+'</b></div>');
				if($('#no_changeOH').length==0){
					$('#admin_day_profile').html(admin_day_profile);
					block_worker_hours_month_box();
					$('#business_details .op_hours').html(new_opening_hours);					
					if($('#opening_hours').length==0){
						$("h2:contains('Opening Hours')").after('<a href=""  rel="networks/opening_hoursAJAX/'+array_path[2]+'/'+network_id+'" id="opening_hours">Edit</a>');
						$('#opening_hours').click(function(e){
							opening_hoursMakeBox(e);		
						});
					}
				}	
			},
			error: function(){
				$('#send_opening_hours').html('<div style="color:red;text-align:center"><b>Error. <br />Please refresh the page</b></div>');
			}
		}); 

	}
/*////////////////////////////////*/
/*  end position Opening Hours*/
/*////////////////////////////////*/

/*////////////////////////////////*/
/* begin section Description*/
/*////////////////////////////////*/
	function description(){
		
		$('#description').click(function(e){
			descriptionMakeBox(e);
		});
	}
	function descriptionMakeBox(e){		
		e.preventDefault();

		if($('.desc .empty_slot').length==1)
			var text='';
		else
			var text=$('#business_details .desc').text();
			
		$('body').prepend('<div id="dark"></div>');
		$('#dark').css({'left':'0px','right':'0px','opacity':'0.4','background':'#000','width':$('body').width()+'px','height':$(document).height()+'px','z-index':'10','position':'absolute'});
		var baner='<div id="JSnew_mesage" style="background:url(\''+STATIC_IMG_DIR+'plans/content_message.gif\') repeat-x #d0d0d0;left:'+($(window).width()/2-250)+'px;position:absolute;top:'+($(document).scrollTop()+$(window).height()/2-100)+'px;width:500px;z-index:11">';
			baner+='<div style="cursor:move;color:#fff;font-size:16px;font-weight:bold;padding:6px 0 6px 14px;">Edit Description</div>';
			baner+='<div style="background:#fff;margin:14px;padding:19px 10px 21px 15px;width:447px">';
			baner+='<div id="send_description">';
			baner+='<form id="edit_description">';
			baner+='<textarea style="width:435px;height:100px;" name="data[EditDescription][text]">'+text+'</textarea>';
			baner+='</form>';
			baner+='</div>';
			baner+='<div style="float:right;padding:10px 3px 0 0;width:116px">';	
			baner+='<a id="JSsave" href=""></a>';
			baner+='<a id="JSclose" href="" style="float:right"></a>';
			baner+='<div class="clear"></div></div><div class="clear"></div></div></div>';			
		$('body').prepend(baner);
		
		$('#JSnew_mesage').draggable();
		$('#JSclose').click(function(e){
			e.preventDefault();
			$('#JSnew_mesage, #JSclose, #JSsave').unbind();
			$('#JSnew_mesage, #dark').remove();			
		});
		$('#JSsave').click(function(e){
			e.preventDefault();
			$(this).unbind('click').remove();
			descriptionAJAX($('#description').attr('rel'));
			});			
	}	
	
	function descriptionAJAX(path){
		var desc='';
		var array_path=path.split('/');
		$.ajax({
			type:"POST",
			url:URL_A+path,
			data: $('#edit_description').serialize(),
			timeout:25000,
			beforeSend: function(){
				desc=$('#edit_description textarea').val();
				$('#send_description').html('<div style="text-align:center;padding:30px 0 20px 0"><img src="'+STATIC_IMG_DIR+'spinner.gif" alt=""/></div>');
			},
			success: function(msg){
				$('#send_description').html('<div style="text-align:center;padding:30px 0 20px 0"><b>'+msg+'</b></div>');
				if($('#no_changeOH').length==0){
					$('#business_details .desc').html(desc.replace(/[\n]/gi, "<br />")).append('<div class="clear"></div>');
					if($('#description').length==0){
						$("h2:contains('Description')").after('<a href=""  rel="networks/descriptionAJAX/'+array_path[2]+'/'+network_id+'" id="description">Edit</a>');
						$('#description').click(function(e){
							descriptionMakeBox(e);		
						});
					}					
				}
			},
			error: function(){
				$('#send_description').html('<div style="color:red;text-align:center"><b>Error. <br />Please refresh the page</b></div>');
			}
		}); 
	}

/*////////////////////////////////*/
/*  end position Description*/
/*////////////////////////////////*/


/*////////////////////////////////*/
/* begin section services*/
/*////////////////////////////////*/
	function services(){		
		$('#services').click(function(e){
			servicesMakeBox(e);		
		});
	}
	function servicesMakeBox(e){
		
		e.preventDefault();		
		$('body').prepend('<div id="dark"></div>');
		$('#dark').css({'left':'0px','right':'0px','opacity':'0.4','background':'#000','width':$('body').width()+'px','height':$(document).height()+'px','z-index':'10','position':'absolute'});
		var baner='<div id="JSnew_mesage" style="background:url(\''+STATIC_IMG_DIR+'plans/content_message.gif\') repeat-x #d0d0d0;left:'+($(window).width()/2-285)+'px;position:absolute;top:'+($(document).scrollTop()+$(window).height()/2-100)+'px;width:570px;z-index:11">';
			baner+='<div style="cursor:move;color:#fff;font-size:16px;font-weight:bold;padding:6px 0 6px 14px;">Services</div>';
			baner+='<div style="background:#fff;margin:14px;padding:19px 10px 21px 15px;width:517px">';
			baner+='<div id="send_services">';
			baner+='<form id="edit_services">';

			baner+='</form>';
			baner+='</div>';
			baner+='<div style="float:right;padding:10px 3px 0 0;width:116px">';	
			baner+='<a id="JSsave" href=""></a>';
			baner+='<a id="JSclose" href="" style="float:right"></a>';
			baner+='<div class="clear"></div></div><div class="clear"></div></div></div>';			
		$('body').prepend(baner);
		var fields='<table cellpadding="0" cellspacing="1" border="0" id="addServicesAjaxTable">';
			fields+='<tr><td style="text-align:center"><b>Type of service</b></td><td style="text-align:center"><b>Price</b></td><td style="text-align:center"><b>Time</b></td><td></td></tr>';
			fields+='<tr>';
			fields+='<td><input type="text" value="" id="title_0" name="data[Services][title_0]"  style="margin-bottom:2px;width:275px;" />&#160;</td>';
			fields+='<td>&#163;&#160;&#160;<input type="text" value="" id="price_0" name="data[Services][price_0]" style="margin-bottom:2px;width:30px;" />&#160;</td>';
			fields+='<td><input type="text" value="" id="time_0" name="data[Services][time_0]" style="margin-bottom:2px;width:100px;"/></td>';				
			fields+='<td></td></tr>';
			
			var count_td=1;
			$('#business_details .services tr').each(function(){
				fields+='<tr>';
				fields+='<td><input type="text" value="'+htmlentities($(this).children('td:eq(1)').text(),"ENT_QUOTES")+'" id="title_'+count_td+'" name="data[Services][title_'+count_td+']"  style="margin-bottom:2px;width:275px;" />&#160;</td>';
				fields+='<td>&#163;&#160;&#160;<input type="text" value="'+$(this).children('td:eq(2)').children('span').text()+'" id="price_'+count_td+'" name="data[Services][price_'+count_td+']" style="margin-bottom:2px;width:30px;" />&#160;</td>';
				fields+='<td><input type="text" value="'+htmlentities($(this).children('td:eq(3)').text(),"ENT_QUOTES")+'" id="time_'+count_td+'" name="data[Services][time_'+count_td+']" style="margin-bottom:2px;width:100px;" /></td>';				
				fields+='<td style="width:70px"><a href="#" id="remove_'+count_td+'" class="JSremove" style="float:right"></a></td>';					
				fields+='</tr>';					
				count_td++;
			});
			fields+='</table><a href="#" onClick="return false;" id="addNewService">Add another service</a><input type="hidden" value="'+(count_td-1)+'" name="data[Services][count]" id="dataServicesCount" />';
			
		$('#edit_services').append(fields);
		
		$('#JSnew_mesage').draggable();
		$('.JSremove').click(function(e){
			e.preventDefault();
			var href_attr=$(this).attr('id').split('_');
			$('#title_'+href_attr[1]+', #price_'+href_attr[1]+', #time_'+href_attr[1]).val('');
		});
		
		$('#JSclose').click(function(e){
			e.preventDefault();
			$('#JSnew_mesage, #JSclose, #JSsave, .JSremove').unbind();
			$('#JSnew_mesage, #dark').remove();			
		});
		
		$('#addNewService').click(function(){
			e.preventDefault();
			newfields='<tr>';
			newfields+='<td><input type="text" value="" id="title_'+count_td+'" name="data[Services][title_'+count_td+']"  style="margin-bottom:2px;width:275px;" />&#160;</td>';
			newfields+='<td>&#163;&#160;&#160;<input type="text" value="" id="price_'+count_td+'" name="data[Services][price_'+count_td+']" style="margin-bottom:2px;width:30px;" />&#160;</td>';
			newfields+='<td><input type="text" value="" id="time_'+count_td+'" name="data[Services][time_'+count_td+']" style="margin-bottom:2px;width:100px;"/></td>';				
			newfields+='<td></td></tr>';
			$('#dataServicesCount').val(count_td);
			$('#addServicesAjaxTable tr:first').after(newfields);
			count_td++;
		});
		
		$('#JSsave').click(function(e){
			e.preventDefault();
			$('.JSremove').unbind('click');
			$(this).unbind('click').remove();
			servicesAJAX($('#services').attr('rel'));
		});		
	}
	
	function servicesAJAX(path){
		var desc='';
		var array_path=path.split('/');
		$.ajax({
			type:"POST",
			url: URL_A+path,
			data: $('#edit_services').serialize(),
			timeout:25000,
			beforeSend: function(){
				$('#send_services').html('<div style="text-align:center;padding:30px 0 20px 0"><img src="'+STATIC_IMG_DIR+'spinner.gif" alt=""/></div>');
			},
			success: function(msg){
				msg=msg.split('SEPARATE_R5ODV');
				$('#send_services').html('<div style="text-align:center;padding:30px 0 20px 0"><b>'+msg[1]+'</b></div>');
				if($('#no_changeOH').length==0){
					$('#business_details .services').html('<table cellpadding="0" cellspacing="4" border="0">'+msg[0]+'</table>');
					if($('#services').length==0){
						$("h2:contains('Services')").after('<a href=""  rel="networks/servicesAJAX/'+array_path[2]+'/'+network_id+'" id="services">Edit</a>');
						$('#services').click(function(e){
							servicesMakeBox(e);		
						});
					}
				}
			},
			error: function(){
				$('#send_services').html('<div style="color:red;text-align:center"><b>Error. <br />Please refresh the page</b></div>');
			}
		}); 
	}

/*////////////////////////////////*/
/*  end position services*/
/*////////////////////////////////*/



/*////////////////////////////////*/
/* begin section Next Booking Availability*/
/*////////////////////////////////*/

	function add_new_booking(){

		$('#moving_31 .make_a_booking').click(function(e){
			e.preventDefault();
			$('#new_booking').remove();

			if($('#plannerInner').length==0){
				$('#calendar_container').prepend('<div id="plannerInner"></div>');
				user_id=$('.booking_availability .b_right a.make_a_booking').attr('rel');
			}
			$('#plannerInner').prepend('<div id="new_booking"></div>');

			create_plan_events('new_booking',null,null);
		});
	}

/*////////////////////////////////*/
/*  end position Next Booking Availability*/
/*////////////////////////////////*/



/*///////////////////////////////////////*/
/* begin section for New Booking Requests*/
/*///////////////////////////////////////*/

	function getfriendsplansrequestsBookingRequests(){
		
		dontGetIds = $('#hiddenRequestsDontGetIds').val();
		
		$.post(URL_A+'plans/ajax_getfriendsplansRequests_business/'+network_id+'/'+dontGetIds, function(data){

			var str = new String(data);
			//alert(data)
			if(str.match("friendsPlansRequestsContainerHidden")){
				
				$('#friendsPlansRequestsContainer').prepend(data);
				
				if($('#noplansrequests').length){
					$('#noplansrequests').slideUp(function(){						
						$(this).remove();
					});
				}
				$('#requestssplansspinner').slideUp(function(){$(this).css({'display':'none'})});
				
				if($('#friendsPlansRequestsContainer').height()==80 && $('.friendsPlansRequestsContainerHidden').length>0)
					$('#friendsPlansRequestsContainer').animate({height:'240px'}, 'fast',function(){
						if($('#dark').length){
							$('#dark').height($(document).height());
						}
					});
					
				if($('#friendsPlansRequestsContainer').parent().parent().css('display')=='none')
					$('#friendsPlansRequestsContainer').css({'height':'240px'});				
				$('.friendsPlansRequestsContainerHidden').slideDown().animate({ backgroundColor: "white" }, 2000);
			
				if($('.friendsPlansRequestsContainerHidden').length){
					var link=$('#friendsPlansRequestsContainer .friendsPlansRequestsContainerHidden:first a.square').attr('href');
					if($('.friendsPlansRequestsContainerHidden').length>1)
						$('#moving_30 .admin span').html('<a href="'+link+'">'+$('.friendsPlansRequestsContainerHidden').length+' new bookings</a>');
					else
						$('#moving_30 .admin span').html('<a href="'+link+'">'+$('.friendsPlansRequestsContainerHidden').length+' new booking</a>');
				}			
			}else{
				
				if(numberofrequestssplans==0){
					$('#requestssplansspinner').slideUp('fast',function(){$(this).css({'display':'none'})});
					$('#friendsPlansRequestsContainer').append('<div id="noplansrequests"  class="no_reminders" ><b>0 New Booking Requests<\/b><\/div>');
				}
			}
			
			numberofrequestssplans++;
		});
		
		clearTimeout(re);
		re = setTimeout('getfriendsplansrequestsBookingRequests()',requestssplansPref+50);		

	}


/*////////////////////////////////////*/
/*end section for New Booking Requests*/
/*////////////////////////////////////*/





/*/////////////////////////////*/
/* begin section for show Month for box 'Business Planner'*/
/*/////////////////////////////*/
 
	function business_start_initMonthScheduler_box(){	
		business_initMonthScheduler_box();	
	}
	 
 
/* function sets initial date for view Month */

    function business_initMonthScheduler_box()
    { 
        business_dateStartOfMonth_box = new Date();
        business_updateHeaderDatesMonth_box();
		$('#left_small_plans').click(function(e){
			e.preventDefault();
			business_displayPreviousMonth_box();
		});
		$('#right_small_plans').click(function(e){
			e.preventDefault();
			business_displayNextMonth_box();
		});
    }

/* function showing date for view Month  */ 
    function business_updateHeaderDatesMonth_box()
    {
        var tabsMonth=new Array('January','February','March','April','May','June','July','August','September','October','November','December');
        var tmpDate2 = new Date(business_dateStartOfMonth_box);
        $('#cener_small_plans').html(tabsMonth[tmpDate2.getMonth()]+ ' '+ tmpDate2.getFullYear());
		var new_date=tmpDate2.getFullYear() +'/'+(tmpDate2.getMonth()+1)+'/'+tmpDate2.getDate();
		business_month_ajax_box('small_planer_AJAX',new_date);
        
    }

/* function changes date for view Month  */ 
    function business_displayPreviousMonth_box()
    {
        var tmpTime = business_dateStartOfMonth_box.getTime();        
        if (business_dateStartOfMonth_box.getFullYear()%4 ==0) {var howInFab=29} else {var howInFab=28}
        
        if(business_dateStartOfMonth_box.getMonth()==0)
            var current_month=11;
        else
            var current_month=business_dateStartOfMonth_box.getMonth()-1;        
        
        var howManyDay=new Array(31,howInFab,31,30,31,30,31,31,30,31,30,31);
        
        tmpTime = tmpTime - (1000*60*60*24*howManyDay[current_month])- (1000*60*business_dateStartOfMonth_box.getTimezoneOffset());
        business_dateStartOfMonth_box.setTime(tmpTime);
        business_updateHeaderDatesMonth_box();	
    }
    
/* function changes date for view Month  */ 
    function business_displayNextMonth_box()
    {
        var tmpTime = business_dateStartOfMonth_box.getTime();        
        if (business_dateStartOfMonth_box.getFullYear()%4 ==0) {var howInFab=29} else {var howInFab=28}
         
        var current_month=business_dateStartOfMonth_box.getMonth(); 
        var howManyDay=new Array(31,howInFab,31,30,31,30,31,31,30,31,30,31);
        tmpTime = tmpTime + (1000*60*60*24*howManyDay[current_month])- (1000*60*business_dateStartOfMonth_box.getTimezoneOffset());
        business_dateStartOfMonth_box.setTime(tmpTime);    
        business_updateHeaderDatesMonth_box();
        
    }

    function business_month_ajax_box(id_element,path){

        $.ajax({
			type:"POST",
			url: URL_A + 'plans/business_box_planner/'+session_id+'/'+user_id+'/'+add_zero_for_date(path)+'/'+network_id,
			timeout:15000,
			data:'start=1',
			beforeSend: function(){
				$('#'+id_element+' td').unbind('click');
				$('#'+id_element).html('<table cellpadding="0" cellspacing="0" style="height:'+$('#'+id_element).height()+'px;width:274px;border:1px solid #d3d3d3;"><tr><td style="vertical-align:middle;text-align:center" align="cener" valign="middle"><img src="'+STATIC_IMG_DIR+'spinner.gif" alt="" /></td></tr></table>');
			},
			success: function(msg){
                $('#'+id_element).html(msg);
				$('#'+id_element+' td[id]').click(function(){
					document.location.href=URL_A+'plans/'+$(this).attr('id');					
				});
  			},
			error: function(){
				$('#'+id_element).html('<table cellpadding="0" cellspacing="0" style="height:'+$('#'+id_element).height()+'px;width:274px;border:1px solid #d3d3d3;"><tr><td style="vertical-align:middle;text-align:center;color:red" align="cener" valign="middle">Error. <br /> Please try again to click in anchor</td></tr></table>');
			}
		});
    }


/*///////////////////////////*/
/* end section for show Month*/
/*///////////////////////////*/
