var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
               && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
               && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_nav4 = (is_nav && (is_major == 4));
var is_nav6 = (is_nav && (is_major == 5));
var is_nav6up = (is_nav && (is_major >= 5));
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));

var mouseXStartPos =0;
var mouseYStartPos =0;
var offsetX=0;
var offsetY=0;
var toolTipSTYLE;
isIE=document.all;
var e = new Object();
var url = window.location.href;
var hostPort = url.split('index.php')[0]
var image_loading = '<img style="border:0" src='+hostPort+'images/common/loading2.gif>';
var loader_div_24="<div class=\"loader_img_24\"><img src=\"/themes/french_tuesdays/images/ajax-loader-24x24.gif\" style=\"border:0; padding:0; margin:0;\" /></div>";
var loader_div_16="<div class=\"loader_img_16\"><img src=\"/themes/french_tuesdays/images/ajax-loader-16x16.gif\" style=\"border:0; padding:0; margin:0;\" /></div>";
var domain_name = document.domain;
var notification_img_new_msg = "<img src=\"/themes/french_tuesdays/images/msg_new_message_notification.gif\" />";
var notification_img_friendship_msg = "<img src=\"/themes/french_tuesdays/images/msg_added_friend_notification.gif\" />";
var loader_div_24_blk="<div class=\"loader_img_24\"><img src=\"/themes/french_tuesdays/images/icons/loader.gif\" style=\"border:0; padding:0; margin:0;\" /></div>";

function GetXmlHttpObject(){
	var xmlHttp=null;
	try
	{
 		// Firefox, Opera 8.0+, Safari
 		xmlHttp=new XMLHttpRequest();
 	}
	catch (e){
	 	//Internet Explorer
	 	try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  	}
	 	catch (e){
	  		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  	}
 	}
	return xmlHttp;
}

function loadCal(){
	$('.trip_cal').datepick({showOnFocus: true, showTrigger: '#calImg'});
}

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function loadPage()
{
	if (document.login)
	{
		document.login.email.focus();
		document.login.password.focus();
	}
}

function isValidEmail(str) {
    if (str.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		return true;
	else
		return false;
}

function isCharacter(str){
    if (str.match(/^[A-Za-z\ \-\']+$/) == null){
        return false;
    }
    else{
        return true;
    }
}

function validateForm(){
	var email = $.trim($("input#login_email_input").val());
	var password = $.trim($("input#login_password_input").val());
	var error="";
	var err=0;
	
	if(email.length>0 && email!="email@eprovider.com"){
		if(!isValidEmail(email)){
			err++;
			error=error+"Invalid email entered.\n";
		}
	}
	else{
		if(email.length>0 && email=="email@eprovider.com"){
			err++;
			error=error+"Please enter real email.\n";
		}
		else{
			err++;
			error=error+"Email is required.\n";
		}
	}
	
	if(password.length==0 || password=="" || password==null){
		err++;
		error=error+"Password is required.\n";
	}
	
	error = $.trim(error);
	if(error.length>0 && err > 0){
		alert(error);
		return false;
	}
	
	return true;
	
}

function loginHover(){
	$('input#submit_signin').mouseup(function(){
		$(this).css({"margin-top":"0px"});
	}).mousedown(function(){
		$(this).css({"margin-top":"1px"});
    });
	return false;
}

/* hide selected light-box */
// December 9th, 2011
function hide_box(light_box_id){
	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	if(light_box_id=="event_light_box_book_table"){
		$("div.table_num_bottles > div.event_book_table_bottle").each(function(i){
			if(i>0){
				$(this).empty().remove();
			}
		});
		$('#ppl_num_select').find('option:first').attr('selected', 'selected').parent('select');
	}
	$("div."+light_box_id).css({"display" :"none" , "visibility":"hidden"});
}

/* event policy function */
// December 9th, 2011
function show_event_policy(city_id,light_box_id,request_type){
	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	$("div.event_light_box").css({"display" :"none" , "visibility":"hidden"});
	$("div."+light_box_id).css({"display" :"block" , "visibility":"visible"});
}

/* event chat box */
function activate_chat(city_id,light_box_id,request_type){
	$("div.event_light_box").css({"display" :"none" , "visibility":"hidden"});
	$("div."+light_box_id).css({"display" :"block" , "visibility":"visible"});
}

/* event map directions */
function show_map_directions(city_id,light_box_id,request_type,event_address){
	$("div.event_light_box").css({"display" :"none" , "visibility":"hidden"});
	var map_iframe = document.getElementById("evnt_map_direction");
	map_iframe.src = "http://"+domain_name+"/geomap.php?adr="+event_address;
	$("div."+light_box_id).css({"display" :"block" , "visibility":"visible"});
}
/* show all registered members box */
function show_reg_all(mem_id,evn_id,country_id,light_box_id,request_type,limit_start,limit_end,type){
	$("div.event_light_box").css({"display" :"none" , "visibility":"hidden"});
	load_all_reg_members(mem_id,evn_id,country_id,limit_start,limit_end,type);
	$("div."+light_box_id).css({"display" :"block" , "visibility":"visible"});
}
/* book table box */
function book_table_box(mem_id,evn_id,light_box_id,request_type){
	$("div.event_light_box").css({"display" :"none" , "visibility":"hidden"});
	// calling function to get booked table [if any] by the current logged-in user
	if(mem_id > 0 && evn_id > 0){
		show_booked_table(mem_id , evn_id);
		$("div."+light_box_id).css({"display" :"block" , "visibility":"visible"});
	}
}

function manage_guestlist_box(mem_id,evn_id,light_box_id,request_type){
	$("div.event_light_box").css({"display" :"none" , "visibility":"hidden"});
	$("div.emgla_head").hide();
	$("div.emgla_guest_container").empty().html("");
	$("div.emgla_guest_container").html(loader_div_16).html();
	$("input#invitee_fn_input_new").val("");
	$("input#invitee_ln_input_new").val("");
	$("input#invitee_email_input_new").val("");
	$("input#invitee_phone_input_new").val("");
	$("input#invitee_save_chkbox").removeAttr('checked');
	$("div.emgla_guest_container").empty().html("");
	load_guests_list(mem_id,evn_id);
	$("div."+light_box_id).css({"display" :"block" , "visibility":"visible"});
}

function load_guestList(mem_id,evn_id,light_box_id,request_type){
	$("div.event_light_box").css({"display" :"none" , "visibility":"hidden"});
	load_savedguests_list(mem_id,evn_id,light_box_id,0);
	$("div."+light_box_id).css({"display" :"block" , "visibility":"visible"});
}

function edit_savedguest_info(lbx_id,mem_id,evn_id,mgi_id,inv_id){
	$("div.event_light_box").css({"display" :"none" , "visibility":"hidden"});
	load_currentguest_info(mem_id,evn_id,lbx_id,mgi_id,inv_id);
	$("div."+lbx_id).css({"display" :"block" , "visibility":"visible"});
}

/* MANAGE BOOKED TABLES FUNCTIONS */
function addNewRow(){
	var allele = $("div#hidden_combobox_list").html();
	var elediv = "<div class=\"event_book_table_bottle\" id=\"event_book_table_bottle_0\">"+allele+"</div>"; // row_next
	var eleId = $("div.table_num_bottles > div.event_book_table_bottle").size()*1;
	elediv = elediv.replace("bottle_select_quantity_0" , "bottle_select_quantity_"+(eleId+1)*1);
	elediv = elediv.replace("bottle_type_0" , "bottle_type_"+(eleId+1)*1);
	elediv = elediv.replace("event_book_table_bottle_0" , "event_book_table_bottle_"+(eleId+1)*1);
	elediv = elediv.replace("row_0" , "event_book_table_bottle_"+(eleId+1)*1);
	elediv = elediv.replace(-1 , (eleId+1)*1);
	elediv = elediv.replace("-1" , (eleId+1)*1);
	$("div.table_num_bottles").append(elediv);
	$("div.table_num_bottles > div#event_book_table_bottle_"+eleId+" > div.nb_bottles_types > div.select_bottle_add").removeClass("row_current").addClass("row_prev").removeClass("row_current");
	$("div.table_num_bottles > div#event_book_table_bottle_"+(eleId+1)+" > div.nb_bottles_types > div.select_bottle_add").removeClass("row_next").addClass("row_current").removeClass("row_next");
	$("div.table_num_bottles > div#event_book_table_bottle_"+eleId+" > div.nb_bottles_types > div.row_prev > a").hide();
}

function removeRow(id,index){
	var eleSizeO = $("div.table_num_bottles > div.event_book_table_bottle").size();
	var eleId = "event_book_table_bottle_"+(id*1);
	var index = $("div.table_num_bottles > div#"+eleId+" > div.nb_bottles_types > div.select_bottle_delete a").attr("id");
	var counter=0;
	var idSetter = 1;
	var removeEle = false;
	$("div.table_num_bottles > div.event_book_table_bottle").each(function(){
		if(!removeEle){
			counter = counter+1;
		}
		var eleCheck = "event_book_table_bottle_"+counter;
		if(eleId==eleCheck){
			if(eleSizeO>1){
				$("#"+eleId).empty().remove();
				removeEle = true;
			}
			else{
				alert("Cannot delete the first record.");
			}
		}
		
	});
	var eleSizeN = $("div.table_num_bottles > div.event_book_table_bottle").size();
	if(index < eleSizeN){
		$("div.table_num_bottles > div.event_book_table_bottle").each(function(i){
			$(this).removeAttr("id");
			$(this).attr("id" , "event_book_table_bottle_"+(i+1)*1);
			$("div.nb_bottles_types > div.select_bottle_delete > a" , this).removeAttr("id");
			$("div.nb_bottles_types > div.select_bottle_delete > a" , this).attr("id" , (i+1)*1);
			$("div.nb_bottles > div.nb_bottle_select > select" , this).removeAttr("id");
			$("div.nb_bottles > div.nb_bottle_select > select" , this).attr("id" , "bottle_select_quantity_"+(i+1)*1);
			$("div.nb_bottles_types > div.nb_bottle_type > select" , this).removeAttr("id");
			$("div.nb_bottles_types > div.nb_bottle_type > select" , this).attr("id" , "bottle_type_"+(i+1)*1);
		});
	}
	else if(index > eleSizeN){ // 
		$("div.table_num_bottles > div.event_book_table_bottle").each(function(i){
			$(this).removeAttr("id");
			$(this).attr("id" , "event_book_table_bottle_"+(i+1)*1);
			$("div.nb_bottles_types > div.select_bottle_delete > a" , this).removeAttr("id");
			$("div.nb_bottles_types > div.select_bottle_delete > a" , this).attr("id" , (i+1)*1);
			$("div.nb_bottles > div.nb_bottle_select > select" , this).removeAttr("id");
			$("div.nb_bottles > div.nb_bottle_select > select" , this).attr("id" , "bottle_select_quantity_"+(i+1)*1);
			$("div.nb_bottles_types > div.nb_bottle_type > select" , this).removeAttr("id");
			$("div.nb_bottles_types > div.nb_bottle_type > select" , this).attr("id" , "bottle_type_"+(i+1)*1);
			if(eleSizeN==((i+1)*1)){ // 2=2
				$("div.nb_bottles_types > div.select_bottle_add", this).removeClass("row_prev").addClass("row_current").removeClass("row_prev");
				$("div.nb_bottles_types > div.row_current > a" , this).show();
			}
		});
	}
	else if(index == eleSizeN){
		$("div.table_num_bottles > div.event_book_table_bottle").each(function(i){
			$(this).removeAttr("id");
			$(this).attr("id" , "event_book_table_bottle_"+(i+1)*1);
			$("div.nb_bottles_types > div.select_bottle_delete > a" , this).removeAttr("id");
			$("div.nb_bottles_types > div.select_bottle_delete > a" , this).attr("id" , (i+1)*1);
			$("div.nb_bottles > div.nb_bottle_select > select" , this).removeAttr("id");
			$("div.nb_bottles > div.nb_bottle_select > select" , this).attr("id" , "bottle_select_quantity_"+(i+1)*1);
			$("div.nb_bottles_types > div.nb_bottle_type > select" , this).removeAttr("id");
			$("div.nb_bottles_types > div.nb_bottle_type > select" , this).attr("id" , "bottle_type_"+(i+1)*1);
		});
	}
}
/* event registration*/
// December 21st, 2011
function event_register(mem_id,level_id,evn_id,returnUrl,contextPath,hash_string){
    if(level_id == 15 || level_id == 16){//only web member or pending approval
        if(!confirm("Remember you can register to only 2 events per year. Register only if you are sure to come. In case of no-show, registration rights won't be recredited on your profile.")){
            return;
        }
    }
    var xmlHttpReq = false;
    var self = this;
	var attend = document.getElementById("attend");
	var notattend = document.getElementById("notattend");
    var send_cell_phone = document.getElementById("send_cell_phone");
    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if (window.ActiveXObject){//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
	$("div#main_event_loader").css("visibility","visible");
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if(self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
            errorNumber = self.xmlHttpReq.responseText;	
            if(errorNumber == "1"){
                //document.location.href = returnUrl;
                document.location.href = returnUrl+"/?registered="+hash_string;
            }
            else if(errorNumber == "2"){
                alert("You can not register for this event because of member city restriction.");
                notattend.checked="true";

            }
            else if(errorNumber == "3"){
                alert("You have reached the maximum number of events you can attend. Please contact FT Team for more explanations.");
               	notattend.checked="true";
            }
            else if(errorNumber == "4"){
                alert("The registration still has not opened or the registration is closed.");
            	notattend.checked="true";

            }
            else if(errorNumber == "5"){
                alert("You have reach the maximum of attendees.");
                notattend.checked="true";
            }
            else if(errorNumber.charAt(0) == '0'){
                var sur_id = errorNumber.substring(1,errorNumber.length);
                //document.location.href = contextPath + "index.php?page=polls&section=vote&sur="+sur_id;
            }
        }
    }
    if(send_cell_phone){
        if(send_cell_phone.checked){
            self.xmlHttpReq.send("handler=events&action=reg&id="+evn_id+"&send_confirm=1");
        }
        else{
            self.xmlHttpReq.send("handler=events&action=reg&id="+evn_id);
        }
    }
    else{
        self.xmlHttpReq.send("handler=events&action=reg&id="+evn_id);
    }

}
/* event unregistration */
function UnregisterEvent(mem_id,evn_id,url){
    var xmlHttpReq = false;
    var self = this;
	var attend = document.getElementById("attend");
	var notattend = document.getElementById("notattend");
    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if (window.ActiveXObject){//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
	$("div#main_event_loader").css("visibility","visible");
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if(self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
            if(self.xmlHttpReq.responseText == 1){
                document.location.href = url;
            }
            else if(self.xmlHttpReq.responseText == 2){
                alert("You can not register for this event because of member city restriction.");
               	attend.checked = 'true';
            }
            else if(self.xmlHttpReq.responseText == 4){
                alert("The registration still has not opened or the registration is closed.");
               	attend.checked = 'true'
            }
        }
    }
    self.xmlHttpReq.send("handler=events&action=unreg&id="+evn_id);
}
/* BOOK TABLE FUNCTION */
function show_booked_table(mem_id , evn_id){
    var xmlHttpReq = false;
    var self = this;
	var respText;
    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject){//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			if(respText=="nam"){	// no mem id
				// nothing
			}
			else if(respText=="nae"){	// no event id
				// nothing
			}
			else if(respText=="ntf"){	// no table found
				$("div.event_book_table_container").html("");
				$("div#evn_bk_tbl_ttl").html("");
				$("div#evn_bk_tbl_ttl").html("You currently have no table(s) booked. Use the section below to book a table").html();
				show_available_bottles(mem_id , evn_id);
			}
			else{
				$("div.table_num_bottles > div.event_book_table_bottle").each(function(i){
					if(i>0){
						$(this).empty().remove();
					}
				});
				
				$("div#evn_bk_tbl_ttl").html("Booked table(s)");
				$("div.event_book_table_container").html(respText).html();
				// calling function to list available services for this level of member
				show_available_bottles(mem_id , evn_id);
			}			
        }
    }
    self.xmlHttpReq.send("handler=events&action=show_saved_table&mem_id="+mem_id+"&evn_id="+evn_id);
}

function show_available_bottles(mem_id,evn_id){
	var xmlHttpReq = false;
    var self = this;
	var respText;
    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject){//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			if(respText=="nam"){	// no mem id
				// nothing
			}
			else if(respText=="nae"){	// no event id
				// nothing
			}
			else if(respText=="ntf"){	// no table found
				$("div#evn_bk_tbl_ttl").html("");
				$("div#evn_bk_tbl_ttl").html("You currently have no table(s) booked. Use the section below to book a table").html();
			}
			else{

				$("div#event_book_table_bottle_1").html("");
				var respTextT = respText;
				respText = respText.replace("bottle_select_quantity_0" , "bottle_select_quantity_1");
				respText = respText.replace("bottle_type_0" , "bottle_type_1");
				respText = respText.replace("XXX000" , "1");
				$("div#event_book_table_bottle_1").html(respText).html();
				$("div#hidden_combobox_list").html("");
				respTextT = respTextT.replace("XXX000" , "-1");
				$("div#hidden_combobox_list").html(respTextT).html();
			}
        }
    }
    self.xmlHttpReq.send("handler=events&action=show_available_bottles&mem_id="+mem_id+"&evn_id="+evn_id);
}

function addTable(mem_id,evn_id){
	var selec="";
	var nb_type="";
	var nb_quantity="";
	var arrayParameters = new Array();
	$("select.bottle_select_quantity :selected").each(function(i){
		if(i > 0){
			if(i==1){
				nb_quantity = nb_quantity+$(this).val()*1;
			}
			else{
				nb_quantity = nb_quantity+":"+$(this).val()*1;
			}
		}
	});
	$("select.bottle_type :selected").each(function(i){
		if(i > 0){
			if(i==1)
			{
				nb_type = nb_type+$(this).val()*1;
			}
			else{
				nb_type = nb_type+":"+$(this).val()*1;
			}
			
		}
	});
	var ppl_num = $("select#ppl_num_select :selected").val()*1;
	ppl_num = ppl_num+"_"+nb_quantity+"_"+nb_type;
	var xmlHttpReq = false;
    var self = this;
	var respText;
    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject){//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){           
			respText = self.xmlHttpReq.responseText;			
			if(respText=="nam"){	// no mem id
				// nothing
			}
			else if(respText=="nae"){	// no event id
				// nothing
			}
			else if(respText=="ntf"){	// no table found
				
			}
			else if(respText=="nav"){	// no table found
				
			}
			else{
				show_booked_table(mem_id , evn_id);
				$('#ppl_num_select').find('option:first').attr('selected', 'selected').parent('select');
			}
        }
    }
    self.xmlHttpReq.send("handler=events&action=add_service_table&mem_id="+mem_id+"&evn_id="+evn_id+"&values="+ppl_num);
}

function pop_rest(id){
	var eleNum = id.id;
	eleNum = eleNum.split("_"); //bottle_type_2
	var as_id = id.value;
	var xmlHttpReq = false;
    var self = this;
	var respText;

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject){//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){            
			respText = self.xmlHttpReq.responseText;			
			if(respText=="nam"){	// no mem id
				// nothing
			}
			else if(respText=="nae"){	// no event id
				// nothing
			}
			else if(respText=="ntf"){	// no table found
				
			}
			else if(respText=="nav"){	// no table found
				
			}
			else{
				$("div.table_num_bottles > div#event_book_table_bottle_"+eleNum[2]+" > div.nb_bottles > div.nb_bottle_select").html();
				respText = respText.replace("bottle_select_quantity_x" , "bottle_select_quantity_"+eleNum[2]);
				$("div.table_num_bottles > div#event_book_table_bottle_"+eleNum[2]+" > div.nb_bottles > div.nb_bottle_select").html(respText).html();
			}
        }
    }
    self.xmlHttpReq.send("handler=events&action=show_min_max&as_id="+as_id);
}

// edit services table
function editTable(mem_id,evn_id,tbl_id){
	$("div.table_num_bottles > div.event_book_table_bottle").each(function(i){
		if(i>0){
			$("div#event_book_table_bottle_"+(i+1) , this).empty().remove();
		}
	});
	$('#ppl_num_select').find('option:first').attr('selected', 'selected').parent('select');
	$("div.event_light_box").css({"display" :"none" , "visibility":"hidden"});
	$("div.event_light_box_edit_booked_tbl").css({"display" :"block" , "visibility":"visible"});
	var xmlHttpReq = false;
	var self = this;
	var respText;

	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			if(respText=="nam"){	// no mem id
				// nothing
			}
			else if(respText=="nae"){	// no event id
				// nothing
			}
			else if(respText=="nav"){	// no event id
				// nothing
			}
			else if(respText=="ntf"){	// no table found
				// nothing
			}
			else{
				$("div.edit_event_selecte_your_table").empty().html("");
				$("div.edit_event_selecte_your_table").html(respText).html();
				$("div.edit_edit_event_book_table_save > div.edit_delete_booked_table > a").attr("id" , "delete_"+mem_id+"_"+evn_id+"_"+tbl_id);
				$("div.edit_edit_event_book_table_save > div.edit_save_booked_table > a").attr("id" , "save_"+mem_id+"_"+evn_id+"_"+tbl_id);
			}
		}
	}
	self.xmlHttpReq.send("handler=events&action=edit_service_table&mem_id="+mem_id+"&evn_id="+evn_id+"&tbl_id="+tbl_id);
}
// delete services table
function deleteTable(mem_id,evn_id,tbl_id){
	var conf_del = confirm("Do you really want to delete this table?\nServices included in this table may not be available later.");
	if(conf_del){
		var xmlHttpReq = false;
		var self = this;
		var respText;

		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				if(respText=="nam"){	// no mem id
					// nothing
				}
				else if(respText=="nae"){	// no event id
					// nothing
				}
				else if(respText=="nav"){	// no event id
					// nothing
				}
				else if(respText=="ntf"){	// no table found
					$("div.event_book_table_container").html("");
					$("div#evn_bk_tbl_ttl").html("");
					$("div#evn_bk_tbl_ttl").html("You currently have no table(s) booked. Use the section below to book a table").html();
					show_available_bottles(mem_id , evn_id);
				}
				else{
					$("div#evn_bk_tbl_ttl").html("Booked table(s)");
					$("div.event_book_table_container").html(respText).html();
				}
			}
		}
		self.xmlHttpReq.send("handler=events&action=delete_service_table&mem_id="+mem_id+"&evn_id="+evn_id+"&tbl_id="+tbl_id);
	}
}

function edit_addRow(){
	var ext_rows = $("div.edit_table_num_bottles > div.edit_event_book_table_bottle").size()*1;
	var new_row = (ext_rows*1)+1;	// 4
	var curr_row = (ext_rows*1)-1;	// 3 [eq(3) = 4th row]
	$("div.edit_table_num_bottles > div.edit_event_book_table_bottle").eq(curr_row).clone().appendTo("div.edit_table_num_bottles");
	$("div.edit_table_num_bottles > div.edit_event_book_table_bottle").each(function(i){
		if(i==curr_row){
		$("div.edit_edit_nb_bottles_types > div.edit_select_bottle_add" ,this).hide();
		}
		if(i==ext_rows){
			$(this).removeAttr("id");
			$(this).attr("id" , "edit_event_book_table_bottle_"+(new_row*1));			
			$("div.edit_nb_bottles" , this).removeAttr("id");
			$("div.edit_nb_bottles" , this).attr("id" , "edit_nb_bottles_"+(new_row*1));			
			$("div.edit_nb_bottles > div.edit_nb_bottle_select" , this).removeAttr("id");
			$("div.edit_nb_bottles > div.edit_nb_bottle_select" , this).attr("id" , "edit_nb_bottle_select_"+(new_row*1));			
			$("div.edit_nb_bottles > div.edit_nb_bottle_select > select.edit_bottle_select_quantity" , this).removeAttr("id");
			$("div.edit_nb_bottles > div.edit_nb_bottle_select > select.edit_bottle_select_quantity" , this).attr("id" , "edit_bottle_select_quantity_"+(new_row*1));
			$("div.edit_nb_bottles > div.edit_nb_bottle_select > select.edit_bottle_select_quantity" , this).find('option:first').attr('selected', 'selected').parent('select');			
			$("div.edit_edit_nb_bottles_types > div.edit_nb_edit_bottle_type > select.edit_edit_bottle_type" , this).removeAttr("id");
			$("div.edit_edit_nb_bottles_types > div.edit_nb_edit_bottle_type > select.edit_edit_bottle_type" , this).attr("id" , "edit_edit_bottle_type_"+(new_row*1));			
			$("div.edit_edit_nb_bottles_types > div.edit_select_bottle_delete > a" , this).removeAttr("id");
			$("div.edit_edit_nb_bottles_types > div.edit_select_bottle_delete > a" , this).removeAttr("alt");
			$("div.edit_edit_nb_bottles_types > div.edit_select_bottle_delete > a" , this).attr("alt" , "no_data_bound");
			$("div.edit_edit_nb_bottles_types > div.edit_select_bottle_delete > a" , this).attr("id" , "edit_select_bottle_delete_"+(new_row*1));
			$("div.edit_edit_nb_bottles_types > div.edit_select_bottle_delete > a" , this).removeAttr("rel");
			$("div.edit_edit_nb_bottles_types > div.edit_select_bottle_delete > a" , this).attr("rel" , "0");			
			$("div.edit_edit_nb_bottles_types > div.edit_select_bottle_add > a" , this).removeAttr("id");
			$("div.edit_edit_nb_bottles_types > div.edit_select_bottle_add > a" , this).attr("id" , "edit_select_bottle_add_"+(new_row*1));
		}
	});
}

function edit_deleteRow(id){
	var check_del_type = $("a#"+id).attr("alt");
	var eleNum = id.split("_");
	eleNum = eleNum[4];
	var ext_rows = $("div.edit_table_num_bottles > div.edit_event_book_table_bottle").size()*1;
	if(check_del_type=="no_data_bound"){
		if(eleNum==ext_rows){
			$("div#edit_event_book_table_bottle_"+(eleNum*1)).empty().remove();
			$("div#edit_event_book_table_bottle_"+((eleNum-1)*1)+" > div.edit_edit_nb_bottles_types > div.edit_select_bottle_add").show();
		}
		if(eleNum < ext_rows){
			$("div#edit_event_book_table_bottle_"+(eleNum*1)).empty().remove();
			var new_eleNum = (eleNum-1)*1;
			var new_row = eleNum*1;
			$("div.edit_table_num_bottles > div.edit_event_book_table_bottle").each(function(i){
				if(i>=new_eleNum){
					$(this).removeAttr("id");
					$(this).attr("id" , "edit_event_book_table_bottle_"+(new_row*1));
					
					$("div.edit_nb_bottles" , this).removeAttr("id");
					$("div.edit_nb_bottles" , this).attr("id" , "edit_nb_bottles_"+(new_row*1));
					
					$("div.edit_nb_bottles > div.edit_nb_bottle_select" , this).removeAttr("id");
					$("div.edit_nb_bottles > div.edit_nb_bottle_select" , this).attr("id" , "edit_nb_bottle_select_"+(new_row*1));
					
					$("div.edit_nb_bottles > div.edit_nb_bottle_select > select.edit_bottle_select_quantity" , this).removeAttr("id");
					$("div.edit_nb_bottles > div.edit_nb_bottle_select > select.edit_bottle_select_quantity" , this).attr("id" , "edit_bottle_select_quantity_"+(new_row*1));
					$("div.edit_nb_bottles > div.edit_nb_bottle_select > select.edit_bottle_select_quantity" , this).find('option:first').attr('selected', 'selected').parent('select');
					
					$("div.edit_edit_nb_bottles_types > div.edit_nb_edit_bottle_type > select.edit_edit_bottle_type" , this).removeAttr("id");
					$("div.edit_edit_nb_bottles_types > div.edit_nb_edit_bottle_type > select.edit_edit_bottle_type" , this).attr("id" , "edit_edit_bottle_type_"+(new_row*1));
					
					$("div.edit_edit_nb_bottles_types > div.edit_select_bottle_delete > a" , this).removeAttr("id");
					$("div.edit_edit_nb_bottles_types > div.edit_select_bottle_delete > a" , this).removeAttr("alt");
					$("div.edit_edit_nb_bottles_types > div.edit_select_bottle_delete > a" , this).attr("alt" , "no_data_bound");
					$("div.edit_edit_nb_bottles_types > div.edit_select_bottle_delete > a" , this).attr("id" , "edit_select_bottle_delete_"+(new_row*1));
					$("div.edit_edit_nb_bottles_types > div.edit_select_bottle_delete > a" , this).removeAttr("rel");
					$("div.edit_edit_nb_bottles_types > div.edit_select_bottle_delete > a" , this).attr("rel" , "0");
					
					$("div.edit_edit_nb_bottles_types > div.edit_select_bottle_add > a" , this).removeAttr("id");
					$("div.edit_edit_nb_bottles_types > div.edit_select_bottle_add > a" , this).attr("id" , "edit_select_bottle_add_"+(new_row*1));
					new_row=new_row+1;
				}
			});
		}
	}
	else{
		if(ext_rows == 1){
			alert("Please use [Delete booked table] link [bottom left]\nto remove the last service.");
		}
		else{
			var conf_del = confirm("Do you really want to delete this Service? This service may not be available later.");
			if(conf_del){
				var check_rel = $("a#"+id).attr("rel");
				check_rel = check_rel.split("_");	// [0]mem_id_[1]evn_id_[2]tbl_id_[3]msb_id
				var mem_id = check_rel[0] * 1;
				var evn_id = check_rel[1] * 1;
				var tbl_id = check_rel[2] * 1;
				var msb_id = check_rel[3] * 1;
			
				var xmlHttpReq = false;
				var self = this;
				var respText;

				if(window.XMLHttpRequest){//Mozilla/Safari
					self.xmlHttpReq = new XMLHttpRequest();
				}
				else if(window.ActiveXObject){//IE
					self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
				}
				self.xmlHttpReq.open('POST', "index.php", true);
				self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				self.xmlHttpReq.onreadystatechange = function(){
					if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
						respText = self.xmlHttpReq.responseText;
						if(respText=="nam"){	// no mem id
							// nothing
						}
						else if(respText=="nae"){	// no event id
							// nothing
						}
						else if(respText=="nav"){	// no event id
							// nothing
						}
						else if(respText=="nab"){	// no bottle service found
							// nothing
						}
						else{
							//all services deleted.
							if(respText=="nsf"){
								$("div.edit_event_selecte_your_table").empty().html("");
								$("div.edit_edit_event_book_table_save > div.edit_delete_booked_table > a").removeAttr("id");
								$("div.edit_edit_event_book_table_save > div.edit_save_booked_table > a").removeAttr("id");
								book_table_box(mem_id,evn_id,'event_light_box_book_table','event_book_table');
							}
							else{
								$("div.edit_event_selecte_your_table").empty().html("");
								$("div.edit_event_selecte_your_table").html(respText).html();
								$("div.edit_edit_event_book_table_save > div.edit_delete_booked_table > a").attr("id" , "delete_"+mem_id+"_"+evn_id+"_"+tbl_id);
								$("div.edit_edit_event_book_table_save > div.edit_save_booked_table > a").attr("id" , "save_"+mem_id+"_"+evn_id+"_"+tbl_id);
							}
						}
					}
				}
				self.xmlHttpReq.send("handler=events&action=edit_deleterow&mem_id="+mem_id+"&evn_id="+evn_id+"&tbl_id="+tbl_id+"&msb_id="+msb_id);
			}
		}
	}
}
// delete edited table
function edit_deleteTable(id){
	var eleParams = id;
	eleParams = eleParams.split("_");
	mem_id = eleParams[1]*1;
	evn_id = eleParams[2]*1;
	tbl_id = eleParams[3]*1;
	var conf_del = confirm("Do you really want to delete this table?\nServices included in this table may not be available later.");
	if(conf_del){
		var xmlHttpReq = false;
		var self = this;
		var respText;

		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				if(respText=="nam"){	// no mem id
					// nothing
				}
				else if(respText=="nae"){	// no event id
					// nothing
				}
				else if(respText=="nav"){	// no event id
					// nothing
				}
				else if(respText=="ntf"){	// no table found
					$("div.edit_event_selecte_your_table").empty().html("");
					$("div.edit_edit_event_book_table_save > div.edit_delete_booked_table > a").removeAttr("id");
					$("div.edit_edit_event_book_table_save > div.edit_save_booked_table > a").removeAttr("id");
					$("div.event_book_table_container").html("");
					$("div#evn_bk_tbl_ttl").html("");
					$("div#evn_bk_tbl_ttl").html("You currently have no table(s) booked. Use the section below to book a table").html();
					book_table_box(mem_id,evn_id,'event_light_box_book_table','event_book_table');
				}
				else{
					$("div.edit_event_selecte_your_table").empty().html("");
					$("div.edit_edit_event_book_table_save > div.edit_delete_booked_table > a").removeAttr("id");
					$("div.edit_edit_event_book_table_save > div.edit_save_booked_table > a").removeAttr("id");
					$("div.event_book_table_container").html("");
					$("div#evn_bk_tbl_ttl").html("");
					book_table_box(mem_id,evn_id,'event_light_box_book_table','event_book_table');
				}
			}
		}
		self.xmlHttpReq.send("handler=events&action=edit_delete_service_table&mem_id="+mem_id+"&evn_id="+evn_id+"&tbl_id="+tbl_id);
	}
}

function edit_saveTable(id){
	var eleParams = id;
	eleParams = eleParams.split("_");
	mem_id = eleParams[1]*1;
	evn_id = eleParams[2]*1;
	tbl_id = eleParams[3]*1;
	
	var selec="";
	var nb_type="";
	var nb_quantity="";
	var arrayParameters = new Array();
	$("select.edit_bottle_select_quantity :selected").each(function(i){
		if(i==0){
			nb_quantity = nb_quantity+$(this).val()*1;
		}
		else{
			nb_quantity = nb_quantity+":"+$(this).val()*1;
		}
		
	});
	$("select.edit_edit_bottle_type :selected").each(function(i){
		if(i==0)
		{
			nb_type = nb_type+$(this).val()*1;
		}
		else{
			nb_type = nb_type+":"+$(this).val()*1;
		}		
	});
	var ppl_num = $("select#edit_ppl_num_select :selected").val()*1;
	ppl_num = ppl_num+"_"+nb_quantity+"_"+nb_type;
	
	var xmlHttpReq = false;
	var self = this;
	var respText;

	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			if(respText=="nam"){	// no mem id
				// nothing
			}
			else if(respText=="nae"){	// no event id
				// nothing
			}
			else if(respText=="nav"){	// no event id
				// nothing
			}
			else if(respText=="ntf"){	// no table found
				// nothing
			}
			else{
				alert("Changes have been saved.");
				$("div.edit_event_selecte_your_table").empty().html("");
				$("div.edit_edit_event_book_table_save > div.edit_delete_booked_table > a").removeAttr("id");
				$("div.edit_edit_event_book_table_save > div.edit_save_booked_table > a").removeAttr("id");
				$("div.event_book_table_container").html("");
				$("div#evn_bk_tbl_ttl").html("");
				book_table_box(mem_id,evn_id,'event_light_box_book_table','event_book_table');
			}
		}
	}
	self.xmlHttpReq.send("handler=events&action=edit_save_service_table&mem_id="+mem_id+"&evn_id="+evn_id+"&tbl_id="+tbl_id+"&values="+ppl_num);
}

function loadBottleNum(id){
	var eleNum = id.id;
	eleNum = eleNum.split("_"); //edit_edit_bottle_type_x	[eleNum[4]] / edit_bottle_select_quantity_x [eleNum[4]]
	var as_id = id.value;
	var xmlHttpReq = false;
    var self = this;
	var respText;

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject){//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			
			if(respText=="nam"){	// no mem id
				// nothing
			}
			else if(respText=="nae"){	// no event id
				// nothing
			}
			else if(respText=="ntf"){	// no table found
				
			}
			else if(respText=="nav"){	// no table found
				
			}
			else{
				$("div.edit_table_num_bottles > div#edit_event_book_table_bottle_"+eleNum[4]+" > div#edit_nb_bottles_"+eleNum[4]+" > div#edit_nb_bottle_select_"+eleNum[4]).html();
				respText = respText.replace("edit_bottle_select_quantity_x" , "edit_bottle_select_quantity_"+eleNum[4]);
				$("div.edit_table_num_bottles > div#edit_event_book_table_bottle_"+eleNum[4]+" > div#edit_nb_bottles_"+eleNum[4]+" > div#edit_nb_bottle_select_"+eleNum[4]).html(respText).html();	
			}
        }
    }
    self.xmlHttpReq.send("handler=events&action=edit_show_min_max&as_id="+as_id);	
}

function load_guests_list(mem_id,evn_id){
	$("div.emgla_head").hide();
	$("div.emgla_guest_container").empty().html("");
	$("div.emgla_guest_container").html(loader_div_16).html();
	$("div.invitee_add_guest_btn > a").hide();
	$("div.emgla_invite_select_saved_guest").hide();
	var xmlHttpReq = false;
    var self = this;
	var respText;

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject){//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			
			if(respText=="nam"){	// no mem id
				// nothing
			}
			else if(respText=="nae"){	// no event id
				// nothing
			}
			else{
				$("div.emgla_head").show();
				$("div.emgla_guest_container").empty().html("");
				$("div.emgla_guest_container").html(respText).html();
				$("div.emgla_head > div.emgla_num").empty().html("");
				$("div.emgla_head > div.emgla_num").html($("input#total_invitations").val()*1);
				var a = $("input#max_guests_allowed").val()*1;
				if(a == 0){
					$("div.invitee_add_guest_btn > a").hide();
					$("div.emgla_invite_select_saved_guest").hide();
				}
				else{
					$("div.invitee_add_guest_btn > a").show();
					$("div.emgla_invite_select_saved_guest").show();
				}
				if(a==-1){
					a="Unlimited"
				}
				$("div.emgla_can_invite > div.emgla_can_invite_msg > span.emgla_can_invite_num").empty().html("");
				$("div.emgla_can_invite > div.emgla_can_invite_msg > span.emgla_can_invite_num").html(a);
				var b = $("input#available_all_seats").val()*1;
				var c = $("input#available_guestadd_num").val()*1;
				if(b < c && b!=0 && b!=-1){	// available slots are less than current member's guest allotment
					$("div.emgla_can_invite > div.emgla_can_invite_msg > span.emgla_can_invite_num").empty().html("");
					$("div.emgla_can_invite > div.emgla_can_invite_msg > span.emgla_can_invite_num").html(b*1);
				}
				if(b == 0){
					$("div.emgla_can_invite > div.emgla_can_invite_msg > span.emgla_can_invite_num").empty().html("");
					$("div.emgla_can_invite > div.emgla_can_invite_msg > span.emgla_can_invite_num").html("Fully booked");
					$("div.invitee_add_guest_btn > a").hide();
					$("div.emgla_invite_select_saved_guest").hide();
				}
			}
        }
    }
    self.xmlHttpReq.send("handler=events&action=load_guests_list&mem_id="+mem_id+"&evn_id="+evn_id);
}

function delete_guest_info(mem_id,evn_id,inv_id){
	var conf_del = confirm("Do you really want to delete this guest?");
	if(conf_del){
		$("div.emgla_head").hide();
		$("div.emgla_guest_container").empty().html("");
		$("div.emgla_guest_container").html(loader_div_16).html();
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				if(respText=="nam"){	// no mem id
					// nothing
				}
				else if(respText=="nae"){	// no event id
					// nothing
				}
				else if(respText=="nai"){	// no invitation id
					
				}
				else{
					$("div.emgla_head").show();
					$("div.emgla_guest_container").empty().html("");
					$("div.emgla_guest_container").html(respText).html();
					$("div.emgla_head > div.emgla_num").empty().html("");
					$("div.emgla_head > div.emgla_num").html($("input#total_invitations").val()*1);
					var a = $("input#max_guests_allowed").val()*1;
					if(a == 0){
						$("div.invitee_add_guest_btn > a").hide();
						$("div.emgla_invite_select_saved_guest").hide();
					}
					else{
						$("div.invitee_add_guest_btn > a").show();
						$("div.emgla_invite_select_saved_guest").show();
					}
					
					if(a==-1){
						a="Unlimited"
					}
					$("div.emgla_can_invite > div.emgla_can_invite_msg > span.emgla_can_invite_num").empty().html("");
					$("div.emgla_can_invite > div.emgla_can_invite_msg > span.emgla_can_invite_num").html(a);
					var b = $("input#available_all_seats").val();
					var c = $("input#available_guestadd_num").val();
					if(b < c && b!=0 && b!=-1){	// available slots are less than current member's guest allotment
						$("div.emgla_can_invite > div.emgla_can_invite_msg > span.emgla_can_invite_num").empty().html("");
						$("div.emgla_can_invite > div.emgla_can_invite_msg > span.emgla_can_invite_num").html(b*1);
					}
					if(b == 0){
						$("div.emgla_can_invite > div.emgla_can_invite_msg > span.emgla_can_invite_num").empty().html("");
						$("div.emgla_can_invite > div.emgla_can_invite_msg > span.emgla_can_invite_num").html("Fully booked");
						$("div.invitee_add_guest_btn > a").hide();
						$("div.emgla_invite_select_saved_guest").hide();
					}
					var email_found = $("input#notify_email").val();	// yes or no
					var allowed_delete = $("input#allowed_delete").val();	// no
					if(allowed_delete=="yes" && email_found=="yes"){
						alert("Guest removed successfully.\nA notification email has been sent.");
					}
					if(allowed_delete=="yes" && email_found=="no"){
						alert("Guest removed successfully.");
					}
					if(allowed_delete=="no"){
						alert("Unable to remove guest due to event restrictions.");
					}
				}		
			}
		}
		self.xmlHttpReq.send("handler=events&action=delete_guest_info&mem_id="+mem_id+"&evn_id="+evn_id+"&inv_id="+inv_id);
	} // if conf
}
// edit selected guests info [if exists in [members_guests_invited] then update this table as well] otherwsie update [invitations] table only
function edit_guest_info(mem_id,evn_id,inv_id,type){
	var xmlHttpReq = false;
	var self = this;
	var respText;

	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){			
			respText = self.xmlHttpReq.responseText;			
			if(respText=="nam"){	// no mem id
				// nothing
			}
			else if(respText=="nae"){	// no event id
				// nothing
			}
			else if(respText=="nai"){	// no invitation id
				
			}
			else if(respText=="nat"){	// no type available
			
			}
			else{				
				$("div.event_light_box").css({"display" :"none" , "visibility":"hidden"});				
				$("div.emgla_invite_edit > div.emgla_invite_row_edit").empty().html("");
				$("div.emgla_invite_edit > div.emgla_invite_row_edit").html(respText).html();				
				$("div.emgla_can_invite_edit > div.emgla_can_invite_btn > a").removeAttr("id");
				$("div.emgla_can_invite_edit > div.emgla_can_invite_btn > a").attr("id" , ""+inv_id+"");				
				$("div.evnt_mng_gstlst_edt").css({"display" :"block" , "visibility":"visible"});				
			}
		}
	}
	self.xmlHttpReq.send("handler=events&action=load_edit_save_guest_info&mem_id="+mem_id+"&evn_id="+evn_id+"&inv_id="+inv_id+"&type="+type);
}
// save invited guests info into [members_guests_invited] table for future use.
function save_guest_info(mem_id,evn_id,inv_id){
	var xmlHttpReq = false;
	var self = this;
	var respText;

	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;			
			if(respText=="nam"){	// no mem id
				// nothing
			}
			else if(respText=="nae"){	// no event id
				// nothing
			}
			else if(respText=="nai"){	// no invitation id
				
			}
			else{
				$("div.emgla_guest_container").empty().html("");
				$("div.emgla_guest_container").html(respText).html();				
				$("div.emgla_head > div.emgla_num").empty().html("");
				$("div.emgla_head > div.emgla_num").html($("input#total_invitations").val()*1);				
				var a = $("input#max_guests_allowed").val()*1;				
				if(a == 0){
					$("div.invitee_add_guest_btn > a").hide();
					$("div.emgla_invite_select_saved_guest").hide();
				}
				else{
					$("div.invitee_add_guest_btn > a").show();
					$("div.emgla_invite_select_saved_guest").show();
				}				
				if(a==-1){
					a="Unlimited"
				}				
				$("div.emgla_can_invite > div.emgla_can_invite_msg > span.emgla_can_invite_num").empty().html("");
				$("div.emgla_can_invite > div.emgla_can_invite_msg > span.emgla_can_invite_num").html(a);
				alert("Guest saved for future event(s) invitation(s)");
			}		
		}
	}
	self.xmlHttpReq.send("handler=events&action=save_guest_info&mem_id="+mem_id+"&evn_id="+evn_id+"&inv_id="+inv_id);
}

function save_edited_guestInfo(element,mem_id,evn_id){
	var inv_id = element;
	var fname = $("input#invitee_fn_input_edit").val();
	var lname = $("input#invitee_ln_input_edit").val();
	var email = $("input#invitee_email_input_edit").val();
	var phone = $("input#invitee_phone_input_edit").val();
	var already_saved = $("input#already_saved").val();
	var save_new_guest = $("input#invitee_savechkbox_edit").is(':checked')==true?"y":"n";
	var org_fname = $("input#org_invitee_fn_input_edit").val();
	var org_lname = $("input#org_invitee_ln_input_edit").val();
	var org_email = $("input#org_invitee_email_input_edit").val();
	var org_phone = $("input#org_invitee_phone_input_edit").val();
	
	if(email != ""){
        if(!isValidEmail(email)){
            alert("Please enter a valid Email");
            return false;
        }
    }
    if(fname != "" && lname != ""){
        if(fname != ""){
            if(!isCharacter(fname)){
                alert("The names can only contain letters");
                return false;
            }
        }
        if(lname != ""){
            if(!isCharacter(lname)){
                alert("The names can only contain letters");
                return false;
            }
        }
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				if(respText=="ok"){
					$("div.event_light_box").css({"display" :"none" , "visibility":"hidden"});
					$("div.emgla_guest_container").empty().html("");
					load_guests_list(mem_id,evn_id);
					$("div.evnt_gst_lst_box").css({"display" :"block" , "visibility":"visible"});
					alert("Guest info modified successfully.");
				}
			}
		}
		self.xmlHttpReq.send("handler=events&action=edit_save_guest_info&mem_id="+mem_id+"&evn_id="+evn_id+"&inv_id="+inv_id+"&fname="+fname+"&lname="+lname+"&email="+email+"&phone="+phone+"&already_saved="+already_saved+"&save_new_guest="+save_new_guest+"&org_fname="+org_fname+"&org_lname="+org_lname+"&org_email="+org_email+"&org_phone="+org_phone);
	}
}

function load_savedguests_list(mem_id,evn_id,lbx_id,sort_by){
	$("#event_manage_guest_list").empty().html("");
	$("#event_manage_guest_list").html(loader_div_16).html();
	if(sort_by==0){
		sort_by=1;
	}
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			if(respText=="nam"){	// no mem id
				// nothing
			}
			else if(respText=="nae"){	// no event id
				// nothing
			}
			else if(respText=="nai"){	// no invitation id
				
			}
			else{
				$("#event_manage_guest_list").empty().html("");
				$("#event_manage_guest_list").html(respText).html();
			}		
		}
	}
	self.xmlHttpReq.send("handler=events&action=load_savedguests_list&mem_id="+mem_id+"&evn_id="+evn_id+"&sort_by="+sort_by);
}

function chkbox_select_all(eleClass){
	var	allInputs = $("input."+eleClass).size();
	var remaining_slots = $("#avb_reg_spots").val()*1;
	var guest_slots = $("#evnt_max_gst_settings").val()*1;
	var remaining_guest_slots = $("#avb_gst_spots").val()*1;
	var selected_elements=0;
	var all_selected=true;
	$("input."+eleClass).each(function(){
		if($(this).attr('disabled') != true){
			$(this).attr('checked','checked');
			all_selected=false;
			selected_elements++;
		}
	});
	if(((selected_elements > remaining_guest_slots) && remaining_guest_slots > 0) || ((selected_elements > remaining_slots) && remaining_slots > 0)){
		remaining_guest_slots = remaining_guest_slots>remaining_slots?remaining_slots:remaining_guest_slots;
		var spots="spot is";
		if(remaining_guest_slots > 1 || remaining_slots > 1){
			spots="spots are";
		}
		if((selected_elements > remaining_guest_slots) && remaining_guest_slots > 0){
			alert("Selected # of guests exceeds alloted spots.\nOnly "+remaining_guest_slots+" "+spots+" available.");
			$("input."+eleClass).attr('checked',false);
			return false;
		}
		if((selected_elements > remaining_slots) && remaining_slots > 0){
			alert("Selected # of guests exceeds available booking spots.\nOnly "+remaining_slots+" "+spots+" available.");	
			$("input."+eleClass).attr('checked',false);
			return false;
		}
	}
	if(all_selected){
		alert("All your guests are already on your invitee list for this event.");
	}
}

function chkbox_deselect_all(eleClass){
	$("input."+eleClass).each(function(){
		$(this).removeAttr('checked');
	});
}

function delete_savedguest_info(lbx_id,mem_id,evn_id,mgi_id){
	var conf_del = confirm("Do you really want to delete this guest?");
	if(conf_del){
		var xmlHttpReq = false;
		var self = this;
		var respText;

		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				
				if(respText=="nam"){	// no mem id
					// nothing
				}
				else if(respText=="nae"){	// no event id
					// nothing
				}
				else if(respText=="nai"){	// no invitation id
					
				}
				else{
					if(respText=="ok"){
						load_savedguests_list(mem_id,evn_id,'lbx_id',0);
					}
				}		
			}
		}
		self.xmlHttpReq.send("handler=events&action=delete_savedguest_info&mem_id="+mem_id+"&evn_id="+evn_id+"&mgi_id="+mgi_id);
	}
}

function load_currentguest_info(mem_id,evn_id,lbx_id,mgi_id,inv_id){
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			$("div.emgla_invite_row_edit_sg").empty().html();
			$("div.emgla_can_invite_edit_sg > div.emgla_can_invite_btn > a.mgi_id").removeAttr("id");
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				$("div.event_light_box").css({"display" :"none" , "visibility":"hidden"});
				$("div.emgla_invite_row_edit_sg").html(respText).html();
				$("div.evnt_mng_gstlst_edt_gs").css({"display" :"block" , "visibility":"visible"});
				$("div.emgla_can_invite_edit_sg > div.emgla_can_invite_btn > a.mgi_id").attr("id",$("input#mgi_id_sg").val()*1);
			}
		}
		self.xmlHttpReq.send("handler=events&action=load_currentguest_info&mem_id="+mem_id+"&evn_id="+evn_id+"&mgi_id="+mgi_id+"&inv_id="+inv_id);
}

function save_edit_sged_guestInfo(mgi_id,mem_id,evn_id){
	var fname = $("input#invitee_fn_input_gs").val();
	var lname = $("input#invitee_ln_input_gs").val();
	var email = $("input#invitee_email_input_gs").val();
	var phone = $("input#invitee_phone_input_gs").val();
	var inv_id = $("input#inv_id_sg").val();
	if(email != ""){
        if(!isValidEmail(email)){
            alert("Please enter a valid Email");
            return false;
        }
    }
    if(fname != "" && lname != ""){
        if(fname != ""){
            if(!isCharacter(fname)){
                alert("The names can only contain letters");
                return false;
            }
        }
        if(lname != ""){
            if(!isCharacter(lname)){
                alert("The names can only contain letters");
                return false;
            }
        }
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				if(respText=="ok"){
					$("div.event_light_box").css({"display" :"none" , "visibility":"hidden"});
					load_savedguests_list(mem_id,evn_id,'lbx_id',0);	//mng_gstlst_svd_gsts
					$("div.mng_gstlst_svd_gsts").css({"display" :"block" , "visibility":"visible"});
					alert("Guest info updated successfully.");
				}
			}
		}
		self.xmlHttpReq.send("handler=events&action=save_currentguest_info&mem_id="+mem_id+"&mgi_id="+mgi_id+"&fname="+fname+"&lname="+lname+"&email="+email+"&phone="+phone+"&inv_id="+inv_id);
	}
}

function save_select_all_guests(chkboxId,mem_id,evn_id){
	var	allInputs = $("input."+chkboxId).size();
	var remaining_slots = $("#avb_reg_spots").val()*1;
	var guest_slots = $("#evnt_max_gst_settings").val()*1;
	var remaining_guest_slots = $("#avb_gst_spots").val()*1;
	var selected_elements=0;
	var mgi_id='';
	var counter=0;
	var all_selected=true;
	$("input."+chkboxId).each(function(){
		if($(this).attr('checked') == true){
			all_selected=false;
			selected_elements++;
		}
	});
	if(((selected_elements > remaining_guest_slots) && remaining_guest_slots > 0) || ((selected_elements > remaining_slots) && remaining_slots > 0)){
		remaining_guest_slots = remaining_guest_slots>remaining_slots?remaining_slots:remaining_guest_slots;
		var spots="spot is";
		if(remaining_guest_slots > 1 || remaining_slots > 1){
			spots="spots are";
		}
		if((selected_elements > remaining_guest_slots) && remaining_guest_slots > 0){
			alert("Selected # of guests exceeds alloted spots.\nOnly "+remaining_guest_slots+" "+spots+" available.");
			$("input."+chkboxId).attr('checked',false);
			return false;
		}
		if((selected_elements > remaining_slots) && remaining_slots > 0){
			alert("Selected # of guests exceeds available booking spots.\nOnly "+remaining_slots+" "+spots+" available.");	
			$("input."+chkboxId).attr('checked',false);
			return false;
		}
	}
	$("input."+chkboxId).each(function(i){
		if($(this).attr('disabled') == false){
			if($(this).attr('checked')==true){
				if(counter==0){
					mgi_id = mgi_id+$(this).attr('id')*1;
				}
				else{
					mgi_id = mgi_id+","+$(this).attr('id')*1;
				}
				counter++;
			}
		}
	});
	if(counter>0){
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				if(respText=="nam"){	// no mem id
					// nothing
				}
				else if(respText=="nae"){	// no event id
					// nothing
				}
				else if(respText=="nai"){	// no invitation id
					
				}
				else{
					if(respText=="ok"){
						manage_guestlist_box(mem_id,evn_id,'evnt_gst_lst_box' , 'mng_gst_lst');
					}
				}		
			}
		}
		self.xmlHttpReq.send("handler=events&action=save_selected_guests&mem_id="+mem_id+"&evn_id="+evn_id+"&mgi_id="+mgi_id);
	}
	else{
		alert("Please select atleast 1 saved guest to add.");
	}
}

function save_guestInfo(mem_id,evn_id){
	var s_g = 0;
	var fname = $("input#invitee_fn_input_new").val();
	var lname = $("input#invitee_ln_input_new").val();
	var email = $("input#invitee_email_input_new").val();
	var phone = $("input#invitee_phone_input_new").val();
	if($("input#invitee_save_chkbox").attr('checked')==true){
		s_g = 1;
	}
	if(email != ""){
        if(!isValidEmail(email)){
            alert("Please enter a valid Email");
            return false;
        }
    }
    if(fname != "" && lname != ""){
        if(fname != ""){
            if(!isCharacter(fname)){
                alert("The names can only contain letters");
                return false;
            }
        }
        if(lname != ""){
            if(!isCharacter(lname)){
                alert("The names can only contain letters");
                return false;
            }
        }
		var empty_email_msg='';
		if(email.length==0 || email=="" || email==''){
			empty_email_msg = "NOTE: Without email, event invitation will not be emailed to the guest.\n";
		}
		var xmlHttpReq = false;
		var self = this;
		var respText;

		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				if(respText=="ok"){
					manage_guestlist_box(mem_id,evn_id,'evnt_gst_lst_box' , 'mng_gst_lst');
					alert(empty_email_msg+"Guest Added successfully. Please use [Invite Guests] to\nemail (where provided) invitation to your new guest(s).")
				}
			}
		}
		self.xmlHttpReq.send("handler=events&action=save_newguest_info&mem_id="+mem_id+"&evn_id="+evn_id+"&fname="+fname+"&lname="+lname+"&email="+email+"&phone="+phone+"&save_guest="+s_g);
	}
	else{
		alert("First & Last name is required.");
	}
}
// sending out invitation emails
function send_invitations(mem_id,evn_id){
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			if(respText=="nam"){	// no mem id
				// nothing
			}
			else if(respText=="nae"){	// no event id
				// nothing
			}
			else if(respText=="nai"){	// no invitation id
				
			}
			else{
				if(respText=="ok"){
					alert("Invitation(s) sent to your guests for this event.");
				}
				if(respText=="no"){
					alert("No pending invitations found for this event.");
				}
			}		
		}
	}
	self.xmlHttpReq.send("handler=events&action=send_invitations&mem_id="+mem_id+"&evn_id="+evn_id);
}
/* LOAD INFO [IMG/FLAG] of all registered members for a given event */
function load_all_reg_members(mem_id,evn_id,country_id,limit_start,limit_end,type){
	var xmlHttpReq = false;
	var self = this;
	var respText;
	$("div.ft_event_reg_members_list").empty().html(loader_div_24);
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			if(respText=="nam"){	// no mem id
				// nothing
			}
			else if(respText=="nae"){	// no event id
				// nothing
			}
			else if(respText=="nai"){	// no invitation id
				
			}
			else{
				$("div.ft_event_reg_members_list").empty().html("");
				$("div.ft_event_reg_members_list").html(respText).html();
			}		
		}
	}
	self.xmlHttpReq.send("handler=events&action=load_all_reg_members&mem_id="+mem_id+"&evn_id="+evn_id+"&country_id="+country_id+"&limit_start="+limit_start+"&limit_end="+limit_end+"&type="+type);
}

function load_pages(mem_id,evn_id,country_id,limit_start,limit_end,type){
	var xmlHttpReq = false;
	var self = this;
	var respText;
	$("div.event_registered_members_list").empty().html(loader_div_24);
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			if(respText=="nam"){	// no mem id
				// nothing
			}
			else if(respText=="nae"){	// no event id
				// nothing
			}
			else if(respText=="nai"){	// no invitation id
				
			}
			else{
				$("div.event_registered_members_list").empty().html("");
				$("div.event_registered_members_list").html(respText).html();
			}		
		}
	}
	self.xmlHttpReq.send("handler=events&action=load_pages&mem_id="+mem_id+"&evn_id="+evn_id+"&country_id="+country_id+"&limit_start="+limit_start+"&limit_end="+limit_end+"&type="+type);
}
/* LOAD INFO [IMG/FLAG] of selected country registered members for a given event */
function load_all_reg_members_two(mem_id,evn_id,country_id,limit_start,limit_end,type){
	var xmlHttpReq = false;
	var self = this;
	var respText;
	$("div.selected_nationality > div.sel_flag").empty().html("");
	$("div.selected_nationality > div.sel_flag").html("<img src='"+$("input#flag_"+country_id).val()+"' />").html();
	$("div.selected_nationality > div.sel_nationality").empty().html("");
	$("div.selected_nationality > div.sel_nationality").html($("input#name_"+country_id).val()).html();
	$("div.event_registered_members_list").empty().html(loader_div_24);
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			
			if(respText=="nam"){	// no mem id
				// nothing
			}
			else if(respText=="nae"){	// no event id
				// nothing
			}
			else if(respText=="nai"){	// no invitation id
				
			}
			else{
				$("div.event_registered_members_list").empty().html("");
				$("div.event_registered_members_list").html(respText).html();
			}		
		}
	}
	self.xmlHttpReq.send("handler=events&action=load_all_reg_members&mem_id="+mem_id+"&evn_id="+evn_id+"&country_id="+country_id+"&limit_start="+limit_start+"&limit_end="+limit_end+"&type="+type);
}

function load_this_flag(mem_id,evn_id,country_id,limit_start,limit_end,type){
	$("div.ft_reg_all").css({"display" :"block" , "visibility":"visible"});
	var xmlHttpReq = false;
	var self = this;
	var respText;
	$("div.ft_event_reg_members_list").empty().html(loader_div_24);
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			if(respText=="nam"){	// no mem id
				// nothing
			}
			else if(respText=="nae"){	// no event id
				// nothing
			}
			else if(respText=="nai"){	// no invitation id
				
			}
			else{
				$("div.ft_event_reg_members_list").empty().html("");
				$("div.ft_event_reg_members_list").html(respText).html();
			}		
		}
	}
	self.xmlHttpReq.send("handler=events&action=load_selected_reg_members&mem_id="+mem_id+"&evn_id="+evn_id+"&country_id="+country_id+"&limit_start="+limit_start+"&limit_end="+limit_end+"&type="+type);
}
/*
MY FRENCH TUESDAYS
*/
/* ==================== MY STATUS ====================== */
function load_manage_mystatus_box(mem_id){
	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	$("div.ft_content_container").addClass("myft_statusbox");
	manage_mystatus_box(mem_id);
	$("div#myft_statusbox_lbx_main_box").css({"display" :"block" , "visibility":"visible"});
}

function manage_mystatus_box(mem_id){
	var myStatus_text = $("span.ft_my_status_quote_box_text_one").text();
	myStatus_text = $.trim(myStatus_text);
	if(myStatus_text.length > 0 && myStatus_text!='What\'s on your mind?'){	// status is set so load it
		$("div.status_timestamp").text("");
		$("div.status_timestamp").text($("input#date_posted").val());
		$("div.mystatus_text").text("");
		$("div.mystatus_text").text(myStatus_text);
		$("input#status_text_input").val(myStatus_text);
		var remainingChars = 250 - (myStatus_text.length)*1;
		$("span#mystatus_text_counter").html(remainingChars).html();
	}
}

function check_limit(v){
	if(v.length==250){
		return false;
	}
	return true;
}

function set_counter(i,v,e){
	if (!e) var e = window.event;
	if(v.length <= 250) {
		var remainingChars = 250 - (v.length)*1;
		$("span#mystatus_text_counter").html(remainingChars).html();
		return true;
	}
	if(v.length>250)
	{
		$("span#mystatus_text_counter").html('Limited reached').html();
		document.getElementById("status_text_input").value=v.substr(0,250);
	}
	if(v.length==250)
	{
		$("span#mystatus_text_counter").html('Limited reached').html();
		if(e.keyCode>46 && e.keyCode<112 || e.keyCode>123)
		{
			return false;
		}
	}
}

function set_counter_two(i,v,e){
	if (!e) var e = window.event;
	if(v.length <= 250) {
		var remainingChars = 250 - (v.length)*1;
		$("span#mystatus_text_counter").html(remainingChars).html();
		return true;
	}
	if(v.length>250)
	{
		$("span#mystatus_text_counter").html('Limited reached').html();
		document.getElementById("my-status-textarea").value=v.substr(0,250);
	}
	if(v.length==250)
	{
		$("span#mystatus_text_counter").html('Limited reached').html();
		if(e.keyCode>46 && e.keyCode<112 || e.keyCode>123)
		{
			return false;
		}
	}
}
/*
rest of the pages except my_frenchtuesdays & related tab pages
*/
function load_manage_mystatus_box_one(mem_id){
	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	$("div.ft_content_container").addClass("myft_statusbox");
	manage_mystatus_box_one(mem_id);
	$("div#myft_statusbox_lbx_main_box").css({"display" :"block" , "visibility":"visible"});
}

function manage_mystatus_box_one(mem_id){
	var myStatus_text = $("div.my_current_status").text();
	myStatus_text = $.trim(myStatus_text);
	if(myStatus_text.length > 0 && myStatus_text!='What\'s on your mind?'){	// status is set so load it
		$("div.status_timestamp").text("");
		$("div.status_timestamp").text($("input#date_posted").val());
		$("div.mystatus_text").text("");
		$("div.mystatus_text").text(myStatus_text);
		$("input#status_text_input").val(myStatus_text);
	}
}

function set_myStatus(mem_id,status_type){
	if(status_type=="set_status"){
		var statusText = $("input#status_text_input").val();
		if(statusText.length<=250){
			statusText = escape($.trim(statusText));
			if(statusText.length > 0 && unescape(statusText)!="What's on your mind?"){
				var xmlHttpReq = false;
				var self = this;
				var respText;
				if(window.XMLHttpRequest){//Mozilla/Safari
					self.xmlHttpReq = new XMLHttpRequest();
				}
				else if(window.ActiveXObject){//IE
					self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
				}
				self.xmlHttpReq.open('POST', "index.php", true);
				self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				self.xmlHttpReq.onreadystatechange = function(){
					if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
						respText = self.xmlHttpReq.responseText;
						if(respText=="OK"){
							unload_mystatus_box('id');
							$("span.ft_my_status_quote_box_text_one").text("");
							$("span.ft_my_status_quote_box_text_one").text(unescape(statusText));
							$("div.ft_my_status_edit > a").text("Edit my status");							
							$("div.my_current_status").text("");
							$("div.my_current_status").text(unescape(statusText));
							$("div.change_current_status > a").text("Change my status");
							//a_xyz_profile / a_xyz_id , a_xyz_at
							var allowed = $("input#a_xyz_profile").val();
							if(allowed && allowed==1){
								var at = $("input#a_xyz_at").val();
								if(at!=0 || at > 0){	// December 21st, 2011
									shareMyStatus(at,unescape(statusText));
								}
							}
							get_updated_my_status(mem_id);
						}
					}
				}
				self.xmlHttpReq.send("handler=my_frenchtuesdays&action=set_my_status&mem_id="+mem_id+"&statusText="+statusText);
			}
			else{
				alert("Please enter valid status text");
			}
		}
		else{
			alert("Maximum characters allowed are 250 only.");
		}
	}
	else{
		statusText = '';
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				if(respText=="OK"){
					$("span.ft_my_status_quote_box_text_one").text("");
					$("span.ft_my_status_quote_box_text_one").text("What\'s on your mind?");
					$("div#mystatus_text").text("");
					$("div#mystatus_text").text("What's on your mind?");
					$("input#status_text_input").val("What's on your mind?");
					$("div.ft_my_status_edit > a").text("Set my status");
					$("div.my_current_status").text("");
					$("div.my_current_status").text("What's on your mind?");
					$("div.change_current_status > a").text("Set my status");
					get_updated_my_status(mem_id);
				}
				$("span#mystatus_text_counter").html('250').html();
			}
		}
		self.xmlHttpReq.send("handler=my_frenchtuesdays&action=set_my_status&mem_id="+mem_id+"&statusText="+statusText);
	}
}

function set_myStatus_one(mem_id,status_type){
	if(status_type=="set_status"){
		var statusText = $("textarea#my-status-textarea").val();
		if(statusText.length<=250){
			statusText = escape($.trim(statusText));
			if(statusText.length > 0 && unescape(statusText)!="What's on your mind?"){
				var xmlHttpReq = false;
				var self = this;
				var respText;
				if(window.XMLHttpRequest){//Mozilla/Safari
					self.xmlHttpReq = new XMLHttpRequest();
				}
				else if(window.ActiveXObject){//IE
					self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
				}
				self.xmlHttpReq.open('POST', "index.php", true);
				self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				self.xmlHttpReq.onreadystatechange = function(){
					if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
						respText = self.xmlHttpReq.responseText;
						if(respText=="OK"){
							$("span.ft_my_status_quote_box_text_one").text("");
							$("span.ft_my_status_quote_box_text_one").text(unescape(statusText));
							$("div.ft_my_status_edit > a").text("Edit my status");
							$("div.my_current_status").text("");
							$("div.my_current_status").text(unescape(statusText));
							$("div.change_current_status > a").text("Change my status");
							$('span#my-status-text-holder').removeClass("hide_span").css({"display":"block" , "visibility":"visible"});
							$('div#my-status-textarea-holder').css({"display":"none" , "visibility":"hidden"});
							$('div#my-status-textarea-holder > textarea#my-status-textarea').empty().val('').css({height: "50px"});
							//a_xyz_profile / a_xyz_id , a_xyz_at
							var allowed = $("input#a_xyz_profile").val();
							if(allowed && allowed==1){
								var at = $("input#a_xyz_at").val();
								if(at!=0 || at > 0){	// December 21st, 2011
									shareMyStatus(at,unescape(statusText));
								}
							}
							get_updated_my_status(mem_id);
						}
					}
				}
				self.xmlHttpReq.send("handler=my_frenchtuesdays&action=set_my_status&mem_id="+mem_id+"&statusText="+statusText);
			}
			else{
				alert("Please enter valid status text");
			}
		}
		else{
			alert("Maximum characters allowed are 250 only.");
		}
	}
	else{
		statusText = '';
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				if(respText=="OK"){
					$("span.ft_my_status_quote_box_text_one").text("");
					$("span.ft_my_status_quote_box_text_one").text("What\'s on your mind?");
					$("div#mystatus_text").text("");
					$("div#mystatus_text").text("What's on your mind?");
					$("input#status_text_input").val("What's on your mind?");
					$("div.ft_my_status_edit > a").text("Set my status");
					$("div.my_current_status").text("");
					$("div.my_current_status").text("What's on your mind?");
					$("div.change_current_status > a").text("Set my status");
					get_updated_my_status(mem_id);
				}
				$("span#mystatus_text_counter").html('250').html();
			}
		}
		self.xmlHttpReq.send("handler=my_frenchtuesdays&action=set_my_status&mem_id="+mem_id+"&statusText="+statusText);
	}
}

function check_value(id,val){
	if(val == "What\'s on your mind?"){
		$("input#"+id).val("");
	}
}

function check_v(id,val){
	if(val == "What\'s on your mind?"){
		$("textarea#"+id).val("");
	}
	else{
		var ty = 250 - val.length;
		$('span#mystatus_text_counter').empty().html('');
		$('span#mystatus_text_counter').html(ty).html();
	}
}

function get_updated_my_status(mem_id){
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			var updated_dt = respText.split("_|_");
			var updated_dtOne = updated_dt[0];
			var updated_dtTwo = updated_dt[1];
			$("div.ft_my_status_date_posted").text("");
			$("div.ft_my_status_date_posted").text(updated_dtOne);
			$("div.status_timestamp").text("");
			$("div.status_timestamp").text(updated_dtTwo);
			$("input#hidden_date").val("");
			$("input#hidden_date").val(updated_dtOne);
			$("input#date_posted").val("");
			$("input#date_posted").val(updated_dtTwo);
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=get_updated_my_status&mem_id="+mem_id);
}

function unload_mystatus_box(id){
	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	$("div.ft_content_container").removeClass("myft_statusbox");
	$("div#myft_statusbox_lbx_main_box").css({"display" :"none" , "visibility":"hidden"});
	$("input#status_text_input").val("What\'s on your mind?");
}

function load_default_tab(mem_id,sQuantity,mQuantity,cDate,loadType,divID){
	$("div.ft_my_feed_box").css({"display" :"none" , "visibility":"hidden"});
	$("div.ft_my_feed_item").removeClass("item_active");
	$("div#sl_myfeeds").addClass("item_active");
	$("div.ft_my_feed_tab").removeClass("tab_active");
	$("div#ft_myfeeds").addClass("tab_active");
	$("div#myfeeds").css({"display" :"block" , "visibility":"visible"});
}

function load_tab(mem_id,sQuantity,mQuantity,cDate,loadType,divID,isguest){
	$("div#myft_main_loader > img#img_myft_loader").css("visibility","visible");
	if(isguest=='n'){
		if(divID=="myfeeds"){
			$(document).attr("title" , "My feeds - French Tuesdays");
		}
		if(divID=="aboutme"){
			$(document).attr("title" , "About me - French Tuesdays");
		}
		if(divID=="myevents"){
			$(document).attr("title" , "My events - French Tuesdays");
		}
		$('div.not_for_friends_tab').css({"display" : "block" , "visibility" : "visible"});
		$('div#ppl_you_may_know_container_myft').css({"display" : "none" , "visibility" : "hidden"});
		var p = $('input#profile_progress_number').val() * 1;
		if(p>99){
			$('div.ft_myfrenchtuesdays_incomplete_profile_notice').css({"display" : "none" , "visibility" : "hidden"});
		}
	}
	else{
		var fname = $("input#mem_fname").val();
		if(divID=="myfeeds"){
			$(document).attr("title" , fname+"' feeds - French Tuesdays");
		}
		if(divID=="aboutme"){
			$(document).attr("title" , fname+"' info - French Tuesdays");
		}
		if(divID=="myevents"){
			$(document).attr("title" , fname+"' events - French Tuesdays");
		}
	}
	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	$("div.ft_my_feed_box").css({"display" :"none" , "visibility":"hidden"});
	$("div.ft_my_feed_item").removeClass("item_active");
	$("div#sl_"+divID).addClass("item_active");
	$("div.ft_my_feed_tab").removeClass("tab_active");
	$("div#ft_"+divID).addClass("tab_active");
	if(divID=="aboutme"){
		load_aboutme_content(mem_id,isguest);
	}
	if(divID=="myfeeds"){
		load_feeds_ini(mem_id,0,30,'x',0);
		$("div#myfeeds").css({"display" :"block" , "visibility":"visible"});
	}
	if(($("div#ft_"+divID+" > a").attr("rel")=="1") && (divID=="myfriends")){
		load_frnd_pen_pages(mem_id,1,3,-1,"ajax");
	}
	if($("div#ft_"+divID+" > a").attr("rel")=="0"){
		$("div#ft_"+divID+" > a").removeAttr("rel");
		$("div#ft_"+divID+" > a").attr("rel" , "1");
	}
	//myevents not loaded through ajax but loaded on initial page load.
	$("div#"+divID).css({"display" :"block" , "visibility":"visible"});
}

function load_feeds_ini(mem_id,sQuantity,mQuantity,cDate,loadType){
	var return_type='ajax';
	if(cDate=='x'){
		cDate = $("input#last_date_x").val();
	}
	var xmlHttpReq = false;
	var self = this;
	var respText;
	$("a#myft_feeds_loader").css("visibility","visible");
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			$("div#myft_main_loader > img#img_myft_loader").css("visibility","hidden");
			$("a#myft_feeds_loader").css("visibility","hidden");
			respText = self.xmlHttpReq.responseText;
			if(respText=="no_feeds"){
				alert("no more feeds found");
			}
			else if(respText=="feeds_limit_reached"){
				alert("feeds_limit_reached");
			}
			else{
				if(loadType==0){
					$("div#myfeeds").empty().html("");
					$("div#myfeeds").html(respText).html();
				}
				$("div.ft_myfrenchtuesdays_show_more_feeds > a.ft_myfrenchtuesdays_show_more_feeds_link").removeAttr("id");
				$("div.ft_myfrenchtuesdays_show_more_feeds > a.ft_myfrenchtuesdays_show_more_feeds_link").attr("id" , $("input#curr_date_x").val()*1);
			}
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=load_feeds_ini&mem_id="+mem_id+"&start_quantity="+sQuantity+"&my_quantity="+mQuantity+"&current_date="+cDate+"&loadType="+loadType+"&return_type="+return_type);
}

function load_feeds(mem_id,sQuantity,mQuantity,cDate,loadType){
	if(cDate=='x'){
		cDate = $("input#last_date_x").val();
	}
	$("a#myft_feeds_loader").css("visibility","visible");
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			$("div#myft_main_loader > img#img_myft_loader").css("visibility","hidden");
			$("a#myft_feeds_loader").css("visibility","hidden");
			respText = self.xmlHttpReq.responseText;
			if(respText=="no_feeds"){
				alert("no more feeds found");
			}
			else if(respText=="feeds_limit_reached"){
				alert("feeds_limit_reached");
			}
			else{
				if(loadType==0){
					$("div.ft_my_feed_element").empty().html("");
					$("div.ft_my_feed_element").html(respText).html();
				}
				if(loadType==1){
					$("input#last_date_x").remove();
					$("input#curr_date_x").remove();
					$("div.ft_my_feed_element").append(respText).html();
				}
				$("div.ft_myfrenchtuesdays_show_more_feeds > a.ft_myfrenchtuesdays_show_more_feeds_link").removeAttr("id");
				$("div.ft_myfrenchtuesdays_show_more_feeds > a.ft_myfrenchtuesdays_show_more_feeds_link").attr("id" , $("input#curr_date_x").val()*1);
			}
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=load_feeds&mem_id="+mem_id+"&start_quantity="+sQuantity+"&my_quantity="+mQuantity+"&current_date="+cDate+"&loadType="+loadType);
}

// friends pagination
function load_friends_page(mem_id,start,limit,friends_count){
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div.ft_myfrenchtuesdays_friends").empty().html("");
			$("div.ft_myfrenchtuesdays_friends").html(respText).html();
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=load_friends_page&mem_id="+mem_id+"&start="+start+"&limit="+limit+"&friends_count="+friends_count);
}
// hide lightbox
function hide_lbx(id){
	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	$("div#"+id).css({"display" :"none" , "visibility":"hidden"});
	$("div.myftData").empty().html("");
	$("a.mydb_class").removeAttr("rel");
	$("a.mydb_class").attr("rel" , "0");
}

function show_myinfo_lbx(mem_id,id,section){
	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	$("div.myftData").css({"display" :"none" , "visibility":"hidden"});
	my_profile_info(mem_id,'my_profile_info','id_myinfo_profile');
	$("div#"+id).css({"display" :"block" , "visibility":"visible"});
	$("div#"+section).css({"display" :"block" , "visibility":"visible"});
	$("div#"+section).html(loader_div_24).html();
}

function show_profpic_lbx(mem_id,id,section){
	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	$("div.myftData").css({"display" :"none" , "visibility":"hidden"});
	my_profile_info(mem_id,'my_profile_pic','id_myinfo_profile_pic');
	$("div#"+id).css({"display" :"block" , "visibility":"visible"});
	$("div#"+section).css({"display" :"block" , "visibility":"visible"});
}

function show_myaccount_lbx(mem_id,id,section){
	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	$("div.myftData").css({"display" :"none" , "visibility":"hidden"});
	my_profile_info(mem_id,'myinfo_myaccount','id_myinfo_myaccount');
	$("div#"+id).css({"display" :"block" , "visibility":"visible"});
	$("div#"+section).css({"display" :"block" , "visibility":"visible"});
}

function show_mydata_lbx(mem_id,id,section,sec,div){
	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	$("div.myftData").css({"display" :"none" , "visibility":"hidden"});
	my_profile_info(mem_id,sec,div);
	$("div#"+id).css({"display" :"block" , "visibility":"visible"});
	$("div#"+section).css({"display" :"block" , "visibility":"visible"});
	$("div#"+section).html("<center><b><font color=\"black\">Loading your data.</font></b></center>").html();
}

function show_myaccountsettings_lbx(mem_id,id,section){
	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	$("div.myftData").css({"display" :"none" , "visibility":"hidden"});
	my_profile_info(mem_id,'myinfo_myaccount_settings','id_myinfo_accountsettings');
	$("div#"+id).css({"display" :"block" , "visibility":"visible"});
	$("div#"+section).css({"display" :"block" , "visibility":"visible"});
}

function load_aboutme_content(mem_id,isguest){
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			$("div#myft_main_loader > img#img_myft_loader").css("visibility","hidden");
			respText = self.xmlHttpReq.responseText;
			$("div#aboutme").empty().html("");
			$("div#aboutme").html(respText).html();
			setTimeout('update_progress_meter('+mem_id+',\'ajax\')', 500);
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=load_aboutme_content&mem_id="+mem_id+"&isguest="+isguest);
}
/* event map directions */
function show_mapaccess_directions(city_id,light_box_id,request_type,event_address){
	var map_iframe = document.getElementById("evnt_map_direction");
	map_iframe.src = "http://"+domain_name+"/geomap.php?adr="+event_address;
	$("div."+light_box_id).css({"display" :"block" , "visibility":"visible"});
}

function hide_ma_box(light_box_id){
	$("div."+light_box_id).css({"display" :"none" , "visibility":"hidden"});
}

function hide_divbox(id){
	$("div."+id).remove();
}

function ft_past_events(mem_id,start,limit,total){
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div.myft_events_past_container").empty().html("");
			$("div.myft_events_past_container").html(respText).html();
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=ft_past_events_paginate&mem_id="+mem_id+"&start="+start+"&limit="+limit+"&total="+total);
}

function load_mydb_section(mem_id,hide_id,section,aid){
	$("div."+hide_id).css({"display" :"none" , "visibility":"hidden"});
	if(section=="id_myinfo_profile"){
		my_profile_info(mem_id,'my_profile_info',section);
	}
	if(section=="id_myinfo_business"){
		my_profile_info(mem_id,'my_business_info',section);
	}
	if(section=="id_myinfo_school"){
		my_profile_info(mem_id,'my_school_info',section);
	}
	if(section=="id_myinfo_profile_pic"){
		my_profile_info(mem_id,'my_profile_pic',section);
	}
	if(section=="id_myinfo_myaccount"){
		my_profile_info(mem_id,'myinfo_myaccount',section);
	}
	if(section=="id_myinfo_accountsettings"){
		my_profile_info(mem_id,'myinfo_myaccount_settings',section);
	}
	$("div#"+section).css({"display" :"block" , "visibility":"visible"});
}

function reload_mydb_section(mem_id,hide_id,section,func,type){
	$("div."+hide_id).css({"display" :"none" , "visibility":"hidden"});
	my_profile_info(mem_id,func,section);
	$("div#"+section).css({"display" :"block" , "visibility":"visible"});
	alert("Record "+type+" successfully.");
}

function my_profile_info(mem_id,func,id){
	$("div#"+id).empty().html("");
	$("div#"+id).html(loader_div_24).html();
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div#"+id).empty().html("");
			$("div#"+id).html(respText).html();
			setTimeout('update_progress_meter('+mem_id+',\'ajax\')', 100);
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action="+func+"&mem_id="+mem_id);
}
// profession data record insertion
function add_prof_record(mem_id){
	var error=0;
	var msg='';
	var company_name = escape($("input#add_company_name_input").val());
	var job_title =  escape($("input#add_position_title_input").val());
	var industry_id = $("select.add_industry_type_slctbox :selected").val();
	var from_year = escape($("input#date_from_input").val());
	var to_year = escape($("input#date_to_input").val());
	var description = escape($("textarea#add_company_description_textarea").val());
	if(company_name.length==0 || company_name=='' || company_name==""){
		msg=msg+"Company name is required.\n";
		error=error+1;
	}
	if(job_title.length==0 || job_title=='' || job_title==""){
		msg=msg+"Position title is required.\n";
		error=error+1;
	}
	if(industry_id.length==0 || industry_id=='' || industry_id==""){
		msg=msg+"Industry is required.\n";
		error=error+1;
	}
	if(from_year.length==0 || from_year=='' || from_year==""){
		msg=msg+"From date is required.";
		error=error+1;
	}
	if(error>0){
		alert(msg);
		return false;
	}
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("input#add_company_name_input").val("");
			$("input#add_position_title_input").val("");
			$("select.add_industry_type_slctbox").find('option:first').attr('selected', 'selected').parent('select');
			$("input#date_from_input").val("");
			$("input#date_to_input").val("");
			$("textarea#add_company_description_textarea").val("");
			$("div.switch_mybusinessprofile_maincontainer_items_belt").empty().html("");
			$("div.switch_mybusinessprofile_maincontainer_items_belt").html(respText).html();
			alert("New record added successfully");
			setTimeout('load_aboutme_content('+mem_id+')' , 500);
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=add_prof_record&mem_id="+mem_id+"&company_name="+company_name+"&job_title="+job_title+"&industry_id="+industry_id+"&from_year="+from_year+"&to_year="+to_year+"&description="+description);
}

function delete_prof(mem_id,pro_id){
	var conf_del = confirm("Do you really want to delete this record?");
	if(conf_del){
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				$("div.switch_mybusinessprofile_maincontainer_items_belt").empty().html("");
				$("div.switch_mybusinessprofile_maincontainer_items_belt").html(respText).html();
				alert("Record removed successfully");
				setTimeout('load_aboutme_content('+mem_id+')' , 500);
			}
		}
		self.xmlHttpReq.send("handler=my_frenchtuesdays&action=delete_prof&mem_id="+mem_id+"&pro_id="+pro_id);
	}
}

function edit_prof(mem_id,pro_id){
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div.switch_mybusinessprofile_maincontainer_right").empty().html("");
			$("div.switch_mybusinessprofile_maincontainer_right").html(respText).html();
			$("div.switch_mybusinessprofile_btns").css({"display" : "block" , "visibility" : "visible"});
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=edit_prof&mem_id="+mem_id+"&pro_id="+pro_id);
}

function safe_close_pro(mem_id,type){
	var pro_id = $("input#pro_id").val();
	var error=0;
	var msg='';
	var company_name = escape($("input#add_company_name_input").val());
	var job_title =  escape($("input#add_position_title_input").val());
	var industry_id = $("select.add_industry_type_slctbox :selected").val();
	var from_year = escape($("input#date_from_input").val());
	var to_year = escape($("input#date_to_input").val());
	var description = escape($("textarea#add_company_description_textarea").val());
	if(company_name.length==0 || company_name=='' || company_name==""){
		msg=msg+"Company name is required.\n";
		error=error+1;
	}
	if(job_title.length==0 || job_title=='' || job_title==""){
		msg=msg+"Position title is required.\n";
		error=error+1;
	}
	if(industry_id.length==0 || industry_id=='' || industry_id==""){
		msg=msg+"Industry is required.\n";
		error=error+1;
	}
	if(from_year.length==0 || from_year=='' || from_year==""){
		msg=msg+"From date is required.";
		error=error+1;
	}
	if(error>0){
		alert(msg);
		return false;
	}
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			if(respText!="done"){
				if(type=="save"){	// save the record and keep popup intact
					$("input#add_company_name_input").val("");
					$("input#add_position_title_input").val("");
					$("select.add_industry_type_slctbox").find('option:first').attr('selected', 'selected').parent('select');
					$("input#date_from_input").val("");
					$("input#date_to_input").val("");
					$("textarea#add_company_description_textarea").val("");
					$('div.switch_mybusinessprofile_maincontainer_items_belt').empty().html('');
					$('div.switch_mybusinessprofile_maincontainer_items_belt').html(respText).html();
					alert("Record updated successfully.");
				}
				if(type=="close"){	// save record and close the popup
					$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
					alert("Record updated successfully.");
				}
				setTimeout(function(){load_aboutme_content(mem_id);}, 150);
			}
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=edit_save_prof_record&mem_id="+mem_id+"&company_name="+company_name+"&job_title="+job_title+"&industry_id="+industry_id+"&from_year="+from_year+"&to_year="+to_year+"&description="+description+"&pro_id="+pro_id);
}

function add_education_record(mem_id){
	var error=0;
	var msg='';
	var sch_name = $.trim(escape($("input#education_schoolname_input").val()));
	var field_of_study = $.trim(escape($("input#education_field_of_study_input").val()));
	var edu = $.trim($("select.education_level_slctbox :selected").val());
	var gra_year = $.trim($("select.education_grad_year_slctbox :selected").val());
	var country = $.trim($("select.education_country_slctbox :selected").val());
	msg = 'Missing required fields:';
	if(edu==0){
		msg=msg+'\nEducation level';
		error=error+1;
	}
	if(sch_name.length==0){
		msg=msg+'\nSchool name';
		error=error+1;
	}
	if(error > 0){
		alert(msg);
		return false;
	}
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("input#education_schoolname_input").val("");
			$("input#education_field_of_study_input").val("");
			$("select.education_level_slctbox").find('option:first').attr('selected', 'selected').parent('select');
			$("select.education_grad_year_slctbox").find('option:first').attr('selected', 'selected').parent('select');
			$("select.education_country_slctbox").find('option:first').attr('selected', 'selected').parent('select');
			$("div.switch_myeducationprofile_maincontainer_items_belt").empty().html("");
			$("div.switch_myeducationprofile_maincontainer_items_belt").html(respText).html();
			alert("Record added successfully.");
			setTimeout('load_aboutme_content('+mem_id+')' , 500);
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=add_education_record&mem_id="+mem_id+"&sch_name="+sch_name+"&field_of_study="+field_of_study+"&edu="+edu+"&gra_year="+gra_year+"&country="+country);
}

function delete_academic_record(aca_id,mem_id){
	var conf_del = confirm("Do you really want to delete this record?");
	if(conf_del){
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				$("div.switch_myeducationprofile_maincontainer_items_belt").empty().html("");
				$("div.switch_myeducationprofile_maincontainer_items_belt").html(respText).html();
				alert("Record removed successfully");
				setTimeout('load_aboutme_content('+mem_id+')' , 500);
			}
		}
		self.xmlHttpReq.send("handler=my_frenchtuesdays&action=delete_academic_record&mem_id="+mem_id+"&aca_id="+aca_id);
	}
}

function edit_academic_record(aca_id,mem_id){
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div.switch_myeducationprofile_maincontainer_right").empty().html("");
			$("div.switch_myeducationprofile_maincontainer_right").html(respText).html();
			$("div.switch_myeducationprofile_btns").css({"display" : "block" , "visibility" : "visible"});
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=edit_academic_record&mem_id="+mem_id+"&aca_id="+aca_id);
}

function save_close_edu_record(mem_id , type){
	var error=0;
	var msg='';
	var aca_id = $("input#edit_aca_id").val();
	var sch_name = $.trim(escape($("input#education_schoolname_input").val()));
	var field_of_study = $.trim(escape($("input#education_field_of_study_input").val()));
	var edu = $.trim($("select.education_level_slctbox :selected").val());
	var gra_year = $.trim($("select.education_grad_year_slctbox :selected").val());
	var country = $.trim($("select.education_country_slctbox :selected").val());
	msg = 'Missing required fields:';
	if(edu==0){
		msg=msg+'\nEducation level';
		error=error+1;
	}
	if(sch_name.length==0){
		msg=msg+'\nSchool name';
		error=error+1;
	}
	if(error > 0){
		alert(msg);
		return false;
	}
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("input#education_schoolname_input").val("");
			$("input#education_field_of_study_input").val("");
			$("select.education_level_slctbox").find('option:first').attr('selected', 'selected').parent('select');
			$("select.education_grad_year_slctbox").find('option:first').attr('selected', 'selected').parent('select');
			$("select.education_country_slctbox").find('option:first').attr('selected', 'selected').parent('select');
			$("div.switch_myeducationprofile_maincontainer_items_belt").empty().html("");
			$("div.switch_myeducationprofile_maincontainer_items_belt").html(respText).html();
			if(type=="close"){
				$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
			}
			alert("Record updated successfully.");
			setTimeout(function(){load_aboutme_content(mem_id);}, 150);
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=save_close_edu_record&mem_id="+mem_id+"&sch_name="+sch_name+"&field_of_study="+field_of_study+"&edu="+edu+"&gra_year="+gra_year+"&country="+country+"&aca_id="+aca_id);
}

function load_frnd_req_pages(mem_id,start,limit,total,call_type){
	$("div.myft_my_friends_received_requests_container_top_block_heading_loader").html(loader_div_16);
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			$("div.myft_my_friends_received_requests_container_top_block_heading_loader").empty().html("");
			respText = self.xmlHttpReq.responseText;
			$("div.myft_my_friends_received_requests_container").empty().html("");
			$("div.myft_my_friends_received_requests_container").html(respText).html();	
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=load_rec_friend_req&mem_id="+mem_id+"&start="+start+"&limit="+limit+"&total="+total+"&call_type="+call_type);
}

function load_frnd_pen_pages(mem_id,start,limit,total,call_type){
	$("div.myft_my_friends_send_pending_requests_container_top_block_heading_loader").html(loader_div_16);
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			$("div.myft_my_friends_send_pending_requests_container_top_block_heading_loader").empty().html("");
			respText = self.xmlHttpReq.responseText;
			$("div.myft_my_friends_send_pending_requests_container").empty().html("");
			$("div.myft_my_friends_send_pending_requests_container").html(respText).html();	
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=load_sent_friend_req&mem_id="+mem_id+"&start="+start+"&limit="+limit+"&total="+total+"&call_type="+call_type);
}

function load_myfrnds_pages(mem_id,start,limit,total,call_type,guest){
	$("div.myft_my_friends_confirmed_container_top_block_heading_loader").html(loader_div_16);
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			$("div.myft_my_friends_confirmed_container_top_block_heading_loader").empty().html("");
			respText = self.xmlHttpReq.responseText;
			$("div.myft_my_friends_confirmed_container").empty().html("");
			$("div.myft_my_friends_confirmed_container").html(respText).html();	
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=load_myfriends&mem_id="+mem_id+"&start="+start+"&limit="+limit+"&total="+total+"&call_type="+call_type+"&guest="+guest);
}
// MODIFIED WMA [December 6th, 2011]
function show_friends_result(mem_id,start,limit,total,call_type,hint,guest){

	$("select.filter_by_sort").find('option:first').attr('selected', 'selected').parent('select');
	$("select.filter_by_city").find('option:first').attr('selected', 'selected').parent('select');

	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	$("div.myft_my_friends_confirmed_container_top_block_heading_loader").html(loader_div_16);
	var a=0;
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div.myft_my_friends_confirmed_container_top_block_heading_loader").empty().html("");
			if(hint.length==0 || hint==""){
				$("div.myft_my_friends_confirmed_container").empty().html("");
				$("div.myft_my_friends_confirmed_container").html(respText).html();
			}
			else{
				respText = respText.split("|");
				var content = respText[0];
				var found_rec = respText[1];
				var pages = respText[2];
				$("div.myft_my_friends_confirmed_container_pagination").empty().html("");
				$("div.myft_my_friends_confirmed_container_main_block").empty().html("");
				$("div.myft_my_friends_confirmed_container_main_block").html(content).html();
				$("div.myft_my_friends_confirmed_container_top_block_heading").empty().html("");
				if(found_rec == 1){
					$("div.myft_my_friends_confirmed_container_top_block_heading").html("<span>"+found_rec+"</span> friend found").html();
				}
				else
				{
					$("div.myft_my_friends_confirmed_container_top_block_heading").html("<span>"+found_rec+"</span> friends found").html();
					if(found_rec > 12){
						$("div.myft_my_friends_confirmed_container_pagination").html(pages).html();
					}
				}
			}
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=load_myfriends_ajax&mem_id="+mem_id+"&start="+start+"&limit="+limit+"&total="+total+"&call_type="+call_type+"&q="+hint+"&a="+a+"&guest="+guest);
}

function ajax_load_myfrnds_pages(mem_id,start,limit,total,call_type,guest){
	var a=1;
	var hint = $("input#myft_friends_ajax_search").val();
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			respText = respText.split("|");
			var content = respText[0];
			var found_rec = respText[1];
			var pages = respText[2];
			$("div.myft_my_friends_confirmed_container_pagination").empty().html("");
			$("div.myft_my_friends_confirmed_container_main_block").empty().html("");
			$("div.myft_my_friends_confirmed_container_main_block").html(content).html();
			$("div.myft_my_friends_confirmed_container_top_block_heading").empty().html("");
			$("div.myft_my_friends_confirmed_container_top_block_heading").html(found_rec+" friends found").html();
			$("div.myft_my_friends_confirmed_container_pagination").html(pages).html();					
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=load_myfriends_ajax&mem_id="+mem_id+"&start="+start+"&limit="+limit+"&total="+total+"&call_type="+call_type+"&q="+hint+"&a="+a+"&guest="+guest);
}
// sender's mem_id	[per_id]
// receiver's id [logged int user's id][mem_id]
// id of the record / message / request	[mes_id]
// action = accept / reject
function friendship_request(per_id,mem_id,mes_id,action){
	$("div.myft_my_friends_received_requests_container_top_block_heading_loader").html(loader_div_16);
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div.myft_my_friends_received_requests_container_top_block_heading_loader").empty().html("");
			$("div.myft_my_friends_received_requests_container").empty().html("");
			$("div.myft_my_friends_received_requests_container").html(respText).html();
			if(action=="accept"){	// December 11th, 2011
				load_myfrnds_pages(mem_id,1,12,-1,'ajax',0);
				setTimeout('load_friends_page('+mem_id+',1,6,-1)', 500);	// calling function after 1/2 second to update side-panel friends div
			}
			setTimeout('update_inv_total()' , 150);
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=friendship_act&mem_id="+mem_id+"&per_id="+per_id+"&mes_id="+mes_id+"&act="+action);
}

function update_inv_total(){
	var new_pm_total = parseInt($("span.ft_inbox_middle").text())*1;	// new messages total
	var newinv_total = parseInt($("span.ft_friends_middle").text())*1;	// new invitations total
	new_pm_total = isNaN(new_pm_total)||(typeof(new_pm_total)==undefined || typeof(new_pm_total)=='undefined')?0:new_pm_total;
	newinv_total = isNaN(newinv_total)||(typeof(newinv_total)==undefined || typeof(newinv_total)=='undefined')?0:newinv_total;
	newinv_total = newinv_total>0?(parseInt(newinv_total)-1):0;
	var full_ttl = parseInt(new_pm_total)+parseInt(newinv_total);	// total of both messages+invitations [top bubble]
	var menu_inv_placeholder = "<span class=\"ft_friends_left\"></span><span class=\"ft_friends_middle\">{#}</span><span class=\"ft_friends_right\"></span>";
	if(newinv_total > 0){
		$("div.ft_my_friends_link").empty().html("");
		menu_inv_placeholder = menu_inv_placeholder.replace("{#}" , newinv_total);
		$("div.ft_my_friends_link").html(menu_inv_placeholder).html();
	}
	else{
		$("div.ft_my_friends_link").empty().html("");
	}
	if(full_ttl > 0){
		$("a#ttl_msgs_holder").html("&nbsp;"+full_ttl+"&nbsp;");
		$("div.myft_messages").css({"display":"block" , "visibility":"visible"});
	}
	else{
		$("div.myft_messages").css({"display":"none" , "visibility":"hidden"});	// hide red bubble in the menu
	}
	$("input#notification_msg_new").val(new_pm_total*1);
	$("input#notification_inv_new").val(newinv_total*1);
	$("input#notification_ttl_new").val(full_ttl*1);
}
// December 10th, 2011
function manage_frndshp_request(mem_id,per_id,mes_id,action,id){
	if(action=="pending"){
		alert("This request is pending approval.");
		return false;
	}
	if(action=="resent"){
		if( $("div.request_action_send_again > a#"+id).hasClass("already_sent_pending")==true ){
			alert("This request is pending approval.");
			return false;
		}
		else{
			var mem_name = $.trim($("span#"+mem_id+"_"+per_id+"_"+mes_id+"_fullname").text());
			$("div.request_action_send_again > a#"+id).addClass("already_sent_pending");
			$("div#ft_message_notification_bar2").hide("500").css({"left": "-9999px"});
			$("span#notification_icon").empty().html("");
			$("span#notification_icon").html(notification_img_friendship_msg).html();
			$("span#notification_new_message").empty().html("");
			$("span#notification_new_message").html("Your friend request is resent to "+mem_name+". [<a href=\"javascript:void(0);\" onClick=\"unloadMsgbar('ft_message_notification_bar2');\">Close</a>]").html();
			//$("span#notification_new_message").html("Your friend request is resent. [<a href=\"javascript:void(0);\" onClick=\"unloadMsgbar('ft_message_notification_bar2');\">Close</a>]").html();
			$("div#ft_message_notification_bar2").css({"left": "0"}).hide().show("500");
		}
	}
	$("div.myft_my_friends_send_pending_requests_container_top_block_heading_loader").html(loader_div_16);
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			$("div.myft_my_friends_send_pending_requests_container_top_block_heading_loader").empty().html("");
			respText = self.xmlHttpReq.responseText;
			if(action=="resent"){
			}
			if(action=="remove"){
				$("div.myft_my_friends_send_pending_requests_container").empty().html("");
				$("div.myft_my_friends_send_pending_requests_container").html(respText).html();
				alert("Your friendship request has been removed.");
			}
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=manage_frndshp_request&mem_id="+mem_id+"&per_id="+per_id+"&mes_id="+mes_id+"&act="+action);
}

function close_fic_lbx(id){
	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	$("div#"+id).css({"display" :"none" , "visibility":"hidden"});
}

function load_fic_lbx(mem_id,per_id,e , a_linkId){
	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div.ft_common_friends_lbx_core").empty().html("");
			$("div.ft_common_friends_lbx_core").html(respText).html();
			var div_height = $("#ltbx_common_friends").height()*1;
			var div_width = $("#ltbx_common_friends").width()*1;
			var leftNudge = (($(window).width()*1) - div_width) / 2;
			leftNudge = Math.ceil(leftNudge);
			var topNudge = (($(window).height()*1) - div_height) / 2;
			topNudge = Math.ceil(topNudge);
			leftNudge = leftNudge>0?leftNudge:0;
			topNudge = topNudge>0?topNudge:0;
			$("div#ltbx_common_friends").css({"display" :"block" , "visibility":"visible" , "left": (($(window).scrollLeft()*1)+leftNudge)+"px" , "top": (($(window).scrollTop()*1)+topNudge)+"px"});
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=load_fic_lbx&mem_id="+mem_id+"&per_id="+per_id);
}

function remove_friend_ntwrk(mem_id,mem_friend_id){
	var conf_del = confirm("Do you really want to delete this member from your network?");
	if(conf_del){
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				$("div.myft_my_friends_confirmed_container").empty().html("");
				$("div.myft_my_friends_confirmed_container").html(respText).html();
				setTimeout('load_friends_page('+mem_id+',1,6,-1)', 500);	// calling function after 1/2 second to update side-panel friends div
			}
		}
		self.xmlHttpReq.send("handler=my_frenchtuesdays&action=remove_friend_ntwrk&mem_id="+mem_id+"&mem_friend_id="+mem_friend_id);
	}
}
// Modified WMA [December 6th, 2011]
function sort_confirmed_friends(mem_id,s,act){
	var sort=0;
	sort = $("select.filter_by_sort :selected").val();
	$('input#sort_option').removeAttr('value');
	$('input#sort_option').val(sort);
	var city=0;
	city = $("select.filter_by_city :selected").val();
	/*$('input#sort_option').removeAttr('value');
	$('input#sort_option').val(sort);*/
	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	$("div.myft_my_friends_confirmed_container_top_block_heading_loader").html(loader_div_16);
	var hint = $('input#myft_friends_ajax_search').val();
	hint = hint=='Search'?'':hint;
	var start=1;
	var total=-1;
	var guest = $('input#is_guest').val();
	guest = guest.length==0?0:1;
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div.myft_my_friends_confirmed_container").empty().html("");
			$("div.myft_my_friends_confirmed_container").html(respText).html();
			$("div.myft_my_friends_confirmed_container_top_block_heading_loader").empty().html("");
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=sort_confirmed_friends&mem_id="+mem_id+"&sort="+sort+"&hint="+hint+"&guest="+guest+"&start="+start+"&total="+total+"&city="+city);
}
// MODIFIED WMA [December 6th, 2011]
function ajax_sort_confirmed_friends(mem_id,start,limit,total,type,guest){
	//var sort = $('input#sort_option').val();
	var sort=0;
	sort = $("select.filter_by_sort :selected").val();
	var city=0;
	city = $("select.filter_by_city :selected").val();
	
	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	$("div.myft_my_friends_confirmed_container_top_block_heading_loader").html(loader_div_16);
	var hint = $('input#myft_friends_ajax_search').val();
	hint = hint=='Search'?'':hint;
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div.myft_my_friends_confirmed_container").empty().html("");
			$("div.myft_my_friends_confirmed_container").html(respText).html();
			$("div.myft_my_friends_confirmed_container_top_block_heading_loader").empty().html("");
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=sort_confirmed_friends&mem_id="+mem_id+"&sort="+sort+"&hint="+hint+"&guest="+guest+"&start="+start+"&total="+total+"&city="+city);
}

function load_profile_data(mem_id){
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div.ft_myfrenchtuesdays_member_profile_details").empty().html("");
			$("div.ft_myfrenchtuesdays_member_profile_details").html(respText).html();
			setTimeout('update_progress_meter('+mem_id+',\'ajax\')', 500);
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=load_profile_data&mem_id="+mem_id);
}

function update_progress_meter(mem_id,type){
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			respText = respText.split("|");	// [0]	profile, [1]	academics , [2]		professionals
			var profile_percentage = (respText[0]*1);
			var academics_percentage = (respText[1]*1);
			var professionals_percentage = (respText[2]*1);
			var picture_percentage = (respText[3]*1);
			var total_percentage = Math.round((((profile_percentage+academics_percentage+professionals_percentage+picture_percentage)*1)/13)*100);
			$("div.progrss_percentage").empty().html("");
			$("div.progrss_percentage").html(total_percentage+"%").html();
			$("div.progress_meter_indicator").css("width" , total_percentage+"%");
			$('input#profile_progress_number').val(0);
			$('input#profile_progress_number').val(total_percentage);
			$("div.info_progrss_percentage").empty().html("");
			$("div.info_progrss_percentage").html(total_percentage+"%").html();
			$("div.info_progress_meter_indicator").css("width" , total_percentage+"%");
			if(picture_percentage==1){
				$("span#id_inc_picture").addClass("complete_profile");
			}
			else{
				$("span#id_inc_picture").removeClass("complete_profile");
			}
			if(profile_percentage==5){	// changed from 10 to 5
				$("span#id_inc_profile").addClass("complete_profile");
			}
			else{
				$("span#id_inc_profile").removeClass("complete_profile");
			}
			if(academics_percentage==2){	// changed from 5 to 2
				$("span#id_inc_school").addClass("complete_profile");
			}
			else{
				$("span#id_inc_school").removeClass("complete_profile");
			}
			if(professionals_percentage==5){	// changed from 6 to 5
				$("span#id_inc_business").addClass("complete_profile");
			}
			else{
				$("span#id_inc_business").removeClass("complete_profile");
			}
			if(total_percentage==100){
				$("div.ft_myfrenchtuesdays_incomplete_profile_notice").css({"display":"none" , "visibility":"hidden"});
				$("div.ft_myfrenchtuesdays_page_holder_left_column_profile_percentage").css("display" , "none");
			}
			else{
				$("div.ft_myfrenchtuesdays_incomplete_profile_notice").css({"display":"block" , "visibility":"visible"});
				$("div.ft_myfrenchtuesdays_page_holder_left_column_profile_percentage").css("display" , "block");
			}
			var abtme_info = (professionals_percentage+academics_percentage)*1;
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=profile_progress_meter&mem_id="+mem_id+"&type="+type);
}

function update_profile_data(mem_id,act){
	var myinfos_bdate_input = $.trim($("input#myinfos_bdate_input").val());
	var myinfos_gender_val = $("input:radio[name=myinfos_gender_val]:checked").val();
	var myinfos_marital_status_slctbox = $("select#myinfos_marital_status_slctbox :selected").val();
	var myinfos_ftcity_slctbox = $("select#myinfos_ftcity_slctbox :selected").val();
	var myinfos_hcountry_slctbox = $("select#myinfos_hcountry_slctbox :selected").val();
	var myinfos_mailing_address_input = escape($.trim($("input#myinfos_mailing_address_input").val()));
	var myinfos_homephone_number_input = $.trim($("input.myinfos_homephone_number_input").val());
	var myinfos_officephone_number_input = $.trim($("input.myinfos_officephone_number_input").val());
	var myinfos_cellphone_number_input = $.trim($("input.myinfos_cellphone_number_input").val());
	var myinfos_citizenship_input = escape($.trim($("input#myinfos_citizenship_input").val()));
	var myinfos_postalcode_input = escape($.trim($("input#myinfos_postalcode_input").val()));
	var msg='';
	var err=0;
	if(myinfos_marital_status_slctbox==0){
		msg=msg+"Marital status is required.\n";
		err=err+1;
	}
	if(myinfos_hcountry_slctbox==-1){
		msg=msg+"Home country is required.\n";
		err=err+1;
	}
	if(myinfos_postalcode_input.length==0 || myinfos_postalcode_input=='' || myinfos_postalcode_input==""){
		msg=msg+"Postal / Zip code is required.";
		err=err+1;
	}
	if(err>0){
		alert(msg);
		return false;
	}
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			if(respText=="ok"){
				setTimeout('load_profile_data('+mem_id+')', 500);	// calling function after 1/2 second to update side-panel friends div
				if(act=="close"){
					hide_lbx('myft_dashboard_lbx_main_box_myinfo');
				}
				alert("Your profile is updated.");
			}
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=update_profile_data&mem_id="+mem_id+"&birthdate="+myinfos_bdate_input+"&gender="+myinfos_gender_val+"&marital_id="+myinfos_marital_status_slctbox+"&primary_city="+myinfos_ftcity_slctbox+"&home_country="+myinfos_hcountry_slctbox+"&mailing_address="+myinfos_mailing_address_input+"&home_phone="+myinfos_homephone_number_input+"&office_phone="+myinfos_officephone_number_input+"&cell_phone="+myinfos_cellphone_number_input+"&citizenship="+myinfos_citizenship_input+"&postal_code="+myinfos_postalcode_input);
}

function save_password(mem_id,act){
	var old_pass = $("input#old_password_input").val();
	var pw1 = $("input#new_password_input").val();
	var pw2 = $("input#conf_new_password_input").val();
	msg='';
	err=0;
	if(old_pass == '') {
		alert('Please enter your old password.');
		$("input#old_password_input").focus();
		return false;
	}
	if (pw1 == '' || pw2 == '') {
		alert('Please type new password in both text boxes.');
		$("input#conf_new_password_input").focus();
		return false;
	}
	if(pw1.length < 6){
		alert('The password should be at least 6 characters long.');
		$("input#new_password_input").focus();
		return false;
	}
	if (pw1 != pw2) {
		alert ("The passwords you typed do not match. Type the new password in both text boxes.");
		$("input#new_password_input").focus();
		return false;
	}
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			if(respText == '1')
       			alert("Old password is incorrect. Letters in password must be typed using the correct case.");
       		else{
				alert("Your password has been changed.\nYou will be logged out to log in again.");
       			if(act=="close"){
					hide_lbx('myft_dashboard_lbx_main_box_myinfo');
				}
				setTimeout(function(){document.location.href="index.php?handler=login&action=do_logout";}, 0);
   			}
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=ft_save_password&mem_id="+mem_id+"&new_pass="+pw1+"&old_pass="+old_pass);
}

function reset_password(mem_id){
	var email = $("input#myaccount_address_input").val();
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			if(respText == '1'){
				alert("Your password has been reset and a temporary password\nhas been sent at this address ["+email+"]");
				return false;
			}
			if(respText == '2'){
				alert("Email address ["+email+"] does not exist.\nPlease check and try again.");
				return false;
			}
			if(respText == '3'){
				alert("Email address ["+email+"] is not yet verified.\nPlease verify and try again.");
				return false;
			}
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=ft_reset_password&mem_id="+mem_id+"&email="+email);
}

function remove_profile_pic(mem_id){
	var curr_pic = $("img#new_img").attr("src");
	if(curr_pic=='./photos/awaiting.gif'){
		alert("Can not remove default profile picture.");
		return false;
	}
	else{
		var isSubmit=1;
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				var small_pic = "./photos/awaiting_small.gif"
				var large_pic = "./photos/awaiting.gif"
				$("img#mem_profile_picture_large")
					.removeAttr("src")
					.attr("src" , large_pic)
					.removeAttr("width")
					.removeAttr("height")
					.removeAttr("style")
					.attr("width" , "247")
					.attr("height" , "216")
					.addClass("mem_profile_picture_large");
				$("img#mem_profile_picture_small")
					.removeAttr("src")
					.attr("src" , small_pic)
					.removeAttr("width")
					.removeAttr("height")
					.removeAttr("style")
					.attr("width" , "57")
					.attr("height" , "50")
					.addClass("mem_profile_picture_small");

				respText = self.xmlHttpReq.responseText;
				$("div#id_myinfo_profile_pic").empty().html("");
				$("div#id_myinfo_profile_pic").html(respText).html();
				setTimeout('update_progress_meter('+mem_id+',\'ajax\')', 500);
			}
		}
		self.xmlHttpReq.send("handler=my_frenchtuesdays&action=my_profile_pic&mem_id="+mem_id+"&isSubmit="+isSubmit);
	}
}

function create_thumbnail(mem_id , divID){
	var curr_pic = $("img#new_img").attr("src");
	if(curr_pic=='./photos/awaiting.gif'){
		alert("Can not create thumbnail of default profile picture.");
		return false;
	}
	else{
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){		
				respText = self.xmlHttpReq.responseText;
				$("div.myftData").css({"display" : "none" , "visibility":"hidden"});
				$("div#id_myinfo_profile_pic").empty().html("");
				$("div#id_myinfo_profile_pic").html(respText).html();
				$("div#id_myinfo_profile_pic").css({"display" : "block" , "visibility":"visible"});
				// disabled
				loadCropper();
			}
		}
		self.xmlHttpReq.send("handler=my_frenchtuesdays&action=load_thumbnail&mem_id="+mem_id+"&curr_pic="+curr_pic);	
	}
}

function loadCropper(){
	$("#cropbox").live("mouseover", function(){
		$(this).imgAreaSelect({ aspectRatio: '1:1', handles: true, fadeSpeed: 200, onSelectChange: preview , parent: '#id_myinfo_profile_pic' });
	});
}

function sarahontumhara(){
	$(function(){
		$("#resizable")
		.resizable({ containment: "parent" , aspectRatio: true })
		.draggable({ containment: "parent" });
		var img_width = $('#cropbox').width()*1;
		var img_height = $('#cropbox').height()*1;
		$("div.switch_myprofile_picture_heading").html(img_width+","+img_height);
	});
}

var loadedobjects="";
function loadobjs(){
	if (!document.getElementById)
	return
	for (i=0; i<arguments.length; i++){
		var file=arguments[i]
		var fileref=""
		if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
			if (file.indexOf(".js")!=-1){ //If object is a js file
				fileref=document.createElement('script')
				fileref.setAttribute("type","text/javascript");
				fileref.setAttribute("src", file);
			}
			else if (file.indexOf(".css")!=-1){ //If object is a css file
				fileref=document.createElement("link")
				fileref.setAttribute("rel", "stylesheet");
				fileref.setAttribute("type", "text/css");
				fileref.setAttribute("href", file);
			}
		}
		if (fileref!=""){
			document.getElementsByTagName("head").item(0).appendChild(fileref)
			loadedobjects+=file+" " //Remember this object as being already added to page
		}
	}
}

function create_save_tn(mem_id,pic,type,thumb){
	var img_x = $('input#img_x').val();
	var img_y = $('input#img_y').val();
	var img_w = $('input#img_w').val();
	var img_h = $('input#img_h').val();
	var small_pic = pic;
	small_pic = small_pic.replace("_med","_small");
	if(img_w==0 || img_h==0){
		alert("Please select an area first");
		return false;
	}
	else{
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				if(respText=="1"){
					var ts = Math.round((new Date()).getTime() / 1000);
					$("img#mem_profile_picture_large")
					.removeAttr("src")
					.attr("src" , pic)
					.removeAttr("width")
					.removeAttr("height")
					.removeAttr("style")
					.removeClass("mem_profile_picture_large");
					
					$("img#mem_profile_picture_small")
					.removeAttr("src")
					.attr("src" , small_pic+"?time="+ts)
					.removeAttr("width")
					.removeAttr("height")
					.removeAttr("style")
					.removeClass("mem_profile_picture_small");

					if(type=="close"){
						$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
						alert("Thumbnail created & saved successfully.");
					}
					else{
						alert("Thumbnail created & saved successfully.");
					}
					setTimeout('update_progress_meter('+mem_id+',\'ajax\')', 500);
				}
				else{
					alert("something went wrong. Please try again.");
				}
			}
		}
		self.xmlHttpReq.send("handler=my_frenchtuesdays&action=create_thumbnail&mem_id="+mem_id+"&curr_pic="+pic+"&img_x="+img_x+"&img_y="+img_y+"&img_w="+img_w+"&img_h="+img_h);
	}
}

function close_save_picture(mem_id,pic,type,thumb){
	var chk_class = $("img#new_img").attr("class");
	if(chk_class=="old_img"){
		alert("Image not saved as is already available.");
		if(type=="close"){
			$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
		}
	}
	else{
		var small_pic = $("img#new_img").attr("src");
		small_pic = small_pic.replace("_med","_small");
		$("img#mem_profile_picture_large")
		.removeAttr("src")
		.attr("src" , $("img#new_img").attr("src"))
		.removeAttr("width")
		.removeAttr("height")
		.removeAttr("style")
		.removeClass("mem_profile_picture_large")
		.attr("height" , $("input#current_uploaded_file_height").val()*1)
		.attr("width" , $("input#current_uploaded_file_width").val()*1);
		
		$("img#mem_profile_picture_small")
		.removeAttr("src")
		.attr("src" , small_pic)
		.removeAttr("width")
		.removeAttr("height")
		.removeAttr("style")
		.removeClass("mem_profile_picture_small")
		.attr("height" , $("input#scurrent_uploaded_file_height").val()*1)
		.attr("width" , $("input#scurrent_uploaded_file_width").val()*1);
		
		if(type=="close"){
			$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
		}
		alert("Profile picture saved successfully.");
		setTimeout('update_progress_meter('+mem_id+',\'ajax\')', 500);
	}
}

function load_common_friends(my_id,mem_id,start,limit,total,type){
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div.ft_myfrenchtuesdays_friends_common").empty().html("");
			$("div.ft_myfrenchtuesdays_friends_common").html(respText).html();
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=load_common_friends&mem_id="+mem_id+"&start="+start+"&limit="+limit+"&total="+total+"&type="+type+"&my_id="+my_id);
}
// MAIL BOX FUNCTIONS
function close_mailbox(id){
	$("div#"+id).css({"display" : "none" , "visibility" : "hidden"});
	$("div#ft_section_inbox_id").empty().html("");
}
//January 12th, 2012
function load_mailbox(mem_id,id,type){
	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	myft_mailbox_inbox_list(mem_id,1,0,0,type,0);
	var c = $('input#current_page').val();	// get current page-in-view
	if(c=="my_frenchtuesdays"){
		var outerWidth = $("div#"+id).outerWidth()*1;
		var outerHeight = $("div#"+id).outerHeight()*1;
		var leftNudge = (($(window).width()*1) - outerWidth) / 2;
		leftNudge = Math.ceil(leftNudge);
		var topNudge = (($(window).height()*1) - outerHeight) / 2;
		topNudge = Math.ceil(topNudge);
		leftNudge = leftNudge>0?leftNudge:0;
		topNudge = topNudge>0?topNudge:0;
		$("div#"+id).attr('style' , 'position:absolute;display:block;visibility:visible;left:'+(($(window).scrollLeft()*1)+leftNudge)+'px!important;top:'+(($(window).scrollTop()*1)+topNudge)+'px!important');
	}
	else{
		$("div#"+id).css({"display" : "block" , "visibility" : "visible"});
	}
}

function myft_mailbox_inbox_list(mem_id,start,limit,total,inbox_type,sort){
	if(inbox_type=="ajax" || inbox_type=='inbox_type'){
		inbox_type = escape($("input#inbox_type").val());
		var paginate=true;
	}
	$("div#ft_section_inbox_id").empty().html("");
	$("div#ft_section_inbox_id").html(loader_div_24).html();
	// if sort ==1 then get sort value [asc / desc] from listbox
	var sSort;
	if(sort==1){
		sSort = "ASC";
	}
	else{
		sSort = "DESC";
		var current_page=1;
	}
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			if(sort<0){	// load inside the div
			}
			else{	// load the whole div inside lbx
				$("div#ft_section_inbox_id").empty().html("");
				$("div#ft_section_inbox_id").html(respText).html();
			}
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=myft_mailbox_inbox_list&mem_id="+mem_id+"&start="+start+"&limit="+limit+"&total="+total+"&sort="+sort+"&inbox_type="+inbox_type+"&current_page="+current_page);
}

function select_all_messages(mem_id,eleClass,id,value){
	var inbox_msg_count = $('input#inbox_msg_count').val();
	var e=document.getElementsByName("myft_inbox_pm_item_chkbox");
	var all_selected=true;
	if(value==0){
		$('input.myft_mailbox_msg_chkbox').each(function(){
			$(this).attr('checked','checked');
		});
		$("input#"+id).val(1);
	}
	else{
		$('input.myft_mailbox_msg_chkbox').each(function(){
			$(this).removeAttr('checked');
		});
		$("input#"+id).val(0);
	}
	all_selected=false;
}

function ft_msgs_action(mem_id,start,limit,total,inbox_type,sort,act){
	// get all checked boxes ids [msg ids]
	var mes_id='';
	var chkbox=0;
	$('input.myft_mailbox_msg_chkbox').each(function(){
		if($(this).attr('checked')==true){
			if(chkbox==0){
				mes_id = mes_id+$(this).val()*1;
			}
			else{
				mes_id = mes_id+","+$(this).val()*1;
			}
			chkbox++;
		}
	});
	if(chkbox==0){
		alert('Please make a selection first');
		return false;
	}
	else{
		$("span.processing_req_span").css("visibility" , "visible");
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				if(sort<0){	// load inside the div
				}
				else{	// load the whole div inside lbx
					$("div#ft_section_inbox_id").empty().html("");
					$("div#ft_section_inbox_id").html(respText).html();
					update_pm_total();
				}
			}
		}
		self.xmlHttpReq.send("handler=my_frenchtuesdays&action=ft_msgs_action&mem_id="+mem_id+"&start="+start+"&limit="+limit+"&total="+total+"&sort="+sort+"&inbox_type="+inbox_type+"&act="+act+"&ids="+mes_id);
	}
}

function update_pm_total(){
	var new_pm_total = $("input#new_pm_total").val()*1;	// new messages total
	var newinv_total = $("input#newinv_total").val()*1;	// new invitations total
	var full_ttl = $("input#full_ttl").val()*1;	// total of both messages+invitations [top bubble]
	new_pm_total = isNaN(new_pm_total)||(typeof(new_pm_total)==undefined || typeof(new_pm_total)=='undefined')?0:new_pm_total;
	newinv_total = isNaN(newinv_total)||(typeof(newinv_total)==undefined || typeof(newinv_total)=='undefined')?0:newinv_total;
	full_ttl = isNaN(full_ttl)||(typeof(full_ttl)==undefined || typeof(full_ttl)=='undefined')?newinv_total+new_pm_total:full_ttl;
	var menu_npm_placeholder = "<span class=\"ft_inbox_left\"></span><span class=\"ft_inbox_middle\">{#}</span><span class=\"ft_inbox_right\"></span>";
	var menu_inv_placeholder = "<span class=\"ft_friends_left\"></span><span class=\"ft_friends_middle\">{#}</span><span class=\"ft_friends_right\"></span>";
	if(new_pm_total > 0){
		$("div.profile_manager_inbox > div.inbox_incap").css({"display":"block" , "visibility":"visible"});
		$("div.profile_manager_inbox > div.inbox_incap > div.inbox_middle").empty().html("");
		$("div.profile_manager_inbox > div.inbox_incap > div.inbox_middle").html(new_pm_total);
		$("div.ft_my_inbox_link").empty().html("");
		menu_npm_placeholder = menu_npm_placeholder.replace("{#}" , new_pm_total);
		$("div.ft_my_inbox_link").html(menu_npm_placeholder).html();
	}
	else{
		$("div.profile_manager_inbox > div.inbox_incap").css({"display":"none" , "visibility":"hidden"});
		$("div.profile_manager_inbox > div.inbox_incap > div.inbox_middle").empty().html("");
		$("div.ft_my_inbox_link").empty().html("");
	}
	if(newinv_total > 0){
		$("div.ft_my_friends_link").empty().html("");
		menu_inv_placeholder = menu_inv_placeholder.replace("{#}" , newinv_total);
		$("div.ft_my_friends_link").html(menu_inv_placeholder).html();
	}
	else{
		$("div.ft_my_friends_link").empty().html("");
	}
	if(full_ttl > 0){
		$("a#ttl_msgs_holder").html("&nbsp;"+full_ttl+"&nbsp;");
		$("div.myft_messages").css({"display":"block" , "visibility":"visible"});
	}
	else{
		$("div.myft_messages").css({"display":"none" , "visibility":"hidden"});	// hide red bubble in the menu
	}
	$("input#notification_msg_new").val(new_pm_total*1);
	$("input#notification_inv_new").val(newinv_total*1);
	$("input#notification_ttl_new").val(full_ttl*1);
}

function myft_read_msg(mem_id,mes_id,viewed,inbox_type,start,sort,total,offset,step){
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;	
			$("div#ft_section_inbox_id").empty().html("");
			$("div#ft_section_inbox_id").html(respText).html();
			update_pm_total();
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=myft_read_msg&mem_id="+mem_id+"&inbox_type="+inbox_type+"&viewed="+viewed+"&mes_id="+mes_id+"&start="+start+"&sort="+sort+"&total="+total+"&offset="+offset+"&step="+step);
}
// modified WMA [December 4th, 2011 (2)]
function ft_send_personal_msg(mem_id,mes_id,per_id,act){

	var my_entire_network = 0;
	var allow_network_messages = $("input#allow_network_messages").val();
	if(allow_network_messages || allow_network_messages==1){
		my_entire_network = $("input#my_entire_network").is(':checked')==true?"1":"0";
	}

	$("span#notification_icon").empty().html("");
	$("div#ft_message_notification_bar2").hide("500").css({"left": "-9999px"});
	$("span#notification_new_message").empty().html("");
	if($.trim($("textarea#msg_reply_text").val()) == '') {
		alert("Error: Please type in your reply.");
		return false;
	}
	else{
		if(mem_id==per_id){
			alert("Error\:\ Cannot sent message to self.");
			return false;
		}
		else{
			$("span.processing_req_span").css("visibility","visible");
			var pmsg = escape($("textarea#msg_reply_text").val());
			pmsg = pmsg.replace(/\n/g, '<br>');
			var xmlHttpReq = false;
			var self = this;
			var respText;
			if(window.XMLHttpRequest){//Mozilla/Safari
				self.xmlHttpReq = new XMLHttpRequest();
			}
			else if(window.ActiveXObject){//IE
				self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
			}
			self.xmlHttpReq.open('POST', "index.php", true);
			self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			self.xmlHttpReq.onreadystatechange = function(){
				if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
					respText = self.xmlHttpReq.responseText;
					$("span.processing_req_span").css("visibility","hidden");
					if(respText==0){
						alert("Something went wrong. Please try again.");
					}
					else{
						if(!my_entire_network || my_entire_network==0){
							$("span#notification_icon").empty().html("");
							$("span#notification_icon").html(notification_img_new_msg).html();
							$("span#notification_new_message").empty().html("");
							$("span#notification_new_message").html("Your reply is sent to "+respText+". [<a href=\"javascript:void(0);\" onClick=\"unloadMsgbar('ft_message_notification_bar2');\">Close</a>]").html();
							$("div#ft_message_notification_bar2").css({"left": "0"}).hide().show("500");
							setTimeout('myft_mailbox_inbox_list('+mem_id+',1,10,0,\'inbox\',0)' , 250);
						}
						else{
							$("span#notification_icon").empty().html("");
							$("span#notification_icon").html(notification_img_new_msg).html();
							$("span#notification_new_message").empty().html("");
							$("span#notification_new_message").html("Your reply is sent to all the members on your network. [<a href=\"javascript:void(0);\" onClick=\"unloadMsgbar('ft_message_notification_bar2');\">Close</a>]").html();
							$("div#ft_message_notification_bar2").css({"left": "0"}).hide().show("500");
							setTimeout('myft_mailbox_inbox_list('+mem_id+',1,10,0,\'inbox\',0)' , 250);
						}
					}
				}
			}
			self.xmlHttpReq.send("handler=my_frenchtuesdays&action=ft_send_personal_msg&mem_id="+mem_id+"&per_id="+per_id+"&act="+act+"&mes_id="+mes_id+"&pmsg="+pmsg+"&my_entire_network="+my_entire_network);
		}
	}
}
// modified WMA [December 4th, 2011 (2)]
function ft_send_personal_msg_new(mem_id,mes_id,per_id,act){

	var my_entire_network = 0;
	var allow_network_messages = $("input#allow_network_messages").val();
	if(allow_network_messages || allow_network_messages==1){
		my_entire_network = $("input#my_entire_network").is(':checked')==true?"1":"0";
	}
	$("span#notification_icon").empty().html("");
	$("div#ft_message_notification_bar2").hide("500").css({"left": "-9999px"});
	$("span#notification_new_message").empty().html("");
	if(!my_entire_network || my_entire_network==0){
		if(($('input.user-contact-id').length==0) || $.trim($("input.as-values").val()) == '' || $.trim($("input#compose_subject_input").val()) == '' || $.trim($("textarea#compose_message").val()) == '') {
			alert("Error [1]: Please type in missing information.");
			return false;
		}
	}
	//else{
		if(!my_entire_network || my_entire_network==0){
			var idz=$.trim($("input.as-values").val());
			if(($('input.user-contact-id').length==0) || (idz.length==1 && idz==",") || idz.length==0){
				alert("Error [2]: Please type in missing information");
				return false;
			}
		}
		//else{
			var err_msg='';
			var err_cnt=0;
			var pmsg = $.trim(escape($("textarea#compose_message").val()));	// message
			var pmsgsubj = $.trim(escape($("input#compose_subject_input").val()));	// subject
			if(pmsgsubj.length==0 || pmsgsubj==""){
				err_msg=err_msg+''+"Missing subject content.\n";
				err_cnt++;
			}
			if(pmsg.length==0 || pmsg==""){
				err_msg=err_msg+''+"Missing message content.";
				err_cnt++;
			}
			
			if(err_cnt>0){
				alert(err_msg);
				return false;
			}
			
			$("span.processing_req_span").css("visibility","visible");
			var ids='';
			$('input.user-contact-id').each(function(){
				ids = ids+','+$(this).val();
			});
			$("input#send_ids").val(unescape(ids));
			pmsg = pmsg.replace(/\n/g, '<br>');
			var xmlHttpReq = false;
			var self = this;
			var respText;
			if(window.XMLHttpRequest){//Mozilla/Safari
				self.xmlHttpReq = new XMLHttpRequest();
			}
			else if(window.ActiveXObject){//IE
				self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
			}
			self.xmlHttpReq.open('POST', "index.php", true);
			self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			self.xmlHttpReq.onreadystatechange = function(){
				if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
					$("span.processing_req_span").css("visibility","hidden");
					respText = self.xmlHttpReq.responseText;
					if(respText==0){
						alert("Something went wrong. Please try again.");
					}
					else{
						if (respText==1){
							if(!my_entire_network || my_entire_network==0){
								$("span#notification_icon").empty().html("");
								$("span#notification_icon").html(notification_img_new_msg).html();
								$("span#notification_new_message").empty().html("");
								//$("span#notification_new_message").html("Your message is sent to all the recepients. [<a href=\"javascript:void(0);\" onClick=\"loadRecepientslist('send_ids');\">View list</a>] [<a href=\"javascript:void(0);\" onClick=\"unloadMsgbar('ft_message_notification_bar2');\">Close</a>]").html();
								// December 9th, 2011
								$("span#notification_new_message").html("Your message is sent to all the recepients. [<a href=\"javascript:void(0);\" onClick=\"unloadMsgbar('ft_message_notification_bar2');\">Close</a>]").html();
								$("div#ft_message_notification_bar2").css({"left": "0"}).hide().show("500");
							}
							else{
								$("span#notification_icon").empty().html("");
								$("span#notification_icon").html(notification_img_new_msg).html();
								$("span#notification_new_message").empty().html("");
								$("span#notification_new_message").html("Your message is sent to all the members on your network. [<a href=\"javascript:void(0);\" onClick=\"unloadMsgbar('ft_message_notification_bar2');\">Close</a>]").html();
								$("div#ft_message_notification_bar2").css({"left": "0"}).hide().show("500");
							}
						}
						else{
							$("span#notification_icon").empty().html("");
							$("span#notification_icon").html(notification_img_new_msg).html();
							$("span#notification_new_message").empty().html("");
							$("span#notification_new_message").html("Your message is sent to "+respText+". [<a href=\"javascript:void(0);\" onClick=\"unloadMsgbar('ft_message_notification_bar2');\">Close</a>]").html();
							$("div#ft_message_notification_bar2").css({"left": "0"}).hide().show("500");
						}
						setTimeout('myft_mailbox_inbox_list('+mem_id+',1,10,0,\'inbox\',0)' , 250);
					}
				}
			}
			self.xmlHttpReq.send("handler=my_frenchtuesdays&action=ft_send_personal_msg&mem_id="+mem_id+"&per_id="+per_id+"&act="+act+"&mes_id="+mes_id+"&pmsg="+pmsg+"&ids="+ids+"&pmsgsubj="+pmsgsubj+"&my_entire_network="+my_entire_network);
		//}
	//}
}

function ft_pm_forward(mem_id,mes_id,per_id,type,total,inbox_type){
	$("div#ft_section_inbox_id").empty().html("");
	$("div#ft_section_inbox_id").html(loader_div_24).html();

	if(total==-1){
		$("div.div_lightbox").css({"display" : "none" , "visibility" : "hidden"});
		$("#ft_mailbox_lbx").css({"display" : "block" , "visibility" : "visible"});
	}
	var xmlHttpReq = false;
	var self = this;
	var respText;

	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div#ft_section_inbox_id").empty().html("");
			$("div#ft_section_inbox_id").html(respText).html();
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=ft_pm_forward&mem_id="+mem_id+"&inbox_type="+inbox_type+"&total="+total+"&mes_id="+mes_id+"&per_id="+per_id+"&type="+type);
}
// modified WMA [December 4th, 2011 (2)]
function ft_send_personal_msg_forward(mem_id,mes_id){

	var my_entire_network = 0;
	var allow_network_messages = $("input#allow_network_messages").val();
	if(allow_network_messages || allow_network_messages==1){
		my_entire_network = $("input#my_entire_network").is(':checked')==true?"1":"0";
	}
	$("span#notification_icon").empty().html("");
	$("div#ft_message_notification_bar2").hide("500").css({"left": "-9999px"});
	$("span#notification_new_message").empty().html("");
	/*if(($('input.user-contact-id').length==0) || $.trim($("input.as-values").val()) == '' || $.trim($("input#compose_subject_input").val()) == '' || $.trim($("textarea#compose_message").val()) == '') {
		alert("Error [1]: Please type in missing information.");
		return false;
	}
	else{
		var idz=$.trim($("input.as-values").val());
		if(($('input.user-contact-id').length==0) || $.trim($("input.as-values").val()) == '' || $.trim($("input#compose_subject_input").val()) == '' || $.trim($("textarea#compose_message").val()) == ''){
			alert("Error [2]: Please type in missing information");
			return false;
		}
		else{*/
	if(!my_entire_network || my_entire_network==0){
		if(($('input.user-contact-id').length==0) || $.trim($("input.as-values").val()) == '' || $.trim($("input#compose_subject_input").val()) == '' || $.trim($("textarea#compose_message").val()) == '') {
			alert("Error [1]: Please type in missing information.");
			return false;
		}
	}
	//else{
		if(!my_entire_network || my_entire_network==0){
			var idz=$.trim($("input.as-values").val());
			if(($('input.user-contact-id').length==0) || (idz.length==1 && idz==",") || idz.length==0){
				alert("Error [2]: Please type in missing information");
				return false;
			}
		}
		//else{
			$("span.processing_req_span").css("visibility","visible");
			var pmsg = escape($("textarea#compose_message").val());	// message
			var pmsgsubj = escape($("input#compose_subject_input").val());	// subject
			var ids='';
			$('input.user-contact-id').each(function(){
				ids = ids+','+$(this).val();
			});
			$("input#send_ids").val(unescape(ids));
			pmsg = pmsg.replace(/\n/g, '<br>');
			var xmlHttpReq = false;
			var self = this;
			var respText;
			if(window.XMLHttpRequest){//Mozilla/Safari
				self.xmlHttpReq = new XMLHttpRequest();
			}
			else if(window.ActiveXObject){//IE
				self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
			}
			self.xmlHttpReq.open('POST', "index.php", true);
			self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			self.xmlHttpReq.onreadystatechange = function(){
				if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
					$("span.processing_req_span").css("visibility","hidden");
					respText = self.xmlHttpReq.responseText;
					if(respText==0){
						alert("Something went wrong. Please try again.");
					}
					else{
						if (respText==1){
							if(!my_entire_network || my_entire_network==0){
								$("span#notification_icon").empty().html("");
								$("span#notification_icon").html(notification_img_new_msg).html();
								$("span#notification_new_message").empty().html("");
								//$("span#notification_new_message").html("Your message is sent to all the recepients. [<a href=\"javascript:void(0);\" onClick=\"loadRecepientslist('send_ids');\">View list</a>] [<a href=\"javascript:void(0);\" onClick=\"unloadMsgbar('ft_message_notification_bar2');\">Close</a>]").html();
								// December 9th, 2011
								$("span#notification_new_message").html("Your message is forwarded to all the recepients. [<a href=\"javascript:void(0);\" onClick=\"unloadMsgbar('ft_message_notification_bar2');\">Close</a>]").html();
								$("div#ft_message_notification_bar2").css({"left": "0"}).hide().show("500");
							}
							else{
								$("span#notification_icon").empty().html("");
								$("span#notification_icon").html(notification_img_new_msg).html();
								$("span#notification_new_message").empty().html("");
								$("span#notification_new_message").html("Your message is forwarded to all the members on your network. [<a href=\"javascript:void(0);\" onClick=\"unloadMsgbar('ft_message_notification_bar2');\">Close</a>]").html();
								$("div#ft_message_notification_bar2").css({"left": "0"}).hide().show("500");
							}
						}
						else{
							$("span#notification_icon").empty().html("");
							$("span#notification_icon").html(notification_img_new_msg).html();
							$("span#notification_new_message").empty().html("");
							$("span#notification_new_message").html("Your message is forwarded to "+respText+". [<a href=\"javascript:void(0);\" onClick=\"unloadMsgbar('ft_message_notification_bar2');\">Close</a>]").html();
							$("div#ft_message_notification_bar2").css({"left": "0"}).hide().show("500");
						}
						setTimeout('myft_mailbox_inbox_list('+mem_id+',1,10,0,\'inbox\',0)' , 250);
					}
				}
			}
			self.xmlHttpReq.send("handler=my_frenchtuesdays&action=do_forward_message&mem_id="+mem_id+"&mes_id="+mes_id+"&pmsg="+pmsg+"&ids="+ids+"&pmsgsubj="+pmsgsubj+"&my_entire_network="+my_entire_network);
	//	}
	//}
}

function unloadMsgbar(id){
	$("span#notification_icon").empty().html("");
	$("div#"+id).hide("500").css({"left": "-9999px"});
	$("span#notification_new_message").empty().html("");
}

function loadRecepientslist(id){	// load lbx to show list to recepients for a new message sent
	unloadMsgbar('ft_message_notification_bar2');
	$("div.div_lightbox").css({"display" : "none" , "visibility" : "hidden"});
	$("#ft_mailbox_lbx").css({"display" : "none" , "visibility" : "hidden"});
	$("div#ft_section_inbox_id").empty().html("");
	var recepient_ids = escape($("input#send_ids").val());
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div#myft_multiple_recepients_list_view_text").empty().html("");
			$("div#myft_multiple_recepients_list_view_text").html(respText).html();
			$("#myft_multiple_recepients_list_view").css({"display" : "block" , "visibility" : "visible"});
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=loadRecepientslist&recepient_ids="+recepient_ids);
}
//January 12th, 2012
function ft_pm_compose(mem_id,inbox_type,total){
	var c = $('input#current_page').val();	// get current page-in-view
	if(c=="my_frenchtuesdays"){
		var outerWidth = $("div#ft_mailbox_lbx").outerWidth()*1;
		var outerHeight = $("div#ft_mailbox_lbx").outerHeight()*1;
		var leftNudge = (($(window).width()*1) - outerWidth) / 2;
		leftNudge = Math.ceil(leftNudge);
		var topNudge = (($(window).height()*1) - outerHeight) / 2;
		topNudge = Math.ceil(topNudge);
		leftNudge = leftNudge>0?leftNudge:0;
		topNudge = topNudge>0?topNudge:0;
		$("div#ft_mailbox_lbx").attr('style' , 'position:absolute;display:block;visibility:visible;left:'+(($(window).scrollLeft()*1)+leftNudge)+'px!important;top:'+(($(window).scrollTop()*1)+topNudge)+'px!important');
	}
	$("div#ft_section_inbox_id").empty().html("");
	$("div#ft_section_inbox_id").html(loader_div_24).html();
	if(total==-1){
		$("div.div_lightbox").css({"display" : "none" , "visibility" : "hidden"});
		$("#ft_mailbox_lbx").css({"display" : "block" , "visibility" : "visible"});
	}
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div#ft_section_inbox_id").empty().html("");
			$("div#ft_section_inbox_id").html(respText).html();
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=ft_pm_compose&mem_id="+mem_id+"&inbox_type="+inbox_type+"&total="+total);
}
/* PHOTO ALBUMS FUNCTIONS */
function load_photos_tab(mem_id,start,limit,total,loadType,divID,isguest){
	$("div#myft_main_loader > img#img_myft_loader").css("visibility","visible");
	if(isguest=='n'){
		$(document).attr("title" , "My photos - French Tuesdays");
	}
	else{
		var fname = $("input#mem_fname").val();
		$(document).attr("title" , fname+"' photos - French Tuesdays");
	}
	if(divID=="myfriends"){
		divID = "tag_events_pictures";
	}
	if(loadType=='photos'){	// load both sections of the photos
	}
	if(loadType=='profile_pix'){	// repopulate PROFILE PICTURES SECTION THROUGH AJAX
	}
	if(loadType=='tagged_pix'){	// repopulate TAGGED PICTURES SECTION THROUGH AJAX
		if(divID=="divid"){
			divID = $("#tag_album_type").val();
		}
	}
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			$("div#myft_main_loader > img#img_myft_loader").css("visibility","hidden");
			respText = self.xmlHttpReq.responseText;
			if(loadType=='photos'){
				$("#myft_photos_container").empty().html("");
				$("#myft_photos_container").html(respText).html();
			}
			if(loadType=='profile_pix'){
				$("#myft_photos_container > #myft_photos_profile_pics").empty().html("");
				$("#myft_photos_container > #myft_photos_profile_pics").html(respText).html();
			}
			if(loadType=='tagged_pix'){
				$("#myft_photos_container > #myft_photos_tagged_pics").empty().html("");
				$("#myft_photos_container > #myft_photos_tagged_pics").html(respText).html();
			}
			$("#ft_myfrenchtuesdays_page_photos").css({"display" : "block" , "visibility" : "visible"});
			$("#ft_myfrenchtuesdays_page_main").css({"display" : "none" , "visibility" : "hidden"});
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=load_myft_photos&isguest="+isguest+"&loadType="+loadType+"&start="+start+"&limit="+limit+"&total="+total+"&mem_id="+mem_id+"&tag_album_type="+divID);
}

function load_other_tab(mem_id,sQuantity,mQuantity,cDate,loadType,divID,isguest){
	$("div#myft_main_loader > img#img_myft_loader").css("visibility","visible");
	if(isguest=='n'){
		if(divID=="myfeeds"){
			$(document).attr("title" , "My Feeds - French Tuesdays");
		}
		if(divID=="aboutme"){
			$(document).attr("title" , "About me - French Tuesdays");
		}
		if(divID=="myevents"){
			$(document).attr("title" , "My events - French Tuesdays");
		}
		$('div.not_for_friends_tab').css({"display" : "block" , "visibility" : "visible"});
		$('div#ppl_you_may_know_container_myft').css({"display" : "none" , "visibility" : "hidden"});
		var p = $('input#profile_progress_number').val() * 1;
		if(p>99){
			$('div.ft_myfrenchtuesdays_incomplete_profile_notice').css({"display" : "none" , "visibility" : "hidden"});
		}
	}
	else{
		var fname = $("input#mem_fname").val();
		if(divID=="myfeeds"){
			$(document).attr("title" , fname+"' feeds - French Tuesdays");
		}
		if(divID=="aboutme"){
			$(document).attr("title" , fname+"' info - French Tuesdays");
		}
		if(divID=="myevents"){
			$(document).attr("title" , fname+"' events - French Tuesdays");
		}
	}
	$("div#ft_myfrenchtuesdays_page_photos").css({"display" : "none" , "visibility" : "hidden"});
	$("div#myft_photos_container").empty().html("");
	$("div#ft_myfrenchtuesdays_page_main").css({"display" : "block" , "visibility" : "visible"});
	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	$("div.ft_my_feed_box").css({"display" :"none" , "visibility":"hidden"});
	$("div.ft_my_feed_item").removeClass("item_active");
	$("div#sl_"+divID).addClass("item_active");
	$("div.ft_my_feed_tab").removeClass("tab_active");
	$("div#ft_"+divID).addClass("tab_active");
	if(divID=="aboutme"){
		load_aboutme_content(mem_id,isguest);
	}
	if(divID=="myfeeds"){
		load_feeds_ini(mem_id,0,30,'x',0);
		$("div#myfeeds").css({"display" :"block" , "visibility":"visible"});
	}
	if(divID=="myevents"){
		$("div#myft_main_loader > img#img_myft_loader").css("visibility","hidden");
	}
	if(($("div#ft_"+divID+" > a").attr("rel")=="1") && (divID=="myfriends")){
		load_frnd_pen_pages(mem_id,1,3,-1,"ajax");
	}
	if($("div#ft_"+divID+" > a").attr("rel")=="0"){
		$("div#ft_"+divID+" > a").removeAttr("rel");
		$("div#ft_"+divID+" > a").attr("rel" , "1");
	}
	$("div#"+divID).css({"display" :"block" , "visibility":"visible"});
}

$(window).load(function(){
	/*we are using $(window).load() here because we want the coding to take
	effect when the image is loaded. */
	//get the width of the parent
	var parent_height = $('div.ft_events_photos_single_album_single_photo_photos_block').height();
	var image_height = $('#the_image').height();
	if(parent_height > image_height){
		var top_margin = (parent_height - image_height)/2;
	}
	if(location.href.toLowerCase().indexOf('page=my_frenchtuesdays&') >= 0 && location.hash){
	}
 });

function load_myft_photos(mem_id,isguest,loadType){
}

function getHash(m,s,l,t,x,y,z){
	if(location.href.toLowerCase().indexOf('page=my_frenchtuesdays_photos') >= 0 && window.location.hash){
		var aryURLparts =  location.hash.toLowerCase().replace("#","").split("_");
		var mem_ID = 0;
		var pho_ID = 0;
		var pho_Type = '';
		var load_Type='';
		var data_type='';
		var agep = 0;
		if(typeof(aryURLparts[0]) != 'undefined' && parseInt(aryURLparts[0]) > 0){
			mem_ID = parseInt(aryURLparts[0]);
		}
		else{
		}
		if(typeof(aryURLparts[1]) != 'undefined' && parseInt(aryURLparts[1]) > 0){
			pho_ID = parseInt(aryURLparts[1]);
		}
		else{
		}
		if(typeof(aryURLparts[2]) != 'undefined' && aryURLparts[2].length > 0){
			pho_Type = aryURLparts[2];
		}
		else{
		}
		if(typeof(aryURLparts[3]) != 'undefined' && aryURLparts[3].length > 0){
			load_Type = aryURLparts[3];
		}
		else{
		}
		if(typeof(aryURLparts[4]) != 'undefined' && aryURLparts[4].length > 0){
			data_type = aryURLparts[4];
		}
		else{
		}
		if(typeof(aryURLparts[5]) != 'undefined' && aryURLparts[5].length > 0){
			agep = aryURLparts[5];
		}
		else{
		}
		if(pho_Type=="profile"){
			window.location.href="/index.php?page=my_frenchtuesdays_photos&pho_id="+pho_ID+"&t="+pho_Type;
		}
		if(pho_Type=="tagged" && data_type=="tap"){
			window.location.href="/index.php?page=my_frenchtuesdays_photos&pho_id="+pho_ID+"&t="+pho_Type+"&alb_id="+agep+"&z="+data_type;
		}
		if(pho_Type=="tagged" && data_type=="tep"){
			window.location.href="/index.php?page=my_frenchtuesdays_photos&gal_id="+agep+"&t="+pho_Type+"&pho_id="+pho_ID+"&z="+data_type;
		}
		if(pho_Type=="tagged" && data_type=="temp"){
			window.location.href="/index.php?page=my_frenchtuesdays_photos&event_id="+agep+"&t="+pho_Type+"&pho_id="+pho_ID+"&z="+data_type;
		}
	}
	else{
	}
	if(location.href.toLowerCase().indexOf('page=photos') >= 0 && window.location.hash){
		/*ajax_tep
		http://prod.frenchtuesdays.com/index.php?page=photos&gal_id=950&pho_id=138042#.Ts2mM21szUA.facebook*/
		if(window.location.hash.toLowerCase().indexOf('_ajax_tep') >= 0){
			/*var gid = gup( 'gal_id' );
			var pid = gup( 'pho_id' );
			alert('XXX - '+gid+','+pid);*/
			var aryURLparts =  location.hash.toLowerCase().replace("#","").split("_");
			var m_ID = 0;
			var p_ID = 0;
			var g_ID = 0;
			var load_Type='';
			var data_type='';
			if(typeof(aryURLparts[0]) != 'undefined' && parseInt(aryURLparts[0]) > 0){
				m_ID = parseInt(aryURLparts[0]);
			}
			else{
			}
			if(typeof(aryURLparts[1]) != 'undefined' && parseInt(aryURLparts[1]) > 0){
				p_ID = parseInt(aryURLparts[1]);
			}
			else{
			}
			if(typeof(aryURLparts[2]) != 'undefined' && aryURLparts[2].length > 0){
				g_ID = aryURLparts[2];
			}
			else{
			}
			window.location.href="/index.php?page=photos&gal_id="+g_ID+"&pho_id="+p_ID;
		}
	}
	else{
	}
}

function slideShow(mem_id,pho_id,t,type,x,y){
	release_cursor();
	var xmlHttpReq = false;
	var self = this;
	var respText;
	$("img#img_myft_profile_picx_loader").css("visibility","visible");
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div.ft_events_photos_single_album_single_photo").empty().html("");
			$("div.ft_events_photos_single_album_single_photo").html(respText).html();
			$("img#img_myft_profile_picx_loader").css("visibility","hidden");
			location.hash=mem_id+"_"+pho_id+"_"+t+"_"+type+"_"+x+"_"+y;
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=load_myft_pictures&mem_id="+mem_id+"&pho_id="+pho_id+"&t="+t+"&type="+type+"&z="+x);
}

function removeTag(tag_id,mem_id,item_id,type,ele){
	$("img#img_myft_profile_picx_loader").css("visibility","visible");
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("span.single_album_random_tags_names_links").empty().html("");
			$("span.single_album_random_tags_names_links").html(respText).html();
			$("img#img_myft_profile_picx_loader").css("visibility","hidden");
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=ft_manage_photoTags&mem_id="+mem_id+"&tag_id="+tag_id+"&item_id="+item_id+"&type="+type+"&ele="+ele);
}
// modified [wma]
function showTag(x,y,z,e,name,mem_id,mem){
	var member;
	if(mem > 0 && mem!=100000){
		member = "Tagged by: <a href=\"/index.php?page=my_frenchtuesdays&section=feeds&mem_id="+mem_id+"\" style=\"color: gold; text-decoration: underline; font-size: 10px;\">"+name+"</a>";
	}else
	{
		member = "Tagged by: <a href=\"javascript:void(0);\" style=\"color: gold; text-decoration: underline; font-size: 10px;\">"+name+"</a>";
	}
	$("div#tagger_name").empty().html('');
	$("div#tagger_name").css({"color":"white" , "font-weight":"bold"});
	$("div#tagger_name").html(member).html();

	$("div.ft_photo_face_detect_div_show").css({"display":"block" , "visibility":"visible" , "top":y+"px" , "left":x+"px"});
	$("div.ft_photo_face_detect_div_core_show").empty().html("");
	$("#tagger_div").empty().html("");
	$("#tagger_div").html(z+"<div class=\"clear\"></div>").html();
}
// modified [wma]
function hideTag(){
	$("div.ft_photo_face_detect_div_show").css({"display":"none" , "visibility":"hidden" , "top":"0px" , "left":"0px"});
	$("div.ft_photo_face_detect_div_core_show").empty().html("");
	$("#tagger_div").empty().html("");
	//$("div#tagger_name").empty().html('');
}
// added [wma]
function keepAlive(id){
	//$("div#tagger_name").html('mouseover');
}
// added[wma]
function makeHide(id){
	//$("div#tagger_name").html('');
}

function loadTab(tab,mem_id,isguest){
	var hash = gup(tab);
	if(hash.length==0){
		$("div.ft_my_feed_item").removeClass("item_active");
		$("#sl_myfeeds").addClass("item_active");
		$("div.ft_my_feed_tab").removeClass("tab_active");
		$("#ft_myfeeds").addClass("tab_active");
		$("#myfeeds").css({"display":"block" , "visibility":"visible"});
	}
	if(hash=="friends"){
		load_friends_tab(mem_id,0,30,'x',0,'myfriends','n');
	}
	if(hash=="photos"){
		$("#ft_myfrenchtuesdays_page_photos").css({"display" : "block" , "visibility" : "visible"});
		$("div#ft_myfrenchtuesdays_page_main").css({"display" : "none" , "visibility" : "hidden"});
		load_photos_tab(mem_id,1,9,0,'photos','myfriends',isguest);
	}
}

function load_friends_tab(mem_id,sQuantity,mQuantity,cDate,loadType,divID,isguest){
	$("div#myft_main_loader > img#img_myft_loader").css("visibility","visible");
	if(isguest=='n'){
		if(divID=="myfriends"){
			$(document).attr("title" , "My friends - French Tuesdays");
		}
		$('div.not_for_friends_tab').css({"display" : "none" , "visibility" : "hidden"});
		$('div#ppl_you_may_know_container_myft').css({"display" : "block" , "visibility" : "visible"});
	}
	else{
		var fname = $("input#mem_fname").val();
		$(document).attr("title" , fname+"' friends - French Tuesdays");
	}
	$("div#ft_myfrenchtuesdays_page_photos").css({"display" : "none" , "visibility" : "hidden"});
	$("div#myft_photos_container").empty().html("");
	$("div#ft_myfrenchtuesdays_page_main").css({"display" : "block" , "visibility" : "visible"});
	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	$("div.ft_my_feed_box").css({"display" :"none" , "visibility":"hidden"});
	$("div.ft_my_feed_item").removeClass("item_active");
	$("div#sl_"+divID).addClass("item_active");
	$("div.ft_my_feed_tab").removeClass("tab_active");
	$("div#ft_"+divID).addClass("tab_active");
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			$("div#myft_main_loader > img#img_myft_loader").css("visibility","hidden");
			respText = self.xmlHttpReq.responseText;
			$("div.myft_my_friends_main_container").empty().html("");
			$("div.myft_my_friends_main_container").html(respText).html();
			$("div#"+divID).css({"display" :"block" , "visibility":"visible"});
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=load_all_friends&mem_id="+mem_id+"&isguest="+isguest);
}

function activate_tagger(){
	$("input#tagger_status").val("on");
	$("#abc").hide();
	change_cursor();
}
/* image tagging */
function change_cursor(){
	var url = window.location.href;
	var hostPort = url.split('index.php')[0];
	if(is_ie){
		document.body.style.cursor="url("+hostPort+"themes/french_tuesdays/gfx/icons/lcross.cur), crosshair";
	}
	else{
		document.body.style.cursor="crosshair";
	}
}

function release_cursor(){
	document.body.style.cursor="default";	
}

function show_tagger(m,x,y,w,h) {
	var t=0;
	var l=0;
	var half_x = w/2;
	half_x = Math.ceil(half_x);
	var half_y = h/2;
	half_y = Math.ceil(half_y);
	if(x < 50){
		x=0;
	}
	else{
		b=(x+100);
		if(b > w){
			x = w-100;
		}
		else{
			x=x-50;
		}
	}
	if(y < 50){
		y=0;
	}
	else{
		a=(y+100);
		if(a > h){
			y = h-100;
		}
		else{
			y=y-50;
		}
	}
	if(x <= half_x && y <= half_y){	// box on the right , top
		t=y;
		l=(x+104);
	}
	if(x >= half_x && y <= half_y){	//box on the left, top
		t=y;
		l=x-232;
	}
	if(x <= half_x && y >= half_y){	// box on the right, bottom
		t=(y+104)-356;
		l=(x+104);
	}
	if(x >= half_x && y >= half_y){	// box on the left, bottom
		t=(y+104)-356;
		l=x-232;
	}
	getFriends(m,"a","ajax");
	$('div.ft_photo_tag_div').css({"display" :"none" , "visibility":"hidden"});
	$("div.ft_photo_face_detect_div").css({"display" : "block" , "visibility" : "visible" , "top":(y)+"px" , "left":(x)+"px"});
	$('div.ft_photo_tag_div').css({"display" : "block" , "visibility" : "visible" , "top":(t)+"px" , "left":(l)+"px"});
	$("input#cord_x").val(x);
	$("input#cord_y").val(y);
}

function close_tagger(id){
	release_cursor();
	$("input#tagger_status").removeAttr("value");
	$('div.ft_photo_tag_div').css({"display" :"none" , "visibility":"hidden"});
	$("div.ft_photo_face_detect_div").css({"display" :"none" , "visibility":"hidden"});
	$("input#cord_x").val(-1);
	$("input#cord_y").val(-1);
	$("#selected_ID").val(-1);
	$("#ft_album_photo_name_tag").val("");
	$("div.ft_photo_tag_div_core_container_chose_person_listbox_list").empty().html("");
}
// modified WMA [December 4th, 2011]
function setTagger(id){
	if($("a#"+id).hasClass("setBorder")==true){
		$("a#"+id).removeClass("setBorder");
		$("#selected_ID").val(-1);
	}
	else{
		$("a.setTagger").removeClass("setBorder");
		$("a#"+id).addClass("setBorder");
		$("#selected_ID").val(id);
	}
}

function getFriends(mem_id,hint,load){
	var xmlHttpReq = false;
	var self = this;
	var respText;
	$("#selected_ID").val(-1);
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div.ft_photo_tag_div_core_container_chose_person_listbox_list").empty().html("");
			$("div.ft_photo_tag_div_core_container_chose_person_listbox_list").html(respText).html();
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=getFriends&mem_id="+mem_id+"&hint="+hint+"&load="+load);
}

function saveTag(mem_id,table,pho_id){
	var cord_x = $("#cord_x").val();
	var cord_y = $("#cord_y").val();
	var mem_id_friend = $("#selected_ID").val();
	if(mem_id_friend==-1){
		var comments = escape($("#ft_album_photo_name_tag").val());
		comments = $.trim(comments);
		if(comments.length <=0){
			alert("Please enter a valid tag or\nselect a member from the list");
			return false;
		}
	}
	if(cord_x==-1 || cord_y==-1){
		alert("Invalid section selected. Please try again");
		return false;
	}
	else{
		$("img#img_myft_profile_picx_loader").css("visibility","visible");
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				$("span.single_album_random_tags_names_links").empty().html("");
				$("span.single_album_random_tags_names_links").html(respText).html();
				$("img#img_myft_profile_picx_loader").css("visibility","hidden");
				$("div.ft_events_photos_single_album_single_photo_photos_tag_me").show(500); //.css({"display":"block" , "visibility":"visible"});
			}
		}
		self.xmlHttpReq.send("handler=my_frenchtuesdays&action=saveTag&mem_id="+mem_id+"&cord_z="+table+"&pho_id="+pho_id+"&cord_x="+cord_x+"&cord_y="+cord_y+"&mem_id_friend="+mem_id_friend+"&comments="+comments);
	}
}

function closeTagger(){
	release_cursor();
	$("input#tagger_status").removeAttr("value");
	$("div.ft_events_photos_single_album_single_photo_photos_tag_me").hide(500); //.css({"display":"none" , "visibility":"hidden"});
	close_tagger('x');
}

function scrollSlider(step){
	var divHeight = $("#ft-album-photos-carousel-slider-belt").height();
	var pos = $("#ft-album-photos-carousel-slider-belt").position();
	var total_steps = $("#total_steps").val();
	var current_step = $("#current_step").val()*1;
	if(step=="up"){
		current_step = (current_step*1)+1;
		if(current_step < total_steps){
			$("#ft-album-photos-carousel-slider-belt").animate({top: (-344*current_step*1)+"px"} , 500);
			$("#current_step").val(current_step*1);
		}
	}
	if(step=="down"){
		current_step = (current_step*1)-1;
		if(current_step >= 0){
			$("#ft-album-photos-carousel-slider-belt").animate({top: (pos.top+344)+"px"} , 500);
			$("#current_step").val(current_step*1);
		}
	}
}

function page_event_album(page,id){
	$("a.page_event_album").removeClass("active");
	$("a#"+id).addClass("active");
	var top_scroll=0;
	top_scroll = page==0?0:((page) * (-456))*1;
	$("div.ft_events_photos_albums_events_albums_container_carousel_slider").animate({top: (top_scroll)+"px"} , 250);
}
// December 12th, 2011
function page_best_viewed_photos(page,id){
	$("a.page_best_viewed_photos").removeClass("active");
	$("a#"+id).addClass("active");
	var top_scroll=0;
	//top_scroll = page==0?0:((page) * (-320))*1;
	top_scroll = page==0?0:((page) * (-480))*1;
	$("div.ft_events_photos_albums_best_photos_container_carousel_slider").animate({top: (top_scroll)+"px"} , 250);
}
// PHOTOS SECTION
function showTagger(m,x,y,w,h) {
	var t=0;
	var l=0;
	var half_x = w/2;
	half_x = Math.ceil(half_x);
	var half_y = h/2;
	half_y = Math.ceil(half_y);
	if(x < 50){
		x=0;
	}
	else{
		b=(x+100);
		if(b > w){
			x = w-100;
		}
		else{
			x=x-50;
		}
	}
	if(y < 50){
		y=0;
	}
	else{
		a=(y+100);
		if(a > h){
			y = h-100;
		}
		else{
			y=y-50;
		}
	}
	if(x <= half_x && y <= half_y){	// box on the right , top
		t=y;
		l=(x+104);
	}
	if(x >= half_x && y <= half_y){	//box on the left, top
		t=y;
		l=x-232;
	}
	if(x <= half_x && y >= half_y){	// box on the right, bottom
		t=(y+104)-356;
		l=(x+104);
	}
	if(x >= half_x && y >= half_y){	// box on the left, bottom
		t=(y+104)-356;
		l=x-232;
	}
	get_Photos_Friends(m,"a","ajax");
	$('div.ft_photo_tag_div').css({"display" :"none" , "visibility":"hidden"});
	$("div.ft_photo_face_detect_div").css({"display" : "block" , "visibility" : "visible" , "top":(y)+"px" , "left":(x)+"px"});
	$('div.ft_photo_tag_div').css({"display" : "block" , "visibility" : "visible" , "top":(t)+"px" , "left":(l)+"px"});
	$("input#cord_x").val(x);
	$("input#cord_y").val(y);
	$('input#ft_album_photo_name_tag').focus();
}

function slideShowGallery(mem_id,pho_id,gal_id,type,x){
	release_cursor();
	$("div.ft_events_photos_single_album_single_photo_info_loader").css("visibility","visible");
	var xmlHttpReq = false;
	var self = this;
	var respText;
	var shareHTML = $("div.ft_events_photos_single_album_single_photo > div.ft_events_photos_single_album_single_photo_share").html();
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			$("div.ft_events_photos_single_album_single_photo_info_loader").empty().html("");
			respText = self.xmlHttpReq.responseText;
			$("div#main_ft_photo_album_container").empty().html("");
			$("div#main_ft_photo_album_container").html(respText).html();
			location.hash=mem_id+"_"+pho_id+"_"+gal_id+"_"+type+"_"+x;
			var event_title = $("span.single_album_title").html();
			var event_city = $("span.single_album_city").html();
			var event_venue = $("input#event_venue_name").val();
			var doc_title = "Photo#"+pho_id+" - "+event_title+" - "+event_venue+event_city;
			$(document).attr("title" , doc_title);
		}
	}
	self.xmlHttpReq.send("handler=manage_photos&action=load_gallery_photos&mem_id="+mem_id+"&phoid="+pho_id+"&galid="+gal_id+"&type="+type+"&z="+x);
}

function paginate_gallery(mem_id,start,limit,total,gal_id,x,y){
	$("div.ft_events_photos_single_album_info_loader").css("visibility","visible");
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			$("div.ft_events_photos_single_album_info_loader").css("visibility","hidden");
			respText = self.xmlHttpReq.responseText;
			$("#ft_events_photos_single_album_photos_x").empty().html("");
			$("#ft_events_photos_single_album_photos_x").html(respText).html();
		}
	}
	self.xmlHttpReq.send("handler=manage_photos&action=load_gallery_album&mem_id="+mem_id+"&start="+start+"&limit="+limit+"&total="+total+"&gal_id="+gal_id);
}

function get_Photos_Friends(mem_id,hint,load){
	var xmlHttpReq = false;
	var self = this;
	var respText;
	$("#selected_ID").val(-1);
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div.ft_photo_tag_div_core_container_chose_person_listbox_list").empty().html("");
			$("div.ft_photo_tag_div_core_container_chose_person_listbox_list").html(respText).html();
		}
	}
	self.xmlHttpReq.send("handler=manage_photos&action=get_Photos_Friends&mem_id="+mem_id+"&hint="+hint+"&load="+load);
}

function save_Tag(mem_id,table,pho_id){
	var cord_x = $("#cord_x").val();
	var cord_y = $("#cord_y").val();
	var mem_id_friend = $("#selected_ID").val();
	var album_gal_id = $("#album_gal_id").val();
	if(mem_id_friend==-1){
		var comments = escape($("#ft_album_photo_name_tag").val());
		comments = $.trim(comments);
		if(comments.length <=0){
			alert("Please enter a valid tag or\nselect a member from the list");
			return false;
		}
	}
	if(cord_x==-1 || cord_y==-1){
		alert("Invalid section selected. Please try again");
		return false;
	}
	else{
		$("div.ft_events_photos_single_album_single_photo_info_loader").css("visibility","visible");
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				$("span.single_album_random_tags_names_links").empty().html("");
				$("span.single_album_random_tags_names_links").html(respText).html();
				$("div.ft_events_photos_single_album_single_photo_info_loader").css("visibility","hidden");
				$("div.ft_events_photos_single_album_single_photo_photos_tag_me").show(500); //.css({"display":"block" , "visibility":"visible"});
				if(mem_id_friend > -1){	// December 21st, 2011
					var fbToken = $.trim($("input#fb_mem_id_"+mem_id_friend).val());
					var fbId = $.trim($("input#fb_mem_"+mem_id_friend).val());
					fbId = (typeof(fbId)==undefined || typeof(fbId)=='undefined')||fbId.length==0||!fbId ? 0 : fbId;
					if(fbToken!=0 || fbToken.length>2){
						//var img_src = $("img#the_image").attr("src");
						var img_src = $.trim($("input#hidden_img_src").val());
						var title = $.trim($(document).attr("title"));
						var m_f_n = $.trim($("input#m_f_n").val());
						//alert(fbId+","+fbToken+","+domain_name+","+img_src+","+title+","+m_f_n+","+pho_id+","+album_gal_id);
						// facebook tag photo call
						sharePhotoTagFB(fbId,fbToken,domain_name,img_src,title,m_f_n,pho_id,album_gal_id);
					}
				}
			}
		}
		self.xmlHttpReq.send("handler=manage_photos&action=save_Tag&mem_id="+mem_id+"&cord_z="+table+"&pho_id="+pho_id+"&cord_x="+cord_x+"&cord_y="+cord_y+"&mem_id_friend="+mem_id_friend+"&comments="+comments+"&album_gal_id="+album_gal_id);
	}
}
// modified wma [December 4th, 2011]
function remove_Tag(tag_id,mem_id,item_id,type,ele){
	$("div.ft_events_photos_single_album_single_photo_info_loader").css("visibility","visible");
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("span.single_album_random_tags_names_links").empty().html("");
			$("span.single_album_random_tags_names_links").html(respText).html();
			$("div.ft_events_photos_single_album_single_photo_info_loader").css("visibility","hidden");
			$("div#tag_id_"+tag_id).empty().remove();
			$("div#tagger_name").empty().html('');
		}
	}
	self.xmlHttpReq.send("handler=manage_photos&action=ft_manage_photoTags&mem_id="+mem_id+"&tag_id="+tag_id+"&item_id="+item_id+"&type="+type+"&ele="+ele);
}

function load_search(){
	var ft_city_select = $("#ft_city_select :selected").val()*1;
	var ft_event_select = $("#ft_event_select :selected").val()*1;
	var ft_venue_select = $("#ft_venue_select :selected").val()*1;
	if(ft_city_select==0 && ft_event_select==0 && ft_venue_select==0){
		setTimeout(function(){window.location.href="index.php?page=photos_search";}, 0);
	}
	else{
		setTimeout(function(){window.location.href="index.php?page=photos_search&city="+ft_city_select+"&event="+ft_event_select+"&venue="+ft_venue_select;}, 0);
	}
}

function load_search_pages(city,start,limit,total,venue,x,event){
	var xmlHttpReq = false;
	var self = this;
	var respText;
	$('span#ft_events_photos_albums_search_lbl_title_loader').css("visibility","visible");
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div.ft_events_photos_albums_search_block").empty().html("");
			$("div.ft_events_photos_albums_search_block").html(respText).html();
			$('span#ft_events_photos_albums_search_lbl_title_loader').css("visibility","hidden");
		}
	}
	self.xmlHttpReq.send("handler=manage_photos&action=load_search_data&city="+city+"&start="+start+"&limit="+limit+"&venue="+venue+"&event="+event);
}

function load_map_data(country_id,mem_id){
	var members_geo_map = document.getElementById("members_geo_map");
	members_geo_map.src = "http://"+domain_name+"/geomap_overview.php?country_id="+country_id+"&mem_id="+mem_id;
}

function post_to_url(path, method) {
    method = method || "POST"; // Set method to post by default, if not specified.
    // The rest of this code assumes you are not using a library.
    // It can be made less wordy if you use one.
    var form = document.createElement("form");
    form.setAttribute("method", method);
    form.setAttribute("action", path);
	var hiddenField = document.createElement("input");
	hiddenField.setAttribute("type", "hidden");
	hiddenField.setAttribute("name", "search_term");
	hiddenField.setAttribute("value", $("#search_field").val());
	form.appendChild(hiddenField);
    document.body.appendChild(form);    // Not entirely sure if this is necessary
    form.submit();
}

function show_trip_lbx(cls,id){
	if(id=='add_my_trip'){
		$("span#ft_text_counter").empty().html('');
		$("span#ft_text_counter").html('450').html();
	}
	$("div.div_lightbox").css({"display":"none" , "visibility":"hidden"});
	$("div."+cls).css({"display":"none" , "visibility":"hidden"});
	$("#"+id).css({"display":"block" , "visibility":"visible"});
}

function hide_trip_lbx(cls,id){
	$("select#ft_trip_city").find('option:first').attr('selected', 'selected').parent('select');
	$("input#ft_trip_locator_input_sdate_value").val("");
	$("input#ft_trip_locator_input_edate_value").val("");
	$("textarea#ft_trip_locator_leave_comment_textarea").val("");
	$("input#ft_trip_locator_input_notify_friend_chkbox_value").removeAttr('checked');
	$("div.div_lightbox").css({"display":"none" , "visibility":"hidden"});
	$("div."+cls).css({"display":"none" , "visibility":"hidden"});
	$("#"+id).css({"display":"none" , "visibility":"hidden"});
}
/* TRIP FUNCTIONS */
var dateFormat = function () {
	var	token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
	timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
	timezoneClip = /[^-+\dA-Z]/g,
	pad = function (val, len) {
		val = String(val);
		len = len || 2;
		while (val.length < len) val = "0" + val;
		return val;
	};
	// Regexes and supporting functions are cached through closure
	return function (date, mask, utc) {
		var dF = dateFormat;
		// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
		if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
			mask = date;
			date = undefined;
		}
		// Passing date through Date applies Date.parse, if necessary
		date = date ? new Date(date) : new Date;
		if (isNaN(date)) throw SyntaxError("invalid date");
		mask = String(dF.masks[mask] || mask || dF.masks["default"]);
		// Allow setting the utc argument via the mask
		if (mask.slice(0, 4) == "UTC:") {
			mask = mask.slice(4);
			utc = true;
		}
		var	_ = utc ? "getUTC" : "get",
			d = date[_ + "Date"](),
			D = date[_ + "Day"](),
			m = date[_ + "Month"](),
			y = date[_ + "FullYear"](),
			H = date[_ + "Hours"](),
			M = date[_ + "Minutes"](),
			s = date[_ + "Seconds"](),
			L = date[_ + "Milliseconds"](),
			o = utc ? 0 : date.getTimezoneOffset(),
			flags = {
				d:    d,
				dd:   pad(d),
				ddd:  dF.i18n.dayNames[D],
				dddd: dF.i18n.dayNames[D + 7],
				m:    m + 1,
				mm:   pad(m + 1),
				mmm:  dF.i18n.monthNames[m],
				mmmm: dF.i18n.monthNames[m + 12],
				yy:   String(y).slice(2),
				yyyy: y,
				h:    H % 12 || 12,
				hh:   pad(H % 12 || 12),
				H:    H,
				HH:   pad(H),
				M:    M,
				MM:   pad(M),
				s:    s,
				ss:   pad(s),
				l:    pad(L, 3),
				L:    pad(L > 99 ? Math.round(L / 10) : L),
				t:    H < 12 ? "a"  : "p",
				tt:   H < 12 ? "am" : "pm",
				T:    H < 12 ? "A"  : "P",
				TT:   H < 12 ? "AM" : "PM",
				Z:    utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
				o:    (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
				S:    ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
			};
		return mask.replace(token, function ($0) {
			return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
		});
	};
}();
// Some common format strings
dateFormat.masks = {
	"default":      "ddd mmm dd yyyy HH:MM:ss",
	shortDate:      "m/d/yy",
	mediumDate:     "mmm d, yyyy",
	longDate:       "mmmm d, yyyy",
	fullDate:       "dddd, mmmm d, yyyy",
	shortTime:      "h:MM TT",
	mediumTime:     "h:MM:ss TT",
	longTime:       "h:MM:ss TT Z",
	isoDate:        "yyyy-mm-dd",
	isoTime:        "HH:MM:ss",
	isoDateTime:    "yyyy-mm-dd'T'HH:MM:ss",
	isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};
// Internationalization strings
dateFormat.i18n = {
	dayNames: [
		"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
		"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
	],
	monthNames: [
		"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
		"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
	]
};
// For convenience...
Date.prototype.format = function (mask, utc) {
	return dateFormat(this, mask, utc);
};
function add_my_trip(mem_id,type){
	var d = new Date();
	var today;
	var day;
	var month;
	var year;
	today = (d.getMonth()+1)+"/"+(d.getDate())+"/"+d.getFullYear();
	today = $.trim(today);
	var error=0;
	var message="";
	var trip_city = $("select#ft_trip_city :selected").val();
	var start_date = $("input#ft_trip_locator_input_sdate_value").val();
	var end_date = $("input#ft_trip_locator_input_edate_value").val();
	var comment = $.trim(escape($("textarea#ft_trip_locator_leave_comment_textarea").val()));
	var notify_friend = $("input#ft_trip_locator_input_notify_friend_chkbox_value").is(':checked')==true?"y":"n";
	var x = new Date(start_date);
	var y = new Date(end_date);
	var z = new Date(today);
	if(start_date.length>0){
		if(x < z){
			message=message+"Start date can\'t be in the past\n";
			error=error+1
		}
		if(x > y){
			message=message+"Start date can\'t be after the end date\n";
			error=error+1
		}
	}
	if(end_date.length>0){
		if(y < z){
			message=message+"End date can\'t be in the past\n";
			error=error+1
		}
		if(y < x){
			message=message+"End date can't be before start date\n";
			error=error+1
		}
	}

	if(trip_city==0){
		message = message+"Please select your trip city.\n";
		error=error+1
	}
	if(start_date.length==0){
		message = message+"Please specify the start date.\n";
		error=error+1
	}
	if(end_date.length==0){
		message = message+"Please specify the end date.\n";
		error=error+1
	}
	if(comment.length>450){
		message = message+"Comment limit is 450 characters.\n";
		error=error+1
	}
	if(error>0)
	{
		alert(message);
	}
	else{
		$("div#ad_1").html(loader_div_16).css("visibility","visible");
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				$("div#ad_1").css("visibility","hidden").empty().html("");
				if(respText!=0 || respText!=""){
					var data = respText.split("<|>");	// output [0] & total trips [1]
					if(type=="community"){
						$("div.preparing_trip_latest_trips_container").empty().html("");
						$("div.preparing_trip_latest_trips_container").html(data[0]).html();
						$("span.total_trips_number").empty().html("");
						$("span.total_trips_number").html(data[1]).html();
					}
					else if(type=="trip_locator"){// January 4th, 2012
					//	$("div.ft_trip_locator_results").empty().html("");
					//	$("div.ft_trip_locator_results").html(respText).html();
					}
					// December 8th, 2011
					$("select#ft_trip_city").find('option:first').attr('selected', 'selected').parent('select');
					$("input#ft_trip_locator_input_sdate_value").val("");
					$("input#ft_trip_locator_input_edate_value").val("");
					$("textarea#ft_trip_locator_leave_comment_textarea").val("");
					$("input#ft_trip_locator_input_notify_friend_chkbox_value").removeAttr('checked');
					alert("Your trip is added successfully.");
					$("#add_my_trip").css({"display":"none" , "visibility":"hidden"});
					// January 4th, 2012
					if(type=="trip_locator"){
						setTimeout(function(){
							load_selected_type(1,1,8,0,'0','b','0');
							$("select#ft_trip_locator_search_bar_view_all_select").val(1);
						}, 100);
					}
				}
				else{
					alert("Something went wrong. Please re-try adding your trip.");
				}
			}
		}
		self.xmlHttpReq.send("handler=community&action=add_my_trip&mem_id="+mem_id+"&trip_city="+trip_city+"&start_date="+start_date+"&end_date="+end_date+"&comment="+comment+"&notify_friend="+notify_friend+"&type="+type);
	}
}

function load_trip_locator(mem_id,type){
	var trip_city = $("select#preparing_trip_meet_someone_form_row_one_select_city :selected").val();
	var start_date = $("#start_date").val();
	var end_date = $("#end_date").val();
	var s;
	var x=0;
	s="&tc="+trip_city;
	if(start_date.length>0 || end_date.length>0){
		if(start_date.length>0){
			s=s+"&sd="+start_date;
		}
		if(end_date.length>0){
			s=s+"&ed="+end_date;
		}
	}
	window.location.href="index.php?page=trip_locator"+$.trim(s);
}

function get_trip_pages(tc,start,limit,total,sd,x,ed){
	$("div#triplocator_loader").css("visibility","visible");
	var trip_id=0;
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			$("div#triplocator_loader").css("visibility","hidden");
			respText = self.xmlHttpReq.responseText;
			$("div.ft_trip_locator_results").empty().html("");
			$("div.ft_trip_locator_results").html(respText).html();
		}
	}
	self.xmlHttpReq.send("handler=community&action=get_trips_data&t="+tc+"&s="+sd+"&e="+ed+"&start="+start+"&limit="+limit+"&total="+total+"&trip_id="+trip_id);
}

function perform_tl_search(){
	var trip_city = $("select#ft_trip_locator_search_bar_search_criteria_city_select :selected").val();
	var start_date = $("#search_sdate").val();
	var end_date = $("#search_edate").val();
	var err=0;
	var err_msg='';
	get_trip_pages(trip_city,1,8,0,start_date,'x',end_date);
}

function load_tc_lbx(mem_id,trip_id,id){
	$("div.div_lightbox").css({"display":"none" , "visibility":"hidden"});
	$("#ft_triplocator_info_comments").empty().html("");
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("#ft_triplocator_info_comments").empty().html("");
			$("#ft_triplocator_info_comments").html(respText).html();
			$("#ft_tl_add_comment").css({"display":"block" , "visibility":"visible"});
		}
	}
	self.xmlHttpReq.send("handler=community&action=load_selected_trip&mem_id="+mem_id+"&trip_id="+trip_id);
}

function checkValue(id,type)	{
	var checkVal = document.getElementById(id).value;
	if(type=="blur"){
		if(checkVal=='' || checkVal=="" || checkVal==null){
			document.getElementById(id).value='Leave a comment';
		}
		return false;
	}
	if(type=="focus"){
		if(checkVal=='Leave a comment'){
			document.getElementById(id).value='';
		}
		return false;
	}
}

function post_trip_comment(mem_id,trip_id){
	var comment = $.trim(escape($("textarea#trip_post_comment").val()));
	if(comment.length==0 || unescape(comment)=="Leave a comment"){
		alert("Please type in your comment");
		return false;
	}
	else{
		// modified wma [December 7th, 2011]
		$("span#post_comments_loader").css({"visibility":"visible"});
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				if(respText!=0){
					var data = respText.split("<|>");	// output [0] & total comments [1]
					$("div.ft_trip_locator_lightbox_layer_core_show_posted_comment_blocks").empty().html("");
					$("div.ft_trip_locator_lightbox_layer_core_show_posted_comment_blocks").html(data[0]).html();
					$("a#comment_counter_"+trip_id).text("");
					$("a#comment_counter_"+trip_id).text("("+data[1]+")");
					// modified wma [December 6th, 2011]
					$("textarea#trip_post_comment").val('Leave a comment');
					// modified wma [December 7th, 2011]
					$("span#post_comments_loader").css({"visibility":"hidden"});
				}
				else{
					alert("Something went wrong. Please re-try submitting your comment. Thankyou.");
				}
			}
		}
		self.xmlHttpReq.send("handler=community&action=post_trip_comment&mem_id="+mem_id+"&trip_id="+trip_id+"&comment="+$.trim(comment));
	}
}

function edit_trip_info(mem_id,trip_id, side){
	$("div.div_lightbox").css({"display":"none" , "visibility":"hidden"});
	$("#c_core").empty().html("");
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("#c_core").empty().html("");
			$("#c_core").html(respText).html();
			$("#modify_my_trip").css({"display":"block" , "visibility":"visible"});
		}
	}
	self.xmlHttpReq.send("handler=community&action=edit_trip_info&mem_id="+mem_id+"&trip_id="+trip_id+"&side="+side);
}

function save_modified_trip(mem_id){
	var d = new Date();
	var today;
	var day;
	var month;
	var year;
	today = (d.getMonth()+1)+"/"+(d.getDate())+"/"+d.getFullYear();
	today = $.trim(today);
	var error=0;
	var message="";
	var trip_id = $("#trip_id").val();
	var side = $("#block_side").val();
	var trip_city = $("select#ft_trip_city :selected").val();
	var start_date = $("input#ft_trip_locator_input_sdate_value").val();
	var end_date = $("input#ft_trip_locator_input_edate_value").val();
	var comment = $.trim(escape($("textarea#ft_trip_locator_leave_comment_textarea").val()));
	var notify_friend = $("input#ft_trip_locator_input_notify_friend_chkbox_value").is(':checked')==true?"y":"n";
	var x = new Date(start_date);
	var y = new Date(end_date);
	var z = new Date(today);
	if(start_date.length>0){
		if(x > y){
			message=message+"Start date can\'t be after the end date\n";
			error=error+1
		}
	}
	if(end_date.length>0){
		if(y < z){
			message=message+"End date can\'t be in the past\n";
			error=error+1
		}
		if(y < x){
			message=message+"End date can't be before start date\n";
			error=error+1
		}
	}
	if(trip_city==0){
		message = message+"Please select your trip city.\n";
		error=error+1
	}
	if(start_date.length==0){
		message = message+"Please specify the start date.\n";
		error=error+1
	}
	if(end_date.length==0){
		message = message+"Please specify the end date.";
		error=error+1
	}
	if(comment.length>450){
		message = message+"Comment limit is 450 characters.\n";
		error=error+1
	}
	if(error>0)
	{
		alert(message);
	}
	else{
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				if(respText!=0 || respText!=""){
					$("#trip_block_"+trip_id).empty().html("");
					$("#trip_block_"+trip_id).html(respText).html();
					alert("Trip modified successfully.");
					$("div.div_lightbox").css({"display":"none" , "visibility":"hidden"});
					$("#modify_my_trip").css({"display":"none" , "visibility":"hidden"});
					$("#c_core").empty().html("");
				}
				else{
					alert("Trip modification failed. Please try again.");
				}
			}
		}
		self.xmlHttpReq.send("handler=community&action=save_edit_trip_info&mem_id="+mem_id+"&trip_city="+trip_city+"&start_date="+start_date+"&end_date="+end_date+"&comment="+comment+"&notify_friend="+notify_friend+"&trip_id="+trip_id+"&side="+side);
	}
}

function load_friends_search(){
	var search_term = $.trim(escape($("#search_field").val()));
	var gender = $("select#ft_search_gender :selected").val();
	var marital_status = $("select#ft_search_marital_status :selected").val();
	var city = $("select#ft_search_city :selected").val();
	var pics_only = $("input#prof_pics_only").is(':checked')==true?1:0;
	var incl_network = $("input#include_network").is(':checked')==true?1:0;
	if(search_term.length < 3 && gender==0 && marital_status==-1 && city==0 && pics_only==0 && incl_network==1){
		if(search_term.length < 3){
			alert("Please specify a search term\n[first/last/full name/email/school/company] atleast upto 3 letters OR\nSpecify an option for the search");
		}
		else{
			alert("Please specify a search term [atleast upto 3 letters] OR\n sprcify an option for the search");
		}
		return false;
	}
	else{
		$("div.ft_community_loader").html("Performing search...");
		setTimeout(function(){window.location.href="index.php?page=community&s=1&search="+search_term+"&g="+gender+"&m="+marital_status+"&c="+city+"&p="+pics_only+"&n="+incl_network;}, 250);
	}
}

function paginate_search_results(mem_id,start,limit,total,x,y,z){
	var search_term;
	if(z=="default"){
		search_term = $.trim(escape($("#search_field").val()));
	}
	else{
		search_term=z;
	}
	var gender = $("select#ft_search_gender :selected").val();
	var marital_status = $("select#ft_search_marital_status :selected").val();
	var city = $("select#ft_search_city :selected").val();
	var pics_only = $("input#prof_pics_only").is(':checked')==true?1:0;
	var incl_network = $("input#include_network").is(':checked')==true?1:0;
	if(search_term.length < 3 && gender==0 && marital_status==-1 && city==0 && pics_only==0 && incl_network==1){
		if(search_term.length < 3){
			alert("Please specify a search term\n[first/last/full name/email/school/company] atleast upto 3 letters OR\nSpecify an option for the search");
		}
		else{
			alert("Please specify a search term [atleast upto 3 letters] OR\n sprcify an option for the search");
		}
		return false;
	}
	else{
		$("div#community_main_loader").css("visibility","visible");
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				$("div#community_main_loader").css("visibility","hidden");
				respText = self.xmlHttpReq.responseText;
				$("#ft_friends_search_results").empty().html("");
				$("#ft_friends_search_results").html(respText).html();
			}
		}
		self.xmlHttpReq.send("handler=community&action=ft_perform_search&mem_id="+mem_id+"&search_term="+search_term+"&start="+start+"&limit="+limit+"&total="+total+"&g="+gender+"&m="+marital_status+"&c="+city+"&p="+pics_only+"&n="+incl_network);
	}
}

function hide_addfriend_lbx(cls,id){
	$("div.div_lightbox").css({"display":"none" , "visibility":"hidden"});
	$("div."+cls).css({"display":"none" , "visibility":"hidden"});
	$("#"+id).css({"display":"none" , "visibility":"hidden"});
}

function load_newfriend_lbx(mem_id,friend_id,message_type,id){
	$("div.div_lightbox").css({"display":"none" , "visibility":"hidden"});
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("#ft_add_as_friend_lbx_core").empty().html("");
			$("#ft_add_as_friend_lbx_core").html(respText).html();
			$("#ft_add_as_friend_lbx").css({"display":"block" , "visibility":"visible"});
		}
	}
	self.xmlHttpReq.send("handler=community&action=get_newfriend_info&mem_id="+mem_id+"&friend_id="+friend_id+"&message_type="+message_type+"&id="+id);
}

function send_frnd_req(mem_id,friend_id,message_type,id){
	var check_page = $('input#check_page').val();	// community=1 , my_frenchtuesdays_feeds=2 , search_fafriend.tpl=3
	$("span#notification_icon").empty().html("");
	$("div#ft_message_notification_bar2").hide("500").css({"left": "-9999px"});
	$("span#notification_new_message").empty().html("");
	var friend_request_message = $.trim(escape($("#frnd_req_msg").val()));
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			if(respText==0){
				alert("Something went wrong. Please try your request again.");
			}
			else{
				$("#"+id).removeAttr("onClick");
				$("#"+id).empty().html("");
				$("div.div_lightbox").css({"display":"none" , "visibility":"hidden"});
				$("div#ft_add_as_friend_lbx").css({"display":"none" , "visibility":"hidden"});
				$("span#notification_icon").empty().html("");
				$("span#notification_icon").html(notification_img_friendship_msg).html();
				$("span#notification_new_message").empty().html("");
				$("span#notification_new_message").html("Your friend request is sent to "+respText+". [<a href=\"javascript:void(0);\" onClick=\"unloadMsgbar('ft_message_notification_bar2');\">Close</a>]").html();
				$("div#ft_message_notification_bar2").css({"left": "0"}).hide().show("500");
				if(check_page==2){	// my_frenchtuesdays_feeds
					setTimeout(function(){load_frnd_pen_pages(mem_id,1,3,-1,"ajax");}, 250);
				}
			}
		}
	}
	self.xmlHttpReq.send("handler=community&action=send_frnd_req&mem_id="+mem_id+"&friend_id="+friend_id+"&message_type="+message_type+"&friend_request_message="+friend_request_message);
}

function delete_my_trip(mem_id){
	var conf_del = confirm("Do you really want to delete this trip?");
	if(conf_del){
		var trip_id = $("#trip_id").val()*1;
		var active_id = $("div.ft_trip_locator_results_padination > a.active").attr("id");
		if(active_id==undefined){
			active_id=1;
		}
		var tc = $("select#ft_trip_locator_search_bar_search_criteria_city_select :selected").val();
		var sd = $("input#search_sdate").val();
		var ed = $("input#search_edate").val();
		var limit=0;
		var total=0;
		var xmlHttpReq = false;
		var self = this;
		var respText;

		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				alert("Your trip is deleted.");
				hide_trip_lbx('ft_trip_locator_lightbox','modify_my_trip');
				$("#c_core").empty().html("");
				$("div.ft_trip_locator_results").empty().html("");
				$("div.ft_trip_locator_results").html(respText).html();
				// January 4th, 2012
				$("select#ft_trip_locator_search_bar_view_all_select").val(0);
			}
		}
		self.xmlHttpReq.send("handler=community&action=get_trips_data&t="+tc+"&s="+sd+"&e="+ed+"&start="+active_id+"&limit="+limit+"&total="+total+"&trip_id="+trip_id);
	}
}

function search_email_contacts(mem_id,load){
	var errors=0;
	var error_msg='';
	var emailFormat = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
	var email = $("#login_email").val();
	var password = $("#login_password").val();
	var provider = $("select#ft_email_clients :selected").val();
	if(email.length==0){
		error_msg=error_msg+"Missing: Email address.\n";
		errors=errors+1;
	}
	if(email.length> 0 && email.search(emailFormat) == -1){
		error_msg=error_msg+"Error: Invalid email format.\n";
		errors=errors+1;
	}
	if(provider==0){
		error_msg=error_msg+"Missing: Email provider.\n";
		errors=errors+1;
	}
	if(password.length==0){
		error_msg=error_msg+"Missing: Password.\n";
		errors=errors+1;
	}
	if(errors > 0){
		alert(error_msg);
		return false;
	}
	$(".processing_data").html("").html("Processing request...").css({"display":"inline" , "visibility":"visible"});
	var xmlHttpReq = false;
	var self = this;
	var respText;
	var dataString = "email="+email+"&password="+password+"&provider="+provider+"&load="+load;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			if(respText=="OK")
			{
				$(".processing_data").css({"display":"none" , "visibility":"hidden"});
				window.location.replace("index.php?page=community&s=1&search=email_contacts");
			}
			else{
				$(".processing_data").html("").html(respText).css({"display":"inline" , "visibility":"visible"});
			}
		}
	}
	self.xmlHttpReq.send("handler=community&action=search_email_contacts&"+dataString);
}

function paginate_ecsearch_results(mem_id,start,limit,total,provider,x,email){
	var xmlHttpReq = false;
	var self = this;
	var respText;
	var max_mcl_id = $("#max_mcl_id").val();
	var dataString = "email="+email+"&provider="+provider+"&start="+start+"&limit="+limit+"&total="+total+"&max_mcl_id="+max_mcl_id;
	$("div#community_main_loader").css("visibility","visible");
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			$("div#community_main_loader").css("visibility","hidden");
			respText = self.xmlHttpReq.responseText;
			$("#ft_friends_search_results").empty().html("");
			$("#ft_friends_search_results").html(respText).html();
		}
	}
	self.xmlHttpReq.send("handler=community&action=load_econtacts_ajax&"+dataString);
}

function search_email_contacts_ajax(mem_id,load){
	var errors=0;
	var error_msg='';
	var emailFormat = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
	var email = $("#login_email").val();
	var password = $("#login_password").val();
	var provider = $("select#ft_email_clients :selected").val();
	if(email.length==0){
		error_msg=error_msg+"Missing: Email address.\n";
		errors=errors+1;
	}
	if(email.length> 0 && email.search(emailFormat) == -1){
		error_msg=error_msg+"Error: Invalid email format.\n";
		errors=errors+1;
	}
	if(provider==0){
		error_msg=error_msg+"Missing: Email provider.\n";
		errors=errors+1;
	}
	if(password.length==0){
		error_msg=error_msg+"Missing: Password.\n";
		errors=errors+1;
	}
	if(errors > 0){
		alert(error_msg);
		return false;
	}
	$("div#community_main_loader").css("visibility","visible");
	var xmlHttpReq = false;
	var self = this;
	var respText;
	var dataString = "email="+email+"&password="+password+"&provider="+provider+"&load="+load;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div#community_main_loader").css("visibility","hidden");
			$("#ft_friends_search_results").empty().html("");
			$("#ft_friends_search_results").html(respText).html();
		}
	}
	self.xmlHttpReq.send("handler=community&action=search_email_contacts_ajax&"+dataString);
}

function check_sam_val(id,type)	{
	var checkVal = document.getElementById(id).value;
	if(type=="blur"){
		if(checkVal=='' || checkVal=="" || checkVal==null){
			document.getElementById(id).value='email@eprovider.com';
		}
		return false;
	}
	if(type=="focus"){
		if(checkVal=='email@eprovider.com'){
			document.getElementById(id).value='';
		}
		return false;
	}
}
// January 31st, 2012
function initiate_invitation(mem_id){
	if($("div.ft_content_container").hasClass("myft_statusbox")==false){
		$("div.ft_content_container").addClass("myft_statusbox");
	}
	$("div.div_lightbox").css({"display":"none" , "visibility":"hidden"});
	$("#myft_invitation_box").hide(150);
	var errors=0;
	var error_msg='';
	var include_custom_msg = $("input#include_custom_msg").is(':checked')==true?"y":"n";
	var friend_email = $.trim($("#sam_email_input").val());
	var emailFormat = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
	if(friend_email.length==0){
		error_msg=error_msg+"Missing: Email address.<br/>";
		errors=errors+1;
	}
	if(friend_email.length> 0 && friend_email.search(emailFormat) == -1){
		error_msg=error_msg+"Error: Invalid email format.<br/>";
		errors=errors+1;
	}
	if(friend_email.length> 0 && friend_email == "email@eprovider.com"){
		error_msg=error_msg+"Error: Please enter real email address.<br/>";
		errors=errors+1;
	}
	var custom_msg='';
	if(include_custom_msg=="y"){
		custom_msg = escape($.trim($("textarea#custom_msg_ta").val()));
		if(custom_msg.length==0||custom_msg==""||custom_msg==''){
			error_msg=error_msg+"Error: Please enter custom message. ["+custom_msg.length+"]";
			errors=errors+1;
		}
	}
	// January 31ST, 2012
	var ftcity = $('select.ft_cities_list').val();
	if(ftcity==-1){	// Other city option selected
		ftcity = $('select.other_cities_list').val();	// get other cities value
		if(ftcity==0) {	// nothing selected
			error_msg=error_msg+"Error: Please select the city for your sponsor";
			errors=errors+1;
		}
	}
	else{
		if(ftcity==0) {
			error_msg=error_msg+"Error: Please select the city for your sponsor";
			errors=errors+1;
		}
	}
	if(errors > 0){
		$("div.sam_email_error_msg").html(error_msg).css({"display":"block" , "visibility":"visible"});
		return false;
	}
	$("div.sam_email_error_msg").html("Processing request...").css({"display":"block" , "visibility":"visible"});
	var xmlHttpReq = false;
	var self = this;
	var respText;
	var dataString = "friend_email="+friend_email+"&mem_id="+mem_id+"&custom_msg="+custom_msg+"&ftcity="+ftcity;// January 31ST, 2012
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "/index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4){
			if(self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				if($("div.ft_content_container").hasClass("myft_statusbox")==false){
					$("div.ft_content_container").addClass("myft_statusbox");
				}
				var data = respText.split("<|>");
				$("#sam_inv_num").html("").html("Invitations left: "+data[0]);
				$("#myinvitation_status_text").empty().html("");
				$("#myinvitation_status_text").html(data[1]).html();
				$("#sam_email_input").val("email@eprovider.com");
				$("div.sam_email_error_msg").html("").css({"display":"none" , "visibility":"hidden"});
				$('input#include_custom_msg').removeAttr('checked');
				$("#custom_msg_div").hide().css("display" , "none");
				$('textarea#custom_msg_ta').val('');
				// JANUARY 31ST, 2012
				$("select#sam_ftcities_list").find('option:first').attr('selected', 'selected').parent('select');
				makeShow();
				$("#myft_invitation_box").css({"display":"block" , "visibility":"visible"}).hide().show(500);
			}
			else{		
			}
		}
	}
	self.xmlHttpReq.send("handler=invite&action=send_invitation&"+dataString);
}

function close_me(id){
	if($("div.ft_content_container").hasClass("myft_statusbox")==false){
		$("div.ft_content_container").addClass("myft_statusbox");
	}
	if(id=="myft_forgot_password_lbx"){
		$("input#reg_email_reset_pw").val("");
		$("div#reset_password_result_text").empty().html("");
		$("div#reset_password_result_text").css({"display":"none" , "visibility":"hidden"});
	}
	$("div.div_lightbox").css({"display":"none" , "visibility":"hidden"});
	$("#"+id).css({"display":"none" , "visibility":"hidden"});
}

function best_viewed_pictures_option(option){
	$("div.ft_events_photos_albums_best_photos_block").empty().html("");
	$("div.ft_events_photos_albums_best_photos_block").html(loader_div_16).html();
	var xmlHttpReq = false;
	var self = this;
	var respText;
	var dataString = "option="+option;
	if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div.ft_events_photos_albums_best_photos_block").empty().html("");
			$("div.ft_events_photos_albums_best_photos_block").html(respText).html();
		}
	}
	self.xmlHttpReq.send("handler=manage_photos&action=best_viewed_pictures_option&"+dataString);
}

function load_myinvitations_lbx(mem_id,inv_type,start , z){
	if($("div.ft_content_container").hasClass("myft_statusbox")==false){
		$("div.ft_content_container").addClass("myft_statusbox");
	}
	if(z==0){
		$("div.div_lightbox").css({"display":"none" , "visibility":"hidden"});
		$("#myft_invitations_lbox").css({"display":"block" , "visibility":"visible"});//.hide().show(300);
		$("div.myinvitations_lister").empty().html("");
		$("div.myinvitations_lister").html(loader_div_16).html();
	}
	else{
		$("#ft_inv_show_loader").empty().html("");
		$("#ft_inv_show_loader").html(loader_div_16).html();
	}
	var xmlHttpReq = false;
	var self = this;
	var respText;
	var dataString = "mem_id="+mem_id+"&inv_type="+inv_type+"&start="+start;
	if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "/index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("#myinvitations_lister").empty().html("");
			$("#myinvitations_lister").html(respText).html();
			$("#ft_inv_show_loader").empty().html("");
		}
	}
	self.xmlHttpReq.send("handler=invite&action=load_my_invitations&"+dataString);
}

function invitations_pages(mem_id,start,limit,total,inv_type,x,y){
	z=1;
	load_myinvitations_lbx(mem_id,inv_type,start,z);
}

function myft_inv_action(mem_id,inv_id,inv_type,start,act,id){
	if(act=="resent"){
		$("#"+id).addClass("inv_req_resent_process").html("").html("Processing...").html();
	}
	if(act=="delete"){
		$("#"+id).addClass("inv_req_delete_process").html("").html("Processing...").html();
	}
	var xmlHttpReq = false;
	var self = this;
	var respText;
	var dataString = "mem_id="+mem_id+"&inv_type="+inv_type+"&start="+start+"&inv_id="+inv_id+"&act="+act;
	if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "/index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("#myinvitations_lister").empty().html("");
			$("#myinvitations_lister").html(respText).html();
			if(act=="resent"){
				$("#"+id)
				.removeClass("inv_req_resent_process")
				.addClass("inv_req_resent_successfull")
				.html("")
				.html("Success")
				.html();
			}
			if(act=="delete"){
				$("#"+id)
				.removeClass("inv_req_delete_process")
				.addClass("inv_req_delete_successfull")
				.html("")
				.html("Success")
				.html();
			}
		}
	}
	self.xmlHttpReq.send("handler=invite&action=myft_inv_action&"+dataString);
}

function ft_other_friends(mem_id,start,a,b,c,d,e) {
	$('div.div_lightbox').css({"display":"none" , "visibility":"hidden"});
	$("div#community_main_loader").css("visibility","visible");
	var xmlHttpReq = false;
	var self = this;
	var respText;
	var dataString = "mem_id="+mem_id+"&start="+start;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			$("div#community_main_loader").css("visibility","hidden");
			respText = self.xmlHttpReq.responseText;
			$("#ft_other_friends_block").empty().html("");
			$("#ft_other_friends_block").html(respText).html();
		}
	}
	self.xmlHttpReq.send("handler=community&action=ft_other_friends&"+dataString);
}

function ft_other_friends_myft(mem_id,start,a,b,c,d,e) {
	$('div.div_lightbox').css({"display":"none" , "visibility":"hidden"});
	$("div#myft_other_friends_main_loader").css("visibility","visible");
	var xmlHttpReq = false;
	var self = this;
	var respText;
	var dataString = "mem_id="+mem_id+"&start="+start;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			$("div#myft_other_friends_main_loader").css("visibility","hidden");
			respText = self.xmlHttpReq.responseText;
			$("#ft_other_friends_block").empty().html("");
			$("#ft_other_friends_block").html(respText).html();
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=ft_other_friends_myft&"+dataString);
}

function load_finc_lbx(mem_id,per_id){
	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "/index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div.ft_common_friends_lbx_core").empty().html("");
			$("div.ft_common_friends_lbx_core").html(respText).html();
			$("div#ltbx_common_friends").css({"display" :"block" , "visibility":"visible"});
		}
	}
	self.xmlHttpReq.send("handler=community&action=load_fic_lbx&mem_id="+mem_id+"&per_id="+per_id);
}

function load_finc_lbx2(mem_id,per_id){
	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "/index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div.ft_common_friends_lbx_core").empty().html("");
			$("div.ft_common_friends_lbx_core").html(respText).html();
			var div_height = $("#ltbx_common_friends").height()*1;
			var div_width = $("#ltbx_common_friends").width()*1;
			var leftNudge = (($(window).width()*1) - div_width) / 2;
			leftNudge = Math.ceil(leftNudge);
			var topNudge = (($(window).height()*1) - div_height) / 2;
			topNudge = Math.ceil(topNudge);
			leftNudge = leftNudge>0?leftNudge:0;
			topNudge = topNudge>0?topNudge:0;
			$("div#ltbx_common_friends").css({"display" :"block" , "visibility":"visible" , "left": (($(window).scrollLeft()*1)+leftNudge)+"px" , "top": (($(window).scrollTop()*1)+topNudge)+"px"});
		}
	}
	self.xmlHttpReq.send("handler=community&action=load_finc_lbx2&mem_id="+mem_id+"&per_id="+per_id);
}


function load_finc_lbx3(mem_id,per_id){
	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "/index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div.ft_common_friends_lbx_core").empty().html("");
			$("div.ft_common_friends_lbx_core").html(respText).html();
			$("div#ltbx_common_friends").css({"display" :"block" , "visibility":"visible"});
		}
	}
	self.xmlHttpReq.send("handler=community&action=load_finc_lbx2&mem_id="+mem_id+"&per_id="+per_id);
}

function load_large_flyer(url){
	var fullPath = "http://"+domain_name+"/"+url;
	var img_height = $("#org_img_height").val()*1;
	var img_width = $("#org_img_width").val()*1;
	var image = $("<img>");
	image.attr("src" , fullPath);
	var leftNudge = (($(window).width()*1) - img_width) / 2;
	leftNudge = Math.ceil(leftNudge);
	var topNudge = (($(window).height()*1) - img_height) / 2;
	topNudge = Math.ceil(topNudge);
	leftNudge = leftNudge>0?leftNudge:0;
	topNudge = topNudge>0?topNudge:0;
	$("#first_tier").css({"display" :"block" , "visibility":"visible"});
	$("#second_tier").css({"display" :"block" , "visibility":"visible" , "left": (($(window).scrollLeft()*1)+leftNudge)+"px" , "top": (($(window).scrollTop()*1)+topNudge)+"px"});
	$("#third_tier").css({"display" :"block" , "visibility":"visible"});
}

function unload_flyer(){
	$("#first_tier").css({"display" :"none" , "visibility":"hidden"});
	$("#second_tier").css({"display" :"none" , "visibility":"hidden"});
	$("#third_tier").css({"display" :"none" , "visibility":"hidden"});
}

function blog_pages(archive,start,limit,total,x,y,z){
	$("div#main_blog_indicator").css("visibility","visible");
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "/index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			$("div#main_blog_indicator").css("visibility","hidden");
			respText = self.xmlHttpReq.responseText;
			$("div.ft_blog_left_column").empty().html("");
			$("div.ft_blog_left_column").html(respText).html();
		}
	}
	self.xmlHttpReq.send("handler=blog&action=get_blog_posts&start="+start+"&total="+total+"&category="+z+"&archive="+archive+"&tag="+escape($.trim(x)));
}

function comments_pagination(blog_id,start,limit,total,x,y,post_id){
	$("#ft_blog_post_comments_box").empty().html("");
	$("#ft_blog_post_comments_box").html(loader_div_16).html();
	var fb_id = $("input#fb_mem_id").val();
	fb_id = fb_id.length>0&&fb_id!=0?fb_id:0;
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "/index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("#ft_blog_post_comments_box").empty().html("");
			$("#ft_blog_post_comments_box").html(respText).html();
		}
	}
	self.xmlHttpReq.send("handler=blog&action=posts_comments&start="+start+"&total="+total+"&post_id="+post_id+"&blog_id="+blog_id+"&fb_id="+fb_id);
}

function load_trip_map(mem_id,trip_id,latitude,longitude){
	$("div.div_lightbox").css({"display":"none" , "visibility":"hidden"});
	var map_iframe = document.getElementById("member_trip_map");
	// ADDED WMA [December 6th, 2011]
	map_iframe.src = "";
	map_iframe.src = "http://"+domain_name+"/trip_locator_map.php?lat="+latitude+"&lon="+longitude;
	$("#ft_t_l_map").css({"display":"block" , "visibility":"visible"});
}

function blog_carousel(){
	var total_blog_posts = $("div.ft_blog_post_holder").size()*1;
	var visible_posts = 3*1;
	var single_post_width = 216;
	var total_scrollable_panels = Math.ceil(total_blog_posts/visible_posts) * 1;
	var total_belt_width = (total_blog_posts*1)*(single_post_width*1);
	var scroll_left = 0;
	var easing_effect = 'swing';
	var easing_duration = 1250;
	$("input#current_panel").val(1);
	$("input#next_panel").val(1*1);
	$("input#total_panel").val(total_scrollable_panels);
	$(".blog_latest_entries_carousel_next").bind('click' , function(){
		if(total_scrollable_panels > 1){
			$(".blog_latest_entries_carousel_prev").css({"opacity" : "1" , "filter" : "alpha(opacity=100)"});
			var get_current_panel = $("input#current_panel").val() * 1;
			if(get_current_panel < total_scrollable_panels){
				scroll_left = get_current_panel * 648;
				var set_current_panel = (get_current_panel*1)+1;
				$("input#current_panel").val(set_current_panel*1);
				$('div.blog_latest_entries_carousel_main_container > div.blog_latest_entries_carousel_main_container_belt').animate({'left' : -(scroll_left)+'px'} , {duration: easing_duration , easing: easing_effect , complete : function(){}});
			}
			
			if(set_current_panel == total_scrollable_panels){
				$(this).css({"opacity" : "0.25" , "filter" : "alpha(opacity=25)"});
			}
		}
	});	// click event
	$(".blog_latest_entries_carousel_prev").bind('click' , function(){
		var check_current_panel = $("input#current_panel").val() * 1;
		if(check_current_panel > 1){
			$(".blog_latest_entries_carousel_next").css({"opacity" : "1" , "filter" : "alpha(opacity=100)"});
			scroll_left = (((check_current_panel)*1)-2) * 648;
			var s_cur_pan = (check_current_panel*1)-1;
			$("input#current_panel").val(s_cur_pan*1);
			$('div.blog_latest_entries_carousel_main_container > div.blog_latest_entries_carousel_main_container_belt').animate({'left' : -(scroll_left)+'px'} , {duration: easing_duration , easing: easing_effect , complete : function(){}});
		}
		if(s_cur_pan==1){
			$(this).css({"opacity" : "0.25" , "filter" : "alpha(opacity=25)"});
		}
	});	// click event //
	// END OF BLOG CAROUSEL CODE
}

function keyNavigation(a,b,c,d,e,v,w,x,y,z){
	if(is_ie){
	}
	else{
		$.trapKey('LEFT').setEvent(function(){
			slideShowGallery(a,b,c,d,e);
		});
		$.trapKey('RIGHT').setEvent(function(){
			slideShowGallery(v,w,x,y,z);
		});
	}
}
// update pm / inv totals on automatic notifications
// December 9th, 2011
function update_notifications_total(mem_id,notifications_indexes,page){
	$("span#notification_icon").empty().html("");
	$("div#ft_message_notification_bar2").hide("500").css({"left": "-9999px"});
	$("span#notification_new_message").empty().html("");
	var notifications_indexes_array = notifications_indexes.split("|");
	var w=0;
	var x=0;
	var y=0;
	var z=0;
	var v=0;
	var a=0;
	var b;
	var c=0;
	var d;
	var e=0;
	var f;
	var g=0;
	var h=0;// December 9th, 2011
	if(notifications_indexes_array[0]=="m"){
		x = isNaN(notifications_indexes_array[1])||(typeof(notifications_indexes_array[1])==undefined || typeof(notifications_indexes_array[1])=='undefined')?0:notifications_indexes_array[1];	// pm received					[x]
		y = isNaN(notifications_indexes_array[2])||(typeof(notifications_indexes_array[2])==undefined || typeof(notifications_indexes_array[2])=='undefined')?0:notifications_indexes_array[2];	// friend requests				[y]
		z = isNaN(notifications_indexes_array[3])||(typeof(notifications_indexes_array[3])==undefined || typeof(notifications_indexes_array[3])=='undefined')?0:notifications_indexes_array[3];	// friendship accepted message	[z]
		w = isNaN(notifications_indexes_array[4])||(typeof(notifications_indexes_array[4])==undefined || typeof(notifications_indexes_array[4])=='undefined')?0:notifications_indexes_array[4];	// verified time
		v = parseInt(x)+parseInt(z);
		y = parseInt(y);
		$("span#notification_icon").html(notification_img_new_msg).html();
		$("span#notification_new_message").html("You have multiple notifications. Click [<a href=\"javascript:void(0);\" onClick=\"load_recent_notifications('"+mem_id+"','"+w+"');\">here</a>] to view them. [<a href=\"javascript:void(0);\" onClick=\"unloadMsgbar('ft_message_notification_bar2');\">Close</a>]").html();
		$("div#ft_message_notification_bar2").css({"left": "0"}).hide().show("500");
	}
	else{
		if(notifications_indexes_array[0]=="a"){	// new pm received
			a = isNaN(notifications_indexes_array[1])||(typeof(notifications_indexes_array[1])==undefined || typeof(notifications_indexes_array[1])=='undefined')?0:notifications_indexes_array[1];	// pm received					[x]
			b = notifications_indexes_array[2];	// name of the sender
			g = notifications_indexes_array[3];	// id of the sender
			$("span#notification_icon").html(notification_img_new_msg).html();
			if(g!=100000){	// if not from ftmain administrator
			$("span#notification_new_message").html("You have a new message from <a href=\"/index.php?page=my_frenchtuesdays&section=feeds&mem_id="+g+"\">"+b+"</a>. Click [<a href=\"javascript:void(0);\" onClick=\"load_mailbox("+mem_id+" ,'ft_mailbox_lbx' , 'inbox');\">here</a>] to read it. [<a href=\"javascript:void(0);\" onClick=\"unloadMsgbar('ft_message_notification_bar2');\">Close</a>]").html();
			}
			else{
			$("span#notification_new_message").html("You have a new message from <a href=\"javascript:void(0);\">"+b+"</a>. Click [<a href=\"javascript:void(0);\" onClick=\"load_mailbox("+mem_id+" ,'ft_mailbox_lbx' , 'inbox');\">here</a>] to read it. [<a href=\"javascript:void(0);\" onClick=\"unloadMsgbar('ft_message_notification_bar2');\">Close</a>]").html();
			}
			$("div#ft_message_notification_bar2").css({"left": "0"}).hide().show("500");
		}
		if(notifications_indexes_array[0]=="b"){
			c = isNaN(notifications_indexes_array[1])||(typeof(notifications_indexes_array[1])==undefined || typeof(notifications_indexes_array[1])=='undefined')?0:notifications_indexes_array[1];	// pm received					[x]
			d = notifications_indexes_array[2];	// name of the sender
			g = notifications_indexes_array[3];	// id of the sender
			// December 9th, 2011
			h = isNaN(notifications_indexes_array[4])||(typeof(notifications_indexes_array[4])==undefined || typeof(notifications_indexes_array[4])=='undefined')?0:notifications_indexes_array[4];
			var read_msg='';
			var manage_req='';
			if(h && h>0){
				read_msg="Read [<a href=\"javascript:void(0);\" onClick=\"show_custom_msg('"+mem_id+"','"+h+"',this);\">message</a>].";
			}
			if(page!="my_frenchtuesdays"){
				manage_req=" Manage [<a href=\"/index.php?page=my_frenchtuesdays&section=feeds&tab=friends\">request</a>].";
			}
			$("span#notification_icon").html(notification_img_friendship_msg).html();
			$("span#notification_new_message").html("You have a new friendship request from <a href=\"/index.php?page=my_frenchtuesdays&section=feeds&mem_id="+g+"\">"+d+"</a>. "+read_msg+""+manage_req+" [<a href=\"javascript:void(0);\" onClick=\"unloadMsgbar('ft_message_notification_bar2');\">Close</a>]").html();
			$("div#ft_message_notification_bar2").css({"left": "0"}).hide().show("500");
			// only when viweing own ft page, call the function to auto-update the ft frndship panal to show the new request
			if(page=="my_frenchtuesdays"){
				setTimeout(function(){
					load_frnd_req_pages(mem_id,1,3,-1,"ajax");
				} , 500);
			}
			else{
				//
			}
		}
		if(notifications_indexes_array[0]=="c"){
			e = isNaN(notifications_indexes_array[1])||(typeof(notifications_indexes_array[1])==undefined || typeof(notifications_indexes_array[1])=='undefined')?0:notifications_indexes_array[1];	// pm received					[x]
			f = notifications_indexes_array[2];	// name of the sender
			g = notifications_indexes_array[3];	// id of the sender
			$("span#notification_icon").html(notification_img_friendship_msg).html();
			$("span#notification_new_message").html("Your friendship request is accepted by <a href=\"/index.php?page=my_frenchtuesdays&section=feeds&mem_id="+g+"\">"+f+"</a>. [<a href=\"javascript:void(0);\" onClick=\"unloadMsgbar('ft_message_notification_bar2');\">Close</a>]").html();
			$("div#ft_message_notification_bar2").css({"left": "0"}).hide().show("500");
		}
	}
	var new_pm_total = $("input#notification_msg_new").val()*1;	// current messages total
	var newinv_total = $("input#notification_inv_new").val()*1;	// current invitations total
	var full_ttl = $("input#notification_ttl_new").val()*1;	// total of both messages+invitations [top bubble]
	new_pm_total = isNaN(new_pm_total)||(typeof(new_pm_total)==undefined || typeof(new_pm_total)=='undefined')?0:new_pm_total;
	newinv_total = isNaN(newinv_total)||(typeof(newinv_total)==undefined || typeof(newinv_total)=='undefined')?0:newinv_total;
	new_pm_total = parseInt(new_pm_total) + parseInt(a) + parseInt(e) + parseInt(v);
	newinv_total = parseInt(newinv_total) + parseInt(c) + parseInt(y);
	full_ttl = parseInt(newinv_total)+parseInt(new_pm_total);
	var menu_npm_placeholder = "<span class=\"ft_inbox_left\"></span><span class=\"ft_inbox_middle\">{#}</span><span class=\"ft_inbox_right\"></span>";
	var menu_inv_placeholder = "<span class=\"ft_friends_left\"></span><span class=\"ft_friends_middle\">{#}</span><span class=\"ft_friends_right\"></span>";
	if(new_pm_total > 0){
		if(page=="my_frenchtuesdays"){
			$("div.profile_manager_inbox > div.inbox_incap").css({"display":"block" , "visibility":"visible"});
			$("div.profile_manager_inbox > div.inbox_incap > div.inbox_middle").empty().html("");
			$("div.profile_manager_inbox > div.inbox_incap > div.inbox_middle").html(new_pm_total);
		}
		$("div.ft_my_inbox_link").empty().html("");
		menu_npm_placeholder = menu_npm_placeholder.replace("{#}" , new_pm_total);
		$("div.ft_my_inbox_link").html(menu_npm_placeholder).html();
	}
	else{
		if(page=="my_frenchtuesdays"){
			$("div.profile_manager_inbox > div.inbox_incap").css({"display":"none" , "visibility":"hidden"});
			$("div.profile_manager_inbox > div.inbox_incap > div.inbox_middle").empty().html("");
			$("div.ft_my_inbox_link").empty().html("");
		}
	}
	if(newinv_total > 0){
		$("div.ft_my_friends_link").empty().html("");
		menu_inv_placeholder = menu_inv_placeholder.replace("{#}" , newinv_total);
		$("div.ft_my_friends_link").html(menu_inv_placeholder).html();
	}
	else{
	}
	if(full_ttl > 0){
		$("a#ttl_msgs_holder").html("&nbsp;"+full_ttl+"&nbsp;");
		$("div.myft_messages").css({"display":"block" , "visibility":"visible"});
	}
	else{
	}
	$("input#notification_msg_new").val(new_pm_total*1);
	$("input#notification_inv_new").val(newinv_total*1);
	$("input#notification_ttl_new").val(full_ttl*1);
}

//  when multiple nofications are available, show them in a listbox
function load_recent_notifications(mem_id,timestamp){
}
// registration function
function registerMe(mem_id,inv_id){
	var is_email = $("input#is_email").val();
	var email = $.trim($("input#ft_register_member_email_val").val());
	if(is_email==1){
		var remail = $.trim($("input#reg_email").val());
		if(email==remail){
			alert("This email exists. Please use a different email to register.");
			return false;
		}
	}
	var fname = $.trim($("input#ft_register_member_fname_val").val());
	var lname = $.trim($("input#ft_register_member_lname_val").val());
	var pw1 = $("input#ft_register_member_password_val").val();
	var pw2 = $("input#ft_register_member_confirm_password_val").val();
	var bday = $.trim($("input#ft_register_member_bdate_val").val());
	var gender = $("input:radio[name=ft_register_member_gender_val]:checked").val();
	var ftcity = $("select#ft_register_member_ftcity_selectbox :selected").val();
	var error='';
	var err=0;
	error = "Error(s) found:\n"
	if(fname=="" || fname.length==0){
		error = error+"First name is required.\n";
		err++;
	}
	if(lname=="" || lname.length==0){
		error = error+"Last name is required.\n";
		err++;
	}
	if(email=="" || email.length==0){
		error = error+"Email is required\n";
		err++;
	}
	if(email != ""){
        if(!isValidEmail(email)){
			error = error+"Invalid email entered.\n";
			err++;
        }
    }
	if ((pw1.length==0 || pw1 == '') || (pw2.length==0 || pw2 == '')) {
		error = error+"Missing passwords.\n";
		err++;
	}
	if(pw1.length > 0 && pw1.length < 6){
		error = error+"Password should be at least 6 characters long\n";
		err++;
	}
	if (pw1 != pw2) {
		error = error+"Passwords you typed do not match.\n";
		err++;
	}
	if(bday=="" || bday.length==0){
		error = error+"Birthdate is required.\n";
		err++;
	}
	if(typeof(gender)==undefined || typeof(gender)=="undefined" || gender=="" || gender.length==0){
		error = error+"Gender is required.\n";
		err++;
	}
	if(ftcity==0){
		error = error+"French Tuesdays city is required.\n";
		err++;
	}
	if(ftcity==1){	// [selected [other], getting the city id from cities combo-box
		var ft_city = $("select#ft_register_member_ftcty_selectbox :selected").val();
		if(ft_city==undefined || ft_city==0){
			error = error+"Please select your city\n";
			err++;
		}
		else{
			ftcity = ft_city;
		}
	}
	if(err > 0){
		alert(error);
		return false;
	}
	else{
		var xmlHttpReq = false;
		var self = this;
		var respText;
		var data;
		data = "&fname="+fname+"&lname="+lname+"&email="+email+"&password="+pw1+"&bday="+bday+"&gender="+gender+"&ftcity="+ftcity+"&inv_id="+inv_id+"&mem_id="+mem_id;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "/index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				if(respText>0){
					setTimeout(function(){window.location.replace("index.php?page=finish_reg&mem_id="+respText);} , 0);
				}
			}
		}
		self.xmlHttpReq.send("handler=featured&action=registerMe"+data);
	}
}

function submit_decline(mem_id,inv_id){
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			if(respText=="no"){
				$("div.ft_become_a_member_error").empty().html("");
				$("div.ft_become_a_member_error").html("This is an invalid invitation.").html();
			}
			else{
				$("div.ft_become_a_member_error").empty().html("");
				$("div.ft_become_a_member_error").html(respText).html();
				$("div.ft_become_a_member_register_btn").empty().html("");
				var a = "<a href=\"javascript:void(0);\" onClick=\"backToHomepage();\" style=\"color: #666666; font-weight: bold; font-size:12px !important; line-height: 100% !important;\">Go back to homepage</a>";
				$("div.ft_become_a_member_register_btn").html(a).html();
			}
		}
	}
    self.xmlHttpReq.send("handler=featured&action=decline&inv_id="+inv_id);
}

function cancel_decline(inv_id){
	setTimeout(function(){document.location.replace("index.php?page=member_registration&inv_id="+inv_id);},0);
}

function backToHomepage(){
	setTimeout(function(){document.location.replace("index.php");},0);
}

function post_my_comment(mem_id,blg_id,pst_id){
	var ft_mem_id = $.trim($("input#ft_mem_id").val());
	var fb_mem_id = $.trim($("input#fb_mem_id").val());
	fb_mem_id = fb_mem_id.length==0?0:fb_mem_id;
	if(ft_mem_id==0 && fb_mem_id==0){
		alert("Please use provided login options to login and post your comment.");
		return false;
	}
	else{
		var fname = escape($.trim($("input#ft_blog_comment_poster_fname_input").val()));
		var lname = escape($.trim($("input#ft_blog_comment_poster_lname_input").val()));
		var email = escape($.trim($("input#ft_blog_comment_poster_email_input").val()));
		var comment = escape($.trim($("textarea#ft_blog_comment_poster_comment_textarea").val()));
		var notify = $("input#ft_blog_comment_poster_comment_notify_chkbox").is(':checked')==true?"y":"n";
		if(comment.length==0 || comment.length<25 || comment=='' || comment==""){
			if(comment.length>0 && comment.length<25){
				alert("Please type atleast 25 letters to post.");
			}
			else{
				alert("Please type your comment to post.");
			}
		}
		else{
			$("img#post_comment_loader").css("visibility","visible");
			var data = "&fname="+fname+"&lname="+lname+"&email="+email+"&comment="+comment+"&notify="+notify+"&blg_id="+blg_id+"&pst_id="+pst_id+"&ft_mem_id="+ft_mem_id+"&fb_mem_id="+fb_mem_id;
			var xmlHttpReq = false;
			var self = this;
			var respText;
			if(window.XMLHttpRequest){//Mozilla/Safari
				self.xmlHttpReq = new XMLHttpRequest();
			}
			else if(window.ActiveXObject){//IE
				self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
			}
			self.xmlHttpReq.open('POST', "index.php", true);
			self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			self.xmlHttpReq.onreadystatechange = function(){
				if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
					$("img#post_comment_loader").css("visibility","hidden");
					respText = self.xmlHttpReq.responseText;
					$("#ft_blog_post_comments_box").empty().html("");
					$("#ft_blog_post_comments_box").html(respText).html();
					$("textarea#ft_blog_comment_poster_comment_textarea").val("");
					setTimeout('update_postcomments_total('+pst_id+')', 500);
					var fbmi = $("input#fb_mem_id").val();
					if(fbmi>0){
						setTimeout('shareCommentonFB('+fbmi+')', 500);
					}
				}
			}
			self.xmlHttpReq.send("handler=blog&action=post_comment"+data);
		}	
	}
}

function load_forgot_lbx(){
	$("div.div_lightbox").css({"display":"none" , "visibility":"hidden"});
	$("#myft_forgot_password_lbx").css({"display":"block" , "visibility":"visible"});
}

function forgot_password_reset(){
	var mem_id=ftloggedInMemberID;
	var email = $.trim($("input#reg_email_reset_pw").val());
	if(email.length==0 || email=='' || email==""){
		alert("Please enter your email");
		return false;
	}
	if(email != ""){
        if(!isValidEmail(email)){
            alert("Please enter a valid Email");
            return false;
        }
    }
	$("span.p_request").css("visibility","visible");
	var xmlHttpReq = false;
	var self = this;
	var respText;

	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			$("span.p_request").css("visibility","hidden");
			respText = self.xmlHttpReq.responseText;
			$("div#reset_password_result_text").empty().html("")
			if(respText == '1'){
				$("div#reset_password_result_text").html("Your password has been reset and a temporary password has been sent at this address ["+email+"]").html();
				$("div#reset_password_result_text").css({"display":"block" , "visibility":"visible" , "color":"green"});
				$("input#reg_email_reset_pw").val("");
				return false;
			}
			if(respText == '2'){
				$("div#reset_password_result_text").html("Email address ["+email+"] does not exist. Please check and try again.").html();
				$("div#reset_password_result_text").css({"display":"block" , "visibility":"visible" , "color":"red"});
				return false;
			}
			if(respText == '3'){
				$("div#reset_password_result_text").html("Email address ["+email+"] is not yet verified. Please verify and try again.").html();
				$("div#reset_password_result_text").css({"display":"block" , "visibility":"visible" , "color":"red"});
				return false;
			}
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=ft_reset_password&mem_id="+mem_id+"&email="+email);
}
// January 4th, 2012
function load_selected_type(val,s,l,t,x,y,z){
	$("div#triplocator_loader").css("visibility","visible");
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			$("div#triplocator_loader").css("visibility","hidden");
			respText = self.xmlHttpReq.responseText;
			$("div.ft_trip_locator_results").empty().html("");
			$("div.ft_trip_locator_results").html(respText).html();
		}
	}
	self.xmlHttpReq.send("handler=community&action=load_selected_type&s="+s+"&val="+val+"&t="+t+"&y="+y);
}
// January 4th, 2012
function get_triptype_pages(val,s,l,t,x,y,z){
	y = $("input#mytl_sort_value").val();
	load_selected_type(val,s,l,t,x,y,z);
}

function getPageCoords(e,m,w,h){
	var tagger_status = $("input#tagger_status").val();
	if(m>0 && tagger_status=="on"){
		var offset = $('#the_image').offset();
		var x = e.pageX - offset.left;
		var y = e.pageY - offset.top;
		if(is_ie){
			x = event.x;
			y = event.y;
		}
		y = (Math.round(y))*1;
		x = (Math.round(x))*1;
		showTagger(m,x,y,w,h);
		$('#the_image').mouseover(function(){
			change_cursor();
		}).mouseout(function(){
			release_cursor();
		});
	}
	else{
		var pho_id = $('input#n_evn_pho_id').val();
		var gal_id = $('input#album_gal_id').val();
		if(pho_id && pho_id.length>0){
			slideShowGallery(m,pho_id,gal_id,'ajax' , 'tep');
		}
	}
}

function delete_blogpost_comment(com_id,blog_id,post_id){
	var conf_del = confirm("Do you really want to delete this comment?");
	if(conf_del){
		var ft_mem_id = $.trim($("input#ft_mem_id").val());
		var fb_mem_id = $.trim($("input#fb_mem_id").val());
		fb_mem_id = fb_mem_id.length==0?0:fb_mem_id;
		var data = "&com_id="+com_id+"&blog_id="+blog_id+"&post_id="+post_id+"&fb_mem_id="+fb_mem_id;
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				$("#ft_blog_post_comments_box").empty().html("");
				$("#ft_blog_post_comments_box").html(respText).html();
				setTimeout('update_postcomments_total('+post_id+')', 500);
			}
		}
		self.xmlHttpReq.send("handler=blog&action=delete_blogpost_comment"+data);
	}
}

function update_postcomments_total(post_id){
	var ttl_pst_cmts = $("input#total_post_comments").val()*1;
	$("div#blog_post_comments_count_"+post_id).empty().html("");
	$("div#blog_post_comments_count_"+post_id).html('('+ttl_pst_cmts+')').html();
}

function delete_trip_comment(trip_comment_id,trip_id){
	var conf_del = confirm("Do you really want to delete this comment?");
	if(conf_del){
		// modified wma [December 7th, 2011]
		$("span#post_comments_loader").css({"visibility":"visible"});
		var data = "&trip_comment_id="+trip_comment_id+"&trip_id="+trip_id;
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				$("div.ft_trip_locator_lightbox_layer_core_show_posted_comment_blocks").empty().html("");
				$("div.ft_trip_locator_lightbox_layer_core_show_posted_comment_blocks").html(respText).html();
				// modified wma [December 7th, 2011]
				$("span#post_comments_loader").css({"visibility":"hidden"});
				setTimeout('update_tripcomments_total('+trip_id+')', 500);
			}
		}
		self.xmlHttpReq.send("handler=community&action=delete_trip_comment"+data);
	}
}

function update_tripcomments_total(trip_id){
	var ttl_trips_cmts = $("input#total_trip_comments").val()*1;
	$("a#comment_counter_"+trip_id).text("");
	$("a#comment_counter_"+trip_id).text("("+ttl_trips_cmts+")");
}

$(document).click(function(event) {
	var a = $(event.target).parents().index($('#sub_ft_menu_login_three'));
	var b = $("span#lgn").hasClass("isActive");
	var c = $(event.target).parents().index($('#ftmlogin'));
	var d = $(event.target).parents().index($('#sub_ft_menu_login_two'));
	if(a==-1 && b==true && c==-1 && d==-1){
		$("div.sub_ft_menu_login_two").css({"display":"none" , "visibility":"hidden"});
		$("div.sub_ft_menu_login_three").css({"display":"none" , "visibility":"hidden"});
		$("span#lgn").removeClass("isActive");
	}
	// ADDED WMA
	var aa = $(event.target).parents().index($('#sub_ft_menu_sam_connected_three'));
	var bb = $("span#ftmsam_connected").hasClass("isActive");
	var cc = $(event.target).parents().index($('div#ftmsam_connected'));
	var dd = $(event.target).parents().index($('#sub_ft_menu_sam_connected_two'));
	if(aa==-1 && bb==true && cc==-1 && dd==-1){
		$("div.sub_ft_menu_sam_connected_two").css({"display":"none" , "visibility":"hidden"});
		$("div.sub_ft_menu_sam_connected_three").css({"display":"none" , "visibility":"hidden"});
		$("span#ftmsam_connected").removeClass("isActive");
		$("span#ftmsam_connected").css({"color":"#ffffff"});
		// JANUARY 31ST, 2012
		$('input#include_custom_msg').removeAttr('checked');
		$("#custom_msg_div").hide().css("display" , "none");
		$('textarea#custom_msg_ta').val('');
		$("#sam_email_input").val("email@eprovider.com");
		$("select#sam_ftcities_list").find('option:first').attr('selected', 'selected').parent('select');
		$("div#other_cities_list").css({"display":"none" , "visibility":"hidden"});
	}
	var f = $(event.target).parents().index($('#ft_my_status_quote_box_text_one'));
	if(f==-1 && ($('span#my-status-text-holder').hasClass('hide_span')==true)){
		var t = $('div#my-status-textarea-holder > textarea#my-status-textarea').val();
		t = $.trim(t);
		var mxyz = $('input#ft_member_id').val();
		if(t.length <= 0 && mxyz > 0){
			var o = $("span.ft_my_status_quote_box_text_one").text();
			$("span.ft_my_status_quote_box_text_one").text("");
			$("span.ft_my_status_quote_box_text_one").text("What\'s on your mind?");
			if($.trim(o) != "What\'s on your mind?"){
				set_myStatus_one(mxyz,'clear_status');
			}
		}
		$('span#my-status-text-holder').removeClass("hide_span").css({"display":"block" , "visibility":"visible"});
		$('div#my-status-textarea-holder').css({"display":"none" , "visibility":"hidden"});
		$('div#my-status-textarea-holder > textarea#my-status-textarea').empty().val('').css({height: "50px"});
		$('input#ft_my_status_quote_box_status').removeAttr('value');
		$('input#ft_my_status_quote_box_status').attr('value' , 0);
	}
});

$('#sub_ft_menu_login_three').click(function(event){
    event.stopPropagation();
});

function showMenu(){
	if($("span#lgn").hasClass("isActive")==true){
		$("div.sub_ft_menu_login_two").css({"display":"none" , "visibility":"hidden"});
		$("div.sub_ft_menu_login_three").css({"display":"none" , "visibility":"hidden"});
		$("span#lgn").removeClass("isActive");
	}
	else{
		$("div.sub_ft_menu_login_two").css({"display":"block" , "visibility":"visible"});
		$("div.sub_ft_menu_login_three").css({"display":"block" , "visibility":"visible"});
		$("span#lgn").addClass("isActive");
	}
}

function load_ft_events_venues_ajax(sel,type){
	var cty_id = $("select#ft_city_select :selected").val()*1;
	var evn_id = $("select#ft_event_select :selected").val()*1;
	var vnu_id = $("select#ft_venue_select :selected").val()*1;
	$("td#load_loader").empty().html("");
	$("td#load_loader").html("<b>loading...</b>").html();
	if(type=='city'){
		evn_id=0;
		vnu_id=0;
		if(evn_id==0){
		}
		if(vnu_id==0){
		}
	}
	if(type=='event'){
		vnu_id=0;
		if(cty_id==0){
		}
		if(vnu_id==0){
		}
	}
	if(type=='venue'){
		evn_id=0;
		if(evn_id==0){
		}
		if(cty_id==0){
		}
	}
	var data = "&cty_id="+cty_id+"&evn_id="+evn_id+"&vnu_id="+vnu_id;
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			
			if(respText==0||respText=="0"){
				alert("No results found.");
			}
			else{
				var result = respText.split("<|>");	// city [0] & event [1] , venue [2]
				$("select#ft_city_select").empty().html("");
				$("select#ft_city_select").html(result[0]).html();
				$("select#ft_event_select").empty().html("");
				$("select#ft_event_select").html(result[1]).html();
				$("select#ft_venue_select").empty().html("");
				$("select#ft_venue_select").html(result[2]).html();
			}
			$("td#load_loader").empty().html("");
		}
	}
	self.xmlHttpReq.send("handler=manage_photos&action=load_ft_events_venues_ajax"+data);
}

function activate_tags(){
	var status = $("input#tagger_status").val();
	status = status.length>0?status:0;
	if(status==0){
		$("img#the_image").css({"cursor":"pointer"});
	}
	else{
		$("img#the_image").css({"cursor":"crosshair"});
	}
}

function deactivate_tags(){
	var status = $("input#tagger_status").val();
	status = status.length>0?status:0;
	if(status==0){
		$("img#the_image").css({"cursor":"default"});
	}
}

function check_cursor() {
	var status = $("input#tagger_status").val();
	status = status.length>0?1:0;
	if(status==1){	// tag this picture button clicked
		change_cursor();
	}
	else{
		release_cursor();
	}
}

function decheck_cursor(){
	release_cursor();
}

var paircount = 0;
/* If you want to desaturate after page loaded - use onload event
* of image.
*/
function initImage(obj)
{
	obj.onload = null;
	var $newthis = $(obj);
	if ($.browser.msie)
	{
	  // You need this only if desaturate png with aplha channel
	  $newthis = $newthis.desaturateImgFix();
	}
	// class for easy switch between color/gray version
	$newthis.addClass("pair_" + ++paircount);
	var $cloned = $newthis.clone().attr('id', '');
	// reset onload event on cloned object
	$cloned.get(0).onload = null;
	// add cloned after original image, we will switch between
	// original and cloned later
	$cloned.insertAfter($newthis).addClass("color").hide();
	// desaturate original
	$newthis = $newthis.desaturate();
	// add events for switch between color/gray versions
	$newthis.bind("mouseenter mouseleave", desevent);
	$cloned.bind("mouseenter mouseleave", desevent);
};

function desevent(event) 
{
	var classString = new String($(this).attr('class'));
	var pair = classString.match(/pair_\d+/);
	// first I try was $("."+pair).toggle() but IE switching very strange...
	$("."+pair).hide();
	if (event.type == 'mouseenter')
	  $("."+pair).filter(".color").show();
	if (event.type == 'mouseleave')
	  $("."+pair).filter(":not(.color)").show();
}

function toogle_me(id){
	var image_one = id.indexOf("_1");
	if(image_one > 0) {
		if($("img#"+id).hasClass("show")){
			$("img#"+id).removeClass("show");
		}
		$("img#"+id).addClass("hide");
		var img_two = id.replace("_1" , "_2");
		$("img#"+img_two).removeClass("hide").addClass("show");
	}
	if(image_one <= 0) {
		if($("img#"+id).hasClass("show")){
			$("img#"+id).removeClass("show");
		}
		$("img#"+id).addClass("hide");
		var img_one = id.replace("_2" , "_1");
		$("img#"+img_one).removeClass("hide").addClass("show");
	}
}

function save_settings(mem_id,type){
	var is_submit = 1;
	var ft_pm = $("input#notification_option_receivepm").is(':checked');
	ft_pm = ft_pm==true?1:0;
	var ft_friend = $("input#notification_option_addfriend").is(':checked');
	ft_friend = ft_friend==true?1:0;
	var ft_tag = $("input#notification_option_tagpicture").is(':checked');
	ft_tag = ft_tag==true?1:0;
	var ft_pn = $("input#privacy_option_show_pn").is(':checked');
	ft_pn = ft_pn==true?1:0;
	var fb_profile = $("input#notification_option_postprofile").is(':checked');
	fb_profile = fb_profile==true?1:0;
	var fb_tag = $("input#notification_option_tagphoto").is(':checked');
	fb_tag = fb_tag==true?1:0;
	var fb_event = $("input#notification_option_eventregist").is(':checked');
	fb_event = fb_event==true?1:0;
	var fb_id = $("input#fb_account_settings_id").val();
	fb_id = fb_id.length==0?0:fb_id;
	var fb_at = $("input#fb_useraccount_acc_tkn").val();
	fb_at = fb_at.length==0?0:fb_at;
	if(fb_profile>0 || fb_tag > 0 || fb_event > 0){
		if(fb_id==0){
			alert("Please connect with facebook to save your facebook settings");
			return false;
		}
	}
	$("input#a_xyz_profile").val(fb_profile);
	$("input#a_xyz_tag").val(fb_tag);
	$("input#a_xyz_event").val(fb_event);
	$("input#a_xyz_id").val(fb_id);
	$("input#a_xyz_at").val(fb_at);
	var data = "&ft_pm="+ft_pm+"&ft_friend="+ft_friend+"&ft_tag="+ft_tag+"&fb_profile="+fb_profile+"&fb_tag="+fb_tag+"&fb_event="+fb_event+"&is_submit="+is_submit+"&fb_id="+fb_id+"&fb_at="+fb_at+"&ft_pn="+ft_pn;
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			if(ft_pn==0){	// hide
				$("div.profile_detail_member_phonen_lbl")
				.removeAttr("style")
				.attr("style","display:none !important;");
				$("div.profile_detail_member_phonen_val")
				.removeAttr("style")
				.attr("style","display:none !important;");
			}
			if(ft_pn==1){	// show
				$("div.profile_detail_member_phonen_lbl")
				.removeAttr("style")
				.attr("style","display:block !important;");
				$("div.profile_detail_member_phonen_val")
				.removeAttr("style")
				.attr("style","display:block !important;");
			}
			alert(respText);
			if(type=="close"){	// save settings and close the popup
				$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
			}
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=save_account_settings"+data);
}

function load_media_search(){
	var media_type = $("select#ft_media_type :selected").val()*1;
	var media_year = $("select#ft_media_year :selected").val()*1;
	var params;
	var count=0;
	if(media_type==0 && media_year==0){
		setTimeout(function(){window.location = "/index.php?page=media&search=all";}, 0);
	}
	else{
		setTimeout(function(){window.location = "/index.php?page=media&mt="+media_type+"&my="+media_year;}, 0);
	}
}

function ft_media_pagination(mt,start,limit,total,search,x,my){
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div.ft_media_block").empty().html("");
			$("div.ft_media_block").html(respText).html();
		}
	}
	self.xmlHttpReq.send("handler=press_releases&action=search_ft_media&mt="+mt+"&start="+start+"&limit="+limit+"&total="+total+"&search="+search+"&my="+my);
}

function show_address_block(cls,city){
	$("div."+cls).hide("slow" , function(){
	});
	$("div#content_"+city).show("slow");
	var city_email = $("input#contact_email_"+city).val();
	$("input#contact_to_email").val(city_email);
	var city_name = $("div#header_"+city).html();
	$("div.contact_form_city").empty().html();
	$("div.contact_form_city").html(city_name+" contact form").html();
}

function clear_form(mem_id){
	if(mem_id==0){
		$("input#contact_form_email").removeAttr("value");
		$("input#contact_form_fname").removeAttr("value");
		$("input#contact_form_lname").removeAttr("value");
	}
	$("input#contact_to_email").removeAttr("value");
	$("input#contact_form_subject").removeAttr("value");
	$("textarea#contact_form_message").val("");
	$("div.contact_form_city").empty().html();
	$("div.contact_form_city").html("contact form").html();
	$("div.ft_address_content").hide("slow" , function(){});
}

function send_my_email(mem_id){
	var to_email = $("input#contact_to_email").val();	// FT CITY EMAIL
	var from_email = $("input#contact_form_email").val();	// MEMBER EMAIL [IF LOGGED] / EMAIL ENTERED BY THE MEMBER [MANUAL [NOT LOGGED IN]]
	var subject = escape($("input#contact_form_subject").val());
	var fname = escape($("input#contact_form_fname").val());
	var lname = escape($("input#contact_form_lname").val());
	var message = escape($("textarea#contact_form_message").val());
	var err=0;
	var error='';
	if(to_email.length==0){
		err++;
		error=error+"Please select your city first.\n";
	}
	if(from_email.length>0){
		if(!isValidEmail(from_email)){
			err++;
			error=error+"Invalid email entered.\n";
		}
	}
	else{
		err++;
		error=error+"Email is required.\n";
	}
	if(fname.length==0 && lname.length==0){
		err++;
			error=error+"First and last name is required.\n";
	}
	else{
		if(fname.length==0){
			err++;
			error=error+"First name is required.\n";
		}
		if(lname.length==0){
			err++;
			error=error+"Last name is required.\n";
		}
	}
	if(subject.length==0){
		err++;
		error=error+"Please enter the subject.\n";
	}
	if(message.length==0){
		err++;
		error=error+"Please enter your message.\n";
	}
	if(err>0){
		alert(error);
	}
	else{
		$("a#pro_req").css("visibility" , "visible");
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				$("a#pro_req").css("visibility" , "hidden");
				if(respText=="OK"){
					clear_form(mem_id);
					alert("Your enquier has been submitted.");
				}
				else{
					alert(respText);
				}
			}
		}
		self.xmlHttpReq.send("handler=contacts&action=send_my_email&to_email="+to_email+"&from_email="+from_email+"&fname="+fname+"&lname="+lname+"&subject="+subject+"&message="+message);
	}
}
function scrollCarousel(g,t,s,d,rem){
	if(d==1 && ((rem*1) >= (t+1))){
		return false;
	}
	else{
		$("div.ft-album-photos-carousel-slider-belt-item-container").html(loader_div_24_blk);
	}
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			$("div.ft-album-photos-carousel-slider-belt-item-container").empty().html("");
			respText = self.xmlHttpReq.responseText;
			$("div.ft-album-photos-carousel").empty().html("");
			$("div.ft-album-photos-carousel").html(respText).html();
		}
	}
	self.xmlHttpReq.send("handler=manage_photos&action=ft_get_album_carousel&gal_id="+g+"&total="+t+"&start="+s+"&d="+d);
}

function show_desc_lbx(mem_id , status , type , e){
	$("div.xxx_holder").css("display" , "none");
	if(status=='show'){
		var l = (($(window).width()*1) - 445) / 2;
		l = Math.ceil(l);
		var t = (($(window).height()*1) - 445) / 2;
		t = Math.ceil(t);
		var posx = 0;
		var posy = 0;
		if (!e) var e = window.event;
		if (e.pageX || e.pageY) 	{
			posx = e.pageX;
			posy = e.pageY;
		}
		else if (e.clientX || e.clientY) 	{
			posx = e.clientX + document.body.scrollLeft
				+ document.documentElement.scrollLeft;
			posy = e.clientY + document.body.scrollTop
				+ document.documentElement.scrollTop;
		}
		var st = document.body.scrollTop;
		$(document).mousemove(function(e){});
		var divHeight = $("div.div_"+type).position();
		var pos = $("div#ft_team_member_info_holder_"+type+"_"+mem_id).position();
		var a = $("div.g_cities").position();
		var popup_text = $("div#ft_team_member_popuptext_"+type+"_"+mem_id).html();
		$('div#ft_member_description_content_holder_'+type).empty().html("");
		$('div#ft_member_description_content_holder_'+type).html(popup_text).html();
		$('div#ft_member_description_content_holder_'+type).css({"display":"block" , "top":(posy)+"px" , "left":(posx+10)+"px"});
	}
	else{
		$('div#ft_member_description_content_holder_'+type).css({"display":"none"});
		$('div#ft_member_description_content_holder_'+type).empty().html("");
	}
}

function close_ft_team_box(){
	$("div.xxx_holder").css("display" , "none");
}

function load_ftteam_search(pc){
	var ft_team_cities = $("select#ft_team_cities :selected").val()*1;
	if(ft_team_cities==0){
		setTimeout(function(){window.location = "/index.php?page=cities&cty_id="+pc;}, 0);
	}
	else{
		setTimeout(function(){window.location = "/index.php?page=cities&cty_id="+ft_team_cities;}, 0);
	}
}

function ft_logout(u){
	var link = $("input#route_to2").val();
	setTimeout(function(){window.location = u+"/index.php?handler=login&action=do_logout&ret_link="+link;}, 0);	
}

function load_partners_search(pc){
	var ft_partners_cities = $("select#ft_partners_cities :selected").val()*1;
	if(ft_partners_cities==0){
		alert("This option is not available");
		return false;
	}
	else{
		setTimeout(function(){window.location = "/index.php?page=partners&cty_id="+ft_partners_cities;}, 0);
	}
}

function blog_accordion(){
	$('ul#archives_accordion a.archive_heading').click(function() {
		$(this).css('outline','none');
		if($(this).parent().hasClass('current')) {
			$(this).siblings('ul').slideUp('slow',function() {
				$(this).parent().removeClass('current');
				$.scrollTo('#archives_accordion',1000);
			});
		} else {
			$('ul#archives_accordion li.current ul').slideUp('slow',function() {
				$(this).parent().removeClass('current');
			});
			$(this).siblings('ul').slideToggle('slow',function() {
				$(this).parent().toggleClass('current');
			});
			$.scrollTo('#archives_accordion',1000);
		}
		return false;
	});
}

function removeImgAttr(){
	$("img.blog_post_image")
	.removeAttr("width")
	.removeAttr("height");
}

function setImgLink(){
	$("div.ft_blog_post_container > div.ft_blog_post_text").each(function() {
		var id = $(this).attr('id');
		$("img" , this).each(function(i){
			var img_w = $('input#post_img_w_'+i).val()*1;
			var img_h = $('input#post_img_h_'+i).val()*1;
			$(this).addClass("blog_post_image");
			var a = $('<a/>').attr('href', '/index.php?page=post&pid='+id).attr('style' , 'width:'+(img_w)*1+'px !important; height:'+(img_h)*1+'px !important;').addClass("blog_post_image_link");
		});
	});
}

function setImgLinkPost(){
	$("div.ft_blog_post_container > div.ft_blog_post_text").each(function() {
		$("img" , this).each(function(i){
			var img_w = $('input#post_img_w_'+i).val()*1;
			var img_h = $('input#post_img_h_'+i).val()*1;
			$(this).attr('style' , 'width:'+(img_w)*1+'px !important; height:'+(img_h)*1+'px !important;').addClass("blog_post_image");
			var img_src = $(this).attr('src');
			img_src = img_src.replace(/https?:\/\/[^\/]+/i, "");
			var t_span = $('<span/>').addClass("top_layer");
			var b_span = $('<span/>').addClass("bottom_layer");
			var span = $('<span/>').attr('rel',img_src).attr('style' , 'width:'+(img_w)*1+'px !important; height:'+(img_h)*1+'px !important;').addClass("post_flyer");
			$(this).wrap(span);
		});
	});
}

function load_blog_post_flyer(){
	$('span.post_flyer').click(function(){
		var rel = $("img" , this).attr('src');
		var img_src = rel;
		rel = rel.replace(/\//g,'');	// remove all forward slashes
		rel = rel.replace(/\./g,'_');	// replace all dots with underlimes
		rel = rel.replace(/\:/g,'');	// remove all :
		var img_attrs = $('input#'+rel).val();
		img_attrs = img_attrs.split(':');	//width:height
		var img_height = img_attrs[1]*1;
		var img_width = img_attrs[0]*1;
		var leftNudge = (($(window).width()*1) - (img_width+4)) / 2;
		leftNudge = Math.ceil(leftNudge);
		var topNudge = (($(window).height()*1) - (img_height+4)) / 2;
		topNudge = Math.ceil(topNudge);
		leftNudge = leftNudge>0?leftNudge:0;
		topNudge = topNudge>0?topNudge:0;
		var div = $('<div></div>');
		div.attr('style' , 'width:'+(img_width+2)*1+'px !important; height:'+(img_height+2)*1+'px !important; border:8px solid #DADADA;').addClass("image_flyer_container");
		$('img#img_tier')
		.removeAttr('width')
		.removeAttr('height')
		.removeAttr('src')
		.removeAttr('style')
		.attr('height' , img_height*1)
		.attr('width' , img_width*1)
		.attr('style' , 'width:'+img_width*1+'px !important; height:'+img_height*1+'px !important; border:2px solid #333333;')
		.attr('src' , img_src);

		$("#first_tier").css({"display" :"block" , "visibility":"visible"});
		$("#second_tier").css({"border":"0" , "display" :"block" , "visibility":"visible" , "left": (($(window).scrollLeft()*1)+leftNudge)+"px" , "top": (($(window).scrollTop()*1)+topNudge)+"px"});
		$("#third_tier")
		.attr('style' , 'width:'+(img_width+4)*1+'px !important; height:'+(img_height+4)*1+'px !important; border:8px solid #DADADA;').addClass("image_flyer_container")
		.css({"display" :"block" , "visibility":"visible"});
	});
}

function load_event(path,id){
	$("img#"+id).css("visibility","visible");
	setTimeout(function(){window.location = path}, 250);
}

function load_events_tab(mem_id,a,b,c,d,e,f){
	$("div#myft_main_loader > img#img_myft_loader").css("visibility","visible");
	if(f=='n'){
		if(e=="myevents"){
			$(document).attr("title" , "My events - French Tuesdays");
		}
		$('div.not_for_friends_tab').css({"display" : "block" , "visibility" : "visible"});
		$('div#ppl_you_may_know_container_myft').css({"display" : "none" , "visibility" : "hidden"});
		var p = $('input#profile_progress_number').val() * 1;
		if(p>99){
			$('div.ft_myfrenchtuesdays_incomplete_profile_notice').css({"display" : "none" , "visibility" : "hidden"});
		}
	}
	else{
		var fname = $("input#mem_fname").val();
		$(document).attr("title" , fname+"' events - French Tuesdays");
	}
	$("div#ft_myfrenchtuesdays_page_photos").css({"display" : "none" , "visibility" : "hidden"});
	$("div#myft_photos_container").empty().html("");
	$("div#ft_myfrenchtuesdays_page_main").css({"display" : "block" , "visibility" : "visible"});
	$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
	$("div.ft_my_feed_box").css({"display" :"none" , "visibility":"hidden"});
	$("div.ft_my_feed_item").removeClass("item_active");
	$("div#sl_"+e).addClass("item_active");
	$("div.ft_my_feed_tab").removeClass("tab_active");
	$("div#ft_"+e).addClass("tab_active");
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			$("div#myft_main_loader > img#img_myft_loader").css("visibility","hidden");
			respText = self.xmlHttpReq.responseText;
			$("div.myft_events").empty().html("");
			$("div.myft_events").html(respText).html();
			$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
			$("div.ft_my_feed_box").css({"display" :"none" , "visibility":"hidden"});
			$("div.ft_my_feed_item").removeClass("item_active");
			$("div#sl_"+e).addClass("item_active");
			$("div.ft_my_feed_tab").removeClass("tab_active");
			$("div#ft_"+e).addClass("tab_active");
			$("div#"+e).css({"display" :"block" , "visibility":"visible"});
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=load_myft_events&mem_id="+mem_id+"&load="+d+"&guest="+f);
}

function show_countries_cities(cty_id){
	if(cty_id==1){	// 1 = show countries [populated] and cities [empty] comboboxes
		$("span#hidden_field").css({"display":"block" , "visibility":"visible"});
	}
	else{
		// hide countries and cities comboboxes
		$("span#hidden_field").css({"display":"none" , "visibility":"hidden"});
	}
}

function load_ft_cities(con_id){
	var xmlHttpReq = false;
	var self = this;
	var respText;
	$("select#ft_register_member_ftcty_selectbox").html("...loading list...").html();
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("select#ft_register_member_ftcty_selectbox").empty().html("");
			$("select#ft_register_member_ftcty_selectbox").html(respText).html();
		}
	}
	self.xmlHttpReq.send("handler=featured&action=get_ft_cities&con_id="+con_id);
}

function textCounter(i,v,e,l){
	if (!e) var e = window.event;
	if(v.length <= l) {
		var remainingChars = l - (v.length)*1;
		$("span#ft_text_counter").html(remainingChars).html();
		return true;
	}
	if(v.length>l)
	{
		$("span#ft_text_counter").html('Limited reached').html();
		document.getElementById("ft_blog_comment_poster_comment_textarea").value=v.substr(0,l);
	}
	if(v.length==l)
	{
		$("span#ft_text_counter").html('Limited reached').html();
		if(e.keyCode>46 && e.keyCode<112 || e.keyCode>123)
		{
			return false;
		}
	}
}

function history_img(){
	$("div.history img").each(function(i){});
}

function load_error(err_msg){
	alert(err_msg);
}
// only for IE
document.onkeydown = function(evt) {
	if($.browser.msie){
		evt = evt || window.event;
		var tagger_status = $.trim($('input#tagger_status').val());
		tagger_status = tagger_status.length>0?tagger_status:0;
		var album_gal_id = $.trim($('input#album_gal_id').val());
		var album_type = $.trim($('input#album_type').val());
		if(evt.keyCode==37){	// LEFT KEY
			var p_evn_pho_id = $.trim($('input#p_evn_pho_id').val());
			p_evn_pho_id = p_evn_pho_id&&p_evn_pho_id.length>0&&p_evn_pho_id>0?p_evn_pho_id:0;
			if(p_evn_pho_id&&p_evn_pho_id>0)
				slideShowGallery(ftloggedInMemberID,p_evn_pho_id,album_gal_id,'ajax',album_type);
		}
		if(evt.keyCode==39){	// RIGHT KEY
			var n_evn_pho_id = $.trim($('input#n_evn_pho_id').val());
			n_evn_pho_id = n_evn_pho_id&&n_evn_pho_id.length>0&&n_evn_pho_id>0?n_evn_pho_id:0;
			if(n_evn_pho_id&&n_evn_pho_id>0)
				slideShowGallery(ftloggedInMemberID,n_evn_pho_id,album_gal_id,'ajax',album_type);
		}
	}
};

function clicked(){
	$('span.ft_my_status_quote_box_text_one').click(function(){
		if($('span#my-status-text-holder').hasClass("hide_span")==false){
			$('textarea.expand').autogrow();
			$('span#my-status-text-holder').addClass("hide_span");
			$('span#my-status-text-holder').css({"display":"none" , "visibility":"hidden"});
			$('div#my-status-textarea-holder').css({"display":"block" , "visibility":"visible"});
			$('div#my-status-textarea-holder > textarea#my-status-textarea').empty().val('').focus();
			var status_text = $.trim($('span#my-status-text-holder').html());
			if(status_text.length > 0 && status_text!='What\'s on your mind?'){
				$('div#my-status-textarea-holder > textarea#my-status-textarea').val(status_text).focus();
			}
			$('input#ft_my_status_quote_box_status').removeAttr('value');
			$('input#ft_my_status_quote_box_status').attr('value' , 1);
		}
	});
}

function clicked_two(event){
	var f = $(event.target).parents().index($('#ft_my_status_quote_box_text_one'));
	var g = $('input#ft_my_status_quote_box_status').val();
	if(g>0 && ($('span#my-status-text-holder').hasClass('hide_span')==true)){
		$('span#my-status-text-holder').removeClass("hide_span").css({"display":"block" , "visibility":"visible"});
		$('div#my-status-textarea-holder').css({"display":"none" , "visibility":"hidden"});
		$('div#my-status-textarea-holder > textarea#my-status-textarea').empty().val('').css({height: "50px"});
		$('input#ft_my_status_quote_box_status').removeAttr('value');
		$('input#ft_my_status_quote_box_status').attr('value' , 0);
	}
}

function btnImg_hover(obj,type){
	if(type=='over'){
		$(obj).css({"margin-top":"0px" , "margin-left":"0px"});
	}
	else{
		$(obj).css({"margin-top":"-1px" , "margin-left":"0px"});
	}
}

function search_mycontacts(mem_id,hint,load){
	var xmlHttpReq = false;
	var self = this;
	var respText;
	if(hint.length < 1 || hint=='' || hint==""){
		$("div#friends_resultset_container").empty().html("");
		return false;
	}
	var ids=0;
	if($('input.user-contact-id').length > 0){
		ids='';
		$('input.user-contact-id').each(function(){
			ids = ids+','+$(this).val();
		});
	}
	if(window.XMLHttpRequest){//Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){//IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
			respText = self.xmlHttpReq.responseText;
			$("div#friends_resultset_container").empty().html("");
			$("div#friends_resultset_container").html(respText).html();
		}
	}
	self.xmlHttpReq.send("handler=my_frenchtuesdays&action=search_mycontacts&mem_id="+mem_id+"&hint="+hint+"&load="+load+"&ids="+ids);
}

function chkval(id,type,mem_id)	{
	var checkVal = document.getElementById(id).value;
	if(type=="blur"){
		if(checkVal=='' || checkVal=="" || checkVal==null){
			document.getElementById(id).value='Search contacts';
		}
		return false;
	}
	if(type=="focus"){
		if(checkVal=='Search contacts'){
			document.getElementById(id).value='';
		}
		else{
			var hint = document.getElementById(id).value;
			search_mycontacts(mem_id,hint,'ajax');
		}
		return false;
	}
}

function addContact(mem_id,contact_id,contact_fullname,container_id){
	var match_contact_id=false;
	if($('input.user-contact-id').length > 0){
		$('input.user-contact-id').each(function(){
			if($(this).val() == contact_id){
				match_contact_id=true;
			}
		});
	}
	if(match_contact_id){
		alert('This contact is already on the list.');
		return false;
	}
	else{
		var data = new Object();
		data.name = $.trim(contact_fullname);
		data.value = $.trim(contact_id);
		$.autoSuggest.my_add_selected_item(data, Math.floor(Math.random() * 11));
		$('#'+container_id).remove();
	}
}

function load_news_item_flyer(){
	var rel = $('img#news_flyer').attr('src');
	var img_src = rel;
	rel = rel.replace(/https?:\/\/[^\/]+/i, '');
	rel = rel.replace(/\//g,'');
	var img_attrs = $('input#new_item_img_attrs').val();
	img_attrs = img_attrs.split(':');	//width:height
	var img_height = img_attrs[1]*1;
	var img_width = img_attrs[0]*1;
	var leftNudge = (($(window).width()*1) - (img_width+4)) / 2;
	leftNudge = Math.ceil(leftNudge);
	var topNudge = (($(window).height()*1) - (img_height+4)) / 2;
	topNudge = Math.ceil(topNudge);
	leftNudge = leftNudge>0?leftNudge:0;
	topNudge = topNudge>0?topNudge:0;
	var div = $('<div></div>');
	div.attr('style' , 'width:'+(img_width+2)*1+'px !important; height:'+(img_height+2)*1+'px !important; border:8px solid #DADADA;').addClass("image_flyer_container");
	$('img#img_tier')
	.removeAttr('width')
	.removeAttr('height')
	.removeAttr('src')
	.removeAttr('style')
	.attr('height' , img_height*1)
	.attr('width' , img_width*1)
	.attr('style' , 'width:'+img_width*1+'px !important; height:'+img_height*1+'px !important; border:2px solid #333333;')
	.attr('src' , img_src);
	
	$("#first_tier").css({"display" :"block" , "visibility":"visible"});
	$("#second_tier").css({"border":"0" , "display" :"block" , "visibility":"visible" , "left": (($(window).scrollLeft()*1)+leftNudge)+"px" , "top": (($(window).scrollTop()*1)+topNudge)+"px"});
	$("#third_tier")
	.attr('style' , 'width:'+(img_width+4)*1+'px !important; height:'+(img_height+4)*1+'px !important; border:8px solid #DADADA;').addClass("image_flyer_container")
	.css({"display" :"block" , "visibility":"visible"});
}
/* ADDED [after gera-it ]*/
function cancel_change(req_type){
	if(req_type=='email'){
		$("#reg_email_change").css({"display" :"none" , "visibility":"hidden"});
		$("input#reg_email_change_input").val('');
		$("textarea#req_echange_text").val('');
	}
	if(req_type=='ft_city'){
		$("#req_ftcity_change").css({"display" :"none" , "visibility":"hidden"});
		$("select#req_ftcity_change_slctbox").find('option:first').attr('selected', 'selected').parent('select');
		$("textarea#req_ftcity_text").val('');
	}
}

function request_change(mem_id , req_type){
	if(req_type=='email'){
		$("#reg_email_change").css({"display" :"block" , "visibility":"visible"});
	}
	if(req_type=='ft_city'){
		$("#req_ftcity_change").css({"display" :"block" , "visibility":"visible"});
	}
}

function submit_req_change(mem_id , req_type){
	var msg;
	var err=0;
	var error='';
	var req;
	$("img#show_hide_loader_img").css({"display":"block"});
	if(req_type=='email'){
		var email = $.trim($("input#reg_email_change_input").val());
		msg = escape($.trim($("textarea#req_echange_text").val()));
		if(email.length>0){
			if(!isValidEmail(email)){
				err++;
				error=error+"Invalid email entered.";
			}
			var curr_email = $.trim($("input#myaccount_address_input").val());
			if(email == curr_email || curr_email == email){
				err++;
				error=error+"This new email is already your current in-use email.\nPlease enter a new email address.";
			}
		}
		else{
			if(email.length==0 || email=='' || email==""){
				err++;
				error=error+"Email is required.";
			}
		}
		req='email';
	}
	if(req_type=='ft_city'){
		var ft_city = $("select#req_ftcity_change_slctbox :selected").val()*1;
		var curr_ft_city = $("select#myinfos_ftcity_slctbox :selected").val()*1;
		if(ft_city == curr_ft_city || curr_ft_city == ft_city){
			err++;
			error=error+"You already have this option as your FT city.\nPlease select a new FT city.";
		}
		msg = escape($.trim($("textarea#req_ftcity_text").val()));
		req = 'ft city';
	}
	if(err > 0){
		$("img#show_hide_loader_img").css({"display":"none"});
		alert(error);
		return false;
	}
	else{	// else
		var data;
		if(req_type=='email'){
			data = "x="+email+"&msg="+msg+"&req_type="+req_type;
		}
		if(req_type=='ft_city'){
			data = "x="+ft_city+"&msg="+msg+"&req_type="+req_type;
		}
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				//7== email exists
				if(respText==7){
					alert('This email is already registered with FT.');
				}
				// ok
				if(respText==1){
					alert('Your request to change your '+req+' has been submitted.');
					cancel_change(req_type);
				}	// error returned
				else{
					alert('Something went wrong with your request submssion.Please try again later.\nIf the problem persists, please contact FT for assistance.\n'+respText);
				}
				$("img#show_hide_loader_img").css({"display":"none"});
			}
		}
		self.xmlHttpReq.send("handler=my_frenchtuesdays&action=request_change&mem_id="+mem_id+"&"+data);
	}	// else
}
/* ADDED WMA */
// January 7th, 2012
function makeShow(){
	if($("span#ftmsam_connected").hasClass("isActive")==true){
		$("div.sub_ft_menu_sam_connected_two").css({"display":"none" , "visibility":"hidden"});
		$("div.sub_ft_menu_sam_connected_three").css({"display":"none" , "visibility":"hidden"});
		$("span#ftmsam_connected").removeClass("isActive");
		$("span#ftmsam_connected").css({"color":"#ffffff"});
		$('input#include_custom_msg').removeAttr('checked');	// Added below
		$("#custom_msg_div").hide().css("display" , "none");
		$('textarea#custom_msg_ta').val('');
		$("#sam_email_input").val("email@eprovider.com");
		// JANUARY 31ST, 2012
		$("select#sam_ftcities_list").find('option:first').attr('selected', 'selected').parent('select');
		$("div#other_cities_list").css({"display":"none" , "visibility":"hidden"});
	}
	else{
		$("div.sub_ft_menu_sam_connected_two").css({"display":"block" , "visibility":"visible"});
		$("div.sub_ft_menu_sam_connected_three").css({"display":"block" , "visibility":"visible"});
		$("span#ftmsam_connected").addClass("isActive");
		$("span#ftmsam_connected").css({"color":"#7D7D7D"});
	}
}
// ADDED WMA
// January 7th, 2012
function checkMenuStatus(){
	if($("span#ftmsam_connected").hasClass("isActive")==true){
		$("div.sub_ft_menu_sam_connected_two").css({"display":"none" , "visibility":"hidden"});
		$("div.sub_ft_menu_sam_connected_three").css({"display":"none" , "visibility":"hidden"});
		$("span#ftmsam_connected").removeClass("isActive");
		$("span#ftmsam_connected").css({"color":"#ffffff"});
		$('input#include_custom_msg').removeAttr('checked');	// Added below
		$("#custom_msg_div").hide().css("display" , "none");
		$('textarea#custom_msg_ta').val('');
		$("#sam_email_input").val("email@eprovider.com");
		// JANUARY 31ST, 2012
		$("select#sam_ftcities_list").find('option:first').attr('selected', 'selected').parent('select');
		$("div#other_cities_list").css({"display":"none" , "visibility":"hidden"});
	}
}
// December 9th, 2011
function show_custom_msg(mem_id, mes_id, obj){	// member id, message id, object
	if(mem_id > 0 && mes_id > 0 ){
		$("div.div_lightbox").css({"display" :"none" , "visibility":"hidden"});
		$("div#ltbx_custom_friendship_msg").css({"display" :"block" , "visibility":"visible"});
		$("div#ltbx_custom_friendship_msg_lister").empty().html("");
		$("div#ltbx_custom_friendship_msg_lister").html(loader_div_16).html();
		var xmlHttpReq = false;
		var self = this;
		var respText;
		if(window.XMLHttpRequest){//Mozilla/Safari
			self.xmlHttpReq = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){//IE
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', "index.php", true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				respText = self.xmlHttpReq.responseText;
				$("div#ltbx_custom_friendship_msg_lister").empty().html("");
				$("div#ltbx_custom_friendship_msg_lister").html(respText).html();
			}
		}
		self.xmlHttpReq.send("handler=community&action=load_frndship_custom_msg&mem_id="+mem_id+"&mes_id="+mes_id);	
	}
}
// January 7th, 2012
function toogle_cmsg_ts(){
	var include_custom_msg = $("input#include_custom_msg").is(':checked')==true?"y":"n";
	if(include_custom_msg=="y"){
		$("#custom_msg_div").css("display" , "block");
	}
	else{
		$("#custom_msg_div").hide().css("display" , "none");
		$('textarea#custom_msg_ta').val('');
	}
}
// January 31ST, 2012
function toogleCitiesList(cty_id){
	if(cty_id==-1){
		$("div#other_cities_list").css({"display":"block" , "visibility":"visible"});
	}
	else{
		$("select.other_cities_list").find('option:first').attr('selected', 'selected').parent('select');
		$("div#other_cities_list").css({"display":"none" , "visibility":"hidden"});
	}
}
