/***************************** My Info Starts *************************************/
function editMyInfo(strUserID)
{
	var txt = "";
	$.ajax({
		type: "POST",
		url: HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_MY_INFO_FORM&strUserID="+strUserID,
		success: function(msg){
			txt = msg;
			$.prompt(txt,{				
				buttons:{Ok:-1,Cancel:0},
				top:'20%',
				submit:function(v,m,f){					
					if(v == 0)
					{
						jQuery.ImpromptuClose();
					}
					else if(v == -1)
						saveMyInfoDetails(v,m,f, strUserID);
					return false;
				}
			});
		}
	});
}

// function to save company division information 
function saveMyInfoDetails(v,m,f, strUserID)
{	
	if (v)
	{
		var actionType = "SAVE_MY_INFO";
		var ObjForm = document.getElementById('myProfileMyInfo');
		var strData = ajaxPost(ObjForm);
		$.ajax({
			type: "POST",
			url: HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
			data: "actionType="+actionType+"&"+strData,
			success: function(msg)
			{
				if (msg == 'success')
				{
					var txt = '<img src="../images/icons/check.png" width="64" height="64" border="0" alt="" align="absmiddle">My Info Updated Successfully.';
					alertBox(txt, false);
					getProfileMyInfoDetails(strUserID);
				}
				else if (msg == 'errorSql')
				{
					var txt = "Error executing sql query.";
					alertBox(txt, true);
					getProfileMyInfoDetails(strUserID);
				}
			}
		});
		jQuery.ImpromptuClose();
	}
}

function getProfileMyInfoDetails(strUserID)
{
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_MY_INFO_DETAILS&strUserID="+strUserID,
		success: function(msg){
			$('#getProfileMyInfoDetails').empty();
			$('#getProfileMyInfoDetails').html(msg);
		}
	});
}
/***************************** My Info Ends *************************************/
/***************************** My Statistics Starts *************************************/
function editMyStatisticsSettings(strUserID)
{
	var txt = "";
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_MY_STATISTICS_FORM&strUserID="+strUserID,
		success: function(msg){
			txt = msg;
			$.prompt(txt,{				
				buttons:{Ok:-1,Cancel:0},
				top:'20%',
				submit:function(v,m,f){					
					if(v == 0)
					{
						jQuery.ImpromptuClose();
					}
					else if(v == -1)
						saveMyStatsDetails(v,m,f, strUserID);
					return false;
				}
			});	
		}
	});
}

function saveMyStatsDetails(v,m,f, strUserID)
{	
	if (v)
	{
		var actionType = "SAVE_MY_STATS";
		var ObjForm = document.getElementById('myProfileMyStats');
		var strData = ajaxPost(ObjForm);
		$.ajax({
			type: "POST",
			url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
			data: "actionType="+actionType+"&"+strData,
			success: function(msg)
			{
				if (msg == 'success')
				{
					var txt = '<img src="../images/icons/check.png" width="64" height="64" border="0" alt="" align="absmiddle">My Staticstics Updated Successfully.';
					alertBox(txt, false);
					getProfileMyStatsDetails(strUserID);
				}
				else if (msg == 'errorSql')
				{
					var txt = "Error executing sql query.";
					alertBox(txt, true);
					getProfileMyStatsDetails(strUserID);
				}
			}
		});
		jQuery.ImpromptuClose();
	}
}

function getProfileMyStatsDetails(strUserID)
{
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_MY_STATISTICS_DETAILS&strUserID="+strUserID,
		success: function(msg){
			$('#getProfileMyStatsDetails').empty();
			$('#getProfileMyStatsDetails').html(msg);
		}
	});
}
/***************************** My Statistics Ends *************************************/
/***************************** My Uploads Starts *************************************/
function editMyUploadsSettings(strUserID)
{
	var txt = "";
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_MY_UPLOADS_FORM&strUserID="+strUserID,
		success: function(msg){
			txt = msg;
			$.prompt(txt,{				
				buttons:{Ok:-1,Cancel:0},
				top:'10%',
				submit:function(v,m,f){					
					if(v == 0)
					{
						jQuery.ImpromptuClose();
					}
					else if(v == -1)
						saveMyUploadsDetails(v,m,f, strUserID);
					return false;
				}
			});	
		}
	});
}

function saveMyUploadsDetails(v,m,f, strUserID)
{	
	if (v)
	{
		var actionType = "SAVE_MY_UPLOADS";
		var ObjForm = document.getElementById('myProfileMyUploads');
		var strData = ajaxPost(ObjForm);
		$.ajax({
			type: "POST",
			url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
			data: "actionType="+actionType+"&"+strData,
			success: function(msg)
			{
				if (msg == 'success')
				{
					var txt = '<img src="../images/icons/check.png" width="64" height="64" border="0" alt="" align="absmiddle">My Uploads Updated Successfully.';
					alertBox(txt, false);
					getProfileMyUploadsDetails(strUserID);
				}
				else if (msg == 'errorSql')
				{
					var txt = "Error executing sql query.";
					alertBox(txt, true);
					getProfileMyUploadsDetails(strUserID);
				}
			}
		});
		jQuery.ImpromptuClose();
	}
}

function getProfileMyUploadsDetails(strUserID)
{
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_MY_UPLOADS_DETAILS&strUserID="+strUserID,
		success: function(msg){
			$('#getProfileMyUploadsDetails').empty();
			$('#getProfileMyUploadsDetails').html(msg);
		}
	});
}
/***************************** My Statistics Ends *************************************/
/***************************** My Friends Starts *************************************/
function saveMyFriendsDetails(v,m,f, strUserID)
{	
	if (v)
	{
		var actionType = "SAVE_MY_FRIENDS";
		var ObjForm = document.getElementById('myProfileMyFriends');
		var strData = ajaxPost(ObjForm);
		$.ajax({
			type: "POST",
			url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
			data: "actionType="+actionType+"&"+strData,
			success: function(msg)
			{
				if (msg == 'success')
				{
					var txt = '<img src="../images/icons/check.png" width="64" height="64" border="0" alt="" align="absmiddle">My Friends Updated Successfully.';
					alertBox(txt, false);
					getProfileMyFriendsDetails(strUserID);
				}
				else if (msg == 'errorSql')
				{
					var txt = "Error executing sql query.";
					alertBox(txt, true);
					getProfileMyFriendsDetails(strUserID);
				}
			}
		});
		jQuery.ImpromptuClose();
	}
}

function editMyFriendsSettings(strUserID)
{
	var txt = "";
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_MY_FRIENDS_FORM&strUserID="+strUserID,
		success: function(msg){
			txt = msg;
			$.prompt(txt,{				
				buttons:{Ok:-1,Cancel:0},
				top:'10%',
				submit:function(v,m,f){					
					if(v == 0)
					{
						jQuery.ImpromptuClose();
					}
					else if(v == -1)
						saveMyFriendsDetails(v,m,f, strUserID);
					return false;
				}
			});	
		}
	});
}

function getProfileMyFriendsDetails(strUserID)
{
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_MY_FRIENDS_DETAILS&strUserID="+strUserID,
		success: function(msg){
			$('#getProfileMyFriendsDetails').empty();
			$('#getProfileMyFriendsDetails').html(msg);
		}
	});
}
/***************************** My Friends Ends *************************************/
/***************************** My Recent Visitors Starts *************************************/
function saveMyVisitorsDetails(v,m,f, strUserID)
{	
	if (v)
	{
		var actionType = "SAVE_MY_VISITORS";
		var ObjForm = document.getElementById('myProfileMyVisitors');
		var strData = ajaxPost(ObjForm);
		$.ajax({
			type: "POST",
			url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
			data: "actionType="+actionType+"&"+strData,
			success: function(msg)
			{
				if (msg == 'success')
				{
					var txt = '<img src="../images/icons/check.png" width="64" height="64" border="0" alt="" align="absmiddle">My Visitors Updated Successfully.';
					alertBox(txt, false);
					getProfileMyVisitorsDetails(strUserID);
				}
				else if (msg == 'errorSql')
				{
					var txt = "Error executing sql query.";
					alertBox(txt, true);
					getProfileMyVisitorsDetails(strUserID);
				}
			}
		});
		jQuery.ImpromptuClose();
	}
}

function editMyVisitorsSettings(strUserID)
{
	var txt = "";
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_MY_VISITORS_FORM&strUserID="+strUserID,
		success: function(msg){
			txt = msg;
			$.prompt(txt,{				
				buttons:{Ok:-1,Cancel:0},
				top:'10%',
				submit:function(v,m,f){					
					if(v == 0)
					{
						jQuery.ImpromptuClose();
					}
					else if(v == -1)
						saveMyVisitorsDetails(v,m,f, strUserID);
					return false;
				}
			});	
		}
	});
}

function getProfileMyVisitorsDetails(strUserID)
{
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_MY_VISITORS_DETAILS&strUserID="+strUserID,
		success: function(msg){
			$('#getProfileMyVisitorsDetails').empty();
			$('#getProfileMyVisitorsDetails').html(msg);
		}
	});
}
/***************************** My Recent Visitors Ends *************************************/
/***************************** My Subscribers Starts *************************************/
function saveMySubscribersDetails(v,m,f, strUserID)
{	
	if (v)
	{
		var actionType = "SAVE_MY_SUBSCRIBERS";
		var ObjForm = document.getElementById('myProfileMySubscribers');
		var strData = ajaxPost(ObjForm);
		$.ajax({
			type: "POST",
			url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
			data: "actionType="+actionType+"&"+strData,
			success: function(msg)
			{
				if (msg == 'success')
				{
					var txt = '<img src="../images/icons/check.png" width="64" height="64" border="0" alt="" align="absmiddle">My Subscribers Updated Successfully.';
					alertBox(txt, false);
					getProfileMySubscribersDetails(strUserID);
				}
				else if (msg == 'errorSql')
				{
					var txt = "Error executing sql query.";
					alertBox(txt, true);
					getProfileMySubscribersDetails(strUserID);
				}
			}
		});
		jQuery.ImpromptuClose();
	}
}

function editMySubscribersSettings(strUserID)
{
	var txt = "";
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_MY_SUBSCRIBERS_FORM&strUserID="+strUserID,
		success: function(msg){
			txt = msg;
			$.prompt(txt,{				
				buttons:{Ok:-1,Cancel:0},
				top:'10%',
				submit:function(v,m,f){					
					if(v == 0)
					{
						jQuery.ImpromptuClose();
					}
					else if(v == -1)
						saveMySubscribersDetails(v,m,f, strUserID);
					return false;
				}
			});	
		}
	});
}

function getProfileMySubscribersDetails(strUserID)
{
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_MY_SUBSCRIBERS_DETAILS&strUserID="+strUserID,
		success: function(msg){
			$('#getProfileMySubscribersDetails').empty();
			$('#getProfileMySubscribersDetails').html(msg);
		}
	});
}
/***************************** My Subscribers Ends *************************************/
/***************************** My Feature Upload Starts *************************************/
function saveMyFeatureUploadDetails(v,m,f, strUserID)
{	
	if (v)
	{
		var actionType = "SAVE_MY_FEATUREUPLOAD";
		var ObjForm = document.getElementById('myProfileMyFeatureUpload');
		var strData = ajaxPost(ObjForm);
		$.ajax({
			type: "POST",
			url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
			data: "actionType="+actionType+"&"+strData,
			success: function(msg)
			{
				if (msg == 'success')
				{
					var txt = '<img src="../images/icons/check.png" width="64" height="64" border="0" alt="" align="absmiddle">My FeatureUpload Updated Successfully.';
					alertBox(txt, false);
					getProfileMyFeatureUploadDetails(strUserID);
				}
				else if (msg == 'errorSql')
				{
					var txt = "Error executing sql query.";
					alertBox(txt, true);
					getProfileMyFeatureUploadDetails(strUserID);
				}
			}
		});
		jQuery.ImpromptuClose();
	}
}

function editMyFeatureUploadSettings(strUserID)
{
	var txt = "";
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_MY_FEATUREUPLOAD_FORM&strUserID="+strUserID,
		success: function(msg){
			txt = msg;
			$.prompt(txt,{				
				buttons:{Ok:-1,Cancel:0},
				top:'10%',
				submit:function(v,m,f){					
					if(v == 0)
					{
						jQuery.ImpromptuClose();
					}
					else if(v == -1)
						saveMyFeatureUploadDetails(v,m,f, strUserID);
					return false;
				}
			});	
		}
	});
}

function getProfileMyFeatureUploadDetails(strUserID)
{
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_MY_FEATUREUPLOAD_DETAILS&strUserID="+strUserID,
		success: function(msg){
			$('#getProfileMyFeatureUploadDetails').empty();
			$('#getProfileMyFeatureUploadDetails').html(msg);
		}
	});
}
/***************************** My Feature Upload Ends *************************************/

function friendReq(strUserID, toFriendID)
{
	$("#lnkReqFrndship").attr("disabled", "disabled");

	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=FRIENDSHIP_REQUEST&strUserID="+strUserID+"&toFriendID="+toFriendID,
		success: function(msg){
			if (msg == 1)
			{
				var txt = '<img src="../images/icons/check.png" width="64" height="64" border="0" alt="" align="absmiddle">Friend request is sent.<br />Waiting for the approval from the user.';
				alertBox(txt, false);
				$('#divFriends').hide('slow');
				$('#divBreakFriendship').html('');
				$('#divBreakFriendship').html('Approval Pending');
				//$('#divBreakFriendship').show('fast');
				$('#divBreakFriendship').css('display','inline');
			}
		}
	});
}

/***************************** My Comments Starts *************************************/
function saveMyCommentsSettings(v,m,f, strUserID)
{
	if (v)
	{
		var actionType = "SAVE_MY_COMMENTS_SETTINGS";
		var ObjForm = document.getElementById('myProfileCommentsSettings');
		var strData = ajaxPost(ObjForm);
		$.ajax({
			type: "POST",
			url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
			data: "actionType="+actionType+"&"+strData,
			success: function(msg)
			{
				if (msg == 'success')
				{
					var txt = '<img src="../images/icons/check.png" width="64" height="64" border="0" alt="" align="absmiddle">Comment Settings Updated Successfully.';
					alertBox(txt, false);
					getProfileMyCommentsSettings(strUserID);
				}
				else if (msg == 'errorSql')
				{
					var txt = "Error executing sql query.";
					alertBox(txt, true);
					getProfileMyCommentsSettings(strUserID);
				}
			}
		});
		jQuery.ImpromptuClose();
	}
}

function editMyCommentsSettings(strUserID)
{
	var txt = "";
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_MY_COMMENTS_SETTINGS_FORM&strUserID="+strUserID,
		success: function(msg){
			txt = msg;
			$.prompt(txt,{				
				buttons:{Ok:-1,Cancel:0},
				top:'10%',
				submit:function(v,m,f){					
					if(v == 0)
					{
						jQuery.ImpromptuClose();
					}
					else if(v == -1)
						saveMyCommentsSettings(v,m,f, strUserID);
					return false;
				}
			});	
		}
	});
}

function submitUserComments(strUserID)
{
	$('#btnComments').attr("disabled","disabled");
	var objUserComments = document.getElementById('frmUserComments');

	if(objUserComments.txtarUserComments.value == "")
	{
		var txt = '<img src="../images/icons/Help.png" width="64" height="64" border="0" alt="" align="absmiddle">Please enter the comment.';
		$.prompt(txt,{
			buttons:{Ok:-1},
			submit:function(v,m,f){
				if(v == -1)
				{
					jQuery.ImpromptuClose();
					$('#btnComments').removeAttr("disabled");
				}
				return false;
			}
		});
	}
	else
	{
		//var data = ajaxPost(objUserComments);
		var data = objUserComments.txtarUserComments.value;
		var actionType = "ADD_USER_COMMENTS";
		
		/*----- Replacing "&" with "and" ------ */
		replaceString = /&/g;
		data = data.replace(replaceString, "and");
		/* ----------- */

		$.ajax({
			type: "POST",
			url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
			data: "actionType="+actionType+"&strUserID="+strUserID+"&txtarUserComments="+data,
			success: function(msg){
				if (msg == 'success')
				{
					var txt = '<img src="../images/icons/check.png" width="64" height="64" border="0" alt="" align="absmiddle">Comment Added Successfully.';
					$.prompt(txt,{
						buttons:{Ok:-1},
						submit:function(v,m,f){
							if(v == -1)
							{
								jQuery.ImpromptuClose();
								getProfileMyCommentsSettings(strUserID);
							}
							return false;
						}
					});						
				}
				else if (msg == 'errorSql')
				{
					/*
					var txt = "Error executing sql query.";
					alertBox(txt, true);
					$('#btnComments').removeAttr("disabled");
					*/
					var txt = "Error executing sql query.";
					$.prompt(txt,{
						buttons:{Ok:-1},
						submit:function(v,m,f){
							if(v == -1)
							{
								jQuery.ImpromptuClose();
								$('#btnComments').removeAttr("disabled");
							}
							return false;
						}
					});
				}
			}
		});
	}
}

function getProfileMyCommentsSettings(strUserID, page)
{
	if (page == undefined)
	{
		page = 0;
	}

	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_MY_COMMENTS_SETTINGS&strUserID="+strUserID+"&page="+page,
		success: function(msg){
			$('#getProfileMyCommentsSettings').empty();
			$('#getProfileMyCommentsSettings').html(msg);

			edToolbar('txtarUserComments', 'edToolbar');
		}
	});
}
/***************************** My Comments Ends *************************************/
/***************************** My Settings Starts *************************************/
function saveMySettings(v,m,f, strUserID)
{
	if (v)
	{
		var actionType = "SAVE_MY_SETTINGS";
		var ObjForm = document.getElementById('myProfileMySettings');
		var flagPwd = true;

		objPassword = ObjForm.txtPassword;
		objConfPassword = ObjForm.txtConfPassword;

		if ( objPassword.value != "")
		{
			flagPwd = false;
			if ( objPassword.value.length < 8 )
			{
				var txt = '<img src="../images/icons/Help.png" width="64" height="64" border="0" alt="" align="absmiddle">Password value must be min 8 characters.';
				alertBox(txt, false);
			}
			else if ( objPassword.value != "" &&  objPassword.value !=  objConfPassword.value)
			{
				objPassword.value = "";
				objConfPassword.value = "";
				var txt = '<img src="../images/icons/Help.png" width="64" height="64" border="0" alt="" align="absmiddle">Password and Confirm Password values does not match.';
				alertBox(txt, false);
			}
			else
			{
				flagPwd = true;
			}
		}

		if (flagPwd)
		{
			//alert($('#cmbPhoneModel option:selected').text());

			var strData = ajaxPost(ObjForm);
			$.ajax({
				type: "POST",
				url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
				data: "actionType="+actionType+"&"+strData,
				success: function(msg)
				{
					if (msg == 'success')
					{
						var txt = '<img src="../images/icons/check.png" width="64" height="64" border="0" alt="" align="absmiddle">My Settings Updated Successfully.';
						alertBox(txt, false);
						getProfileMySettings(strUserID);
						getProfileMyInfoDetails(strUserID);
					}
					else if (msg == 'errorSql')
					{
						var txt = "Error executing sql query.";
						alertBox(txt, true);
						getProfileMySettings(strUserID);
					}
				}
			});
			jQuery.ImpromptuClose();
		}
	}
}

function editMySettings(strUserID)
{
	var txt = "";
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+ "myProfileAjax.php",
		data: "actionType=GET_MY_SETTINGS_FORM&strUserID="+strUserID,
		success: function(msg){
			txt = msg;
			$.prompt(txt,{
				buttons:{Ok:-1,Cancel:0},
				top:'10%',
				submit:function(v,m,f){					
					if(v == 0)
					{
						jQuery.ImpromptuClose();
					}
					else if(v == -1)
						saveMySettings(v,m,f, strUserID);
					return false;
				}
			});				
			//$('#txtDOB').datepicker();
		}		
	});	
}

$(function(){
	$('#txtDOB').datepicker({
			inline: false,
			dateFormat:'yy-mm-dd',
			changeMonth: true,
			changeYear: true,
			yearRange: '-80:+0'
	});
});

var chkValidate = false;

function showPhone(id)
{
	$("#divPhone").html($("#"+id).html());
	if (id == "divYourPhone")
	{
		chkValidate = false;
	}
	else
	{
		chkValidate = true;
	}
}
/***************************** My Settings Ends *************************************/

/**************************** Delete Comment **************************/
function deleteComment(obj, strUserID)
{
	var txt = "Are you sure you want to hide this comment?";
	$.prompt(txt,{		
		buttons:{Ok:-1,Cancel:0},
		submit:function(v,m,f){
			if(v == 0)
			{
				jQuery.ImpromptuClose();
			}
			else if(v == -1)
			{
				$.ajax({
					type: "POST",
					url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
					data: "actionType=REMOVE_COMMENT&itemID="+obj.id,
					success: function(msg){
						jQuery.ImpromptuClose();
						if (msg == '1')
						{
							var txt = '<img src="../images/icons/check.png" width="64" height="64" border="0" alt="" align="absmiddle">Comment hidden successfully!!!';
							alertBox(txt, false);
							getProfileMyCommentsSettings(strUserID);
						}
					}
				});
			}		
			return false;
		}
	});	
}

function showComment(obj, itemID, type)
{
	var txt = "Are you sure you want to show this comment visible?";
	$.prompt(txt,{		
		buttons:{Ok:-1,Cancel:0},
		submit:function(v,m,f){
			if(v == 0)
			{
				jQuery.ImpromptuClose();
			}
			else if(v == -1)
			{
				$.ajax({
					type: "POST",
					url:HTTP_SERVER+DIR_WS_HTTP+"ajaxDownloadSingle.php",
					data: "actionType=SHOW_COMMENT&itemID="+obj.id,
					success: function(msg){
						jQuery.ImpromptuClose();
						if (msg == '1')
						{
							var txt = '<img src="../images/icons/check.png" width="64" height="64" border="0" alt="" align="absmiddle">Comment is now visible';
							alertBox(txt, false);
							getProfileMyCommentsSettings(itemID, type);
						}
					}
				});
			}		
			return false;
		}
	});	
}

/************************************************ CustText Starts ************************************************/
function saveProfileCustText(v,m,f, strUserID)
{	
	if (v)
	{
		var actionType = "SAVE_PROFILE_CUST_TEXT";
		var ObjForm = document.getElementById('myProfileCustText');
		var strData = ajaxPost(ObjForm);
		$.ajax({
			type: "POST",
			url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
			data: "actionType="+actionType+"&"+strData,
			success: function(msg)
			{
				if (msg == 'success')
				{
					var txt = '<img src="../images/icons/check.png" width="64" height="64" border="0" alt="" align="absmiddle">My Custom Text Updated Successfully.';
					alertBox(txt, false);
					getProfileCustText(strUserID);
				}
				else if (msg == 'errorSql')
				{
					var txt = "Error executing sql query.";
					alertBox(txt, true);
					getProfileCustText(strUserID);
				}
			}
		});
		jQuery.ImpromptuClose();
	}
}

function editProfileCustTextSettings(strUserID)
{
	var txt = "";
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_PROFILE_CUST_TEXT_FORM&strUserID="+strUserID,
		success: function(msg){
			txt = msg;
			$.prompt(txt,{				
				buttons:{Ok:-1,Cancel:0},
				top:'10%',
				submit:function(v,m,f){					
					if(v == 0)
					{
						jQuery.ImpromptuClose();
					}
					else if(v == -1)
						saveProfileCustText(v,m,f, strUserID);
					return false;
				}
			});	
		}
	});
}

function getProfileCustText(strUserID)
{
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_PROFILE_CUST_TEXT&strUserID="+strUserID,
		success: function(msg){
			$('#getProfileCustText').empty();
			$('#getProfileCustText').html(msg);
		}
	});
}
/************************************************ CustText Ends ************************************************/
/************************************************ Copyrights Starts ************************************************/
function saveProfileCopyrights(v,m,f, strUserID)
{	
	if (v)
	{
		var actionType = "SAVE_PROFILE_COPYRIGHTS";
		var ObjForm = document.getElementById('myProfileCopyrights');
		var strData = ajaxPost(ObjForm);
		$.ajax({
			type: "POST",
			url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
			data: "actionType="+actionType+"&"+strData,
			success: function(msg)
			{
				if (msg == 'success')
				{
					var txt = '<img src="../images/icons/check.png" width="64" height="64" border="0" alt="" align="absmiddle">Copyright Updated Successfully.';
					alertBox(txt, false);
					getProfileCopyrights(strUserID);
				}
				else if (msg == 'errorSql')
				{
					var txt = "Error executing sql query.";
					alertBox(txt, true);
					getProfileCopyrights(strUserID);
				}
			}
		});
		jQuery.ImpromptuClose();
	}
}

function editProfileCopyrightsSettings(strUserID)
{
	var txt = "";
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_PROFILE_COPYRIGHTS_FORM&strUserID="+strUserID,
		success: function(msg){
			txt = msg;
			$.prompt(txt,{				
				buttons:{Ok:-1,Cancel:0},
				top:'10%',
				submit:function(v,m,f){					
					if(v == 0)
					{
						jQuery.ImpromptuClose();
					}
					else if(v == -1)
						saveProfileCopyrights(v,m,f, strUserID);
					return false;
				}
			});	
		}
	});
}

function getProfileCopyrights(strUserID)
{
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_PROFILE_COPYRIGHTS&strUserID="+strUserID,
		success: function(msg){
			$('#getProfileCopyrights').empty();
			$('#getProfileCopyrights').html(msg);
		}
	});
}
/************************************************ Copyrights Ends ************************************************/
/************************************************ UserCollections Starts ************************************************/

function saveProfileUserCollections(v,m,f, strUserID)
{	
	if (v)
	{
		var actionType = "SAVE_PROFILE_USERCOLLECTIONS";
		var ObjForm = document.getElementById('myProfileUserCollections');
		var strData = ajaxPost(ObjForm);
		$.ajax({
			type: "POST",
			url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
			data: "actionType="+actionType+"&"+strData,
			success: function(msg)
			{
				if (msg == 'success')
				{
					var txt = '<img src="../images/icons/check.png" width="64" height="64" border="0" alt="" align="absmiddle">Favourites Updated Successfully.';
					alertBox(txt, false);
					getProfileUserCollections(strUserID);
				}
				else if (msg == 'errorSql')
				{
					var txt = "Error executing sql query.";
					alertBox(txt, true);
					getProfileUserCollections(strUserID);
				}
			}
		});
		jQuery.ImpromptuClose();
	}
}

function editProfileUserCollectionsSettings(strUserID)
{
	var txt = "";
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_PROFILE_USERCOLLECTIONS_FORM&strUserID="+strUserID,
		success: function(msg){
			txt = msg;
			$.prompt(txt,{				
				buttons:{Ok:-1,Cancel:0},
				top:'10%',
				submit:function(v,m,f){					
					if(v == 0)
					{
						jQuery.ImpromptuClose();
					}
					else if(v == -1)
						saveProfileUserCollections(v,m,f, strUserID);
					return false;
				}
			});	
		}
	});
}

function getProfileUserCollections(strUserID)
{
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_PROFILE_USERCOLLECTIONS&strUserID="+strUserID,
		success: function(msg){
			$('#getProfileUserCollections').empty();
			$('#getProfileUserCollections').html(msg);
		}
	});
}
/************************************************ UserCollections Ends ************************************************/


/************************************************ UserAwards Starts ************************************************/

function saveProfileUserAwards(v,m,f, strUserID)
{	
	if (v)
	{
		var actionType = "SAVE_PROFILE_USERAWARDS";
		var ObjForm = document.getElementById('myProfileUserAwards');
		var strData = ajaxPost(ObjForm);
		$.ajax({
			type: "POST",
			url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
			data: "actionType="+actionType+"&"+strData,
			success: function(msg)
			{
				if (msg == 'success')
				{
					var txt = '<img src="../images/icons/check.png" width="64" height="64" border="0" alt="" align="absmiddle">Awards Updated Successfully.';
					alertBox(txt, false);
					getProfileUserAwards(strUserID);
				}
				else if (msg == 'errorSql')
				{
					var txt = "Error executing sql query.";
					alertBox(txt, true);
					getProfileUserAwards(strUserID);
				}
			}
		});
		jQuery.ImpromptuClose();
	}
}

function editProfileUserAwardsSettings(strUserID)
{
	var txt = "";
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_PROFILE_USERAWARDS_FORM&strUserID="+strUserID,
		success: function(msg){
			txt = msg;
			$.prompt(txt,{				
				buttons:{Ok:-1,Cancel:0},
				top:'10%',
				submit:function(v,m,f){					
					if(v == 0)
					{
						jQuery.ImpromptuClose();
					}
					else if(v == -1)
						saveProfileUserAwards(v,m,f, strUserID);
					return false;
				}
			});	
		}
	});
}

function getProfileUserAwards(strUserID)
{
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_PROFILE_USERAWARDS&strUserID="+strUserID,
		success: function(msg){
			$('#getProfileUserAwards').empty();
			$('#getProfileUserAwards').html(msg);
		}
	});
}
/************************************************ UserAwards Ends ************************************************/

/************************************************ AboutMe Starts ************************************************/
function saveProfileAboutMe(v,m,f, strUserID)
{
	if (v)
	{
		var actionType = "SAVE_PROFILE_ABOUTME";
		var ObjForm = document.getElementById('myProfileAboutMe');
		var strData = ajaxPost(ObjForm);
		$.ajax({
			type: "POST",
			url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
			data: "actionType="+actionType+"&"+strData,
			success: function(msg)
			{
				if (msg == 'success')
				{
					var txt = '<img src="../images/icons/check.png" width="64" height="64" border="0" alt="" align="absmiddle">About Me Updated Successfully.';
					alertBox(txt, false);
					getProfileAboutMe(strUserID);
				}
				else if (msg == 'errorSql')
				{
					var txt = "Error executing sql query.";
					alertBox(txt, true);
					getProfileAboutMe(strUserID);
				}
			}
		});
		jQuery.ImpromptuClose();
	}
}

function custSaveProfileAboutMe()
{
	var ObjForm = document.getElementById('myProfileAboutMe');
	var myIframe = document.getElementById('showAboutMeValue');	
	var content = myIframe.contentWindow.document.body.innerHTML;

	var rteContent = document.getElementById('rteContent');		
	rteContent.value = content;
	
	ObjForm.myProfileAboutMeActionType.value = 'SAVE_PROFILE_ABOUTME';	
	
	ObjForm.submit();
	return true;
}

function editProfileAboutMeSettings(strUserID)
{
	window.open (HTTP_SERVER + DIR_WS_HTTP + "editAboutMe.php", "mywindow", "menubar=0, resizable=0, status=0, scrollbars=0, toolbar=0, location=0, directories=0, width=950px, height=600px");
}

function getProfileAboutMe(strUserID)
{
	$.ajax({
		type: "POST",
		url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
		data: "actionType=GET_PROFILE_ABOUTME&strUserID="+strUserID,
		success: function(msg){
			$('#getProfileAboutMe').empty();
			$('#getProfileAboutMe').html(msg);

		}
	});
}
/************************************************ AboutMe Ends ************************************************/


function postReply(commentID, strUserID)
{
	var aa = $('#postReply').html();
	$('#postReply').html("");						

	$.prompt(aa,{
			buttons:{Ok:-1,Cancel:0},
			submit:function(v,m,f){
				if(v == 0)
				{
					$('#postReply').html(aa);
					jQuery.ImpromptuClose();
				}
				else if(v == -1)
				{
					jQuery.ImpromptuClose();
					var objUserComments = document.getElementById('frmPostCommentReply');

					if(objUserComments.txtarUserCommentsReply.value == "")
					{
						var txt = '<img src="'+DIR_WS_IMAGES+'icons/Help.png" width="64" height="64" border="0" alt="" align="absmiddle">Please enter the comment.';
						alertBox(txt, false);
					}
					else
					{
						//var data = ajaxPost(objUserComments);
						var data = objUserComments.txtarUserCommentsReply.value;
						var actionType = "ADD_USER_COMMENTS";

						/*----- Replacing "&" with "and" ------ */
						replaceString = /&/g;
						data = data.replace(replaceString, "and");
						/* ----------- */

						$.ajax({
							type: "POST",
							url:HTTP_SERVER+DIR_WS_HTTP+"myProfileAjax.php",
							data: "actionType="+actionType+"&strUserID="+strUserID+"&txtarUserComments="+data+"&parentID="+commentID.id,
							success: function(msg){
								if (msg == 'success')
								{
									var txt = '<img src="'+DIR_WS_IMAGES+'icons/check.png" width="64" height="64" border="0" alt="" align="absmiddle">Comment Added Successfully.';
									$.prompt(txt,{
										buttons:{Ok:-1},
										submit:function(v,m,f){
											if(v == -1)
											{
												jQuery.ImpromptuClose();
												getProfileMyCommentsSettings(strUserID);
											}
											return false;
										}
									});					
								}
								else if (msg == 'errorSql')
								{
									var txt = "Error executing sql query.";
									$.prompt(txt,{
										buttons:{Ok:-1},
										submit:function(v,m,f){
											if(v == -1)
											{
												jQuery.ImpromptuClose();
											}
											return false;
										}
									});
								}
							}
						});
					}
					$('#postReply').html(aa);
				}
				return false;
			}
		});
		$('.jqiclose').hide();
}