$(document).ready(function(){
$('#ll_load').load("includes/link_menu_load.php");
setInterval(function(){
$.ajax({
	   type:"POST",
	   url:"alert_check.php",
	   data:"",
	   success: function(html){
		   var res=html.substring(3);
		   if(res!=0)
		   {
		   $.facebox(html);
		   }
		   }
	   });
},10000);
});
function menu_ref()
{
setTimeout(function(){
$('#ll_load').load("includes/link_menu_load.php");
},6000);
}
function update_tagline()
{
$("#tag_update").val("wait...");
$("#tag_update").attr("disabled", true);
$.ajax({
type: "POST",
url: "tagline_update.php",
data: 	{ comment:$("#tagline_txt").val() }, 
success: function(html){
$("#tag_update").val("Update");
$("#tag_update").attr("disabled", false);
$("#err_tag").html(html);
}
});
}
function add_friend(m)
{
d="#aaf"+m;
$(d).val("Please wait...");
$(d).attr("disabled",true);
$.ajax({
type: "POST",
url: "add_friend.php",
data: 	"id="+m, 
success: function(html){
$(d).val("Request Sent");
$.facebook("<div align='center'><b>Your request has been sent.</b></div>");
}
});
}
function add_friend1(m)
{
d="#join_btn_club";
$(d).val("Please wait...");
$(d).attr("disabled",true);
$.ajax({
type: "POST",
url: "add_friend.php",
data: 	"id="+m, 
success: function(html){
$(d).val("Request Sent");
$.facebox.close();
alert('Your Request has been sent.');
}
});
}
function add_fan(m)
{
d="#fan"+m;
$(d).val("Please wait...");
$(d).attr("disabled",true);
$.ajax({
type: "POST",
url: "add_fan.php",
data: 	"id="+m, 
success: function(html){
$(d).hide();
}
});
}
function fri_accept(m)
{
d="#acc"+m;
e="#dec"+m;
$(d).val("Please wait...");
$(d).attr("disabled",true);
$(e).attr("disabled",true);
$.ajax({
type: "POST",
url: "fri_req_action_acc.php",
data: 	"id="+m, 
success: function(html){
$(d).val("Request Accepted");
}
});
}
function fri_decline(m)
{
d="#acc"+m;
e="#dec"+m;
$(e).val("Please wait...");
$(d).attr("disabled",true);
$(e).attr("disabled",true);
$.ajax({
type: "POST",
url: "fri_req_action_dec.php",
data: 	"id="+m, 
success: function(html){
$(e).val("Request Declined");
}
});
}
function change_pass()
{
	   var j=0;
   var value=$('#np').val();
   var iChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
   for (var i = 0; i < value.length; i++) {
		if (iChars.indexOf(value.charAt(i)) == -1) {
		j=1;
		}
   }
   
   
		var k=0;
		var m=0;
	   var iChars1 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
	   var iChars2 = "0123456789"; 
   for (var i = 0; i < value.length; i++) {
  	if (iChars1.indexOf(value.charAt(i)) > -1) {
	k=1;
  	}
  }
  for (var l = 0; l < value.length; l++) {
  	if (iChars2.indexOf(value.charAt(l)) > -1) {
	m=1;
  	}
  }
   
if($('#op').val()=="")
{
$('#cpass').html("Please enter your old password");
$('#op').focus();
}
else if($('#np').val()=="")
{
$('#cpass').html("Please enter your new password");
$('#np').focus();
}
else if(value.length<8)
{
	$('#cpass').html("Password must be minium 8 characters.");
	$('#np').focus();
}
else if(j==1)
{
	$('#cpass').html("Must be contain only Alpha-Numeric Characters<br>(Special characters are not allowed)");
	$('#np').focus();
}
else if((k!=1)||(m!=1))
{
	$('#cpass').html("Password must have atleast one alphabet and one numeric value.");
	$('#np').focus();
}
else if($('#np1').val()=="")
{
$('#cpass').html("Please enter your new password again");
$('#np1').focus();
}
else if($('#np1').val()!=$('#np').val())
{
$('#cpass').html("New password and Confirm new password should be same");
$('#np1').focus();
}
else
{
$("#c_pass").attr("disabled",true);
$("#c_pass").val("Please wait...");
$.ajax({
type: "POST",
url: "change_password_action.php",
data: 	"op="+$('#op').val()+
"&np="+$('#np').val()+
"&np1="+$('#np1').val(), 
success: function(html){
var res=html.substring(3);
if(res=="denied")
{
$("#c_pass").attr("disabled",false);
$("#c_pass").val("Submit");
$('#cpass').html("Old password did not match with our database");
}
else if(res=="success")
{
$("#c_pass").val("Submit");
$('#cpass').html("<span style='color:green'>Password has been changed successfully</span>");
$('#op').val('');
$('#np').val('');
$('#np1').val('');
setTimeout(function() {
$("#c_pass").attr("disabled",false);
$(document).trigger('close.facebox') 
},2000);
}
}
});
}
}
function ch()
{
var con=confirm("Are you sure to delete the selected friends");
if(con==true)
{
return true;
}
else
{
return false;
}
}
function pic_comm(m,n)
{
if(($('#comm').val()=="")||($('#comm').val()=="Write a comment..."))
{
$.facebox("<div align='center'><b style='color:red'>Please enter a comment.</b></div>");
return false;
}
$('#sub_comm').attr("disabled",true);
$('#sub_comm').val('Please wait...');
$.ajax({
type: "POST",
url: "pic_comm_action.php",
data: 	{ com:$('#comm').val(), id:m }, 
success: function(html){
$("#sub_comm").attr("disabled", false);
$("#sub_comm").val("Submit Comment");
$("#comm").val("Write a comment...");
var p="pic_com.php?id="+m+"&uid1="+n;
$("#res").load(p);
}	
});
}
function del_com(m,n,o)
{
var con=confirm("Are you sure to delete this comment.");
if(con==true)
{
$.facebox('Please wait...');
$.ajax({
type: "POST",
url: "del_pic_comm.php",
data: 	"id="+m, 
success: function(html){
var p="pic_com.php?id="+n+"&uid1="+o;
$("#res").load(p);
$.facebox.close();
}	
});
}
}
function send_msg()
{
$("#err_dis").html("");
$('#sub_msg').attr("disabled",true);
$('#sub_msg').val('Please wait...');
$.ajax({
type: "POST",
url: "send_msg_action.php",
data: 	{ rid:$("#rec").val(), sub1:$("#sub").val(), com:$("#msg").val() }, 
success: function(html){
var res=html.substring(3);
if(res=="denied")
{
$("#err_dis").html("Please fill all the fields");
$('#sub_msg').attr("disabled",false);
$('#sub_msg').val('Send Message');
}
else if(res=="success")
{
$("#err_dis").html("<span style='color:green'>Your message has been sent</span>");
$("#sub").val('');
$("#msg").val('');
$('#sub_msg').attr("disabled",false);
$('#sub_msg').val('Send Message');
setTimeout(function(){
$.facebox.close();
},1500);
}
}	
});
}
function pic_like(res,tbl,id)
{
var d="#"+res;
if($(d).html()=="like")
{
$(d).html("please wait...");
$.ajax({
type: "POST",
url: "pic_like_action.php",
data: 	"tbl="+tbl+"&id="+id, 
success: function(html){
$(d).html('you like this');
$(d).css('cursor','auto');
}	
});
}
}
function con_del_url(m)
{
var con=confirm("Are you sure to delete this picture.");
if(con==true)
{
window.location.href=m;
}
}
function submit_common_com(m,n,o,p,q,r,s)
{
var btn="#sub_comm"+m;
var com="#comm"+m;
var com1=$(com).val();
var res="#upd"+m;
if((com1=="Write a comment...")||(com1==""))
{
$.facebox("<b style='color:red;'>Please enter your comment</b>");
return false;
}
$(btn).val("please wait...");
$.ajax({
type: "POST",
url:  "submit_update_com_action.php",
data: ({ tbl:n, field_name:o, field_id:p, comm:$(com).val() }),
success: function(html){
$(btn).val("Submit Comment");
$(com).val("Write a comment...");
var fl=q+"?table_name="+n+"&field="+o+"&field_id="+p+"&fl="+r+"&id="+s;
$(res).load(fl);
}	
});
}
function delete_common_com(m,n,o,p,q,r)
{
var res="#upd"+r;
var con=confirm("Are you sure to delete this comment");
if(con==true)
{
$.facebox("Please wait...");
$.ajax({
type: "POST",
url:  "delete_update_com_action.php",
data: ({ id:m, tbl:n, field_name:o, field_id:p }),
success: function(html){
var fl=q+"?table_name="+n+"&field="+o+"&field_id="+p;
$(res).load(fl);
$.facebox.close();
}	
});
}
}
function vali()
{
$('#send_btn').val('Please wait...');
$('#send_btn').attr('disabled',true);
va=$('input[name=rb]:checked').val();
$.ajax({
type:'POST',
url:'emoticons_action.php',
data:{ tbl:$('#tbl').val(), tid:$('#tid').val(), eid:va, },
success: function(html){
$('#send_btn').val('Send');
$('#send_btn').attr('disabled',false);
$.facebox.close();
$('#emoticon_res').load("emoticons_response.php?tbl="+$('#tbl').val()+"&tid="+$('#tid').val());
}
});
}
function event_city(m,n,o,p,q,r,s)
{
city=$('#evecity').val();
var1=m+'?city='+city+'&id='+n+'&val='+o+'&pg='+p+'&msg='+q+'&pp='+r+'&evid='+s;
window.location.replace(var1);
}
function del_msg(m)
{
var con=confirm("Are you sure to delete this message");
if(con==true)
{
window.location.href=m;
}
}
function join_club(m,n)
{
btn="#join_btn"+n;
$(btn).val('Please wait...');
$(btn).attr('disabled',true);
$.ajax({
type:'POST',
url:'join_club_action.php',
data:{ mm:m, nn:n },
success: function(html){
$(btn).val('Join Now!');
$(btn).hide();
}
});
}
function join_club_pop(n)
{
btn="#join_btn_club";
$(btn).val('Please wait...');
$(btn).attr('disabled',true);
$.ajax({
type:'POST',
url:'join_club_action.php',
data:{ nn:n },
success: function(html){
$(btn).val('Join Now!');
$(btn).hide();
window.location.href='mpm_club.php?id='+n;
}
});
}
function join_club_pop1(n)
{
btn="#join_btn_club";
$(btn).val('Please wait...');
$(btn).attr('disabled',true);
$.ajax({
type:'POST',
url:'join_club_action1.php',
data:{ nn:n },
success: function(html){
$(btn).val('Join Now!');
$(btn).hide();
window.location.href='friends_fan_profile.php?id='+n;
}
});
}
function vgood_scat(m,n)
{
$('#vgoods').html('Please wait...');
$('#bck').show();
$('#bck2').show();
$('#bck1').hide();
b=m;
$.ajax({
type:'POST',
url:'vgood_scat_action.php',
data:{ mm:m, nn:n},
success: function(html){
$('#vgoods').html(html);
}
});
}
function vgood_scat_update(m,n)
{
$('#vgoods').html('Please wait...');
$('#bck').show();
$('#bck2').show();
$('#bck1').hide();
b=m;
$.ajax({
type:'POST',
url:'vgood_scat_update_action.php',
data:{ mm:m, nn:n},
success: function(html){
$('#vgoods').html(html);
}
});
}
function vgood_scat_fan(m,fid)
{
$('#vgoods').html('Please wait...');
$('#bck').show();
$('#bck2').show();
$('#bck1').hide();
b=m;
$.ajax({
type:'POST',
url:'vgood_scat_fan_action.php',
data:{ mm:m,fid1:fid },
success: function(html){
$('#vgoods').html(html);
}
});
}
function vgoods_display(m,did)
{
$('#vgoods').html('Please wait...');
$('#bck').show();
$('#bck1').show();
$('#bck2').hide();
$.ajax({
type:'POST',
url:'vgoods_display_action.php',
data:{ mm:m,did:did },
success: function(html){
$('#vgoods').html(html);
}
});
}
function vgoods_display_update(m,did)
{
$('#vgoods').html('Please wait...');
$('#bck').show();
$('#bck1').show();
$('#bck2').hide();
$.ajax({
type:'POST',
url:'vgoods_display_update_action.php',
data:{ mm:m,did:did },
success: function(html){
$('#vgoods').html(html);
}
});
}
function vgoods_display_fan(m,fid)
{
$('#vgoods').html('Please wait...');
$('#bck').show();
$('#bck1').show();
$('#bck2').hide();
$.ajax({
type:'POST',
url:'vgoods_display_fan_action.php',
data:{ mm:m,fid1:fid },
success: function(html){
$('#vgoods').html(html);
}
});
}
function send_vgood(m,n,tblname,cid)
{
$.facebox.close();
$.ajax({
type:'POST',
url:'vgoods_send.php',
data:{ mm:m,nn:n,tbn:tblname,cid:cid },
success: function(html){
setTimeout(function(){
$.facebox("<div align='center' class='content1'><b>Your virtual good has been sent.</b></div>");
setTimeout(function(){
$.facebox.close();
},2000);
},1000);
}
});
}
function send_vgood_fan(m,n,tblname,fid)
{
$.facebox.close();
$.ajax({
type:'POST',
url:'vgoods_send_fan.php',
data:{ mm:m,nn:n,tbn:tblname,fid:fid },
success: function(html){
setTimeout(function(){
$.facebox("<div align='center' class='content1'><b>Your virtual good has been sent.</b></div>");
setTimeout(function(){
$.facebox.close();
},2000);
},1000);
}
});
}
function vgoods_updates(m,n)
{
$.ajax({
type:'POST',
url:'virtual_goods_update.php',
data:{ mm:m,nn:n },
success: function(html){
$('#vgoods_up').html(html);
}
});
}
function fan_info_comm(m,n)
{
if(($('#comm').val()=="")||($('#comm').val()=="Write a comment..."))
{
$.facebox("<div align='center'><b style='color:red'>Please enter a comment.</b></div>");
return false;
}
$('#sub_comm').attr("disabled",true);
$('#sub_comm').val('Please wait...');
$.ajax({
type: "POST",
url: "fan_comm_action.php",
data: 	{ com:$('#comm').val(), id:m }, 
success: function(html){
$("#sub_comm").attr("disabled", false);
$("#sub_comm").val("Submit Comment");
$("#comm").val("Write a comment...");
var p="fan_info_com.php?id="+m+"&uid1="+n;
$("#res").load(p);
}	
});
}
function fan_del_com(m,n,o)
{
var con=confirm("Are you sure to delete this comment.");
if(con==true)
{
$.facebox('Please wait...');
$.ajax({
type: "POST",
url: "del_fan_comm.php",
data: 	"id="+m, 
success: function(html){
var p="fan_info_com.php?id="+n+"&uid1="+o;
$("#res").load(p);
$.facebox.close();
}	
});
}
}
function search_event_comm(m,n)
{
if(($('#comm').val()=="")||($('#comm').val()=="Write a comment..."))
{
$.facebox("<div align='center'><b style='color:red'>Please enter a comment.</b></div>");
return false;
}
$('#sub_comm').attr("disabled",true);
$('#sub_comm').val('Please wait...');
$.ajax({
type: "POST",
url: "event_comment_action.php",
data: 	{ com:$('#comm').val(), id:m ,eid:n }, 
success: function(html){
$("#sub_comm").attr("disabled", false);
$("#sub_comm").val("Submit Comment");
$("#comm").val("Write a comment...");
var p="search_event_com.php?id="+m+"&uid1="+n;
$("#res").load(p);
}	
});
}
function event_del_com(m,n,o)
{
var con=confirm("Are you sure to delete this comment.");
if(con==true)
{
$.facebox('Please wait...');
$.ajax({
type: "POST",
url: "del_event_comm.php",
data: 	"id="+m, 
success: function(html){
var p="search_event_com.php?id="+n+"&uid1="+o;
$("#res").load(p);
$.facebox.close();
}	
});
}
}
function chat_alert()
{
$.facebox('You have to be fan of this page to use online chat');
}
function chat_alert_club(n)
{
$.facebox({ ajax:'club_join.php?id='+n });
}
function chat_alert_club1(n)
{
$.facebox({ ajax:'club_join1.php?id='+n });
}
function use_sel_per()
{
	$('#usp_res').load('usp.php',function (){
	var html=$('#usp_res').html();
	var res=html.substring(3);
	if(res==0)
	{
		$('#usp_res').html('There is no selected persons. Please start a new search.');
	}
	else
	{
		$('#usp_res').html('Persons selected.');
		$('#amount2').html(parseInt($('#sms_rs').val())*res);
		tot_am();
	}
										   });
}
function use_sel_per_email()
{
	$('#usp_res_email').load('usp_email.php',function (){
	var html=$('#usp_res_email').html();
	var res=html.substring(3);
	if(res==0)
	{
		$('#usp_res_email').html('There is no selected persons. Please start a new search.');
	}
	else
	{
		$('#usp_res_email').html('Persons selected.');
		$('#amount3').html(parseInt($('#email_rs').val())*res);
		tot_am();
	}
										   });
}
function use_sel_per_alert()
{
	$('#usp_res_alert').load('usp_alert.php',function (){
	var html=$('#usp_res_alert').html();
	var res=html.substring(3);
	if(res==0)
	{
		$('#usp_res_alert').html('There is no selected persons. Please start a new search.');
	}
	else
	{
		$('#usp_res_alert').html('Persons selected.');
		$('#amount4').html(parseInt($('#alert_rs').val())*res);
		tot_am();
	}
										   });
}
function update_sms()
{
	$('#usp_res').load('sms_update.php',function (){
	var html=$('#usp_res').html();
	var res=html.substring(3);
	if(res>0)
	{
		$('#usp_res').html('Persons selected.');
		$('#amount2').html(parseInt($('#sms_rs').val())*res);
		tot_am();
	}
										   });
}
function update_email()
{
	$('#usp_res_email').load('email_update.php',function (){
	var html=$('#usp_res_email').html();
	var res=html.substring(3);
	if(res>0)
	{
		$('#usp_res_email').html('Persons selected.');
		$('#amount3').html(parseInt($('#email_rs').val())*res);
		tot_am();
	}
										   });
}
function update_alert()
{
	$('#usp_res_alert').load('alert_update.php',function (){
	var html=$('#usp_res_alert').html();
	var res=html.substring(3);
	if(res>0)
	{
		$('#usp_res_alert').html('Persons selected.');
		$('#amount4').html(parseInt($('#alert_rs').val())*res);
		tot_am();
	}
										   });
}
function reset_sms()
{
	$('#amount2').html('0');
	tot_am();
	$('#usp_res').load('sms_session_reset.php');
}
function reset_email()
{
	$('#amount3').html('0');
	tot_am();
	$('#usp_res_email').load('email_session_reset.php');
}
function reset_alert()
{
	$('#amount4').html('0');
	tot_am();
	$('#usp_res_alert').load('alert_session_reset.php');
}


function bemyfan_alert(n)
{
$.facebox({ ajax:'bemyfan_bookatable.php?id='+n });
}

function be_myfan_pop(n)
{
btn="#be_my_fan";
$(btn).val('Please wait...');
$(btn).attr('disabled',true);
$.ajax({
type:'POST',
url:'fan_like_action.php',
data:{ nn:n },
success: function(html){
$('#bef_fan').hide();
$('#res_fan').html('Thanks for join us...');
/*setInterval(function(){window.location.href='book_table_confirm.php?id='+n;},1500
);*/
window.location.href='book_table_confirm.php?id='+n;
}
});
}
function tabbook_details(n)
{
$.facebox({ ajax:'table_booking_details.php?id='+n });
}
alert_n=0;
function alert_menu(m,n)
{
	$('.alert_menu').hide();
	di="#"+m;
	$(di).show();
	$(di).html('Please wait...');
	$(di).load(n,function () {
						   
						   });
	$(document).click(function(){
					setTimeout(function() {
					if(alert_n==0)
					{
					setTimeout(function() {
					$(di).hide();
					},1000);
					}
					},10);	   

						});
}

function ap_f2()
{
	if(($('#ap').val()=='')||($('#wi').val()==''))
	{
		$('#response11').html('Please fill all the fields.');
		return false;
	}
	else
	{
		$('#response11').html('');
	}
	$('#save_btn').val('Please wait...');
	$('#save_btn').attr('disabled',true);
	$.ajax({
		   type:'POST',
		   url:'fan_left_action.php',
		   data:{apf2:1,average_price:$('#ap').val(),which_includes:$('#wi').val()},
		   success:function(html){
			   $('#save_btn').val('Changes Saved');
			   $('#save_btn').attr('disabled',false);
			   }
		   });
}

$(document).ready(function(){
$("#music_fan").validate({	
submitHandler: function(form) {
			    $("#save_btn_music").val("Please wait...");
				$("#save_btn_music").attr("disabled", true);
		$.ajax({
			type:"POST",
			url:$("#music_fan").attr( 'action' ),
			data:$("#music_fan").serialize(), 
			success: function(html){
				$("#save_btn_music").val("Changes Saved");
				$("#save_btn_music").attr("disabled", false);
			}
		});	
        }
});

$("#signature_drink").validate({	
submitHandler: function(form) {
			    $("#signature_drink_btn").val("Please wait...");
				$("#signature_drink_btn").attr("disabled", true);
		$.ajax({
			type:"POST",
			url:$("#signature_drink").attr( 'action' ),
			data:$("#signature_drink").serialize(), 
			success: function(html){
				$("#signature_drink_btn").val("Changes Saved");
				$("#signature_drink_btn").attr("disabled", false);
			}
		});	
        }
});

$("#signature_food").validate({
submitHandler: function(form) {
			    $("#signature_food_btn").val("Please wait...");
				$("#signature_food_btn").attr("disabled", true);
		$.ajax({
			type:"POST",
			url:$("#signature_food").attr( 'action' ),
			data:$("#signature_food").serialize(), 
			success: function(html){
				$("#signature_food_btn").val("Changes Saved");
				$("#signature_food_btn").attr("disabled", false);
			}
		});	
        }
});

$("#testform").validate({
rules:
	{
		fname:{	required:true },
		lname:{	required:true },
		sex: { required:true }
	},

messages:
	{
		fname: "please enter first name",
		sex: "please select gender"
	},
	
submitHandler: function(form) {
		$.ajax({
			type:"POST",
			url:$("#form1").attr( 'action' ),
			data:$("#form1").serialize(), 
			success: function(html){
				$("#code").val('');
				$("#submit").val("create");
				$("#submit").attr("disabled", false);
				$('#response').html(html);
			}
		});	
        }
});
});



function search_photo_galry_comm(m,n)
{
if(($('#comm').val()=="")||($('#comm').val()=="Write a comment..."))
{
$.facebox("<div align='center'><b style='color:red'>Please enter a comment.</b></div>");
return false;
}
$('#sub_comm').attr("disabled",true);
$('#sub_comm').val('Please wait...');
$.ajax({
type: "POST",
url: "photogalry_comment_action.php",
data: 	{ com:$('#comm').val(), id:m ,eid:n }, 
success: function(html){
$("#sub_comm").attr("disabled", false);
$("#sub_comm").val("Submit Comment");
$("#comm").val("Write a comment...");
var p="photo_galry_com.php?id="+m+"&uid1="+n;
$("#res").load(p);
}	
});
}

function photo_galry_del_com(m,n)
{
var con=confirm("Are you sure to delete this comment.");
if(con==true)
{
$.facebox('Please wait...');
$.ajax({
type: "POST",
url: "del_photogalry_comm.php",
data: 	"id="+m, 
success: function(html){
var p="photo_galry_com.php?id="+n;
$("#res").load(p);
$.facebox.close();
}	
});
}
}

function photo_galry_like(res,tbl,id)
{
var d="#"+res;
if($(d).html()=="like")
{
$(d).html("please wait...");
$.ajax({
type: "POST",
url: "pic_like_action.php",
data: 	"tbl="+tbl+"&id="+id, 
success: function(html){
$(d).html('you like this');
$(d).css('cursor','auto');
}	
});
}
}



function search_fanphoto_galry_comm(m,n)
{
if(($('#comm').val()=="")||($('#comm').val()=="Write a comment..."))
{
$.facebox("<div align='center'><b style='color:red'>Please enter a comment.</b></div>");
return false;
}
$('#sub_comm').attr("disabled",true);
$('#sub_comm').val('Please wait...');
$.ajax({
type: "POST",
url: "fan_photogalry_comment_action.php",
data: 	{ com:$('#comm').val(), id:m ,eid:n }, 
success: function(html){
$("#sub_comm").attr("disabled", false);
$("#sub_comm").val("Submit Comment");
$("#comm").val("Write a comment...");
var p="fan_photo_galry_com.php?id="+m+"&uid1="+n;
$("#res").load(p);
}	
});
}

function photo_fangalry_del_com(m,n)
{
var con=confirm("Are you sure to delete this comment.");
if(con==true)
{
$.facebox('Please wait...');
$.ajax({
type: "POST",
url: "del_fanphotogalry_comm.php",
data: 	"id="+m, 
success: function(html){
var p="fan_photo_galry_com.php?id="+n;
$("#res").load(p);
$.facebox.close();
}	
});
}
}

function photo_fangalry_like(res,tbl,id)
{
var d="#"+res;
if($(d).html()=="like")
{
$(d).html("please wait...");
$.ajax({
type: "POST",
url: "pic_like_action.php",
data: 	"tbl="+tbl+"&id="+id, 
success: function(html){
$(d).html('you like this');
$(d).css('cursor','auto');
}	
});
}
}

function sendgift(m,n,o,p)
{
$.ajax({
type: "POST",
url: "users.php",
data: { mm:m,nn:n,oo:o,pp:p },
success: function(html){
	var res=html.substring(3);
		   if(res!=0)
		   {
		   $.facebox(html);
		   }
setTimeout(function() {
window.close();
},2000);
}
});
}
function sendgift_update(m,n,o,p)
{
$.ajax({
type: "POST",
url: "users_update.php",
data: { mm:m,nn:n,oo:o,pp:p },
success: function(html){
$.facebox('<div align="center" class="content1" style="color:#FF0000;">Your gift has been sent.</div>');
var res=html.substring(3);
setTimeout(function() {
window.close();
},2000);
var ele="vgood"+res;
//window.opener.$(ele).html('sdf');
no_vg=window.opener.document.getElementById(ele).innerHTML;
window.opener.document.getElementById(ele).innerHTML=parseInt(no_vg)+1;
}
});
}


function search_photograper_photo_comm(m,n)
{
if(($('#comm').val()=="")||($('#comm').val()=="Write a comment..."))
{
$.facebox("<div align='center'><b style='color:red'>Please enter a comment.</b></div>");
return false;
}
$('#sub_comm').attr("disabled",true);
$('#sub_comm').val('Please wait...');
$.ajax({
type: "POST",
url: "photogarapher_photo_comment_action.php",
data: 	{ com:$('#comm').val(), aid:m ,pid:n }, 
success: function(html){
$("#sub_comm").attr("disabled", false);
$("#sub_comm").val("Submit Comment");
$("#comm").val("Write a comment...");
var p="photogarapher_photo_com.php?aid="+m+"&pid="+n;
$("#res").load(p);
}	
});
}

function photographer_photo_del_com(m,n,v)
{  
var con=confirm("Are you sure to delete this comment.");
if(con==true)
{
$.facebox('Please wait...');
$.ajax({
type: "POST",
url: "del_photogar_photo_comm.php",
data: 	"id="+m, 
success: function(html){
var p="photogarapher_photo_com.php?aid="+n+"&pid="+v;
$("#res").load(p);
$.facebox.close();
}	
});
}
}

function photogrpher_photo_like(res,tbl,id)
{
var d="#"+res;
if($(d).html()=="like")
{
$(d).html("please wait...");
$.ajax({
type: "POST",
url: "pic_like_action.php",
data: 	"tbl="+tbl+"&id="+id, 
success: function(html){
$(d).html('you like this');
$(d).css('cursor','auto');
}	
});
}
}

function onb_submit(m)
{
	if(($('#onb').val()=="")||($('#onb').val()=="Write on board..."))
	{
		$.facebox('Please enter your comment.');
		return false;
	}
$('#onbs').attr("disabled",true);
$('#onbs').val('Please wait...');
$.ajax({
type: "POST",
url: "on_board.php",
data: { mm:m, nn:$('#onb').val() }, 
success: function(html){
	$('#onbs').attr("disabled",false);
$('#onbs').val('Submit');
$('#onb').val('');
$('#respo').html('Your comment has been posted.');
setTimeout(function() {
$('#board_update').load('my_board_update.php?val='+m);
$('#myboard').slideToggle();
$('#respo').html('');
},2000);
}	
});
}

function onb_submit1(m)
{
	if(($('#onb').val()=="")||($('#onb').val()=="Write on board..."))
	{
		$.facebox('Please enter your comment.');
		return false;
	}
$('#onbs').attr("disabled",true);
$('#onbs').val('Please wait...');
$.ajax({
type: "POST",
url: "on_board.php",
data: { mm:m, nn:$('#onb').val() }, 
success: function(html){
	$('#onbs').attr("disabled",false);
$('#onbs').val('Submit');
$('#onb').val('');
$('#respo').html('Your comment has been posted.');
setTimeout(function() {
$('#my_board_fan_update').load('my_board_update_fan.php?id='+m);
$('#myboard').slideToggle();
$('#respo').html('');
},2000);
}	
});
}

function onb_submit_pro()
{
	if(($('#onb').val()=="")||($('#onb').val()=="Write on board..."))
	{
		$.facebox('Please enter your comment.');
		return false;
	}
$('#onbs').attr("disabled",true);
$('#onbs').val('Please wait...');
$.ajax({
type: "POST",
url: "on_board.php",
data: { mm:'', nn:$('#onb').val() }, 
success: function(html){
	$('#onbs').attr("disabled",false);
$('#onbs').val('Submit');
$('#onb').val('');
$('#respo').html('Your comment has been posted.');
setTimeout(function() {
$('#update').load('my_board_update_profile.php');
$('#myboard').slideToggle();
$('#respo').html('');
},2000);
}	
});
}

function fea_city_change(m)
{
	$("#load_fea").html('<div align="center" style="color:black; height:30px;"><b>Please wait...</b></div>');
	$("#load_fea").load('featured_load.php?city='+m);
}

function update_like(m,n,o)
{
	$('#'+m).html('Please wait...');
	$.ajax({
	type: "POST",
	url: "update_like_action.php",
	data: { elementid:m, tblid:n, tblname:o }, 
	success: function(html){
		$('#'+m).html('you like this');
		$('#'+m).css('cursor','default');
		$('#'+m).click(function(){
								$.facebox('you already like this.');
								});
		}	
	});
}

function report_error()
{
if($('#email1').val()=="")
{
	$('#cpass').html("Please enter your email");
	$('#email1').focus();
}
else if(($('#email1').val().indexOf('.')==-1)||($('#email1').val().indexOf('@')==-1))
{
	$('#cpass').html("Please enter a valid email");
	$('#email1').focus();
}
else if($('#rerr').val()=="")
{
$('#cpass').html("Please report your error");
$('#rerr').focus();
}
else if($('#security_code').val()=="")
{
$('#cpass').html("Please enter your security");
$('#security_code').focus();
}
else
{
$("#c_pass").attr("disabled",true);
$("#c_pass").val("Please wait...");
$.ajax({
type: "POST",
url: "report_error_action.php",
data: { name:$('#name').val(), email1:$('#email1').val(), rerr:$('#rerr').val(), security_code:$('#security_code').val() },
success: function(html){
var res=html.substring(3);
if(res=="denied")
{
$("#c_pass").attr("disabled",false);
$("#c_pass").val("Submit");
$('#cpass').html("Invalid Security Code. Please try again.");
}
else if(res=="success")
{
$("#c_pass").val("Submit");
$('#cpass').html("<span style='color:green'>Your error has been reported to MyPurpleMartini Development Team.</span>");
$('#name').val('');
$('#email1').val('');
$('#rerr').val('');
$('#security_code').val('');
setTimeout(function() {
$("#c_pass").attr("disabled",false);
$(document).trigger('close.facebox') 
},4000);
}
}
});
}
}

function send_emoticon(m,n,o,p)
{
$.facebox.close();
$.ajax({
type:'POST',
url:'send_emoticons_action.php',
data:{ tbl:n, tid:m, eid:o },
success: function(html){
	setTimeout(function(){
						$.facebox('<div style="color:red;" align="center">Emoticon has been sent.</div>');
						},1000);
var ele="#emo"+n+m;
$(ele).html(parseInt($(ele).html())+1);
}
});
}

function sub_comm_up(tbl,tid,touid)
{
var id=tbl+tid;
var btnid="#btn"+id;
var comid="#com"+id;
var vallid="#viewall"+id;
if(($(comid).val()=="")||($(comid).val()=="Give your comment..."))
{
	alert("Please enter your comment.");
	$(comid).focus();
	return false;
}
$(btnid).val('Wait..');
$(btnid).attr("disabled",true);
$.ajax({
type:'POST',
url:'comment_up_action.php',
data:{ tbl:tbl, tid:tid, touid:touid, com:$(comid).val() },
success: function(html){
$(btnid).val('Submit');
$(btnid).attr("disabled",false);
$(comid).val('');
if($(vallid).val()=="1")
	{
		$("#"+id).load('comments_load.php?tblid='+tid+'&tbl='+tbl+'&viewall=1');
	}
else
	{
		$("#"+id).load('comments_load.php?tblid='+tid+'&tbl='+tbl);
	}
}
});
}

function del_comm_up(m,tbl,tblid)
{
var res=confirm("Are you sure to delete this comment.");
if(res==false)
{
	return false;
}
var vallid="#viewall"+tbl+tblid;
$.facebox('Please wait...');
$.ajax({
type:'POST',
url:'del_comm_up_action.php',
data:{ id:m },
success: function(html){
if($(vallid).val()=="1")
	{
		$('#'+tbl+tblid).load('comments_load.php?tblid='+tblid+'&tbl='+tbl+'&viewall=1',function(){ $.facebox.close(); });
	}
else
	{
		$('#'+tbl+tblid).load('comments_load.php?tblid='+tblid+'&tbl='+tbl,function(){ $.facebox.close(); });
	}
}
});
}

function write_wall(m)
{
	$('#one div').hide();
	$('#'+m).show();
}

function write_wall_sub(m)
{
	if(($('#wall_comm').val()=='Write on board...')||($('#wall_comm').val()==''))
	{
		alert("Please enter the post.");
		$('#wall_comm').focus();
		$('#wall_comm').val('');
		return false;
	}
	$('#ww_btn').val('Please wait...');
	$('#ww_btn').attr('disabled',true);
	$.ajax({
		   type:'POST',
		   url:'ww_sub_action.php',
		   data:{ comment:$('#wall_comm').val(), id:m },
		   success: function(html){
			   $('#ww_btn').val('Submit');
			   $('#ww_btn').attr('disabled',false);
			   $('#response_sub').html(html);
			   setTimeout(function(){
								   location.reload(true);
								   },500);
			   }
		   });
}
