function show_search_options_in_left_div(container,url)

{

	setTimeout("show_search_options_in_left_div_after_delay('"+container+"','"+url+"')",100);

}

function show_search_options_in_left_div_after_delay(container,url)

{

	if($(container))

	{

		new Effect.ScrollTo('siadecontenar');
		
		AjaxRequest.post({
			'url':url,
			'onLoading':function(req){setCoverOnAjaxRequest();},
			'onSuccess':function(req){
				$(container).innerHTML=req.responseText;
				removeCoverOnAjaxRequest();
			},
			'onError':function(req){
				alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);
			}
		});
		/*new Ajax.Updater(container,url, {onLoading:function(request){$('image_load').innerHTML="<img src="+WEB_ROOT_images+"loading_background.gif>"}, onComplete:function(request){$('image_load').innerHTML='&nbsp;'; Effect.SlideDown(container);new Effect.Highlight(container); }});
		$('image_load').innerHTML='';*/
	}

	else

	{

		setTimeout("show_search_options_in_left_div_after_delay('"+container+"','"+url+"')",500);

	}

}

/* Refs #584. Create function checkSendMessageWordFilter for checking words for filtering */
function checkSendMessageWordFilter(filter_st,block_st,fromuid,touid,userfname)
{
	if((/^\s*$/.test($F('txt_subject'))) || (/^undefined$/.test($F('txt_subject'))))

	{

		$('error_msg').innerHTML='&nbsp;';
		alert("Please Enter Subject");

		return false;

	}

	if((/^\s*$/.test($F('txt_message'))) || (/^undefined$/.test($F('txt_message'))))

	{

		$('error_msg').innerHTML='&nbsp;';
		alert("Please Enter Message");

		return false;

	}
	if($F('no_of_replies') > 0)
	{
		var url=WEB_ROOT+"ajax_pd.php?action=check_total_number_replies&uid="+fromuid+"&touid="+touid;
		/* Refs #749. Change ajax get method to post method */
		AjaxRequest.post({
	
				'url':url,
	
				'onLoading':function(req){},
	
				'onSuccess':function(req)
	
					{
						if(parseInt(req.responseText) < $F('no_of_replies'))
						{
							if($('counter_mis').value<3)
							{
								if(filter_st=='Y')
								{
									AjaxRequest.post({
										'url':WEB_ROOT+"ajax_pd.php?action=validate_word_filter&your_text="+escape($F('txt_subject')),
										'onLoading':function(req){$('error_msg').innerHTML="<img src="+WEB_ROOT_images+"loading_background.gif />";},
										'onSuccess':function(req){
											if(req.responseText.length>2)
											{
												$('error_msg').innerHTML=$F('warning_message');
												new Effect.Highlight('error_msg');
												if(block_st=='Y')
												{
													/*$('txt_subject').focus();*/
												}
											}
										},
										'onError':function(req){
											alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);
										}
									});
									
									AjaxRequest.post({
										'url':WEB_ROOT+"ajax_pd.php?action=validate_word_filter&your_text="+escape($F('txt_message')),
										'onLoading':function(req){},
										'onSuccess':function(req){
											
											if(req.responseText.length>2)
											{
												$('error_msg').innerHTML=$F('warning_message');
												new Effect.Highlight('error_msg');
												if(block_st=='Y')
												{
													/*$('txt_message').focus();*/
												}
											}
										},
										'onError':function(req){
											alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);
										}
									});	
									
									var AllText = escape($F('txt_subject'))+" "+escape($F('txt_message'));
									AjaxRequest.post({
										'url':WEB_ROOT+"ajax_pd.php?action=validate_word_filter&your_text="+AllText,
										'onLoading':function(req){$('error_msg').innerHTML="<img src="+WEB_ROOT_images+"loading_background.gif />";},
										'onSuccess':function(req){
											if(req.responseText.length>2)
											{
												if(block_st=='Y')
												{
													/*$('error_msg').innerHTML=req.responseText;*/
													/*new Effect.Highlight('error_msg');*/
													/*$('txt_subject').focus();*/
												}
												else
												{
													$('counter_mis').value=parseInt($('counter_mis').value)+1;
													if($('counter_mis').value==3)
													{
														$('error_msg').innerHTML=$F('three_times_message');
														new Effect.Highlight('error_msg');
													}
												}
											}else
											{
												if($('upgrade_windows_pop').value == 'Y')
												{
													var AllReplaceText = escape($F('txt_subject'))+"\n\n"+escape($F('txt_message'));
													AjaxRequest.post({
														'url':WEB_ROOT+"ajax_pd.php?action=replace_word_filter&your_text="+AllReplaceText,
														'onLoading':function(req){$('loadingdiv').innerHTML=loadstatustext;},
														'onSuccess':function(req){
															$('loadingdiv').innerHTML='';
															var intro_text = $F('intro_text');
															var outro_text = $F('outro_text');
															if($F('filter_word_check') == 'N')
															{
																var alertText = userfname.substr(0, 1).toUpperCase() + userfname.substr(1) +", "+intro_text+"\n\n"+$F('txt_subject')+"\n\n"+$F('txt_message')+"\n\n"+outro_text;
															}
															else
															{
																var alertText = userfname.substr(0, 1).toUpperCase() + userfname.substr(1) +", "+intro_text+"\n\n"+req.responseText+"\n\n"+outro_text;
															}
															if(confirm(alertText))
															{
																if($('word_filter_module').value == "Reply") {
																	var feature = "Conversation History Reply";
																}
																else
																{
																	var feature = "Conversation History Initial Message Send";
																}
																userSendSimpleMessage(fromuid,touid);
																creatContainerDivFull('Payment_popup_div',WEB_ROOT+'payment/showpayment.php?last_touid='+touid+'&Feature='+feature,'Payment Gateway');
															}
															else
															{
																userSendSimpleMessage(fromuid,touid);
															}
														},
														'onError':function(req){
															alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);
														}
													});
												}
												else
												{
													userSendSimpleMessage(fromuid,touid);
												}
											}
										},
										'onError':function(req){
											alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);
										}
									});
								}
								else
								{
									if($F('paid_member_pop')=='Y')
									{
										var intro_text = $F('intro_text');
										var outro_text = $F('outro_text');
										var alertText = userfname.substr(0, 1).toUpperCase() + userfname.substr(1) +", "+intro_text+"\n\n"+outro_text;
										alert(alertText);
									}
									userSendSimpleMessage(fromuid,touid);
								}
							}
							else
							{
								if($F('paid_member_pop')=='Y')
								{
									var intro_text = $F('intro_text');
									var outro_text = $F('outro_text');
									var alertText = userfname.substr(0, 1).toUpperCase() + userfname.substr(1) +", "+intro_text+"\n\n"+outro_text;
									alert(alertText);
								}
								var AllText = escape($F('txt_subject'))+" "+escape($F('txt_message'));
								AjaxRequest.post({
									'url':WEB_ROOT+"ajax_pd.php?action=validate_word_filter&your_text="+AllText,
									'onLoading':function(req){$('error_msg').innerHTML="<img src="+WEB_ROOT_images+"loading_background.gif />";},
									'onSuccess':function(req){
										if(req.responseText.length>2)
										{
											if(block_st=='Y')
											{
												$('error_msg').innerHTML=$F('warning_message');
												new Effect.Highlight('error_msg');
												$('txt_subject').focus();
											}
											else
											{
												if($('upgrade_windows_pop').value == 'Y')
												{
													var AllReplaceText = escape($F('txt_subject'))+"\n\n"+escape($F('txt_message'));
													AjaxRequest.post({
														'url':WEB_ROOT+"ajax_pd.php?action=replace_word_filter&your_text="+AllReplaceText,
														'onLoading':function(req){$('loadingdiv').innerHTML=loadstatustext;},
														'onSuccess':function(req){
															$('loadingdiv').innerHTML='';
															var intro_text = $F('intro_text');
															var outro_text = $F('outro_text');
															if($F('filter_word_check') == 'N')
															{
																var alertText = userfname.substr(0, 1).toUpperCase() + userfname.substr(1) +", "+intro_text+"\n\n"+$F('txt_subject')+"\n\n"+$F('txt_message')+"\n\n"+outro_text;
															}
															else
															{
																var alertText = userfname.substr(0, 1).toUpperCase() + userfname.substr(1) +", "+intro_text+"\n\n"+req.responseText+"\n\n"+outro_text;
															}
															if(confirm(alertText))
															{
																if($('word_filter_module').value == "Reply") {
																	var feature = "Conversation History Reply";
																}
																else
																{
																	var feature = "Conversation History Initial Message Send";
																}
																userSendSimpleMessage(fromuid,touid);
																creatContainerDivFull('Payment_popup_div',WEB_ROOT+'payment/showpayment.php?last_touid='+touid+'&Feature='+feature,'Payment Gateway');
															}
															else
															{
																userSendSimpleMessage(fromuid,touid);
															}
														},
														'onError':function(req){
															alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);
														}
													});
												}
												else
												{
													userSendSimpleMessage(fromuid,touid);
												}
											}
										}else
										{
											if($('upgrade_windows_pop').value == 'Y')
											{
												var AllReplaceText = escape($F('txt_subject'))+"\n\n"+escape($F('txt_message'));
												AjaxRequest.post({
													'url':WEB_ROOT+"ajax_pd.php?action=replace_word_filter&your_text="+AllReplaceText,
													'onLoading':function(req){$('loadingdiv').innerHTML=loadstatustext;},
													'onSuccess':function(req){
														$('loadingdiv').innerHTML='';
														var intro_text = $F('intro_text');
														var outro_text = $F('outro_text');
														if($F('filter_word_check') == 'N')
														{
															var alertText = userfname.substr(0, 1).toUpperCase() + userfname.substr(1) +", "+intro_text+"\n\n"+$F('txt_subject')+"\n\n"+$F('txt_message')+"\n\n"+outro_text;
														}
														else
														{
															var alertText = userfname.substr(0, 1).toUpperCase() + userfname.substr(1) +", "+intro_text+"\n\n"+req.responseText+"\n\n"+outro_text;
														}
														if(confirm(alertText))
														{
															if($('word_filter_module').value == "Reply") {
																var feature = "Conversation History Reply";
															}
															else
															{
																var feature = "Conversation History Initial Message Send";
															}
															userSendSimpleMessage(fromuid,touid);
															creatContainerDivFull('Payment_popup_div',WEB_ROOT+'payment/showpayment.php?last_touid='+touid+'&Feature='+feature,'Payment Gateway');
														}
														else
														{
															userSendSimpleMessage(fromuid,touid);
														}
													},
													'onError':function(req){
														alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);
													}
												});
											}
											else
											{
												userSendSimpleMessage(fromuid,touid);
											}
										}
									},
									'onError':function(req){
										alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);
									}
								});
							}
						}
						else
						{
							alert("You have sent maximum messages to a profile");
						}
					}
		});
	}
	else
	{
		if($('counter_mis').value<3)
		{
			if(filter_st=='Y')
			{
				AjaxRequest.post({
					'url':WEB_ROOT+"ajax_pd.php?action=validate_word_filter&your_text="+escape($F('txt_subject')),
					'onLoading':function(req){$('error_msg').innerHTML="<img src="+WEB_ROOT_images+"loading_background.gif />";},
					'onSuccess':function(req){
						if(req.responseText.length>2)
						{
							$('error_msg').innerHTML=$F('warning_message');
							new Effect.Highlight('error_msg');
							if(block_st=='Y')
							{
								/*$('txt_subject').focus();*/
							}
						}
					},
					'onError':function(req){
						alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);
					}
				});
				
				AjaxRequest.post({
					'url':WEB_ROOT+"ajax_pd.php?action=validate_word_filter&your_text="+escape($F('txt_message')),
					'onLoading':function(req){},
					'onSuccess':function(req){
						
						if(req.responseText.length>2)
						{
							$('error_msg').innerHTML=$F('warning_message');
							new Effect.Highlight('error_msg');
							if(block_st=='Y')
							{
								/*$('txt_message').focus();*/
							}
						}
					},
					'onError':function(req){
						alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);
					}
				});	
				
				var AllText = escape($F('txt_subject'))+" "+escape($F('txt_message'));
				AjaxRequest.post({
					'url':WEB_ROOT+"ajax_pd.php?action=validate_word_filter&your_text="+AllText,
					'onLoading':function(req){$('error_msg').innerHTML="<img src="+WEB_ROOT_images+"loading_background.gif />";},
					'onSuccess':function(req){
						if(req.responseText.length>2)
						{
							if(block_st=='Y')
							{
								/*$('error_msg').innerHTML=req.responseText;*/
								/*new Effect.Highlight('error_msg');*/
								/*$('txt_subject').focus();*/
							}
							else
							{
								$('counter_mis').value=parseInt($('counter_mis').value)+1;
								if($('counter_mis').value==3)
								{
									$('error_msg').innerHTML=$F('three_times_message');
									new Effect.Highlight('error_msg');
								}
							}
						}else
						{
							if($('upgrade_windows_pop').value == 'Y')
							{
								var AllReplaceText = escape($F('txt_subject'))+"\n\n"+escape($F('txt_message'));
								AjaxRequest.post({
									'url':WEB_ROOT+"ajax_pd.php?action=replace_word_filter&your_text="+AllReplaceText,
									'onLoading':function(req){$('loadingdiv').innerHTML=loadstatustext;},
									'onSuccess':function(req){
										$('loadingdiv').innerHTML='';
										var intro_text = $F('intro_text');
										var outro_text = $F('outro_text');
										if($F('filter_word_check') == 'N')
										{
											var alertText = userfname.substr(0, 1).toUpperCase() + userfname.substr(1) +", "+intro_text+"\n\n"+$F('txt_subject')+"\n\n"+$F('txt_message')+"\n\n"+outro_text;
										}
										else
										{
											var alertText = userfname.substr(0, 1).toUpperCase() + userfname.substr(1) +", "+intro_text+"\n\n"+req.responseText+"\n\n"+outro_text;
										}
										if(confirm(alertText))
										{
											if($('word_filter_module').value == "Reply") {
												var feature = "Conversation History Reply";
											}
											else
											{
												var feature = "Conversation History Initial Message Send";
											}
											userSendSimpleMessage(fromuid,touid);
											creatContainerDivFull('Payment_popup_div',WEB_ROOT+'payment/showpayment.php?last_touid='+touid+'&Feature='+feature,'Payment Gateway');
										}
										else
										{
											userSendSimpleMessage(fromuid,touid);
										}
									},
									'onError':function(req){
										alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);
									}
								});
							}
							else
							{
								userSendSimpleMessage(fromuid,touid);
							}
						}
					},
					'onError':function(req){
						alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);
					}
				});
			}
			else
			{
				if($F('paid_member_pop')=='Y')
				{
					var intro_text = $F('intro_text');
					var outro_text = $F('outro_text');
					var alertText = userfname.substr(0, 1).toUpperCase() + userfname.substr(1) +", "+intro_text+"\n\n"+outro_text;
					alert(alertText);
				}
				userSendSimpleMessage(fromuid,touid);
			}
		}
		else
		{
			if($F('paid_member_pop')=='Y')
			{
				var intro_text = $F('intro_text');
				var outro_text = $F('outro_text');
				var alertText = userfname.substr(0, 1).toUpperCase() + userfname.substr(1) +", "+intro_text+"\n\n"+outro_text;
				alert(alertText);
			}
			var AllText = escape($F('txt_subject'))+" "+escape($F('txt_message'));
			AjaxRequest.post({
				'url':WEB_ROOT+"ajax_pd.php?action=validate_word_filter&your_text="+AllText,
				'onLoading':function(req){$('error_msg').innerHTML="<img src="+WEB_ROOT_images+"loading_background.gif />";},
				'onSuccess':function(req){
					if(req.responseText.length>2)
					{
						if(block_st=='Y')
						{
							$('error_msg').innerHTML=$F('warning_message');
							new Effect.Highlight('error_msg');
							$('txt_subject').focus();
						}
						else
						{
							if($('upgrade_windows_pop').value == 'Y')
							{
								var AllReplaceText = escape($F('txt_subject'))+"\n\n"+escape($F('txt_message'));
								AjaxRequest.post({
									'url':WEB_ROOT+"ajax_pd.php?action=replace_word_filter&your_text="+AllReplaceText,
									'onLoading':function(req){$('loadingdiv').innerHTML=loadstatustext;},
									'onSuccess':function(req){
										$('loadingdiv').innerHTML='';
										var intro_text = $F('intro_text');
										var outro_text = $F('outro_text');
										if($F('filter_word_check') == 'N')
										{
											var alertText = userfname.substr(0, 1).toUpperCase() + userfname.substr(1) +", "+intro_text+"\n\n"+$F('txt_subject')+"\n\n"+$F('txt_message')+"\n\n"+outro_text;
										}
										else
										{
											var alertText = userfname.substr(0, 1).toUpperCase() + userfname.substr(1) +", "+intro_text+"\n\n"+req.responseText+"\n\n"+outro_text;
										}
										if(confirm(alertText))
										{
											if($('word_filter_module').value == "Reply") {
												var feature = "Conversation History Reply";
											}
											else
											{
												var feature = "Conversation History Initial Message Send";
											}
											userSendSimpleMessage(fromuid,touid);
											creatContainerDivFull('Payment_popup_div',WEB_ROOT+'payment/showpayment.php?last_touid='+touid+'&Feature='+feature,'Payment Gateway');
										}
										else
										{
											userSendSimpleMessage(fromuid,touid);
										}
									},
									'onError':function(req){
										alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);
									}
								});
							}
							else
							{
								userSendSimpleMessage(fromuid,touid);
							}
						}
					}else
					{
						if($('upgrade_windows_pop').value == 'Y')
						{
							var AllReplaceText = escape($F('txt_subject'))+"\n\n"+escape($F('txt_message'));
							AjaxRequest.post({
								'url':WEB_ROOT+"ajax_pd.php?action=replace_word_filter&your_text="+AllReplaceText,
								'onLoading':function(req){$('loadingdiv').innerHTML=loadstatustext;},
								'onSuccess':function(req){
									$('loadingdiv').innerHTML='';
									var intro_text = $F('intro_text');
									var outro_text = $F('outro_text');
									if($F('filter_word_check') == 'N')
									{
										var alertText = userfname.substr(0, 1).toUpperCase() + userfname.substr(1) +", "+intro_text+"\n\n"+$F('txt_subject')+"\n\n"+$F('txt_message')+"\n\n"+outro_text;
									}
									else
									{
										var alertText = userfname.substr(0, 1).toUpperCase() + userfname.substr(1) +", "+intro_text+"\n\n"+req.responseText+"\n\n"+outro_text;
									}
									if(confirm(alertText))
									{
										if($('word_filter_module').value == "Reply") {
											var feature = "Conversation History Reply";
										}
										else
										{
											var feature = "Conversation History Initial Message Send";
										}
										userSendSimpleMessage(fromuid,touid);
										creatContainerDivFull('Payment_popup_div',WEB_ROOT+'payment/showpayment.php?last_touid='+touid+'&Feature='+feature,'Payment Gateway');
									}
									else
									{
										userSendSimpleMessage(fromuid,touid);
									}
								},
								'onError':function(req){
									alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);
								}
							});
						}
						else
						{
							userSendSimpleMessage(fromuid,touid);
						}
					}
				},
				'onError':function(req){
					alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);
				}
			});
		}
	}
}

function userSendSimpleMessage(fromuid,touid)

{   /* refs #844. Check permission for maximum sending message */
	var checkurl=WEB_ROOT+"ajax_pd.php?action=check_message_permission&uid="+fromuid;
	AjaxRequest.get({

		'url':checkurl,

		'onLoading':function(req){},

		'onSuccess':function(req)

			{

				if(req.responseText == "FALSE") {
					alert("You have reached your message sending limit today");
				}
				
				else
				{
					
					if((/^\s*$/.test($F('txt_subject'))) || (/^undefined$/.test($F('txt_subject'))))

					{
				
						$('error_msg').innerHTML='&nbsp;';
						alert("Please Enter Subject");
				
						return false;
				
					}
				
					if((/^\s*$/.test($F('txt_message'))) || (/^undefined$/.test($F('txt_message'))))
				
					{
				
						$('error_msg').innerHTML='&nbsp;';
						alert("Please Enter Message");
				
						return false;
				
					}
				
					var url=WEB_ROOT+"ajax_pd.php?action=send_simple_message&fromuid="+fromuid+"&touid="+touid+"&subj="+escape($F('txt_subject'))+"&msg="+escape($F('txt_message'))+"&frommessageid="+$F('frommessageid')+"&counter_mis="+$F('counter_mis');
					/* Refs #749. Change ajax get method to post method */
					AjaxRequest.post({
				
							'url':url,
				
							'onLoading':function(req){$('error_msg').innerHTML="<img src="+WEB_ROOT_images+"loading_background.gif />";},
				
							'onSuccess':function(req)
				
								{
				
									$('error_msg').innerHTML='&nbsp;';
				/*
				 * Displaying message immediately after sending message, updating the converstion screen in real time like on facebook, On Line No : 77-78, For The Ticket - refs #556
				 refs #844. Add checking to display error message of send mail
				 */					if(req.responseText == 'You can\'t send any more message today')
									{
										$('error_msg').innerHTML="You can't send any more message today";
									}
									else
									{
										$('dvSimpleEmailMsg').innerHTML="Message Sent Successfully";
										$('divRecentMail').innerHTML=req.responseText+$('divRecentMail').innerHTML;
									}
									
									new Effect.Highlight('dvSimpleEmailMsg');
				/*
				 * After sending message, message box is getting blank, On Line No : 81, For The Ticket - refs #556
				 */
									$('txt_message').value = '';
				
								}
				
						});
					
				}

			}

	});

}

function userSaveSimpleMessage(fromuid,touid)

{

	if((/^\s*$/.test($F('txt_subject'))) || (/^undefined$/.test($F('txt_subject'))))

	{

		alert("Please Enter Subject");

		return false;

	}

	if((/^\s*$/.test($F('txt_message'))) || (/^undefined$/.test($F('txt_message'))))

	{

		alert("Please Enter Message");

		return false;

	}		

	var url=WEB_ROOT+"ajax_pd.php?action=save_simple_message&fromuid="+fromuid+"&touid="+touid+"&subj="+escape($F('txt_subject'))+"&msg="+escape($F('txt_message'))+"&frommessageid="+$F('frommessageid');
	/* Refs #749. Change ajax get method to post method */
	AjaxRequest.post({

			'url':url,

			'onSuccess':function(req)

				{

					$('dvSimpleEmailMsg').innerHTML=req.responseText;

					new Effect.Highlight('dvSimpleEmailMsg');

				}

		})

}



function getMessageById(msgid)

{

	if($('dvMessage_'+msgid).innerHTML=='')

	{

		var url=WEB_ROOT+"ajax_pd.php?action=getMessageById&message_id="+msgid;

		AjaxRequest.get({

				'url':url,

				'onSuccess':function(req)

				{

					var dv=$('dvMessage_'+msgid);

					dv.innerHTML=req.responseText;

					dv.className='img_red_border';

					dv.style.backgroundColor='ivory';

				}

			})

	}

	else

	{

		var dv=$('dvMessage_'+msgid);

		dv.innerHTML='';

		dv.className='';

		dv.style.backgroundColor='';

	}

}

function userSendForwardMessage(fwid,myid)

{

	if((/^\s*$/.test($F('email_to'))) || (/^undefined$/.test($F('email_to'))))

	{

		alert("Please Enter Email ID");

		return false;

	}

	if((/^\s*$/.test($F('txt_subject'))) || (/^undefined$/.test($F('txt_subject'))))

	{

		alert("Please Enter Subject");

		return false;

	}

	if((/^\s*$/.test($F('txt_message'))) || (/^undefined$/.test($F('txt_message'))))

	{

		alert("Please Enter Message");

		return false;

	}

	var url=WEB_ROOT+"ajax_pd.php?action=send_forward_message&fwid="+fwid+"&myid="+myid+"&subj="+escape($F('txt_subject'))+"&msg="+escape($F('txt_message'))+"&email="+$F('email_to');
/* Refs #749. Change ajax get method to post method */
	AjaxRequest.post({

			'url':url,

			'onLoading':function(req){$('error_msg').innerHTML='<center><img src='+WEB_ROOT_images+'loading_background.gif /></center>';},

			'onSuccess':function(req)

				{
					$('error_msg').innerHTML='&nbsp;';
					
					$('dvSimpleEmailMsg').className = "redbold";

					$('dvSimpleEmailMsg').innerHTML="thank you, your message was sent.";

					new Effect.Highlight('dvSimpleEmailMsg');

				}

		});

}


/* refs #715 - add 3 function below for send and save message */
function userSendProfileMessage(fromuid,touid)

{
	/* refs #844. Check permission for maximum sending message */
	var checkurl=WEB_ROOT+"ajax_pd.php?action=check_message_permission&uid="+fromuid;

	AjaxRequest.get({

		'url':checkurl,

		'onLoading':function(req){},

		'onSuccess':function(req)

			{

				if(req.responseText == "FALSE") {
					alert("You have reached your message sending limit today");
				}
				else
				{
					
					/* refs #556. Change the filed name at line 255, 265, 275, 307, 317, 327, 356, 357 */
					if((/^\s*$/.test($F('txt_subject_profile'))) || (/^undefined$/.test($F('txt_subject_profile'))))
				
					{
				
						alert("Please Enter Subject");
				
						return false;
				
					}
				
					if((/^\s*$/.test($F('txt_message_profile'))) || (/^undefined$/.test($F('txt_message_profile'))))
				
					{
				
						alert("Please Enter Message");
				
						return false;
				
					}
				/*  refs #844. Add checking to display error message of send mail */
					var url=WEB_ROOT+"ajax_pd.php?action=send_simple_message&fromuid="+fromuid+"&touid="+touid+"&subj="+escape($F('txt_subject_profile'))+"&msg="+escape($F('txt_message_profile'))+"&frommessageid="+$F('frommessageid')+"&counter_mis="+$F('counter_mis');
				/* Refs #749. Change ajax get method to post method */
					AjaxRequest.post({
				
							'url':url,
				
							'onLoading':function(req){$('error_msg').innerHTML='Wait Sending Message....111';},
				
							'onSuccess':function(req)
				
								{
				
									$('error_msg').innerHTML='&nbsp;';
				
									$('dvSimpleEmailMsg_message').style.display = '';
									
									$('dvSimpleEmailMsg').style.display = 'none';
				
									$('dvSimpleEmailMsg_message').innerHTML=req.responseText;
				
									new Effect.Highlight('dvSimpleEmailMsg_message');
				
								}
				
						});
					
				}

			}

	});
}

function userSaveProfileMessage(fromuid,touid)

{

	if((/^\s*$/.test($F('txt_subject_profile'))) || (/^undefined$/.test($F('txt_subject_profile'))))

	{

		alert("Please Enter Subject");

		return false;

	}

	if((/^\s*$/.test($F('txt_message_profile'))) || (/^undefined$/.test($F('txt_message_profile'))))

	{

		alert("Please Enter Message");

		return false;

	}		

	var url=WEB_ROOT+"ajax_pd.php?action=save_simple_message&fromuid="+fromuid+"&touid="+touid+"&subj="+escape($F('txt_subject_profile'))+"&msg="+escape($F('txt_message_profile'))+"&frommessageid="+$F('frommessageid');
/* Refs #749. Change ajax get method to post method */
	AjaxRequest.post({

			'url':url,

			'onSuccess':function(req)

				{

					$('dvSimpleEmailMsg_message').style.display = '';
					
					$('dvSimpleEmailMsg').style.display = 'none';
					
					$('dvSimpleEmailMsg_message').innerHTML=req.responseText;

					new Effect.Highlight('dvSimpleEmailMsg_message');

				}

		})

}

function profileMsgDisplay()
{
	document.getElementById("dvSimpleEmailMsg_message").style.display = 'none';
	document.getElementById("dvSimpleEmailMsg").style.display = '';
	
	document.getElementById("txt_subject_profile").value = '';
	document.getElementById("txt_message_profile").value = '';
	
	
	document.getElementById("profileSendMsg").style.display = '';
	document.getElementById("profileSendMsg_space").style.display = '';
	document.getElementById("profileMsgConv").style.display = '';
	document.getElementById("profileMsgConv_space").style.display = '';
	
	profile_msg_hideshow('profile_send_message_hideshow');
	profile_msg_hideshow('profile_message_conversation_hideshow');
}
/* refs #ticket 613 - add new javascript function to hide and unhide photos in mailbox */
function mailBoxHideUnhidePhoto(status, total)
{
	var dDate=new Date();
	dDate.setDate(dDate.getDate()+50);
	if(status == 0)
	{
		setCookie("saveHideUnhide","display",dDate);
		var echoTxt = '';
		document.getElementById("unhideID").style.display = 'none';
		document.getElementById("hideID").style.display = '';
	}
	else
	{
		setCookie("saveHideUnhide","none",dDate);
		var echoTxt = 'none';
		document.getElementById("unhideID").style.display = '';
		document.getElementById("hideID").style.display = 'none';
	}
	
	if(total > 0)
	{
		for(i = 1; i <= total; i++)
		{
			/* var ID = eval("displayPhotoID_"+i); */
			document.getElementById("displayPhotoID_"+i).style.display = echoTxt;
		}
	}
}

/* refs ticket 755. Create 2 functions below 

setCoverOnAjaxRequest() is for creating a layer when sending ajax request.

removeCoverOnAjaxRequest() is for removing the created layer. on completing the ajax request this function gets called.

*/


function setCoverOnAjaxRequest()
{
	var screenHeight=(document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight);
	var objBody = document.getElementsByTagName("body").item(0);
	id = "bodyCov";
	var cover=document.createElement("div");
	cover.setAttribute('id',id+"Cover");
	cover.setAttribute('rel',"Cover");
	cover.style.position="absolute";
	cover.style.left=0;
	cover.style.top=0;
	cover.style.zIndex=1;
	cover.innerHTML="<table width='100%' cellpadding='0' cellspacing='0'><tr><td align='center' height='600' valign='middle'><img src='"+WEB_ROOT_images+"ajax-loader.gif' align='absmiddle' /></td></tr></table>";
	cover.style.display='';
	objBody.appendChild(cover);
	
	/* set opacity and references */
	var cvrOpacity = '0.60';
	var cover      = $(id+'Cover');
	
	/* set cover/container background colors and opacities */
	cover.style.backgroundColor='black';
	cover.setOpacity(cvrOpacity);
	
	/* get page and screen sizes */
	var arrPageSize=getPageSize();
	/* set the cover element's height and width */
	Element.setHeight(id+'Cover', arrPageSize[1]);
	Element.setWidth(id+'Cover', arrPageSize[0]);
	
	hideSelectBoxes();
	Element.show(id+'Cover');
}

function removeCoverOnAjaxRequest()
{
	id = "bodyCov";
	if(!(/^\s*$/.test(id) || /^\s*undefined\s*$/.test(id)))
	{
		Element.hide(id+'Cover');
	}
	var arr=document.getElementsByTagName("Div");
	for(var i=arr.length-1;i>=0;i--)
	{
		if(arr[i].getAttribute("rel")=="Cover")
		{
			if(arr[i].style.display!='none')
			{
				hideSelectBoxes();
				break;
			}
			else
			{
				showSelectBoxes();
			}
		}
		else
		{
			showSelectBoxes();
		}
	}
	if(!(/^\s*$/.test(id) || /^\s*undefined\s*$/.test(id)))
	{
		$(id+'Cover').parentNode.removeChild($(id+'Cover'));
	}	
}

/* Refs #831 Create function set_search_result_subtab_url to set subtab url dynamically */
/* Refs #831 Set more subtab links */
/* Refs #831. Check if the subtab is enabled, then change the url */
function set_search_result_subtab_url(param)
{
	if(param != '') param = "&"+param;
	if(checkElementExistInArray('search_last_login', seeSubtabsInUserList))
	{
		var prevUrl1 = WEB_ROOT+"search/search_result.php?srch_sort_by=LastLogin";
		var newUrl1 = prevUrl1+param;
		document.getElementById('a_search_last_login').href = newUrl1;
	}
	if(checkElementExistInArray('search_most_popular', seeSubtabsInUserList))
	{
		var prevUrl2 = WEB_ROOT+"search/search_result.php?srch_sort_by=Popular";
		var newUrl2 = prevUrl2+param;
		document.getElementById('a_search_most_popular').href = newUrl2;
	}
	if(checkElementExistInArray('search_newest', seeSubtabsInUserList))
	{
		var prevUrl3 = WEB_ROOT+"search/search_result.php?srch_sort_by=New";
		var newUrl3 = prevUrl3+param;
		document.getElementById('a_newest').href = newUrl3;
	}
	if(checkElementExistInArray('search_no_of_photos', seeSubtabsInUserList))
	{
		var prevUrl4 = WEB_ROOT+"search/search_result.php?srch_sort_by=Pics";
		var newUrl4 = prevUrl4+param;
		document.getElementById('a_search_no_of_photos').href = newUrl4;
	}
	if(checkElementExistInArray('search_closest_to_me', seeSubtabsInUserList))
	{
		var prevUrl5 = WEB_ROOT+"search/search_result.php?srch_sort_by=Close";
		var newUrl5 = prevUrl5+param;
		document.getElementById('a_search_closest_to_me').href = newUrl5;
	}
	if(checkElementExistInArray('search_viewed_myprofile', seeSubtabsInUserList))
	{
		var prevUrl6 = WEB_ROOT+"search/search_result.php?srch_sort_by=ViewedProfile";
		var newUrl6 = prevUrl6+param;
		document.getElementById('a_search_viewed_myprofile').href = newUrl6;
	}
	if(checkElementExistInArray('search_sent_me_msg', seeSubtabsInUserList))
	{
		var prevUrl7 = WEB_ROOT+"search/search_result.php?srch_sort_by=MessageToMe";
		var newUrl7 = prevUrl7+param;
		document.getElementById('a_search_sent_me_msg').href = newUrl7;
	}
	if(checkElementExistInArray('search_have_history_with', seeSubtabsInUserList))
	{
		var prevUrl8 = WEB_ROOT+"search/search_result.php?srch_sort_by=haveHistoryWith";
		var newUrl8 = prevUrl8+param;
		document.getElementById('a_search_have_history_with').href = newUrl8;
	}
	if(checkElementExistInArray('search_My_Favorite', seeSubtabsInUserList))
	{
		var prevUrl9 = WEB_ROOT+"search/search_result.php?srch_sort_by=MyFavorite";
		var newUrl9 = prevUrl9+param;
		document.getElementById('a_search_My_Favorite').href = newUrl9;
	}
	if(checkElementExistInArray('search_added_me_fav', seeSubtabsInUserList))
	{
		var prevUrl10 = WEB_ROOT+"search/search_result.php?srch_sort_by=IAmFavorite";
		var newUrl10 = prevUrl10+param;
		document.getElementById('a_search_added_me_fav').href = newUrl10;
	}
	if(checkElementExistInArray('search_mutual_interest', seeSubtabsInUserList))
	{
		var prevUrl11 = WEB_ROOT+"search/search_result.php?srch_sort_by=MutualInterest";
		var newUrl11 = prevUrl11+param;
		document.getElementById('a_search_mutual_interest').href = newUrl11;
	}
	if(checkElementExistInArray('search_tagged_my_photos', seeSubtabsInUserList))
	{
		var prevUrl12 = WEB_ROOT+"search/search_result.php?srch_sort_by=PicsTaggedMine";
		var newUrl12 = prevUrl12+param;
		document.getElementById('a_search_tagged_my_photos').href = newUrl12;
	}
	if(checkElementExistInArray('search_tagged_their_photo', seeSubtabsInUserList))
	{
		var prevUrl13 = WEB_ROOT+"search/search_result.php?srch_sort_by=PicsITagged";
		var newUrl13 = prevUrl13+param;
		document.getElementById('a_search_tagged_their_photo').href = newUrl13;
	}
	if(checkElementExistInArray('search_last_action', seeSubtabsInUserList))
	{
		var prevUrl13 = WEB_ROOT+"search/search_result.php?srch_sort_by=lastAction";
		var newUrl13 = prevUrl13+param;
		document.getElementById('a_search_last_action').href = newUrl13;
	}
}
/* Refs #831. Create function checkElementExistInArray for checking value exists in array */
function checkElementExistInArray(value, arrName)
{
	for (var i = 0; i < arrName.length; i++)
	{
		if(arrName[i].toLowerCase() == value.toLowerCase())
		{
			return true;	
		}
	}
	return false;
};