var global_key;
var global_key2;

function get_radio_value(field)
{
for (var i=0; i < field.length; i++)
   {
   if (field[i].checked)
      {
      var rad_val = field[i].value;
	  return rad_val;
      }
   }
}



function divert_forgot_password()
{
	if(get_radio_value(document.forgot_pass.role) == 'comm_member')
	return forgot_password();
	else
	return expert_forgot_password();
}

function divert_register()
{
	if(get_radio_value(document.regi.user_type) == 1)
	return registration();
	else
	return expert_registration();
}

function registration()
{
	if(xmlHttp==null)
	{
		var frmvalidator  = new Validator("regi");
		frmvalidator.addValidation("name","req","Please Enter Your Name");
		frmvalidator.addValidation("email","req","Please Enter Email Address");
		frmvalidator.addValidation("email","email","Please Enter Valid Email Address");
		frmvalidator.addValidation("username","req","Please Enter Your Username");
		frmvalidator.addValidation("password","req","Please Enter Your Password");
		frmvalidator.addValidation("cpassword","req","Please Enter Confirmation Password");
		frmvalidator.addValidation("captcha","req","Please Enter Captcha ccode");
		if(frmvalidator.validate() == true)
		{
			if(document.getElementById("password").value != document.getElementById("cpassword").value)
			{
				document.getElementById("err_cpassword").innerHTML="Password and confirmation Password should be same";
			}
			else if(document.getElementById("state").value == "")
			{
				document.getElementById("err_state").innerHTML="Please Select State";;
			}
			else if(document.getElementById("city").value == "")
			{
				document.getElementById("err_state").innerHTML="";;
				document.getElementById("err_city").innerHTML="Please Select City";;
			}
			else
			{
				document.getElementById("err_state").innerHTML="";;
				document.getElementById("err_city").innerHTML="";;
				var url="register.php?action=ajax&";
				url +=get_form_values(document.regi);
				xmlHttp=GetXmlHttpObject();
				xmlHttp.onreadystatechange=registration;
				xmlHttp.open("get",url,true);
				xmlHttp.send(null);
				document.getElementById("loader").style.display="block";
			}
		}
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("loader").style.display="none";
			var result=xmlHttp.responseText;
			if(result == 5)
			{
				alert("Please enter correct captcha code!");
			}
			else if(result == 0)
			{
				alert("Username already exist!");
			}
			else if(result == 1)
			{
				alert("Successfully Registered! Please check your EMail!");
				window.location.href="log_in.php";
			}
			else if(result == 2)
			{
				alert("Email Address already exist!");
			}
			else if(result == 3)
			{
				alert("Your Request has been sent for approval!");
				window.location.href="index.php";
			}
			else if(result == 4)
			{
				alert("Successfully Registered!");
				window.location.href="home.php";
			}
			else
			{
				ajax_error();
			}
			xmlHttp=null;
		}
	}
	return false;
}

function account()
{
	if(xmlHttp==null)
	{
		var frmvalidator  = new Validator("frm_account");
		frmvalidator.addValidation("name","req","Please Enter Your Name");
		if(frmvalidator.validate() == true)
		{
			if(document.getElementById("state").value == "")
			{
				document.getElementById("err_state").innerHTML="Please Select State";;
			}
			else if(document.getElementById("city").value == "")
			{
				document.getElementById("err_state").innerHTML="";;
				document.getElementById("err_city").innerHTML="Please Select City";;
			}
			else
			{
				document.getElementById("err_state").innerHTML="";;
				document.getElementById("err_city").innerHTML="";;
				var url="account.php?action=ajax&";
				url +=get_form_values(document.frm_account);
				xmlHttp=GetXmlHttpObject();
				xmlHttp.onreadystatechange=account;
				xmlHttp.open("get",url,true);
				xmlHttp.send(null);
				document.getElementById("loader").style.display="block";
			}
		}
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("loader").style.display="none";
			var result=xmlHttp.responseText;
			if(result == 1)
			{
				manage_top_msg_status("show","Successfully Updated!");
//				alert("Successfully Updated!");
			}
			else if(result == 2)
			{
				alert("Email Addrss already exist!");
			}
			else
			{
				ajax_error();
			}
			xmlHttp=null;
		}
	}
	return false;
}

function login()
{
	if(xmlHttp==null)
	{
		var frmvalidator  = new Validator("frm_login");
		frmvalidator.addValidation("login_username","req","Please Enter Your Username");
		frmvalidator.addValidation("login_password","req","Please Enter Your Password");
		if(frmvalidator.validate() == true)
		{
			var url="login.php?ajax=login&";
			url +=get_form_values(document.frm_login);
			if(document.getElementById("remember").checked)
			url +="remember="+document.getElementById("remember").value+"&";
			xmlHttp=GetXmlHttpObject();
			xmlHttp.onreadystatechange=login;
			xmlHttp.open("get",url,true);
			xmlHttp.send(null);
			document.getElementById("loader").innerHTML='Loading...'
		}
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("loader").innerHTML=''
			var result=xmlHttp.responseText;
			if(result == 0)
			{
				document.getElementById("loader").innerHTML="Invalid Login!";
			}
			else if(result == 1)
			{
				document.getElementById("loader").innerHTML="Login Success!";
				if(document.getElementById('role'))
				{
					if(document.getElementById('role').value=='comm_member')
					window.location.href="home.php";
					else
					window.location.href="expert_myaccount.php";
				}
				else
				{
					if(document.frm_login.role[0].checked)
					window.location.href="home.php";
					else
					window.location.href="expert_myaccount.php";
				}
			}
			else if(result == 2)
			{
				document.getElementById("loader").innerHTML="Login Blocked!";
				window.location.href="renew_account.php";
			}
			else
			{
				ajax_error();
			}
			xmlHttp=null;
		}
	}
	return false;
}

function logout()
{
	if(xmlHttp==null)
	{
		var url="login.php?ajax=logout&";
		xmlHttp=GetXmlHttpObject();
		xmlHttp.onreadystatechange=logout;
		xmlHttp.open("get",url,true);
		xmlHttp.send(null);
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			var result=xmlHttp.responseText;
			if(result == 1)
			{
				location.href="index.php";
			}
			else
			{
				ajax_error();
			}
			xmlHttp=null;
		}
	}
	return false;
}

function forgot_password()
{
	if(xmlHttp==null)
	{
		var frmvalidator  = new Validator("forgot_pass");
		frmvalidator.addValidation("email","req","Please Enter Email Address");
		frmvalidator.addValidation("email","email","Please Enter Valid Email Address");
		
		if(frmvalidator.validate() == true)
		{
			if(document.frm_login.role.length != undefined)
			{
				if(document.frm_login.role[0].checked)
				var url="password_forgotten.php?ajax=forgot_password&";
				else
				var url="expert_password_forgotten.php?ajax=forgot_password&";			
			}
			else
				var url="password_forgotten.php?ajax=forgot_password&";

			url +=get_form_values(document.forgot_pass);
			xmlHttp=GetXmlHttpObject();
			xmlHttp.onreadystatechange=forgot_password;
			xmlHttp.open("get",url,true);
			xmlHttp.send(null);
			document.getElementById("result").innerHTML="Loading...";
		}
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("result").innerHTML="";
			var result=xmlHttp.responseText;
			if(result == 0)
			{
				document.getElementById("result").innerHTML="Email Address is not found!";
			}
			else if(result == 1)
			{
				document.getElementById("result").innerHTML="Success! Your Password has been sent to your Email!";
//				clear_form_values(document.forgot_pass);
			}
			else if(result == 2)
			{
				document.getElementById("result").innerHTML="Success! Your Username has been sent to your Email!";
//				clear_form_values(document.forgot_pass);
			}
			else
			{
				ajax_error();
			}
			xmlHttp=null;
		}
	}
	return false;
}

function change_password()
{
	if(xmlHttp==null)
	{
		var frmvalidator  = new Validator("change_pass");
		frmvalidator.addValidation("old_password","req","Please Enter Old Username");
		frmvalidator.addValidation("new_password","req","Please Enter New Password");
		frmvalidator.addValidation("cnew_password","req","Please Enter Confirmation Password");
		if(frmvalidator.validate() == true)
		{
			if(document.getElementById("new_password").value != document.getElementById("cnew_password").value)
			{
				document.getElementById("err_cnew_password").innerHTML="Password and confirmation Password should be same";
			}
			else
			{
				var url="change_password.php?ajax=change_password&";
				url +=get_form_values(document.change_pass);
				xmlHttp=GetXmlHttpObject();
				xmlHttp.onreadystatechange=change_password;
				xmlHttp.open("get",url,true);
				xmlHttp.send(null);
				document.getElementById("result").innerHTML="Loading...";
			}
		}
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("result").innerHTML="";
			var result=xmlHttp.responseText;
			if(result == 0)
			{
				document.getElementById("result").innerHTML="Old Password is wrong!";
			}
			else if(result == 1)
			{
				document.getElementById("result").innerHTML="";
				manage_top_msg_status("show","Password has been changed successfully!");
				clear_form_values(document.forgot_pass);
			}
			else
			{
				ajax_error();
			}
			xmlHttp=null;
		}
	}
	return false;
}

// Forum section start here

function post_topic_reply(div_id)
{
	if(document.getElementById("div_post_topic"))
	document.getElementById("div_post_topic").style.display="none";
	if(document.getElementById("div_post_reply"))	
	document.getElementById("div_post_reply").style.display="none";
	if(div_id !='cancel')
	document.getElementById(div_id).style.display="block";
}

function post_topic()
{
		var frmvalidator  = new Validator("frm_post_topic");
		frmvalidator.addValidation("topic_topic","req","Please Enter Topic Name");
		frmvalidator.addValidation("topic_desc","req","Please Enter Descrption");
		return frmvalidator.validate();
}

function post_reply()
{
		var frmvalidator  = new Validator("frm_post_reply");
		frmvalidator.addValidation("reply_topic","req","Please Enter Topic Name");
		frmvalidator.addValidation("reply_desc","req","Please Enter Descrption");
		return frmvalidator.validate();
}

// Forum section end here


// Intramail Section start here

function intramail_paging(page)
{
	if(xmlHttp==null)
	{
		if(document.getElementById('div_intramail_compose').style.display == 'block')
		intramail_compose('cancel')
		document.getElementById('div_intramail').style.display='block';		
		document.getElementById('div_intramail_view').style.display='none';		
		var mail_type=document.frm_intramail.mail_type.value;
		var url="intramail.php?ajax=intramail_paging&mail_type="+mail_type+"&page="+page+"&";
		xmlHttp=GetXmlHttpObject();
		xmlHttp.onreadystatechange=intramail_paging;
		xmlHttp.open("get",url,true);
		xmlHttp.send(null);
		document.getElementById("intramail_loader").innerHTML="Loading...Please wait!";
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("intramail_loader").innerHTML="";
			var result=xmlHttp.responseText;
			xmlHttp=null;
			document.getElementById("div_intramail").innerHTML=result;
		}
	}
	return false;
}

function intramail_compose(task)
{
	if(task == 'compose')
	{
		document.getElementById('div_intramail').style.display='none';
		document.getElementById('div_intramail_compose').style.display='block';
	}
	else if(task == 'reply')
	{
		var reply_username=document.getElementById('view_username').innerHTML;
		var view_subject=document.getElementById('view_subject').innerHTML;		 
		document.getElementById('div_intramail').style.display='none';
		document.getElementById('div_intramail_compose').style.display='block';
		intramail_view('cancel');
		document.getElementById('mail_to').value=reply_username+",";
		document.getElementById('mail_subject').value="Re:"+view_subject;
	}
	else if(task == 'forward')
	{
		var reply_username=document.getElementById('view_username').innerHTML;
		var view_subject=document.getElementById('view_subject').innerHTML;		 
		var view_msg=document.getElementById('view_msg').innerHTML;		 
		document.getElementById('div_intramail').style.display='none';
		document.getElementById('div_intramail_compose').style.display='block';
		intramail_view('cancel');
//		document.getElementById('mail_to').value=reply_username+",";
		document.getElementById('mail_subject').value=view_subject;
	}
	else if(task == 'cancel')
	{
		document.getElementById('mail_to').value='';
		document.getElementById('mail_subject').value='';
		document.getElementById('div_intramail').style.display='block';
		document.getElementById('div_intramail_compose').style.display='none';
	}
	else if(task == 'send')
	{
		var frmvalidator  = new Validator("frm_intramail_compose");
		frmvalidator.addValidation("mail_to","req","Please Enter Recipient");
		frmvalidator.addValidation("mail_subject","req","Please Enter Mail Subject");
		frmvalidator.addValidation("mail_msg","req","Please Enter Message");
		if(frmvalidator.validate()==true)
		{
		document.frm_intramail_compose.mail_to.disabled=false;
		return true;
		}
		else
		return false;
	}
}

function intramail_import(task)
{
	if(task == 'import')
	{
		var max_import=document.getElementById('max_import').value;
		var mail_to='';
		for(var i=1;i<=max_import;i++)
		{
			if(document.getElementById('box_import_'+i).checked==true)
			mail_to+=document.getElementById('name_import_'+i).innerHTML+',';
		}
		document.getElementById('mail_to').value+=mail_to;
		intramail_import('cancel');
		return false;
	}
	else if(task == 'cancel')
	{
		document.getElementById("div_import").innerHTML='';
		document.getElementById("div_import").style.display='none';
		return false;
	}
	if(xmlHttp==null)
	{
		var url="intramail.php?ajax=intramail_import&";
		xmlHttp=GetXmlHttpObject();
		xmlHttp.onreadystatechange=intramail_import;
		xmlHttp.open("get",url,true);
		xmlHttp.send(null);
		document.getElementById("import_loader").innerHTML="Loading..."
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("import_loader").innerHTML=""
			var result=xmlHttp.responseText;
			xmlHttp=null;
			document.getElementById("div_import").style.display='block';
			document.getElementById("div_import").innerHTML=result;
		}
	}
}

function intramail_delete(task)
{
	if(xmlHttp==null)
	{
		global_key=task;
		var check=check_checkbox(document.frm_intramail.mail_delete);
		if(check[0]==false)
		{
			return false;
		}
		if(task == "intramail_trash")
		var confirm_txt="Are you sure to move to trash?";
		else
		var confirm_txt="Are you sure to delete it permanently?";
		
		if(!confirm(confirm_txt))
		{
			return false;
		}
		var mail_type=document.frm_intramail.mail_type.value;
		var url="intramail.php?ajax="+task+"&mail_type="+mail_type;
		url+="&mail_delete="+check[1];
		xmlHttp=GetXmlHttpObject();
		xmlHttp.onreadystatechange=intramail_delete;
		xmlHttp.open("get",url,true);
		xmlHttp.send(null);
		document.getElementById("intramail_loader").innerHTML="Loading...Please wait!";
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("intramail_loader").innerHTML="";
			var result=xmlHttp.responseText;
			xmlHttp=null;
			if(global_key == "intramail_trash")
			manage_top_msg_status("show","Successfully trshed!");			
			else if(global_key == "intramail_delete")
			manage_top_msg_status("show","Successfully deleted!")			
			intramail_paging(1);
		}
	}
	return false;
}


function intramail_view(mail_id)
{
	if(mail_id == 'cancel')
	{
		document.getElementById("div_intramail_view_details").innerHTML="";
		document.getElementById("div_intramail_view").style.display='none';
		return false;
	}
	if(xmlHttp==null)
	{
		var mail_type=document.frm_intramail.mail_type.value;
		var url="intramail.php?ajax=intramail_view&mail_id="+mail_id+"&mail_type="+mail_type;
		xmlHttp=GetXmlHttpObject();
		xmlHttp.onreadystatechange=intramail_view;
		xmlHttp.open("get",url,true);
		xmlHttp.send(null);
		document.getElementById("div_intramail").style.display='none';
		document.getElementById("div_intramail_view").style.display='block';
		document.getElementById("div_intramail_view_details").innerHTML="<span class=err>Loading...</span>";
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("div_intramail_view_details").innerHTML="";
			var result=xmlHttp.responseText;
			xmlHttp=null;
			document.getElementById("div_intramail_view_details").innerHTML=result;
		}
	}
	return false;
}

// Intramail Section end here


function showUser(str)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url="getuser.php"
url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("get",url,true)
xmlHttp.send(null)
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("txtHint").innerHTML=xmlHttp.responseText 
 xmlHttp=null;
 } 
}


function show_per_page(per_page)
{
  xmlHttp=GetXmlHttpObject()
  if (xmlHttp==null)
  {
	 alert ("Browser does not support HTTP Request")
	 return
  }
  var url="browse.php"
  url=url+"?ajax_page=ajax_page&per_page="+per_page
  alert(url);
  xmlHttp.onreadystatechange=stateChanged_per_page 
  xmlHttp.open("get",url,true)
  xmlHttp.send(null)
}

function stateChanged_per_page() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
  var result = xmlHttp.responseText;
  //alert(result);
  } 
}

function search_friends(page)
{
	var keywords=document.getElementById("keywords").value;
	var sort_by=document.getElementById("sort_by").value;
	
	if(keywords != "")
	{
		common_paging("search.php",page,"keywords="+keywords+"&sort_by="+sort_by);
	}
	else
	{
		document.getElementById("paging_result").innerHTML="Enter Keywords!";		
	}
	return false;
}


function send_friends_request(reciever)
{
	if(xmlHttp == null)
	{
		var url="https://unitedmingle.com/member.php?ajax=friends_request&reciever="+reciever;
		xmlHttp=GetXmlHttpObject();
		xmlHttp.onreadystatechange=send_friends_request;
		xmlHttp.open("get",url,true);
		xmlHttp.send(null);
		document.getElementById('loader_request').style.display='block';
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById('loader_request').style.display='none';
			var result=xmlHttp.responseText;
			if(result == 1)
			{
				manage_top_msg_status("show","Friend request sent");
//				document.getElementById("link_request").innerHTML="<span class=err>Request Sent!</span>";
			}
			else if(result == 2)
			{
				manage_top_msg_status("show","Friend request remainder sent");
//				document.getElementById("link_request").innerHTML="<span class=err>Remainder Sent!</span>";
			}
			else
			{
				ajax_error();
			}
			xmlHttp=null;
		}
	}
}

function manage_request_for_you(task,id)
{
	if(xmlHttp == null)
	{
		global_key=id;
		global_key2=task;
		var url="friends_request.php?ajax=manage_request_for_you&task="+task+"&id="+id;
		xmlHttp=GetXmlHttpObject();
		xmlHttp.onreadystatechange=manage_request_for_you;
		xmlHttp.open("get",url,true);
		xmlHttp.send(null);
		document.getElementById('for_loading_'+id).innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			if(global_key2 == "accept")
			document.getElementById('status_for_you_'+global_key).innerHTML="Accepted";
			else
			document.getElementById('status_for_you_'+global_key).innerHTML="Rejected";
			var result=xmlHttp.responseText;
			xmlHttp=null;
		}
	}
	return false;
}

function manage_request_from_you(task,id)
{
	if(xmlHttp == null)
	{
		global_key=id;
		global_key2=task;
		var url="friends_request.php?ajax=manage_request_from_you&task="+task+"&id="+id;
		xmlHttp=GetXmlHttpObject();
		xmlHttp.onreadystatechange=manage_request_from_you;
		xmlHttp.open("get",url,true);
		xmlHttp.send(null);
		document.getElementById('from_loading_'+id).innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			if(global_key2 == "remaind")
			{
				manage_top_msg_status("show","Friend request remainder sent");
				document.getElementById('status_from_you_'+global_key).innerHTML="";
			}
			else
			{
				manage_top_msg_status("show","Friend request cancelled");
				document.getElementById('status_from_you_'+global_key).innerHTML="";
			}
			var result=xmlHttp.responseText;
			xmlHttp=null;
		}
	}
	return false;
}

function quick_message(id,task)
{
	if(xmlHttp == null)
	{
		if(task=='send')
		{
			var message=document.getElementById("message").value;
			if(message != "")
			{
				var url="https://unitedmingle.com/member.php?ajax=quick_message&id="+id+"&message="+escape(message);
				xmlHttp=GetXmlHttpObject();
				xmlHttp.onreadystatechange=quick_message;
				xmlHttp.open("get",url,true);
				xmlHttp.send(null);
				document.getElementById('quick_loader').innerHTML="<img src='"+HTTP_HOST+"images/loader.gif' border=0>";
			}
		}
		else
		{
			if(document.getElementById('quick_div').style.display=='none')
			document.getElementById('quick_div').style.display='block';
			else
			document.getElementById('quick_div').style.display='none'			
		}
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById('quick_loader').innerHTML="Sent";
			document.getElementById("message").value="";
			var result=xmlHttp.responseText;
			xmlHttp=null;
		}
	}
	return false;
}

var xmlHttp_privacy_profile=null;

function manage_privacy_profile(privacy_profile)
{
	if(xmlHttp_privacy_profile == null)
	{
		var url="privacy_settings.php?ajax=manage_privacy_profile&privacy_profile="+privacy_profile;
		xmlHttp_privacy_profile=GetXmlHttpObject();
		xmlHttp_privacy_profile.onreadystatechange=manage_privacy_profile;
		xmlHttp_privacy_profile.open("get",url,true);
		xmlHttp_privacy_profile.send(null);
		document.getElementById('loading_privacy_profile').innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp_privacy_profile.readyState==4)
		{ 
			document.getElementById('loading_privacy_profile').innerHTML="Updated!";
			var result=xmlHttp_privacy_profile.responseText;
			xmlHttp_privacy_profile=null;
			setTimeout("document.getElementById('loading_privacy_profile').innerHTML=''",3000);
		}
	}
}

var xmlHttp_privacy_connection=null;

function manage_privacy_connection(privacy_connection)
{
	if(xmlHttp_privacy_connection == null)
	{
		var url="privacy_settings.php?ajax=manage_privacy_connection&privacy_connection="+privacy_connection;
		xmlHttp_privacy_connection=GetXmlHttpObject();
		xmlHttp_privacy_connection.onreadystatechange=manage_privacy_connection;
		xmlHttp_privacy_connection.open("get",url,true);
		xmlHttp_privacy_connection.send(null);
		document.getElementById('loading_privacy_connection').innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp_privacy_connection.readyState==4)
		{ 
			document.getElementById('loading_privacy_connection').innerHTML="Updated!";
			var result=xmlHttp_privacy_connection.responseText;
			xmlHttp_privacy_connection=null;
			setTimeout("document.getElementById('loading_privacy_connection').innerHTML=''",3000);
		}
	}
}

var xmlHttp_privacy_profileview=null;

function manage_privacy_profileview(privacy_profileview)
{
	if(xmlHttp_privacy_profileview == null)
	{
		var url="privacy_settings.php?ajax=manage_privacy_profileview&privacy_profileview="+privacy_profileview;
		xmlHttp_privacy_profileview=GetXmlHttpObject();
		xmlHttp_privacy_profileview.onreadystatechange=manage_privacy_profileview;
		xmlHttp_privacy_profileview.open("get",url,true);
		xmlHttp_privacy_profileview.send(null);
		document.getElementById('loading_privacy_profileview').innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp_privacy_profileview.readyState==4)
		{ 
			document.getElementById('loading_privacy_profileview').innerHTML="Updated!";
			var result=xmlHttp_privacy_profileview.responseText;
			xmlHttp_privacy_profileview=null;
			setTimeout("document.getElementById('loading_privacy_profileview').innerHTML=''",3000);
		}
	}
}

var xmlHttp_privacy_music=null;

function manage_privacy_music(privacy_music)
{
	if(xmlHttp_privacy_music == null)
	{
		var url="privacy_settings.php?ajax=manage_privacy_music&privacy_music="+privacy_music;
		xmlHttp_privacy_music=GetXmlHttpObject();
		xmlHttp_privacy_music.onreadystatechange=manage_privacy_music;
		xmlHttp_privacy_music.open("get",url,true);
		xmlHttp_privacy_music.send(null);
		document.getElementById('loading_privacy_music').innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp_privacy_music.readyState==4)
		{ 
			document.getElementById('loading_privacy_music').innerHTML="Updated!";
			var result=xmlHttp_privacy_music.responseText;
			xmlHttp_privacy_music=null;
			setTimeout("document.getElementById('loading_privacy_music').innerHTML=''",3000);
		}
	}
}

var xmlHttp_privacy_online=null;

function manage_privacy_online(privacy_online)
{
	if(xmlHttp_privacy_online == null)
	{
		var url="privacy_settings.php?ajax=manage_privacy_online&privacy_online="+privacy_online;
		xmlHttp_privacy_online=GetXmlHttpObject();
		xmlHttp_privacy_online.onreadystatechange=manage_privacy_online;
		xmlHttp_privacy_online.open("get",url,true);
		xmlHttp_privacy_online.send(null);
		document.getElementById('loading_privacy_online').innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp_privacy_online.readyState==4)
		{ 
			document.getElementById('loading_privacy_online').innerHTML="Updated!";
			var result=xmlHttp_privacy_online.responseText;
			xmlHttp_privacy_online=null;
			setTimeout("document.getElementById('loading_privacy_online').innerHTML=''",3000);
		}
	}
}

var xmlHttp_privacy_comment=null;

function manage_privacy_comment(privacy_comment)
{
	if(xmlHttp_privacy_comment == null)
	{
		var url="privacy_settings.php?ajax=manage_privacy_comment&privacy_comment="+privacy_comment;
		xmlHttp_privacy_comment=GetXmlHttpObject();
		xmlHttp_privacy_comment.onreadystatechange=manage_privacy_comment;
		xmlHttp_privacy_comment.open("get",url,true);
		xmlHttp_privacy_comment.send(null);
		document.getElementById('loading_privacy_comment').innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp_privacy_comment.readyState==4)
		{ 
			document.getElementById('loading_privacy_comment').innerHTML="Updated!";
			var result=xmlHttp_privacy_comment.responseText;
			xmlHttp_privacy_comment=null;
			setTimeout("document.getElementById('loading_privacy_comment').innerHTML=''",3000);
		}
	}
}

var xmlHttp_comment_approval=null;

function manage_comment_approval(comment_approval)
{
	if(xmlHttp_comment_approval == null)
	{
		var url="privacy_settings.php?ajax=manage_comment_approval&comment_approval="+comment_approval;
		xmlHttp_comment_approval=GetXmlHttpObject();
		xmlHttp_comment_approval.onreadystatechange=manage_comment_approval;
		xmlHttp_comment_approval.open("get",url,true);
		xmlHttp_comment_approval.send(null);
		document.getElementById('loading_comment_approval').innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp_comment_approval.readyState==4)
		{ 
			document.getElementById('loading_comment_approval').innerHTML="Updated!";
			var result=xmlHttp_comment_approval.responseText;
			xmlHttp_comment_approval=null;
			setTimeout("document.getElementById('loading_comment_approval').innerHTML=''",3000);
		}
	}
}

var global_key2;

function manage_photo(task,member,id,folder_id)
{
	if(xmlHttp == null)
	{
		global_key=member;
		if(task == "delete")
		{
			global_key2=folder_id;
			if(confirm("Are you sure to delete?"))
			{
				var url="photo.php?ajax=manage_photo&task="+task+"&id="+id;
				xmlHttp=GetXmlHttpObject();
				xmlHttp.onreadystatechange=manage_photo;
				xmlHttp.open("get",url,true);
				xmlHttp.send(null);
				document.getElementById('paging_result').innerHTML="Deleting...";
			}
		}
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById('paging_result').innerHTML="";
			var result=xmlHttp.responseText;
			xmlHttp=null;
			if(global_key2 == 0)
			common_paging("manage_folders.php",1);
			else
			common_paging("manage_photo.php",1,"id="+global_key+"&folder_id="+global_key2);
			manage_top_msg_status("show","Image Successfully Deleted!");
//			else
//			window.location.reload( true );
		}
	}
}

function manage_left(key,key2)
{
	var display=document.getElementById("left_"+key).style.display;
	if(display == "block")
	{
		var new_display="none";
		if(key2 ==1 )
		var html='<img src="'+HTTP_HOST+'images/arrow11.gif" border="0">';
		else
		var html='<img src="'+HTTP_HOST+'images/arrow1.gif" border="0">';
	}
	else
	{
		var new_display="block";
		if(key2 ==1 )
		var html='<img src="'+HTTP_HOST+'images/arrow22.gif" border="0">';
		else
		var html='<img src="'+HTTP_HOST+'images/arrow2.gif" border="0">';		
	}
	document.getElementById("left_link_"+key).innerHTML=html;
	document.getElementById("left_"+key).style.display=new_display;
}

function post_comment()
{
		var frmvalidator  = new Validator("frm_comment");
		frmvalidator.addValidation("comment","req","Please Enter Your Comment");
		return frmvalidator.validate();
}



// start notification for contact settings
var xmlHttp_notification_contact_friend=null;

function manage_notification_contact_friend(notification,notification_contact_friend)
{
	if(xmlHttp_notification_contact_friend== null)
	{
		var url="notification_contacts_settings.php?ajax=manage_notification_contacts_settings&notification_contact_friend="+notification_contact_friend+"&notification="+notification;
		xmlHttp_notification_contact_friend=GetXmlHttpObject();
		xmlHttp_notification_contact_friend.onreadystatechange=manage_notification_contact_friend;
		xmlHttp_notification_contact_friend.open("get",url,true);
		xmlHttp_notification_contact_friend.send(null);
		document.getElementById('loading_notification_contact_friend').innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp_notification_contact_friend.readyState==4)
		{ 
			document.getElementById('loading_notification_contact_friend').innerHTML="Updated!";
			var result=xmlHttp_notification_contact_friend.responseText;
			xmlHttp_notification_contact_friend=null;
			setTimeout("document.getElementById('loading_notification_contact_friend').innerHTML=''",3000);
		}
	}
}

var xmlHttp_notification_contact_comment_music=null;

function manage_notification_contact_comment_music(notification,notification_contact_comment_music)
{
	if(xmlHttp_notification_contact_comment_music== null)
	{
		var url="notification_contacts_settings.php?ajax=manage_notification_contacts_settings&notification_contact_comment_music="+notification_contact_comment_music+"&notification="+notification;
		xmlHttp_notification_contact_comment_music=GetXmlHttpObject();
		xmlHttp_notification_contact_comment_music.onreadystatechange=manage_notification_contact_comment_music;
		xmlHttp_notification_contact_comment_music.open("get",url,true);
		xmlHttp_notification_contact_comment_music.send(null);
		document.getElementById('loading_notification_contact_comment_music').innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp_notification_contact_comment_music.readyState==4)
		{ 
			document.getElementById('loading_notification_contact_comment_music').innerHTML="Updated!";
			var result=xmlHttp_notification_contact_comment_music.responseText;
			xmlHttp_notification_contact_comment_music=null;
			setTimeout("document.getElementById('loading_notification_contact_comment_music').innerHTML=''",3000);
		}
	}
}

var xmlHttp_notification_contact_comment_image=null;

function manage_notification_contact_comment_image(notification,notification_contact_comment_image)
{
	if(xmlHttp_notification_contact_comment_image== null)
	{
		var url="notification_contacts_settings.php?ajax=manage_notification_contacts_settings&notification_contact_comment_image="+notification_contact_comment_image+"&notification="+notification;
		xmlHttp_notification_contact_comment_image=GetXmlHttpObject();
		xmlHttp_notification_contact_comment_image.onreadystatechange=manage_notification_contact_comment_image;
		xmlHttp_notification_contact_comment_image.open("get",url,true);
		xmlHttp_notification_contact_comment_image.send(null);
		document.getElementById('loading_notification_contact_comment_image').innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp_notification_contact_comment_image.readyState==4)
		{ 
			document.getElementById('loading_notification_contact_comment_image').innerHTML="Updated!";
			var result=xmlHttp_notification_contact_comment_image.responseText;
			xmlHttp_notification_contact_comment_image=null;
			setTimeout("document.getElementById('loading_notification_contact_comment_image').innerHTML=''",3000);
		}
	}
}

var xmlHttp_notification_contact_comment_profile=null;

function manage_notification_contact_comment_profile(notification,notification_contact_comment_profile)
{
	if(xmlHttp_notification_contact_comment_profile== null)
	{
		var url="notification_contacts_settings.php?ajax=manage_notification_contacts_settings&notification_contact_comment_profile="+notification_contact_comment_profile+"&notification="+notification;
		xmlHttp_notification_contact_comment_profile=GetXmlHttpObject();
		xmlHttp_notification_contact_comment_profile.onreadystatechange=manage_notification_contact_comment_profile;
		xmlHttp_notification_contact_comment_profile.open("get",url,true);
		xmlHttp_notification_contact_comment_profile.send(null);
		document.getElementById('loading_notification_contact_comment_profile').innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp_notification_contact_comment_profile.readyState==4)
		{ 
			document.getElementById('loading_notification_contact_comment_profile').innerHTML="Updated!";
			var result=xmlHttp_notification_contact_comment_profile.responseText;
			xmlHttp_notification_contact_comment_profile=null;
			setTimeout("document.getElementById('loading_notification_contact_comment_profile').innerHTML=''",3000);
		}
	}
}

var xmlHttp_notification_contact_autobook=null;

function manage_notification_contact_autobook(notification,notification_contact_autobook)
{
	if(xmlHttp_notification_contact_autobook== null)
	{
		var url="notification_contacts_settings.php?ajax=manage_notification_contacts_settings&notification_contact_autobook="+notification_contact_autobook+"&notification="+notification;
		xmlHttp_notification_contact_autobook=GetXmlHttpObject();
		xmlHttp_notification_contact_autobook.onreadystatechange=manage_notification_contact_autobook;
		xmlHttp_notification_contact_autobook.open("get",url,true);
		xmlHttp_notification_contact_autobook.send(null);
		document.getElementById('loading_notification_contact_autobook').innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp_notification_contact_autobook.readyState==4)
		{ 
			document.getElementById('loading_notification_contact_autobook').innerHTML="Updated!";
			var result=xmlHttp_notification_contact_autobook.responseText;
			xmlHttp_notification_contact_autobook=null;
			setTimeout("document.getElementById('loading_notification_contact_autobook').innerHTML=''",3000);
		}
	}
}

var xmlHttp_notification_contact_event_post=null;

function manage_notification_contact_event_post(notification,notification_contact_event_post)
{
	if(xmlHttp_notification_contact_event_post== null)
	{
		var url="notification_contacts_settings.php?ajax=manage_notification_contacts_settings&notification_contact_event_post="+notification_contact_event_post+"&notification="+notification;
		xmlHttp_notification_contact_event_post=GetXmlHttpObject();
		xmlHttp_notification_contact_event_post.onreadystatechange=manage_notification_contact_event_post;
		xmlHttp_notification_contact_event_post.open("get",url,true);
		xmlHttp_notification_contact_event_post.send(null);
		document.getElementById('loading_notification_contact_event_post').innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp_notification_contact_event_post.readyState==4)
		{ 
			document.getElementById('loading_notification_contact_event_post').innerHTML="Updated!";
			var result=xmlHttp_notification_contact_event_post.responseText;
			xmlHttp_notification_contact_event_post=null;
			setTimeout("document.getElementById('loading_notification_contact_event_post').innerHTML=''",3000);
		}
	}
}

var xmlHttp_notification_contact_image_post=null;

function manage_notification_contact_image_post(notification,notification_contact_image_post)
{
	if(xmlHttp_notification_contact_image_post== null)
	{
		var url="notification_contacts_settings.php?ajax=manage_notification_contacts_settings&notification_contact_image_post="+notification_contact_image_post+"&notification="+notification;
		xmlHttp_notification_contact_image_post=GetXmlHttpObject();
		xmlHttp_notification_contact_image_post.onreadystatechange=manage_notification_contact_image_post;
		xmlHttp_notification_contact_image_post.open("get",url,true);
		xmlHttp_notification_contact_image_post.send(null);
		document.getElementById('loading_notification_contact_image_post').innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp_notification_contact_image_post.readyState==4)
		{ 
			document.getElementById('loading_notification_contact_image_post').innerHTML="Updated!";
			var result=xmlHttp_notification_contact_image_post.responseText;
			xmlHttp_notification_contact_image_post=null;
			setTimeout("document.getElementById('loading_notification_contact_image_post').innerHTML=''",3000);
		}
	}
}

var xmlHttp_notification_contact_music_post=null;

function manage_notification_contact_music_post(notification,notification_contact_music_post)
{
	if(xmlHttp_notification_contact_music_post== null)
	{
		var url="notification_contacts_settings.php?ajax=manage_notification_contacts_settings&notification_contact_music_post="+notification_contact_music_post+"&notification="+notification;
		xmlHttp_notification_contact_music_post=GetXmlHttpObject();
		xmlHttp_notification_contact_music_post.onreadystatechange=manage_notification_contact_music_post;
		xmlHttp_notification_contact_music_post.open("get",url,true);
		xmlHttp_notification_contact_music_post.send(null);
		document.getElementById('loading_notification_contact_music_post').innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp_notification_contact_music_post.readyState==4)
		{ 
			document.getElementById('loading_notification_contact_music_post').innerHTML="Updated!";
			var result=xmlHttp_notification_contact_music_post.responseText;
			xmlHttp_notification_contact_music_post=null;
			setTimeout("document.getElementById('loading_notification_contact_music_post').innerHTML=''",3000);
		}
	}
}


// end notification for contact settings

// start notification for Receive message
var xmlHttp_notification_receive_friend=null;

function manage_notification_receive_friend(notification,notification_receive_friend)
{
	if(xmlHttp_notification_receive_friend== null)
	{
		var url="notification_receive_messages.php?ajax=manage_notification_receive_messages&notification_receive_friend="+notification_receive_friend+"&notification="+notification;
		xmlHttp_notification_receive_friend=GetXmlHttpObject();
		xmlHttp_notification_receive_friend.onreadystatechange=manage_notification_receive_friend;
		xmlHttp_notification_receive_friend.open("get",url,true);
		xmlHttp_notification_receive_friend.send(null);
		document.getElementById('loading_notification_receive_friend').innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp_notification_receive_friend.readyState==4)
		{ 
			document.getElementById('loading_notification_receive_friend').innerHTML="Updated!";
			var result=xmlHttp_notification_receive_friend.responseText;
			xmlHttp_notification_receive_friend=null;
			setTimeout("document.getElementById('loading_notification_receive_friend').innerHTML=''",3000);
		}
	}
}

var xmlHttp_notification_receive_message=null;

function manage_notification_receive_message(notification,notification_receive_message)
{
	if(xmlHttp_notification_receive_message== null)
	{
		var url="notification_receive_messages.php?ajax=manage_notification_receive_messages&notification_receive_message="+notification_receive_message+"&notification="+notification;
		xmlHttp_notification_receive_message=GetXmlHttpObject();
		xmlHttp_notification_receive_message.onreadystatechange=manage_notification_receive_message;
		xmlHttp_notification_receive_message.open("get",url,true);
		xmlHttp_notification_receive_message.send(null);
		document.getElementById('loading_notification_receive_message').innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp_notification_receive_message.readyState==4)
		{ 
			document.getElementById('loading_notification_receive_message').innerHTML="Updated!";
			var result=xmlHttp_notification_receive_message.responseText;
			xmlHttp_notification_receive_message=null;
			setTimeout("document.getElementById('loading_notification_receive_message').innerHTML=''",3000);
		}
	}
}

var xmlHttp_notification_receive_comment_music=null;

function manage_notification_receive_comment_music(notification,notification_receive_comment_music)
{
	if(xmlHttp_notification_receive_comment_music== null)
	{
		var url="notification_receive_messages.php?ajax=manage_notification_receive_messages&notification_receive_comment_music="+notification_receive_comment_music+"&notification="+notification;
		xmlHttp_notification_receive_comment_music=GetXmlHttpObject();
		xmlHttp_notification_receive_comment_music.onreadystatechange=manage_notification_receive_comment_music;
		xmlHttp_notification_receive_comment_music.open("get",url,true);
		xmlHttp_notification_receive_comment_music.send(null);
		document.getElementById('loading_notification_receive_comment_music').innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp_notification_receive_comment_music.readyState==4)
		{ 
			document.getElementById('loading_notification_receive_comment_music').innerHTML="Updated!";
			var result=xmlHttp_notification_receive_comment_music.responseText;
			xmlHttp_notification_receive_comment_music=null;
			setTimeout("document.getElementById('loading_notification_receive_comment_music').innerHTML=''",3000);
		}
	}
}

var xmlHttp_notification_receive_comment_image=null;

function manage_notification_receive_comment_image(notification,notification_receive_comment_image)
{
	if(xmlHttp_notification_receive_comment_image== null)
	{
		var url="notification_receive_messages.php?ajax=manage_notification_receive_messages&notification_receive_comment_image="+notification_receive_comment_image+"&notification="+notification;
		xmlHttp_notification_receive_comment_image=GetXmlHttpObject();
		xmlHttp_notification_receive_comment_image.onreadystatechange=manage_notification_receive_comment_image;
		xmlHttp_notification_receive_comment_image.open("get",url,true);
		xmlHttp_notification_receive_comment_image.send(null);
		document.getElementById('loading_notification_receive_comment_image').innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp_notification_receive_comment_image.readyState==4)
		{ 
			document.getElementById('loading_notification_receive_comment_image').innerHTML="Updated!";
			var result=xmlHttp_notification_receive_comment_image.responseText;
			xmlHttp_notification_receive_comment_image=null;
			setTimeout("document.getElementById('loading_notification_receive_comment_image').innerHTML=''",3000);
		}
	}
}

var xmlHttp_notification_receive_comment_profile=null;

function manage_notification_receive_comment_profile(notification,notification_receive_comment_profile)
{
	if(xmlHttp_notification_receive_comment_profile== null)
	{
		var url="notification_receive_messages.php?ajax=manage_notification_receive_messages&notification_receive_comment_profile="+notification_receive_comment_profile+"&notification="+notification;
		xmlHttp_notification_receive_comment_profile=GetXmlHttpObject();
		xmlHttp_notification_receive_comment_profile.onreadystatechange=manage_notification_receive_comment_profile;
		xmlHttp_notification_receive_comment_profile.open("get",url,true);
		xmlHttp_notification_receive_comment_profile.send(null);
		document.getElementById('loading_notification_receive_comment_profile').innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp_notification_receive_comment_profile.readyState==4)
		{ 
			document.getElementById('loading_notification_receive_comment_profile').innerHTML="Updated!";
			var result=xmlHttp_notification_receive_comment_profile.responseText;
			xmlHttp_notification_receive_comment_profile=null;
			setTimeout("document.getElementById('loading_notification_receive_comment_profile').innerHTML=''",3000);
		}
	}
}

var xmlHttp_notification_receive_autobook=null;

function manage_notification_receive_autobook(notification,notification_receive_autobook)
{
	if(xmlHttp_notification_receive_autobook== null)
	{
		var url="notification_receive_messages.php?ajax=manage_notification_receive_messages&notification_receive_autobook="+notification_receive_autobook+"&notification="+notification;
		xmlHttp_notification_receive_autobook=GetXmlHttpObject();
		xmlHttp_notification_receive_autobook.onreadystatechange=manage_notification_receive_autobook;
		xmlHttp_notification_receive_autobook.open("get",url,true);
		xmlHttp_notification_receive_autobook.send(null);
		document.getElementById('loading_notification_receive_autobook').innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp_notification_receive_autobook.readyState==4)
		{ 
			document.getElementById('loading_notification_receive_autobook').innerHTML="Updated!";
			var result=xmlHttp_notification_receive_autobook.responseText;
			xmlHttp_notification_receive_autobook=null;
			setTimeout("document.getElementById('loading_notification_receive_autobook').innerHTML=''",3000);
		}
	}
}

var xmlHttp_notification_receive_virtualgift=null;

function manage_notification_receive_virtualgift(notification,notification_receive_virtualgift)
{
	if(xmlHttp_notification_receive_virtualgift== null)
	{
		var url="notification_receive_messages.php?ajax=manage_notification_receive_messages&notification_receive_virtualgift="+notification_receive_virtualgift+"&notification="+notification;
		xmlHttp_notification_receive_virtualgift=GetXmlHttpObject();
		xmlHttp_notification_receive_virtualgift.onreadystatechange=manage_notification_receive_virtualgift;
		xmlHttp_notification_receive_virtualgift.open("get",url,true);
		xmlHttp_notification_receive_virtualgift.send(null);
		document.getElementById('loading_notification_receive_virtualgift').innerHTML="<img src='images/loader.gif' border=0>";
	}
	else
	{
		if (xmlHttp_notification_receive_virtualgift.readyState==4)
		{ 
			document.getElementById('loading_notification_receive_virtualgift').innerHTML="Updated!";
			var result=xmlHttp_notification_receive_virtualgift.responseText;
			xmlHttp_notification_receive_virtualgift=null;
			setTimeout("document.getElementById('loading_notification_receive_virtualgift').innerHTML=''",3000);
		}
	}
}


// end notification for Receive message

function friends_paging(page,parameters)
{
	var search_friends=document.getElementById('search_friends').value;
	var sort_by=document.getElementById('sort_by').value;
	common_paging('friends.php',page,parameters+"&search_friends="+search_friends+"&sort_by="+sort_by);
	return false;
}

function friends_delete(friend_id)
{
	if(xmlHttp==null)
	{
		if(!confirm("Are you sure to remove this friend?"))
		{
			return false;
		}
		var url="friends.php?ajax=friends_delete&friend_id="+friend_id;
		xmlHttp=GetXmlHttpObject();
		xmlHttp.onreadystatechange=friends_delete;
		xmlHttp.open("get",url,true);
		xmlHttp.send(null);
		document.getElementById("paging_result").innerHTML="Deleting...Please wait!";
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("paging_result").innerHTML="";
			var result=xmlHttp.responseText;
			xmlHttp=null;
			var parameters=document.getElementById('hidden_parameters').value;
			var sort_by=document.getElementById('sort_by').value;
			manage_top_msg_status("show","Friend has been removed successfully!");			
			common_paging('friends.php',1,parameters+"&sort_by="+sort_by);
		}
	}
	return false;
}


function share_profile(task)
{
	var frmvalidator  = new Validator("frm_share_profile");
	frmvalidator.addValidation("mail_to","req","Please Enter Recipient");
	frmvalidator.addValidation("mail_msg","req","Please Enter Message");
	if(frmvalidator.validate()==true)
	{
		document.frm_share_profile.mail_to.disabled=false;
		return true;
	}
	else
	return false;
}


function delete_share()
{
	var checked=check_checkbox(document.frm_share.share_delete);
	if(checked[0] == false)
	return false;
	
	if(!confirm("Are you sure to delete?"))
	{
		return false;
	}
	
	document.getElementById('share_delete_list').value=checked[1];
	document.frm_share.submit();
	return true;
}

function autobook()
{
	var frmvalidator  = new Validator("frm_autobook");
	if(document.getElementById('image_path').value != '')
	{
		frmvalidator.addValidation("image_path","img","Please Select Valid Image");
		if(frmvalidator.validate()==true)
		{
			return true;
		}
		else
		return false;
	}
}

function manage_autobook_images()
{
	var frmvalidator  = new Validator("frm_autobook_images");
	var valid=false;
	if(document.getElementById('autobook_start_image').value != '')
	{
		frmvalidator.addValidation("autobook_start_image","img","Please Select Valid Image");
		valid=true;
	}
	if(document.getElementById('autobook_end_image').value != '')
	{
		frmvalidator.addValidation("autobook_end_image","img","Please Select Valid Image");
		valid=true;
	}
	if(valid == true)
	{
		if(frmvalidator.validate()==true)
		{
			document.getElementById("upload_loader").style.display ='block';
			return true;
		}
		else
		return false;
	}
	else
	return true;
}


function delete_autobook(task)
{
	if(xmlHttp==null)
	{
		var checked=check_checkbox(document.frm_list_autobook.delete_auto);
		if(checked[0] == false)
		return false;
		
		if(!confirm("Are you sure to delete?"))
		{
			return false;
		}
		var url="autobook.php?ajax=delete_autobook&delete_list="+checked[1]+"&task="+task;
		xmlHttp=GetXmlHttpObject();
		xmlHttp.onreadystatechange=delete_autobook;
		xmlHttp.open("get",url,true);
		xmlHttp.send(null);
		document.getElementById("paging_result").innerHTML="Deleting...Please wait!";
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("paging_result").innerHTML="";
			var result=xmlHttp.responseText;
			xmlHttp=null;
			var id=document.getElementById('request_id').value;
			common_paging('autobook.php',1,"id="+id);
		}
	}
	return false;
}

function approve_autobook(task)
{
	if(xmlHttp==null)
	{
		global_key=task;
		var checked=check_checkbox(document.frm_list_autobook.delete_auto);
		if(checked[0] == false)
		return false;
		
		if(!confirm("Are you sure to continue?"))
		{
			return false;
		}
		var url="autobook_approval.php?ajax=autobook_approval&delete_list="+checked[1]+"&task="+task;
		xmlHttp=GetXmlHttpObject();
		xmlHttp.onreadystatechange=approve_autobook;
		xmlHttp.open("get",url,true);
		xmlHttp.send(null);
		document.getElementById("paging_result").innerHTML="Loading...Please wait!";
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("paging_result").innerHTML="";
			var result=xmlHttp.responseText;
			xmlHttp=null;
			if(global_key == "accept")
			manage_top_msg_status("show","Successfully Accepted!")
			else
			manage_top_msg_status("show","Successfully Rejected!")
			common_paging('autobook_approval.php',1);
		}
	}
	return false;
}

function manage_photo_folder(task,folder_id)
{
	if(xmlHttp==null)
	{
		if(task == 'add' || task == 'edit')
		{
			if(task == 'edit')
			{
				global_key=folder_id;
				var folder_name=document.getElementById('folder_name_'+folder_id).innerHTML;
			}
			document.getElementById('task').value=task;
			document.getElementById('div_upload').style.display='block';
			document.getElementById('paging_content').style.display='none';
			if(task == 'edit')
			{
				document.getElementById('folder_id').value=folder_id;
				document.getElementById('folder_name').value=folder_name;
			}
		}
		else if(task == 'cancel')
		{
			document.getElementById('folder_name').value='';
			document.getElementById('task').value='';
			document.getElementById('div_upload').style.display='none';
			document.getElementById('paging_content').style.display='block';
		}
		else if(task == 'submit')
		{
			var frmvalidator  = new Validator("frm_folders");
			frmvalidator.addValidation("folder_name","req","Please Enter Folder Name");
			if(frmvalidator.validate()==true)
			{
				var url="manage_folders.php?ajax=manage_folders&";
				url +=get_form_values(document.frm_folders);
				xmlHttp=GetXmlHttpObject();
				xmlHttp.onreadystatechange=manage_photo_folder;
				xmlHttp.open("get",url,true);
				xmlHttp.send(null);
				document.getElementById("loading_manage").innerHTML="Loading...Please wait!";
			}
		}
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("loading_manage").innerHTML="";
			var result=xmlHttp.responseText;
			xmlHttp=null;
			var task=document.getElementById('task').value;
			if(task == 'add')
			{
				manage_photo_folder('cancel');
				common_paging('manage_folders.php',1);
			}
			else if(task == 'edit')
			{
				var folder_name=document.getElementById('folder_name').value;
				manage_photo_folder('cancel');
				document.getElementById('folder_name_'+global_key).innerHTML=folder_name;
			}
		}
	}
	return false;
}

function manage_photo_add_folder(key)
{
	if(xmlHttp==null)
	{
		if(key=="show")
		{
			document.getElementById("create_folder_input").style.display='block';
			document.getElementById("create_folder_link").style.display='none';
		}
		else if(key=="cancel")
		{
			document.getElementById("create_folder_input").style.display='none';
			document.getElementById("create_folder_link").style.display='block';
			document.getElementById("create_folder").value='';
		}
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("loading_manage").innerHTML="";
			var result=xmlHttp.responseText;
			xmlHttp=null;
			var task=document.getElementById('task').value;
			if(task == 'add')
			{
				manage_photo_folder('cancel');
				common_paging('manage_folders.php',1);
			}
			else if(task == 'edit')
			{
				var folder_name=document.getElementById('folder_name').value;
				manage_photo_folder('cancel');
				document.getElementById('folder_name_'+global_key).innerHTML=folder_name;
			}
		}
	}
	return false;
}

function delete_photo_folder(folder_id)
{
	if(xmlHttp==null)
	{
		if(!confirm("Are you sure to delete?"))
		{
			return false;
		}
		var url="manage_folders.php?ajax=manage_folders&task=delete&folder_id="+folder_id;
		xmlHttp=GetXmlHttpObject();
		xmlHttp.onreadystatechange=delete_photo_folder;
		xmlHttp.open("get",url,true);
		xmlHttp.send(null);
		document.getElementById("paging_result").innerHTML="Deleting...Please wait!";
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("paging_result").innerHTML="";
			var result=xmlHttp.responseText;
			xmlHttp=null;
			if(result == 1)
			{
				common_paging('manage_folders.php',1);
			}
			else if(result == 2)
			{
				alert("Photos are available in this folder.So can't be deleted.");
			}
		}
	}
	return false;
}


function delete_virtual_gift()
{
	if(xmlHttp==null)
	{
		var checked=check_checkbox(document.frm_gift.deleteall);
		if(checked[0] == false)
		return false;
		
		if(!confirm("Are you sure to delete?"))
		{
			return false;
		}
		var url="virtual_gift.php?ajax=delete_virtual_gift&delete_list="+checked[1];
		xmlHttp=GetXmlHttpObject();
		xmlHttp.onreadystatechange=delete_virtual_gift;
		xmlHttp.open("get",url,true);
		xmlHttp.send(null);
		document.getElementById("paging_result").innerHTML="Deleting...Please wait!";
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("paging_result").innerHTML="";
			var result=xmlHttp.responseText;
			xmlHttp=null;
			manage_top_msg_status("show","Successfully deleted!");
			common_paging('virtual_gift.php',1);
		}
	}
	return false;
}

function delete_comments(key)
{
	if(xmlHttp==null)
	{
		global_key=key
		var checked=check_checkbox(document.frm_comment.deleteall);
		if(checked[0] == false)
		return false;
		
		if(!confirm("Are you sure to delete?"))
		{
			return false;
		}
		var url="comments.php?ajax=delete_comments&delete_list="+checked[1];
		xmlHttp=GetXmlHttpObject();
		xmlHttp.onreadystatechange=delete_comments;
		xmlHttp.open("get",url,true);
		xmlHttp.send(null);
		document.getElementById("paging_result").innerHTML="Deleting...Please wait!";
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("paging_result").innerHTML="";
			var result=xmlHttp.responseText;
			xmlHttp=null;
			common_paging('comments.php',1,'id='+global_key);
		}
	}
	return false;
}

function browse(page)
{
	if(xmlHttp==null)
	{
		var url="browse.php?ajax=browse&page="+page+"&";
		xmlHttp=GetXmlHttpObject();
		url +=get_form_values(document.browse_frm);
//		alert(url);
		xmlHttp.onreadystatechange=browse;
		xmlHttp.open("get",url,true);
		xmlHttp.send(null);
		document.getElementById("loading").innerHTML="Loading...Please wait!";
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("loading").innerHTML="";
			var result=xmlHttp.responseText;
			document.getElementById("content").innerHTML=result;
			xmlHttp=null;
		}
	}
	return false;
}

function onload_call()
{
	//if(document.getElementById("message") == null )
	//setTimeout('document.getElementById("body_tag").focus()',1);
	
	manage_top_msg_status();
	
	if(document.getElementById("intramail_task"))
	{
		var task=document.getElementById("intramail_task").value;
		if(task == 'compose')
		{
			intramail_compose('compose');
		}
	}
	if(document.getElementById("browse_onload"))
	{
		// Perform browse by clicking member.php or network_statistics.php
		browse(1);
	}
	if(document.getElementById("timing"))
	{
		// Perform browse by clicking member.php or network_statistics.php
		init();
	}
}

function manage_top_msg_status(task,msg)
{
	if(task == "show")
	{
		document.getElementById("top_msg_status").style.display = "block";
		document.getElementById("top_msg").innerHTML=msg;
	}
	
	if(document.getElementById("top_msg_status").style.display == "block")
	setTimeout("document.getElementById('top_msg_status').style.display = 'none'",5000);
}

function manage_default_content(key,field)
{
	if(key=='post_walk')
	{
		if(document.getElementById(field).value == 'Post a New walk here')
		{
			document.getElementById(field).value='';
		}
	}
	else if(key=='post_photo_comment' || key=='post_music_comment')
	{
		if(document.getElementById(field).value == 'Enter your comment here')
		{
			document.getElementById(field).value='';
		}
	}
	else if(key=='new_event')
	{
		if(document.getElementById(field).value == 'Enter your Event description here')
		{
			document.getElementById(field).value='';
		}
	}
	else if(key=='picture_week')
	{
		if(document.getElementById(field).value == 'Enter your Picture description here')
		{
			document.getElementById(field).value='';
		}
	}
	else if(key=='abuse')
	{
		if(document.getElementById(field).value == 'Enter your report details here')
		{
			document.getElementById(field).value='';
		}
	}
}


var count = "400";   //Example: var count = "175";
function type_limiter(key)
{
	var tex = document.getElementById(key).value;
	var len = tex.length;
	if(len > count){
			tex = tex.substring(0,count);
			document.getElementById(key).value=tex;
	//        document.myform.comment.value =tex;
			return false;
	}
	
			document.getElementById(key+"_remaining").innerHTML=count-len;
	//document.myform.limit.value = count-len;
}


// start expert part
function expert_registration()
{
	if(xmlHttp==null)
	{
		var frmvalidator  = new Validator("regi");
		frmvalidator.addValidation("name","req","Please Enter Your Name");
		frmvalidator.addValidation("email","req","Please Enter Email Address");
		frmvalidator.addValidation("email","email","Please Enter Valid Email Address");
		frmvalidator.addValidation("username","req","Please Enter Your Username");
		frmvalidator.addValidation("password","req","Please Enter Your Password");
		frmvalidator.addValidation("cpassword","req","Please Enter Confirmation Password");
		frmvalidator.addValidation("captcha","req","Please Enter Captcha ccode");
		frmvalidator.addValidation("paypal_email","req","Please Enter Paypal Email Address");
		frmvalidator.addValidation("paypal_email","email","Please Enter Valid Paypal Email Address");
		if(frmvalidator.validate() == true)
		{
			if(document.getElementById("password").value != document.getElementById("cpassword").value)
			{
				document.getElementById("err_cpassword").innerHTML="Password and confirmation Password should be same";
			}
			else if(document.getElementById("state").value == "")
			{
				document.getElementById("err_state").innerHTML="Please Select State";;
			}
			else if(document.getElementById("city").value == "")
			{
				document.getElementById("err_state").innerHTML="";;
				document.getElementById("err_city").innerHTML="Please Select City";;
			}
			else
			{
				document.getElementById("err_state").innerHTML="";;
				document.getElementById("err_city").innerHTML="";;
				var url="expert_register.php?action=ajax&";
				url +=get_form_values(document.regi);
				xmlHttp=GetXmlHttpObject();
				xmlHttp.onreadystatechange=expert_registration;
				xmlHttp.open("get",url,true);
				xmlHttp.send(null);
				document.getElementById("loader").style.display="block";
			}
		}
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("loader").style.display="none";
			var result=xmlHttp.responseText;
			if(result == 5)
			{
				alert("Please enter correct captcha code!");
			}
			else if(result == 0)
			{
				alert("Username already exist!");
			}
			else if(result == 1)
			{
				alert("Successfully Registered! Please check your EMail!");
				window.location.href="log_in.php";
			}
			else if(result == 2)
			{
				alert("Email Address already exist!");
			}
			else if(result == 3)
			{
				alert("Your Request has been sent for approval!");
				window.location.href="index.php";
			}
			else if(result == 4)
			{
				alert("Successfully Registered!");
				window.location.href="home.php";
			}
			else
			{
				ajax_error();
			}
			xmlHttp=null;
		}
	}
	return false;
}

function expert_account()
{
	if(xmlHttp==null)
	{
		var frmvalidator  = new Validator("frm_account");
		frmvalidator.addValidation("name","req","Please Enter Your Name");
		frmvalidator.addValidation("paypal_email","req","Please Enter Paypal Email Address");
		frmvalidator.addValidation("paypal_email","email","Please Enter Valid Paypal Email Address");
		frmvalidator.addValidation("degrees","req","Please Enter Degrees");
		frmvalidator.addValidation("description","req","Please Enter About Me");
		frmvalidator.addValidation("service","req","Please Enter Your Services");
		frmvalidator.addValidation("experience","req","Please Enter Your Experience & Qualification");
		
		if(frmvalidator.validate() == true)
		{
			if(document.getElementById("state").value == "")
			{
				document.getElementById("err_state").innerHTML="Please Select State";;
			}
			else if(document.getElementById("city").value == "")
			{
				document.getElementById("err_state").innerHTML="";;
				document.getElementById("err_city").innerHTML="Please Select City";;
			}
			else
			{
				return true;
//				document.getElementById("err_state").innerHTML="";;
//				document.getElementById("err_city").innerHTML="";;
//				var url="expert_account.php?action=ajax&";
//				url +=get_form_values(document.frm_account);
//				xmlHttp=GetXmlHttpObject();
//				xmlHttp.onreadystatechange=expert_account;
//				xmlHttp.open("get",url,true);
//				xmlHttp.send(null);
//				document.getElementById("loader").style.display="block";
			}
		}
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("loader").style.display="none";
			var result=xmlHttp.responseText;
			if(result == 1)
			{
				manage_top_msg_status("show","Successfully Updated!");
//				alert("Successfully Updated!");
			}
			else if(result == 2)
			{
				alert("Email Addrss already exist!");
			}
			else
			{
				ajax_error();
			}
			xmlHttp=null;
		}
	}
	return false;
}

function expert_login()
{
	if(xmlHttp==null)
	{
		var frmvalidator  = new Validator("frm_login");
		frmvalidator.addValidation("login_username","req","Please Enter Your Username");
		frmvalidator.addValidation("login_password","req","Please Enter Your Password");
		if(frmvalidator.validate() == true)
		{
			var url="expert_log_in.php?ajax=login&";
			url +=get_form_values(document.frm_login);
			if(document.getElementById("remember").checked)
			url +="remember="+document.getElementById("remember").value+"&";
			xmlHttp=GetXmlHttpObject();
			xmlHttp.onreadystatechange=expert_login;
			xmlHttp.open("get",url,true);
			xmlHttp.send(null);
			document.getElementById("loader").innerHTML='Loading...'
		}
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("loader").innerHTML=''
			var result=xmlHttp.responseText;
			if(result == 0)
			{
				document.getElementById("loader").innerHTML="Invalid Login!";
			}
			else if(result == 1)
			{
				document.getElementById("loader").innerHTML="Login Success!";
				window.location.href="expert_myaccount.php";
			}
			else if(result == 2)
			{
				document.getElementById("loader").innerHTML="Login Blocked!";
				window.location.href="renew_account.php";
			}
			else
			{
				ajax_error();
			}
			xmlHttp=null;
		}
	}
	return false;
}

function expert_forgot_password()
{
	if(xmlHttp==null)
	{
		var frmvalidator  = new Validator("forgot_pass");
		frmvalidator.addValidation("email","req","Please Enter Email Address");
		frmvalidator.addValidation("email","email","Please Enter Valid Email Address");
		if(frmvalidator.validate() == true)
		{
			var url="expert_password_forgotten.php?ajax=forgot_password&";
			url +=get_form_values(document.forgot_pass);
			xmlHttp=GetXmlHttpObject();
			xmlHttp.onreadystatechange=forgot_password;
			xmlHttp.open("get",url,true);
			xmlHttp.send(null);
			document.getElementById("result").innerHTML="Loading...";
		}
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("result").innerHTML="";
			var result=xmlHttp.responseText;
			if(result == 0)
			{
				document.getElementById("result").innerHTML="Email Address is not found!";
			}
			else if(result == 1)
			{
				document.getElementById("result").innerHTML="Success! Your Password has been sent to your Email!";
//				clear_form_values(document.forgot_pass);
			}
			else if(result == 2)
			{
				document.getElementById("result").innerHTML="Success! Your Username has been sent to your Email!";
//				clear_form_values(document.forgot_pass);
			}
			else
			{
				ajax_error();
			}
			xmlHttp=null;
		}
	}
	return false;
}

function expert_change_password()
{
	if(xmlHttp==null)
	{
		var frmvalidator  = new Validator("change_pass");
		frmvalidator.addValidation("old_password","req","Please Enter Old Username");
		frmvalidator.addValidation("new_password","req","Please Enter New Password");
		frmvalidator.addValidation("cnew_password","req","Please Enter Confirmation Password");
		if(frmvalidator.validate() == true)
		{
			if(document.getElementById("new_password").value != document.getElementById("cnew_password").value)
			{
				document.getElementById("err_cnew_password").innerHTML="Password and confirmation Password should be same";
			}
			else
			{
				var url="expert_change_password.php?ajax=change_password&";
				url +=get_form_values(document.change_pass);
				xmlHttp=GetXmlHttpObject();
				xmlHttp.onreadystatechange=expert_change_password;
				xmlHttp.open("get",url,true);
				xmlHttp.send(null);
				document.getElementById("result").innerHTML="Loading...";
			}
		}
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("result").innerHTML="";
			var result=xmlHttp.responseText;
			if(result == 0)
			{
				document.getElementById("result").innerHTML="Old Password is wrong!";
			}
			else if(result == 1)
			{
				document.getElementById("result").innerHTML="";
				manage_top_msg_status("show","Password has been changed successfully!");
				clear_form_values(document.forgot_pass);
			}
			else
			{
				ajax_error();
			}
			xmlHttp=null;
		}
	}
	return false;
}

// end expert part

function ask_question()
{
	var frmvalidator  = new Validator("frm_question");
	frmvalidator.addValidation("question","req","Please Enter Your Question");
	frmvalidator.addValidation("description","req","Please Enter Details of your question");
	if(frmvalidator.validate() == true)
	{
		return confirm("Are you sure to proceed?");
	}
	else
	{
		return false;
	}
}

function answer_question()
{
	var frmvalidator  = new Validator("frm_answer");
	frmvalidator.addValidation("answer","req","Please Enter Your Reply");
	if(frmvalidator.validate() == true)
	{
		return confirm("Are you sure to proceed?");
	}
	else
	{
		return false;
	}
}

function search_experts(page)
{
	var keywords=document.getElementById("keywords").value;
	var category_id=document.getElementById("category_id").value;
	
	if(keywords != "")
	{
		common_paging("expert.php",page,"keywords="+keywords+"&category_id="+category_id);
	}
	else
	{
		document.getElementById("paging_result").innerHTML="Enter Keywords!";		
	}
	return false;
}

function manage_expert_picture()
{
	var frmvalidator  = new Validator("frm_expert_picture");
	frmvalidator.addValidation("upload","req","Please Select Picture");
	frmvalidator.addValidation("upload","img","Please Select Valid Picture");
	if(frmvalidator.validate() == true)
	{
		return confirm("Are you sure to proceed?");
	}
	else
	{
		return false;
	}
}

function manage_newsletter()
{
	if(xmlHttp==null)
	{
		var frmvalidator  = new Validator("frm_newsletter");
		frmvalidator.addValidation("news_email","req","Please Enter Your Email Address");
		frmvalidator.addValidation("news_email","email","Please Enter Valid Email Address");
		if(frmvalidator.validate() == true)
		{
			var url="index.php?ajax=manage_newsletter&";
			url +=get_form_values(document.frm_newsletter);
			xmlHttp=GetXmlHttpObject();
			xmlHttp.onreadystatechange=manage_newsletter;
			xmlHttp.open("get",url,true);
			xmlHttp.send(null);
			document.getElementById("news_loader").innerHTML='Loading...'
		}
	}
	else
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("news_loader").innerHTML=''
			var result=xmlHttp.responseText;
			if(result == 1)
			{
				document.getElementById("news_loader").innerHTML="Successfully Registered!";
			}
			else if(result == 2)
			{
				document.getElementById("news_loader").innerHTML="Successfully Unregistered";
			}
			else
			{
				ajax_error();
			}
			xmlHttp=null;
		}
	}
	return false;
}

