﻿// Activate TRIM function for java script
String.prototype.trim = function(){ return this.replace(/^s+|s+$/g,'') }
var ie4 = false; if(document.all) { ie4 = true; }
if (typeof(Sys) !== "undefined") Sys.Application.notifyScriptLoaded();
function noCache(uri){return uri.concat(/\?/.test(uri)?"&":"?","noCache=",(new Date).getTime(),".",Math.random()*1234567)};

/////////////////////////////////////////////////////
//Variables declaration
/////////////////////////////////////////////////////
var divMemberProfile;
var divMemberProfileInformation;
var divMemberProfileTools;
var divMemberVisionMenu;
var divMemberVisionInformation;
var divMemberVisionTools;
var divMemberPracticeInformation;
var divMemberPracticeTools;
var divMemberAcknowledgementInformation;
var divMemberAcknowledgementTools;

/////////////////////////////////////////////////////
//Common functions
/////////////////////////////////////////////////////
function getobject(id) { 
  if (ie4) {     
    return document.all[id];
  }else {  
    return document.getElementById(id); 
  }
}

function trim(cadena)
{
	for(i=0; i<cadena.length; )
	{
		if(cadena.charAt(i)==" ")
			cadena=cadena.substring(i+1, cadena.length);
		else
			break;
	}

	for(i=cadena.length-1; i>=0; i=cadena.length-1)
	{
		if(cadena.charAt(i)==" ")
			cadena=cadena.substring(0,i);
		else
			break;
	}
	
	return cadena;
}
//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function memberProfileVisitor(){  
  PageMethods.memberProfileVisitor(memberProfileVisitorSuccess,memberProfileVisitorFail);  
}

//when function memberProfileVisitor is completed correctly
function memberProfileVisitorSuccess(result, userContext, methodName){ 
  if (result == "owner"){     
    loadOwnerView();
  }      
  else
  {
    loadPublicView();
  }
}

//when function memberProfileVisitor is not completed correctly
function memberProfileVisitorFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// show the divs tools
function showDivsTools(){  
  divShow = getobject("divMemberProfileTools");
  divShow.style.display = "block";      
  divShow = getobject("divMemberVisionTools");
  divShow.style.display = "block";      
}
//************************************************************

//************************************************************
// hide the divs tools
function hideDivsTools(){  
  divShow = getobject("divMemberProfileTools");
  divShow.style.display = "none";      
  divShow = getobject("divMemberVisionTools");
  divShow.style.display = "none";      
}
//************************************************************


/////////////////////////////////////////////////////
//profileInformation
/////////////////////////////////////////////////////
//Get all objects from page 
function loadVarsProfile(){  
  divMemberProfile = getobject("divMemberProfile");
  divMemberProfileInformation = getobject("divMemberProfileInformation");
  divMemberProfileTools = getobject("divMemberProfileTools");
}


//************************************************************
// get all information of the member
function getMemberPersonalInformation(){  
  PageMethods.getMemberPersonalInformation(getMemberPersonalInformationSuccess,getMemberPersonalInformationFail);  
}

//when function getMemberPersonalInformation is completed correctly
function getMemberPersonalInformationSuccess(result, userContext, methodName){ 
  if (result != ""){     
    divMemberProfileInformation = getobject ("divMemberProfileInformation");
    divMemberProfileInformation.innerHTML = result;
  }      
}

//when function getMemberPersonalInformation is not completed correctly
function getMemberPersonalInformationFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// get memberprofile tools
function getMemberProfileTools(view, message){  
  PageMethods.getMemberProfileTools(view, message, getMemberProfileToolsSuccess,getMemberProfileToolsFail);  
}

//when function getMemberProfileTools is completed correctly
function getMemberProfileToolsSuccess(result, userContext, methodName){ 
  if (result != ""){     
    divMemberProfileTools = getobject ("divMemberProfileTools");
    divMemberProfileTools.innerHTML = result;
  }      
}

//when function getMemberProfileTools is not completed correctly
function getMemberProfileToolsFail(error, userContext, methodName){ 
}
//************************************************************

//************************************************************
// load owner view
function loadOwnerView(){  
  showDivsTools();
  getMemberProfileTools("owner", "");    
  showVisionGoalsProjectsInformation(0,"lifevision");
  showPracticeBlogCreationInformation(0, "practice");
  showAcknowledgementsInformation(0, "received");
}
//************************************************************

//************************************************************
// load public view
function loadPublicView(){  
    hideDivsTools();
}
//************************************************************

//************************************************************
// when the owner want to see public view
function loadOwnerPublicView(){  
  hideDivsTools();
  divMemberProfileTools = getobject ("divMemberProfileTools");
  divMemberProfileTools.style.display="block"; 
  getMemberProfileTools("public", "");    
  getLifeVisionTools("", "lifevision");
}
//************************************************************

//************************************************************
// change member profile access
function changeProfileAccess(){  
  index = document.forms[0]["ddlProfileAccess"].selectedIndex;
  PageMethods.changeProfileAccess(document.forms[0]["ddlProfileAccess"].options[index].value, changeProfileAccessSuccess,changeProfileAccessFail);  
}

//when function changeProfileAccess is completed correctly
function changeProfileAccessSuccess(result, userContext, methodName){ 
  getMemberProfileTools('owner', 'Profile was updated Correctly', getMemberProfileToolsSuccess,getMemberProfileToolsFail);
}

//when function changeProfileAccess is not completed correctly
function changeProfileAccessFail(error, userContext, methodName){ 
  getMemberProfileTools('owner', 'Profile was not updated Correctly', getMemberProfileToolsSuccess,getMemberProfileToolsFail);
}
//************************************************************


/////////////////////////////////////////////////////
//Life Vision, goals & commitments, projects
/////////////////////////////////////////////////////
//Get all objects from page 
function loadVarsVsion(){  
  divMemberVisionMenu = getobject("divMemberVisionMenu");
  divMemberVisionInformation = getobject("divMemberVisionInformation");
  divMemberVisionTools = getobject("divMemberVisionTools");
  divMemberPracticeInformation = getobject("divMemberPracticeInformation");
  divMemberPracticeTools = getobject("divMemberPracticeTools");
  divMemberAcknowledgementInformation = getobject("divMemberAcknowledgementInformation");
  divMemberAcknowledgementTools = getobject("divMemberAcknowledgementTools");
}


//************************************************************
// Load information (Vision Section)
function showVisionGoalsProjectsInformation(currentPage, tab){  
  PageMethods.showVisionGoalsProjectsInformation(currentPage, showVisionGoalsProjectsInformationSuccess,showVisionGoalsProjectsInformationFail);  
  getLifeVisionTools("", tab);
}

//when function showVisionGoalsProjectsInformation is completed correctly
function showVisionGoalsProjectsInformationSuccess(result, userContext, methodName){ 
  if (result != ""){     
    divMemberPracticeInformation = getobject("divMemberVisionInformation");
    divMemberPracticeInformation.innerHTML = result;
  }      
}

//when function showVisionGoalsProjectsInformation is not completed correctly
function showVisionGoalsProjectsInformationFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Load information (Practice Section)
function showPracticeBlogCreationInformation(currentPage, tab){  
  PageMethods.showPracticeBlogCreationInformation(currentPage, showPracticeBlogCreationInformationSuccess,showPracticeBlogCreationInformationFail);  
  getPracticeBlogCreationTools("", tab);
}

//when function showPracticeBlogCreationInformation is completed correctly
function showPracticeBlogCreationInformationSuccess(result, userContext, methodName){ 
  if (result != ""){     
    divMemberVisionInformation = getobject ("divMemberPracticeInformation");
    divMemberVisionInformation.innerHTML = result;
  }      
}

//when function showPracticeBlogCreationInformation is not completed correctly
function showPracticeBlogCreationInformationFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Load information (Acknowledgement Section)
function showAcknowledgementInformation(currentPage, tab){  
  PageMethods.showAcknowledgementInformation(currentPage, showAcknowledgementInformationSuccess,showAcknowledgementInformationFail);  
  getPracticeBlogCreationTools("", tab);
}

//when function showAcknowledgementInformation is completed correctly
function showAcknowledgementInformationSuccess(result, userContext, methodName){ 
  if (result != ""){     
    divMemberAcknowledgementInformation = getobject ("divMemberAcknowledgementInformation");
    divMemberAcknowledgementInformation.innerHTML = result;
  }      
}

//when function showAcknowledgementInformation is not completed correctly
function showAcknowledgementInformationFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************


//************************************************************
// get acknowledgement section tools
function getAcknowledgementTools(message, tab){  
  PageMethods.getAcknowledgementTools(message, tab, getAcknowledgementToolsSuccess,getAcknowledgementToolsFail);  
}

//when function getAcknowledgementTools is completed correctly
function getAcknowledgementToolsSuccess(result, userContext, methodName){ 
  if (result != ""){     
    divMemberAcknowledgementTools = getobject ("divMemberAcknowledgementTools");
    divMemberAcknowledgementTools.innerHTML = result;
  }      
}

//when function getAcknowledgementTools is not completed correctly
function getAcknowledgementToolsFail(error, userContext, methodName){ 
}
//************************************************************


//************************************************************
// get practice - blog - creations section tools
function getPracticeBlogCreationTools(message, tab){  
  PageMethods.getPracticeBlogCreationTools(message, tab, getPracticeBlogCreationToolsSuccess,getPracticeBlogCreationToolsFail);  
}

//when function getPracticeBlogCreationTools is completed correctly
function getPracticeBlogCreationToolsSuccess(result, userContext, methodName){ 
  if (result != ""){     
    divMemberPracticeTools = getobject ("divMemberPracticeTools");
    divMemberPracticeTools.innerHTML = result;
  }      
}

//when function getPracticeBlogCreationTools is not completed correctly
function getPracticeBlogCreationToolsFail(error, userContext, methodName){ 
}
//************************************************************


//************************************************************
// get life vision section tools
function getLifeVisionTools(message, tab){  
  PageMethods.getLifeVisionTools(message, tab, getLifeVisionToolsSuccess,getLifeVisionToolsFail);  
}

//when function getLifeVisionTools is completed correctly
function getLifeVisionToolsSuccess(result, userContext, methodName){ 
  if (result != ""){     
    divMemberVisionTools = getobject ("divMemberVisionTools");
    divMemberVisionTools.innerHTML = result;
  }      
}

//when function getLifeVisionTools is not completed correctly
function getLifeVisionToolsFail(error, userContext, methodName){ 
}
//************************************************************



//************************************************************
// show the information of the section to be edited
function editSection(section){  
  PageMethods.editSection(section, editSectionSuccess,editSectionFail);  
}

//when function editSection is completed correctly
function editSectionSuccess(result, userContext, methodName){ 
    window.location="myMorevida.aspx";
}

//when function editSection is not completed correctly
function editSectionFail(error, userContext, methodName){ 
}
//************************************************************

//************************************************************
// show a list of members 
function showMember(){  
  PageMethods.showMember(showMemberSuccess,showMemberFail);  
}

//when function showMember is completed correctly
function showMemberSuccess(result, userContext, methodName){ 
    var divMember = getobject('divMember');
    divMember.innerHTML = result;
}

//when function showMember is not completed correctly
function showMemberFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// show a list of members 
function viewFriendMember(memberId){  
  PageMethods.viewFriendMember(memberId, viewFriendMemberSuccess,viewFriendMemberFail);  
}

//when function viewFriendMember is completed correctly
function viewFriendMemberSuccess(result, userContext, methodName){ 
    window.location="allFriends.aspx";
}

//when function viewFriendMember is not completed correctly
function viewFriendMemberFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// show a list of friends
function seeAllFriends(){  
  PageMethods.seeAllFriends(seeAllFriendsSuccess,seeAllFriendsFail);  
}

//when function seeAllFriends is completed correctly
function seeAllFriendsSuccess(result, userContext, methodName){ 
    window.location="allFriends.aspx";
}

//when function seeAllFriends is not completed correctly
function seeAllFriendsFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// show a list of friends
function sendInvitation(){  
  var txtIntroduction = getobject('txtIntroduction');
  if (trim(txtIntroduction.value)!= '')
      PageMethods.sendInvitation(trim(txtIntroduction.value),sendInvitationSuccess,sendInvitationFail);  
  else
      alert('You must to enter text on introduction field');
}

//when function sendInvitation is completed correctly
function sendInvitationSuccess(result, userContext, methodName){ 
    var aInv = getobject('aInv');
    var imgInv1 = getobject('imgInv1');
    aInv.style['display']='none';
    imgInv1.style['display']='block';
//    divInvitation1.innerHTML = '<b class="verdana11white">YOUR INVITATION WAS SENT SUCCESSFULLY</b>'
    var txtIntroduction = getobject('txtIntroduction');
    txtIntroduction.value='';
    hideDivInvitation();
}

//when function sendInvitation is not completed correctly
function sendInvitationFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// show a list of friends
function acceptInvitation1(tempId){  
  if (trim(tempId)!= '')
      PageMethods.acceptInvitation(trim(tempId),acceptInvitation1Success,acceptInvitation1Fail);  
  else
      alert('Temporary Identification is not valid');
}

//when function acceptInvitation is completed correctly
function acceptInvitation1Success(result, userContext, methodName){ 
  //alert('This Invitation was accepted successfully');
  window.location="profile.aspx";
}

//when function acceptInvitation is not completed correctly
function acceptInvitation1Fail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// reject invitation of the member
function rejectInvitation1(tempId){  
    if (trim(tempId)!= '')
        PageMethods.rejectInvitation(tempId,rejectInvitation1Success,rejectInvitation1Fail);  
    else
        alert('Temporary Identification is not valid');
}

//when function rejectInvitation1 is completed correctly
function rejectInvitation1Success(result, userContext, methodName){ 
    alert('This Invitation was rejected');
    window.location="Friends.aspx";
}

//when function rejectInvitation1 is not completed correctly
function rejectInvitation1Fail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// show a list of friends
function acceptGroupRequest(tempId){  
  if (trim(tempId)!= '')
      PageMethods.acceptGroupRequest(trim(tempId),acceptGroupRequestSuccess,acceptGroupRequestFail);  
  else
      alert('Temporary Identification is not valid');
}

//when function acceptInvitation is completed correctly
function acceptGroupRequestSuccess(result, userContext, methodName){ 
  window.location="groupDetails.aspx";
}

//when function acceptInvitation is not completed correctly
function acceptGroupRequestFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// reject invitation of the member
function rejectGroupRequest(tempId){  
    if (trim(tempId)!= '')
        PageMethods.rejectGroupRequest(trim(tempId),rejectGroupRequestSuccess,rejectGroupRequestFail);  
    else
        alert('Temporary Identification is not valid');
}

//when function rejectGroupRequest is completed correctly
function rejectGroupRequestSuccess(result, userContext, methodName){ 
    window.location="profile.aspx";
}

//when function rejectGroupRequest is not completed correctly
function rejectGroupRequestFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// reject invitation of the member
function loadInformationInvitation(){  
    PageMethods.getMemberPersonalInformation(loadInformationInvitationSuccess,loadInformationInvitationFail);  
}

//when function loadInformationInvitation is completed correctly
function loadInformationInvitationSuccess(result, userContext, methodName){ 
    var divInvitation = getobject('divInvitation');
    divInvitation.innerHTML = result;
}

//when function loadInformationInvitation is not completed correctly
function loadInformationInvitationFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// load all friends of a member
function loadFriends(start, numberPage){  
    PageMethods.loadFriends(start,numberPage, loadFriendsSuccess,loadFriendsFail);  
}

//when function loadFriends is completed correctly
function loadFriendsSuccess(result, userContext, methodName){ 
    var divFriendInformation = getobject('divFriendInformation');
    divFriendInformation.innerHTML = result;
}

//when function loadFriends is not completed correctly
function loadFriendsFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************
//Get all objects from page 
function loadVarsProfile1(){  
  divMemberProfile = getobject("divMemberProfile");
}

//load all invitations
function showInvitations()
{
  var divInvitations= getobject('divInvitations');
    PageMethods.loadInvitations(showInvitationsSuccess,showInvitationsFail);  
//  var divInvHeaderHide = getobject('divInvHeaderHide');
//  divInvHeaderHide.style["display"]= 'block';
//  var divInvHeaderShow = getobject('divInvHeaderShow');
//  divInvHeaderShow.style["display"]= 'none';
  divInvitations.style["display"]= 'block';
}

//when function showInvitations is completed correctly
function showInvitationsSuccess(result, userContext, methodName){   
  var divInvitations = getobject('divInvitations');
  divInvitations.innerHTML = result;
}

//when function showInvitations is not completed correctly
function showInvitationsFail(error, userContext, methodName){ 
  alert(error.getname);
}
//************************************************************

function hideInvitations()
{
    var divInvitations= getobject('divInvitations');
    divInvitations.style["display"]= 'none';
//    Effect.SlideUp('divInvitations',{queue:{scope:'myscope', position:'end'}});
}

//************************************************************
// load all friends invitation of a member
function loadInvitations(){  
    PageMethods.loadInvitations(loadInvitationsSuccess,loadInvitationsFail);  
}

//when function loadInvitations is completed correctly
function loadInvitationsSuccess(result, userContext, methodName){ 
    var divInvitations = getobject('divInvitations');
    divInvitations.innerHTML = result;
}

//when function loadInvitations is not completed correctly
function loadInvitationsFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************
//************************************************************
// load all friends invitation of a member
function acceptInvitation(div, friendInvitationTempId){ 
    var divInvitations = getobject('divInvitations'); 
    PageMethods.acceptInvitation(friendInvitationTempId, acceptInvitationSuccess,acceptInvitationFail);  
}

//when function acceptInvitation is completed correctly
function acceptInvitationSuccess(result, userContext, methodName){ 
    hideInvitations();
    loadFriends(0,1);
    
}

//when function acceptInvitation is not completed correctly
function acceptInvitationFail(error, userContext, methodName){ 
loadInvitations();
}
//************************************************************

//************************************************************
// load all friends invitation of a member
function rejectInvitation(div, friendInvitationTempId){ 
    var divInvitations = getobject('divInvitations'); 
    var asdf = getobject(div);
    asdf.style["display"]='none';
    PageMethods.rejectInvitation(friendInvitationTempId, rejectInvitationSuccess,rejectInvitationFail);  
}

//when function rejectInvitation is completed correctly
function rejectInvitationSuccess(result, userContext, methodName){ 
  hideDivInvitation();
}

//when function rejectInvitation is not completed correctly
function rejectInvitationFail(error, userContext, methodName){ 
loadInvitations();
}
//************************************************************

//************************************************************
// show a list of friends
function seeFriends(memberId){  
  PageMethods.seeFriends(memberId, seeFriendsSuccess,seeFriendsFail);  
}

//when function seeFriends is completed correctly
function seeFriendsSuccess(result, userContext, methodName){ 
    window.location="allFriends.aspx";
}

//when function seeFriends is not completed correctly
function seeFriendsFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// show a list of friends
function seeProfile(memberId){  
  PageMethods.seeProfile(memberId, seeProfileSuccess,seeProfileFail);  
}

//when function seeProfile is completed correctly
function seeProfileSuccess(result, userContext, methodName){ 
    window.location="profileMember.aspx";
}

//when function seeProfile is not completed correctly
function seeProfileFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// show a list of friends
function seeProfilesecure(memberId){  
  PageMethods.seeProfile(memberId, seeProfilesecureSuccess,seeProfilesecureFail);  
}

//when function seeProfilesecure is completed correctly
function seeProfilesecureSuccess(result, userContext, methodName){ 
    window.location="secure/profileMember.aspx";
}

//when function seeProfilesecure is not completed correctly
function seeProfilesecureFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// show a list of friends
function seeProfile1(memberId){  
  PageMethods.seeProfile(memberId, seeProfile1Success,seeProfile1Fail);  
}

//when function seeProfile is completed correctly
function seeProfile1Success(result, userContext, methodName){ 
    window.location="profile.aspx";
}

//when function seeProfile is not completed correctly
function seeProfile1Fail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************


//************************************************************
// show a list of friends
function putMemberEditProfileId(memberId){  
  PageMethods.putMemberEditProfileId(memberId, putMemberEditProfileIdSuccess,putMemberEditProfileIdFail);  
}

//when function putMemberEditProfileId is completed correctly
function putMemberEditProfileIdSuccess(result, userContext, methodName){ 
    //window.location="allFriends.aspx";
    window.location="profile.aspx";
}

//when function putMemberEditProfileId is not completed correctly
function putMemberEditProfileIdFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Load information (Vision Section)
function showAcknowledgementsInformation(currentPage, tab){  
  PageMethods.showAcknowledgementsInformation(currentPage, showAcknowledgementsInformationSuccess,showAcknowledgementsInformationFail);  
  getAcknowledgementsTools("", tab);
}

//when function showAcknowledgementsInformation is completed correctly
function showAcknowledgementsInformationSuccess(result, userContext, methodName){ 
  if (result != ""){     
    var divMemberAcknowledgementInformation;
    divMemberAcknowledgementInformation = getobject("divMemberAcknowledgementInformation");
    divMemberAcknowledgementInformation.innerHTML = result;
  }      
}

//when function showAcknowledgementsInformation is not completed correctly
function showAcknowledgementsInformationFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************
//************************************************************
// get acknowledgements section tools
function getAcknowledgementsTools(message, tab){  
  PageMethods.getAcknowledgementsTools(message, tab, getAcknowledgementsToolsSuccess,getAcknowledgementsToolsFail);  
}

//when function getAcknowledgementsTools is completed correctly
function getAcknowledgementsToolsSuccess(result, userContext, methodName){ 
  if (result != ""){     
    var divMemberAcknowledgementTools;
    divMemberAcknowledgementTools = getobject ("divMemberAcknowledgementTools");
    divMemberAcknowledgementTools.innerHTML = result;
  }      
}

//when function getLifeVisionTools is not completed correctly
function getAcknowledgementsToolsFail(error, userContext, methodName){ 
}
//************************************************************

//************************************************************
// Download a Vision Board
function visionBoardView(inspirationId){  
  PageMethods.visionBoardView(inspirationId, visionBoardViewSuccess,visionBoardViewFail);  
}

//when function visionBoardView is completed correctly
function visionBoardViewSuccess(result, userContext, methodName){ 
  if (result!="")
    window.location=result;
}

//when function visionBoardView is not completed correctly
function visionBoardViewFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************
//************************************************************
// Download a Vision Board
function visionBoardView1(inspirationId){  
  PageMethods.visionBoardView(inspirationId, visionBoardView1Success,visionBoardView1Fail);  
}

//when function visionBoardView1 is completed correctly
function visionBoardView1Success(result, userContext, methodName){ 
    window.location="secure/visionBoardView.aspx";
}

//when function visionBoardView1 is not completed correctly
function visionBoardView1Fail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// get all information of the member
function blogFullView(blogId){  
  PageMethods.blogFullView(blogId, blogFullViewSuccess,blogFullViewFail);  
}

//when function blogFullView is completed correctly
function blogFullViewSuccess(result, userContext, methodName){ 
  window.location ="blogFullView.aspx"
}

//when function blogFullView is not completed correctly
function blogFullViewFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// get all information of the member
function showInvitationDiv(){  
  PageMethods.showInvitationDiv(showInvitationDivSuccess,showInvitationDivFail);  
}

//when function showInvitationDiv is completed correctly
function showInvitationDivSuccess(result, userContext, methodName){ 
  var divInvitation = getobject('divInvitation1');
  //alert(result);
  if (result=='true')
  {
    divInvitation.style["display"]='none';
  }
  else
  {
    divInvitation.style["display"]='block';
  }
}

//when function showInvitationDiv is not completed correctly
function showInvitationDivFail(error, userContext, methodName){ 
alert(error.get_name);
}
//************************************************************

//************************************************************
// load all friends of a member
function loadMembers(start, numberPage){  
    PageMethods.loadMembers(start,numberPage, loadMembersSuccess,loadMembersFail);  
}

//when function loadMembers is completed correctly
function loadMembersSuccess(result, userContext, methodName){ 
    var divMembers = getobject('divMembers');
    divMembers.innerHTML = result;
}

//when function loadMembers is not completed correctly
function loadMembersFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// load all friends of a member
function loadResults(start, currentPage){
    var stateId =0;
    var countryId=0;
    var txtUsername = getobject('txtUsername');
    var indice = document.forms[0]["ddlSex"].selectedIndex;
    var stateIndex = document.forms[0]["ddlState"].selectedIndex;
    var countryIndex = document.forms[0]["ddlCountry"].selectedIndex;
    var option = document.forms[0]["ddlSex"].options[indice].value;    
    try
    {
        stateId = document.forms[0]["ddlState"].options[stateIndex].value;    
    }
    catch (ex)
    {
        stateId=0;
    }
    try
    {
        countryId = document.forms[0]["ddlCountry"].options[countryIndex].value;    
    }
    catch (ex)
    {
        countryId=0;
    }
    var photo = 0;
    var chkPhoto = getobject('chkPhoto');
    if (chkPhoto.checked)
        photo=1;
//    alert(txtUsername.value);
//    alert(option);
//    alert(photo);
    if (txtUsername.value== "" && option=="" && photo==0 && stateId==0 && countryId==0)
        loadFriends(0,1);
    else
        PageMethods.loadResults(txtUsername.value, option, 0,0,photo,1, stateId,countryId, start,currentPage, loadResultsSuccess,loadResultsFail);  
}

//when function loadResults is completed correctly
function loadResultsSuccess(result, userContext, methodName){ 
    var divFriendInformation = getobject('divFriendInformation');
    divFriendInformation.innerHTML = result;
}

//when function loadResults is not completed correctly
function loadResultsFail(error, userContext, methodName){ 
    alert(error.getname);
}
//************************************************************

//************************************************************
// load all friends of a member
function loadFilters(){  
    PageMethods.loadFilters(loadFiltersSuccess,loadFiltersFail);  
}

//when function loadFilters is completed correctly
function loadFiltersSuccess(result, userContext, methodName){
    var divFilters = getobject('divFilters');
    divFilters.innerHTML = result;
}

//when function loadFilters is not completed correctly
function loadFiltersFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// delete a friend
function deleteFriend(memberId, start, numberPage){  
    if (confirm('Are you sure you want to delete this friend?'))
        PageMethods.deleteFriend(memberId, start, numberPage, deleteFriendSuccess,deleteFriendFail);  
}

//when function deleteFriend is completed correctly
function deleteFriendSuccess(result, userContext, methodName){ 
  var r = result.split('|');
  loadFriends(r[0], r[1]);
}

//when function deleteFriend is not completed correctly
function deleteFriendFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************
