/**
 * @fileoverview This file is to be used for Client side User Entity Class. Provides all the activities related to a User Entity like create,
 * update, remove, findById, findByName etc. public getter & setter methods for all attributes are
 * provided too.
 *
 * @author Espre Team
 * @version 0.1
 */

/**
* member functions of class User
*/
UserWidget.prototype.getAllSecretQuestion = getAllSecretQuestion;  // new method

UserWidget.prototype.addBuddyGroup = addBuddyGroup;  // new add method
UserWidget.prototype.editBuddyGroup = editBuddyGroup; // new add method
//UserWidget.prototype.moveBuddyGroup = moveBuddyGroup; // new add method
UserWidget.prototype.removeBuddyGroup = removeBuddyGroup; // new add method
//UserWidget.prototype.subscribeForStatus = subscribeForStatus;
//UserWidget.prototype.unsubscribeForStatus = unsubscribeForStatus;
UserWidget.prototype.getInvitedBuddyList = getInvitedBuddyList; // new add method
UserWidget.prototype.getInvitedBuddyList_CallBackFunction=getInvitedBuddyList_CallBackFunction; // new add method
UserWidget.prototype.acceptedBuddyInvitation=acceptedBuddyInvitation; // new add method
UserWidget.prototype.rejectedBuddyInvitation=rejectedBuddyInvitation; // new add method
UserWidget.prototype.getSentInvitationStatus=getSentInvitationStatus;
UserWidget.prototype.getSentInvitationStatusCallBackFunction=getSentInvitationStatusCallBackFunction;
UserWidget.prototype.setUserNotificationFlagToOne=setUserNotificationFlagToOne;

UserWidget.prototype.addBuddyUsers = addBuddyUsers;
UserWidget.prototype.moveBuddyUser = moveBuddyUser;
UserWidget.prototype.removeUserToBuddyList = removeUserToBuddyList;

UserWidget.prototype.findAllUsers = findAllUsers;
UserWidget.prototype.findAllActiveUsers = findAllActiveUsers;
UserWidget.prototype.findAllBuddyUsers = findAllBuddyUsers;
UserWidget.prototype.findAllBuddyGroups = findAllBuddyGroups;

UserWidget.prototype.findByUserId = findByUserId;
UserWidget.prototype.createUser = createUser;
UserWidget.prototype.activateUser = activateUser;
UserWidget.prototype.deactivateUser = deactivateUser;
UserWidget.prototype.removeUser = removeUser;
UserWidget.prototype.updateUser = updateUser;
UserWidget.prototype.getLoggedInUserInfo = getLoggedInUserInfo;
UserWidget.prototype.findByUserLoginId = findByUserLoginId;
UserWidget.prototype.findByFirstName = findByFirstName;
UserWidget.prototype.findByLastName = findByLastName;
UserWidget.prototype.findByGender = findByGender;
UserWidget.prototype.findByEmailId = findByEmailId;
UserWidget.prototype.findByStatus = findByStatus;
UserWidget.prototype.findByCity = findByCity;
UserWidget.prototype.findByState = findByState;
UserWidget.prototype.findByCountry = findByCountry;
UserWidget.prototype.findByZipCode = findByZipCode;
UserWidget.prototype.changePassword = changePassword;
UserWidget.prototype.forgotPassword = forgotPassword;
UserWidget.prototype.getUserSignIn = getUserSignIn;
UserWidget.prototype.getUserSignOut = getUserSignOut;
UserWidget.prototype.getUnAssignedGroups = getUnAssignedGroups;
UserWidget.prototype.getAssignedGroups = getAssignedGroups;
UserWidget.prototype.addRemoveGroups = addRemoveGroups;
UserWidget.prototype.jsonToResultUser = jsonToResultUser;
UserWidget.prototype.getUserId = getUserId;
UserWidget.prototype.getUserLoginId = getUserLoginId;
UserWidget.prototype.getFirstName = getFirstName;
UserWidget.prototype.getLastName = getLastName;
UserWidget.prototype.getGender = getGender;
UserWidget.prototype.getFax = getFax;
UserWidget.prototype.getDob = getDob;
UserWidget.prototype.getStreetAddress1 = getStreetAddress1;
UserWidget.prototype.getStreetAddress2 = getStreetAddress2;
UserWidget.prototype.getType = getType;
UserWidget.prototype.getEmailId = getEmailId;
UserWidget.prototype.getGroupId = getGroupId;  // for the group
UserWidget.prototype.getName = getName;      // for the group
UserWidget.prototype.getContactNo = getContactNo;
UserWidget.prototype.getStatus = getStatus;
UserWidget.prototype.getCity = getCity;
UserWidget.prototype.getState = getState;
UserWidget.prototype.getCountry = getCountry;
UserWidget.prototype.getZipCode = getZipCode;
UserWidget.prototype.getBuddyCategoryName = getBuddyCategoryName;

UserWidget.prototype.getAnswer = getAnswer;
UserWidget.prototype.getQuestion = getQuestion;
UserWidget.prototype.getQuestionId = getQuestionId;

UserWidget.prototype.setQuestion = setQuestion;
UserWidget.prototype.setQuestionId = setQuestionId;
UserWidget.prototype.setAnswer = setAnswer;
UserWidget.prototype.setUserAccessTime =setUserAccessTime;

UserWidget.prototype.setBuddyCategoryId = setBuddyCategoryId; //new setter method
UserWidget.prototype.setBuddyCategoryName = setBuddyCategoryName; //new setter method
UserWidget.prototype.setBuddyStatus = setBuddyStatus; //new setter method

UserWidget.prototype.getBuddyCategoryId = getBuddyCategoryId; //new getter method
UserWidget.prototype.getBuddyCategoryName = getBuddyCategoryName; //new getter method
UserWidget.prototype.getBuddyStatus= getBuddyStatus; //new getter method

UserWidget.prototype.setUserId = setUserId;
UserWidget.prototype.setUserLoginId = setUserLoginId;
UserWidget.prototype.setFirstName = setFirstName;
UserWidget.prototype.setMiddleName = setMiddleName;
UserWidget.prototype.setLastName = setLastName;
UserWidget.prototype.setGender = setGender;
UserWidget.prototype.setFax = setFax;
UserWidget.prototype.setDob = setDob;
UserWidget.prototype.setType = setType;
UserWidget.prototype.setEmailId = setEmailId;
UserWidget.prototype.setGroupId = setGroupId;  // for the group
UserWidget.prototype.setName = setName;      // for the group
UserWidget.prototype.setContactNo = setContactNo;
UserWidget.prototype.setStatus = setStatus;
UserWidget.prototype.setStreetAddress1 = setStreetAddress1;
UserWidget.prototype.setStreetAddress2 = setStreetAddress2;
UserWidget.prototype.setCity = setCity;
UserWidget.prototype.setState = setState;
UserWidget.prototype.setCountry = setCountry;
UserWidget.prototype.setZipCode = setZipCode;
UserWidget.prototype.setBuddyCategoryName = setBuddyCategoryName;

UserWidget.prototype.setPassword = setPassword;
UserWidget.prototype.setNewPassword = setNewPassword;
UserWidget.prototype.setCallSettingObject = setCallSettingObject;
UserWidget.prototype.setStatusCallBackFunction=setStatusCallBackFunction;
UserWidget.prototype.checkUserAccess=checkUserAccess;
UserWidget.prototype.checkAccessCallBackFunction=checkAccessCallBackFunction;
UserWidget.prototype.checkUserAvailable=checkUserAvailable;

UserWidget.prototype.checkForAlreadyLoginByUserId=checkForAlreadyLoginByUserId;
UserWidget.prototype.checkForAlreadyLoginByUserLoginId=checkForAlreadyLoginByUserLoginId;
UserWidget.prototype.checkIfAlreadyLogin=checkIfAlreadyLogin;


UserWidget.prototype.response = "default";

var externalCallback=''; //new variable for call back

/**
* @constructor
* sets the fields of class User
* @param 	{Array} attributeList
*/

function UserWidget( ){
    /* Specifies user Id for particular user.
    * @type Integer
    */
   	this.userId = '';
   	/*
   	* Specifies user Login Id for particular user.
   	* @type String
   	*/
	this.userLoginId = '';
	/*
	* Specifies password for particular user.
	* @type String
	*/
	this.password = '';
	/* Specifies new Password name for particular user.
	* @type String
	*/
	this.newPassword = '';
    /* Specifies first name for particular user.
    * @type String
    */
	this.firstName = '';
    /*
    * Specifies last name for particular user.
    * @type String
    */
	this.lastName = '';
	/*
	* Specifies gender for particular user.
	* @type gender
	*/
	this.gender = '';
	/* Specifies email Id for particular user.
	* @type String
	*/
	this.fax = '';
	/* Specifies date for particular user.
	* @type String
	*/
	this.dob = '';
	/* Specifies Group type for particular user.
	* @type String
	*/
	this.type = '';
	/* Specifies email Id for particular user.
	* @type String
	*/
	this.emailId = '';
	/* Specifies group id for particular user.
	* @type Integer
	*/
	this.groupId = '';
	/* Specifies group name for particular user.
	* @type String
	*/
	this.name = '';
	/* Specifies contact number for particular user.
	* @type String
	*/
	this.contactNo = '';
	/* Specifies the ststus for particular user.
	* @type String
	*/
	this.status = '';
	/* Specifies the street Address1 name for particular user.
	* @type String
	*/
	this.streetAddress1 = '';
	/* Specifies the street Address2 name for particular user.
	* @type String
	*/
	this.streetAddress2 = '';
	/* Specifies city name for particular user.
	* @type String
	*/
	this.city = '';
	/* Specifies state name for particular user.
	* @type String
	*/
	this.state = '';
	/* Specifies country name for particular user.
	* @type String
	*/
	this.country = '';
	/* Specifies country name for particular user.
	* @type String
	*/
	this.zipCode = '';
	/* Specifies Buddy Category Name for particular user.
	* @type String
	*/
	this.time = 3000;
	this.isSynch = 'false';
	this.arrPagination ='';
    /* Specifies Buddy Category Id for particular user.
	* @type String
	*/
	this.buddyCategoryId = '';
	/* Specifies Buddy Category Name for particular user.
	* @type String
	*/
	this.buddyCategoryName = '';
	/* Specifies Buddy Status for particular user.
	* @type String
	*/
	this.question = '';
	this.answer = '';
	/* Specifies Buddy Status for particular user.
	* @type String
	*/
	this.buddyStatus ='';
	this.userAccessTime = '';
	this.externalCallback='';


	/*
	* setting parameters for dojo.io.bind
	*/
	this.util = new Utility();
	this.util.setSync(this.isSynch);
	this.util.setUrl(_serverControllerPath);
	this.util.setLoad(this.setStatusCallBackFunction);
}

/**
* User Class public setter methods
*/

/**
 * Set the Call Settings object for the user Class
 * @param {int} object
 * @return {void}
 */
function setCallSettingObject(obj){
	if(typeof(obj)== "undefined" || obj== null || /(\w+)\(/.exec(obj.constructor.toString())[1]!= "CallSettings")
		throw new Error("CallSettings object is required to proceed.");

 	this.objCallSetting = obj;
}

/**
 * Set the UserId for the user Class
 * @param {int} userId
 * @return {void}
 */
function setUserId( userId ){
	if (userId !== null){
		this.userId = userId;
	}
}
/**
 * Set the userLoginId for the user Class
 * @param {string} userLoginId
 * @return {void}
 */

function setUserLoginId( userLoginId ){
	if (userLoginId !== null){
		this.userLoginId = userLoginId;
	}
}
/**
 * Set the Password for the user Class
 * @param {string} password
 * @return {void}
 */

function setPassword( pwd ){
	if (pwd !== null){
		this.password = pwd;
	}
}
/**
 * Set the New Password for the user Class
 * @param {string} password
 * @return {void}
 */
function setNewPassword( pwd ){
	if (pwd !== null){
		this.newPassword = pwd;
	}
}
/**
 * Set the First Name for the user Class
 * @param {Object} firstName
 * @return {void}
 */

function setFirstName( firstName ){
	if (firstName !== null){
		this.firstName = firstName;
	}
}
/**
 * Set the Middle Name for the user Class
 * @param {Object} middleName
 * @return {void}
 */
function setMiddleName( middleName ){
	if (middleName !== null){
		this.middleName = middleName;
	}
}
/**
 * Set the Last Name for the user Class
 * @param {Object} lastName
 * @return {void}
 */
function setLastName( lastName ){
	if (lastName !== null){
		this.lastName = lastName;
	}
}
/**
 * Set the Gender for the user Class
 * @param {Object} gender
 * @return {void}
 */
function setGender( gender ){
	if (gender !== null){
		this.gender = gender;
	}
}
/**
 * Set the Fax for the user Class
 * @param {Object} fax
 * @return {void}
 */
function setFax( fax ){
	if (fax !== null){
		this.fax = fax;
	}
}
/**
 * Set the Date Of Birth for the user Class
 * @param {Object} dob
 * @return {void}
 */
function setDob( dob ){
	if (dob !== null){
		this.dob = dob;
	}
}
/**
 * Set the Type for the user Class
 * @param {Object} type
 * @return {void}
 */
function setType( type ){
	if (type !== null){
		this.type = type;
	}
}
/**
 * Set the E mail ID for the user Class
 * @param {Object} emailId
 * @return {void}
 */
function setEmailId( emailId ){
	if (emailId !== null){
		this.emailId = emailId;
	}
}
/**
 * Set the Group ID for the user Class
 * @param {Object} groupId
 * @return {void}
 */
function setGroupId( groupId ){
	if (groupId !== null){
		this.groupId = groupId;
	}
}
function setName( name ){
	if (name !== null){
		this.name = name;
	}
}
/**
 * Set the Contact Number for the user Class
 * @param {Object} ContactNo
 * @return {void}
 */
function setContactNo( contactNo ){
	if (contactNo !== null){
		this.contactNo = contactNo;
	}
}
/**
 * Set the Status for the user Class
 * @param {Object} status
 * @return {void}
 */
function setStatus( status ){
	if (status !== null){
		this.status = status;
	}
}
/**
 * Set the Street Address1 for the user Class
 * @param {Object} streetAddress1
 * @return {void}
 */
function setStreetAddress1( streetAddress1 ){
	if (streetAddress1 !== null){
		this.streetAddress1 = streetAddress1;
	}
}
/**
 * Set the Street Address2 for the user Class
 * @param {Object} streetAddress2
 * @return {void}
 */
function setStreetAddress2( streetAddress2 ){
	if (streetAddress2 !== null){
		this.streetAddress2 = streetAddress2;
	}
}
/**
 * Set the City for the user Class
 * @param {Object} city
 * @return {void}
 */
function setCity( city ){
	if (city !== null){
		this.city = city;
	}
}
/**
 * Set the State for the user Class
 * @param {Object} state
 * @return {void}
 */
function setState( state ){
	if (state !== null){
		this.state = state;
	}
}
/**
 * Set the Country for the user Class
 * @param {Object} country
 * @return {void}
*/
function setCountry( country ){
	if (country !== null){
		this.country = country;
	}
}
/**
 * Set the Zip Code for the user Class
 * @param {Object} zipcode
 * @return {void}
*/
function setZipCode( zipCode ){
	if (zipCode !== null){
		this.zipCode = zipCode;
	}
}
/**
 * Set the Buddy Category Name for the user Class
 * @param {Object} buddyCategoryName
 * @return {void}
*/
function setBuddyCategoryName( buddyCategoryName ){
	if (buddyCategoryName !== null){
		this.buddyCategoryName = buddyCategoryName;
	}
}

/**
 * Set the Buddy Category Id for the user Class
 * @param {Object} buddyCategoryId
 * @return {void}
 */
function setBuddyCategoryId( buddyCategoryId){
	if (buddyCategoryId!== null){
		this.buddyCategoryId = buddyCategoryId;
	}
}
/**
 * Set the Buddy Status for the user Class
 * @param {Object} buddyStatus
 * @return {void}
 */
function setBuddyStatus( buddyStatus ){
	if (buddyStatus !== null){
		this.buddyStatus = buddyStatus ;
	}
}
/**
 * Set the Question for the user Class
 * @param {Object} question
 * @return {void}
 */
function setQuestion( question ){
	if (question !== null){
		this.question = question ;
	}
}
function setQuestionId( questionId ){
	if (questionId !== null){
		this.questionId = questionId ;
	}
}

/**
 * Set the Answer for the user Class
 * @param {Object} answer
 * @return {void}
 */
function setAnswer( answer ){
	if (answer !== null){
		this.answer = answer ;
	}
}
function setUserAccessTime( userAccessTime)
{
	if (userAccessTime !== null){
		this.userAccessTime = userAccessTime;
	}
}

/**
* User Class getter methods
*/

function getUserAccessTime( )
{
	return this.userAccessTime;
}



/**
 * Get the BuddyCategoryName for the user Class
 * @param {String} buddyCategoryName
 * @return buddyCategoryName
*/
function getBuddyCategoryName( )
{
	return this.buddyCategoryName;
}
/**
 * Get the BuddyCategoryId for the user Class
 * @param {Integer} buddyCategoryId
 * @return buddyCategoryId
*/
function getBuddyCategoryId( )
{
	return this.buddyCategoryId;
}
/**
 * Get the BuddyCategoryStatus for the user Class
 * @param {String} buddyStatus
 * @return buddyStatus
*/
function getBuddyStatus()
{
	return this.buddyStatus ;
}

/**
 * Get the UserId for the user Class
 * @param {Integer} userId
 * @return userId
*/
function getUserId( )
{
	return this.userId;
}
/**
 * Get the User Login Id for the user Class
 * @param {String} UserLoginId
 * @return UserLoginId
*/
function getUserLoginId( )
{
	return this.userLoginId;
}
/**
 * Get the First Name for the user Class
 * @param {String} firstName
 * @return  firstName
*/
function getFirstName( )
{
	return this.firstName;
}
/**
 * Get the Middle Name for the user Class
 * @param {String} middleName
 * @return  middleName
*/
function getMiddleName( )
{
	return this.middleName;
}
/**
 * Get the Last Name for the user Class
 * @param {String} lastName
 * @return  lastName
*/
function getLastName( )
{
	return this.lastName;
}
/**
 * Get the Gender for the user Class
 * @param {String} gender
 * @return  gender
*/
function getGender( )
{
	return this.gender;
}
/**
 * Get the Fax for the user Class
 * @param {String} fax
 * @return  fax
 */
function getFax( )
{
	return this.fax;
}
/**
 * Get the Date Of Birth for the user Class
 * @param {String} dob
 * @return  dob
*/
function getDob( )
{
	return this.dob;
}

/**
 * Get the Type for the user Class
 * @param {String} type
 * @return  type
*/
function getType( )
{
	return this.type;
}
/**
 * Get the Email ID for the user Class
 * @param {String} EmailId
 * @return  emailId
*/
function getEmailId( )
{
	return this.emailId;
}
/**
 * Get the Group Id for the user Class
 * @param {String} GroupId
 * @return  groupId
*/
function getGroupId( )
{
	return this.groupId;
}
/**
 * Get the Group Name for the User Class
 * @param {String} Group Name
 * @return  name
*/
function getName( )
{
	return this.name;
}
/**
 * Get the Contact Number for the user Class
 * @param {String} Contact Number
 * @return  contactNo
*/
function getContactNo( )
{
	return this.contactNo;
}
/**
 * Get the Status for the user Class
 * @param {String} status
 * @return  status
*/
function getStatus( )
{
	return this.status;
}
/**
 * Get the Street Addreses1 for the user Class
 * @param {String} streetAddreses1
 * @return  streetAddreses1
*/

function getStreetAddress1( )
{
	return this.streetAddress1;
}
/**
 * Get the Street Address2 for the user Class
 * @param {String} streetAddress2
 * @return  streetAddress2
*/
function getStreetAddress2( )
{
	return this.streetAddress2;
}
/**
 * Get the City for the user Class
 * @param {String} city
 * @return  city
*/
function getCity( )
{
	return this.city;
}
/**
 * Get the State for the user Class
 * @param {String} state
 * @return  state
*/
function getState( )
{
	return this.state;
}
/**
 * Get the Country for the user Class
 * @param {String} Country
 * @return  country
*/
function getCountry( )
{
	return this.country;
}
/**
 * Get the zip Code for the user Class
 * @param {String} zipCode
 * @return  zipCode
*/
function getZipCode( )
{
	return this.zipCode;
}
/**
 * Get the BuddyCategoryName for the user Class
 * @param {String} buddyCategoryName
 * @return buddyCategoryName
*/

function getBuddyCategoryName( )
{
	return this.buddyCategoryName;
}
/**
* Get the Array Paginatione for the user Class
* @param {Array} arrPagination
* @return  arrPagination
*/
function getArrPagination( )
{
	return this.arrPagination;
}
/**
 * Set the Question for the user Class
 * @param {Object} question
 * @return {void}
 */
function getQuestion( question )
{
		return this.question ;
}
function getQuestionId( questionId )
{
		return this.questionId ;
}
/**
 * Set the Answer for the user Class
 * @param {Object} answer
 * @return {void}
 */
function getAnswer( answer )
{
		return this.answer;
}


/**
* This method will create a new user into the system, new created user will have the default status as active.
* His login credentials will have the password set as espre by default. This method will send a request to the server and insert the records in db (TableName Users and userdetails)
* Usage: This method can be invoked through Controller in the following way.
* var cont = new Controller(createUser,"UserWidget",paramList); //paramList: contains the values of attributes which will be set in current (this) Object
* var paramList='userId:abcUser,firstName:abcFirstName,lastName:abcLastName,gender:male,fax:123,dob:01-10-1980,emailId:abc@abc.com,contactNo:123,streetAddress1:abc,streetAddress2:xyz,city:xyz,state:xyz,country:india,zipCode:1234';
* @param paramList
* @return: True: Record updated successfully in the db (tableName: users,userdetail).
* @exception In case the execution of method fails, an Exception of type Error will be raised with the proper message.
*/
function createUser(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
	//alert(UserWidget.prototype.response);
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
/**
* This method is responsible to update the status of user as activate.
* It will send a request to the server which will update the status (Inactivate to activate) of existing user in the db (tableName: users)
* on the basis of userId. The attribute userId of the current object (this) will be used via assessors (getters) to activate the User status in db table (tableName: users).
* ServerAction: activateUser
* Usage: This method can be invoked through Controller in the following way.
* var paramList = 'userId: 1';
* var cont = new Controller(activateUser,'UserWidget',paramList);
* paramList : contains the values of attributes which will be set in current (this) Object
* param: {Integer} userId
* @return: Boolean (True) Record Updated successfully in the db (tableName: users).
* @exception In case the execution of method fails, an Exception of type Error will be raised with the proper message.
*/
function activateUser(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
/**
* This method will update the status of the existing user from activate to the deactivate, a deactivate user couldnot able to login into the system.
* This method will send a request to the sever and update the status attribute of the db (tableName : users)
* Usage: This method can be invoked through Controller in the following way.
* var cont = new Controller(deactivateUser,'UserWidget',paramList);//paramList: contains the values of attributes which will be set in current (this) Object
* Parameters: paramList= 'userid:value';
* @param: paramList
* @return: It will return an array consisting users whose status is active.
* @exception: In case the execution of method fails, an Exception of type Error will be raised with the proper message.
*/
function deactivateUser(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
/**
 * This method is responsible to remove users from system DB (tableName : users)
 * This method will send a request to the server and delete the records from the db for the particular user
 * Method will also convert the result XML from the server in JSON entity array, Values from this array can be
 * fetched using the getters Method of the attribute.Response key of the Array will be true (executes as expected)
 * or false (Error / Exception accured), depending on the manipulation on the server.
 * @serverAction deleteUser
 * @param {Object} paramList
 * @return JSON
 */
function removeUser(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
/**
* This method is responsible to update user information for a particular user.
* It will send a request to the server which will update a existing record in the db (tableName : users, userdetail)
* on the basis of userId. The attributes of the current object (this) will be used via assessors (getters) to
* update the Column values in db table (tableName : users, userdetail).
* @serverAction: updateUser
* @param: paramList : contains the values of attributes which will be set in current (this) Object
* @return: True : Record Updated Succesfully in the db (tableName : users, userdetail).
* @exception:In case the execution of method fails, an Exception of type Error will be raised with the proper message.
*/
function updateUser(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
/**
* This method is responsible to sign in the user. This method will send a request to the server and
* create the session for the particular user Method will also convert the result XML
* from the server in JSON entity array, Values from this array can be fetched using
* the getters Method of the attribute.Response key of the Array will be true (executes as expected)
* or false (Error / Exception accured), depending on the manipulation on the server.
* @param: paramList
* @return: True : Record open the session Succesfully in the db (tableName : users).
* @throw: In case the execution of method fails, an Exception of type Error will be raised with the proper message
*/
function getUserSignIn(paramList){
	//alert(paramList);
	this.util.setContent(paramList);
	this.util.sendRequest();
	//alert(UserWidget.prototype.response);
	//document.write(UserWidget.prototype.response);
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
/**
* This method is responsible to sign out the user This method will send a request to the server and
* close the session for the particular user to avoid any further manipulation.
* @serverAction: getUserSignOut
* @param: paramList
* @return: True : Record closed the session Succesfully in the db (tableName : users).
* @exception: In case the execution of method fails, an Exception of type Error will be raised with the proper message
*/
function getUserSignOut(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
/**
* This method is used to change the existing password of the user to the New specified password.
* For changing the password user has to remember his existing password. This method will send the request to the server and update the corresponding record in the db(tableName : users)
* Usage: This method can be invoked through Controller in the following way.
* var paramList -  'userId:value,oldpassword:value,newPassword:value';
* var cont = new Controller(changePassword,'UserWidget',paramList); paramList : contains the values of attributes which will be set in current (this) Object
* @serverAction: changePassword
* @param :paramList -  'userId:value,oldpassword:value,newPassword:value';
* @return :Boolean
*/
function changePassword(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
/**
* This method is responsible for retrieving the forget password of the user on the basis of unique email Id
* for a particular user. This method will send a request to the server and fetch the password from
* DB (tableName: user). Fetched password will send as an email on that unique emailId.
* The attribute password of the current object (this) will be used via assessors (getters) to search the
* Column Values in db table (tableName: users).
* @serverAction: forgotPassword
* @return: True: Record inserted successfully in the db (tableName: users).
* @exception:In case the execution of method fails, an Exception of type Error will be raised with the proper message.
*/
function forgotPassword(paramList){

	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);

	return resultArray;
}


/**
* This method is responsible for getting the information of Sign In User.
* It will send a request to the server which will fetch the user information from the db (tableName: users and userdetail)
* on the basis of userId. The attribute userId of the current object (this) will be used via assessors (getters)
* to search the Column Values in db table (tableName: users and userdetail).
* @serverAction: getLoggedInUserInfo
* @param : paramList : contains the values of attributes which will be set in current (this) Object
* @return: It will return an array consisting UserWidget class object.
* @exception: In case the execution of method fails, an Exception of type Error will be raised with the proper message
*/
function getLoggedInUserInfo(paramList){
	//alert("getLoggedInUserInfo" + paramList);
	this.util.setContent(paramList);
	this.util.sendRequest();
	//alert("data="+UserWidget.prototype.response);
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}

/**
* This method is responsible to fetch all the un assigned groups of the particular users.
* It will send a request to the server which will search the groups in the db (tableName: usergroupsrelation and buddygroup)
* on the basis of userId. The attribute userId of the current object (this) will be used via assessors (getters) to search the
* Column Values in db table (tableName: usergroupsrelation and buddygroup).
* @serverAction: getUnAssignedGroups
* @param: paramList : contains the values of attributes which will be set in current (this) Object
* @return: It will return an array consisting UserWidget class object.
* @exception: In case the execution of method fails, an Exception of type Error will be raised with the proper message
*/
function getUnAssignedGroups(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	return resultInJSON;
}
/**
 * This method is responsible to fetch all the assigned groups of the particular users.
 * It will send a request to the server which will search the groups in the db (tableName: usergroupsrelation and buddygroup) on the basis of userId.
 * The attribute userId of the current object (this) will be used via assessors
 * (getters) to search the Column Values in db table (tableName: usergroupsrelation and buddygroup)
 * Method will also convert the result XML from the server in JSON entity array, Values from this array can be
 * fetched using the getters Method of the attribute.Response key of the Array will be true (executes as expected)
 * or false (Error / Exception accured), depending on the manipulation on the server.
 * @serverAction getAssignedGroups
 * @return  type Array, containing Groups assigned this user
 */
function getAssignedGroups(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	return resultInJSON;
}

/**
 * Method used for SEARCH the records from the DB (tableName : user and userdetails)
 * This method will send a request to the server and fetch all the messages from the db for the all users
 * Method will also convert the result XML from the server in JSON entity array, Values from this array can be
 * fetched using the getters Method of the attribute.Response key of the Array will be true (executes as expected)
 * or false (Error / Exception accured), depending on the manipulation on the server.
 * @serverAction findAllUsers
 * @param {Object} paramList
 * @return JSON
 */

 /*commented by meutil team*/
//function findAllUsers(paramList){
//	this.util.setContent(paramList);
//	this.util.sendRequest();
//	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
//	var resultArray = jsonToResultUser(resultInJSON);
//	return resultArray;
//}

/**
* This method is responsible for fetching all users on the basis of their status set as Activated.
* It will send a request to the server which will search all the active users in the db (tableName: users and userdetail) on the basis of their Active status.
* The attribute Active status of the current object (this) will be used via assessors (getters) to search the Column Values in db table (tableName : users and userdetail).
* Usage: This method can be invoked through Controller in the following way.
* var cont = new Controller ('findAllActiveUsers','UserWidgets',paramList);//paramList : contains the values of attributes which will be set in current (this) Object
* @ServerAction: findAllActiveUsers
* Parameters:paramList= 'startFrom:value, fetchSize;value';
* @param: paramList
* @return:It will return an array consisting users whose status is active.
* @exception: In case the execution of method fails, an Exception of type Error will be raised with the proper message.
*/
function findAllActiveUsers(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
	//alert(UserWidget.prototype.response);
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	this.arrPagination = resultXMLToArray(resultInJSON, 'Pagination');
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
/**
* This Method is responsible to fetch all the existing users  in the database.
* This method will send a request to the server which will search all the users in the db (tableName: users and userdetail).
* The attribute Active status of the current object (this) will be used via assessors (getters) to search the Column
* values in db table (tableName : users and userdetail).
* @serverAction: findAllUsers
* @param: paramList
* @return:It will return an array consisting users.
* @exception: In case the execution of method fails, an Exception of type Error will be raised with the proper message.
*/

function findAllUsers(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	this.arrPagination = resultXMLToArray(resultInJSON, 'Pagination');
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}


/**
* This Method is responsible to fetch all buddies (Added the buddy list of user) to populate the buddy List of a particular user.
* This method will send a request to the server which will search all the added users in the buddy List of the particular user
* from the db (tableName: userbuddyrelation) on the basis of userId (user for whon all the buddies has to search).
* The attribute userId of the current object (this) will be used via assessors (getters) to search the all the buddyUsers Values
* in db table (tableName : userbuddyrelation).
* @serverAction: findAllBuddyUsers
* @param :paramList : contains the values of attributes which will be set in current (this) Object
* @return: It will return an array consisting buddy users of the particular user.
* @exception:In case the execution of method fails, an Exception of type Error will be raised with the proper message.
*/
function findAllBuddyUsers(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}

/**
* This method is responsible to add new Buddy User to the Buddy List for a particular user.
* The status of new buddy will be displayed as “Add to pending” in the buddy list until he/she doesn’t accept the invitations.
* This method will send a request to the server along with the user name which will be added to buddy list in the db (tableName: userbuddyrelation) on the basis of buddyUserId and Buddy category name. (tableName : userbuddyrelation).
* @ServerAction: addBuddyUsers
* Usage: This method can be invoked through Controller in the following way.
* var paramList = " userName:'abcUser', buddyCategoryId:'2'";
* var cont = new Controller(addBuddyUsers,'UserWidget',paramList); paramList : contains the values of attributes which will be set in current (this) Object
* @param {Object} paramList
* @return: True: Record Updated successfully in the db (tableName: users).
*/
function addBuddyUsers(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
/**
* This method is responsible to move buddy  user from one Buddy Group to another buddy Group.
* It will send a request to the server and update/delete record in the db (tableName : userbuddyrelation)
* on the basis of userId and buddyGroupId.
* @serverAction: moveBuddyUser
* Usage: This method can be invoked through Controller in the following way.
* var paramList = "userId:'1',buddyId:'3',buddyCategoryId:'1'";
* var cont = new Controller("moveBuddyUser","UserWidget",paramList);
* paramList : contains the values of attributes which will be set in current (this) Object
* @param:paramList
* @return: True : Record moved Succesfully in the db (tableName : userbuddyrelation).
* @exception:- In case the execution of method fails, an Exception of type Error will be raised with the proper message.
*/
function moveBuddyUser(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
	//alert(UserWidget.prototype.response);
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
/**
* This method is responsible to remove users from the particular buddy list of user.
* It will send a request to the server which will delete record in the db (tableName : userbuddyrelation)
* on the basis of userId and buddyId.
* @serverAction: removeUserToBuddyList
* @param: paramList
* return: True : Record removed Succesfully in the db (tableName : userbuddyrelation).
* @exception: In case the execution of method fails, an Exception of type Error will be raised with the proper message.
*/
function removeUserToBuddyList(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}

/**
* This method is responsible to fetch the users on the basis of userId.
* It will send a request to the server which will search the user in the db (tableName: users and userdetail)
* on the basis of userId. The attribute status of the current object (this) will be used via assessors (getters)
* to search the Column Values in db table (tableName: users and userdetail).
* @serverAction: findByUserId
* @param: paramList
* @return: It will return an array consisting UserWidget class object.
* @exeption:In case the execution of method fails, an Exception of type Error will be raised with the proper message
*/
function findByUserId(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
	//alert(UserWidget.prototype.response);
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
 /**
* This method is responsible to fetch the users on the basis of userLoginId.
* It will send a request to the server which will search the user in the db (tableName: users and userdetail)
* on the basis of userLoginId. The attribute status of the current object (this) will be used via assessors (getters)
* to search the Column Values in db table (tableName: users and userdetail).
* @serverAction: findByUserLoginId
* @param: paramList : contains the values of attributes which will be set in current (this) Object
* @return: It will return an array consisting UserWidget class object.
* @exception:In case the execution of method fails, an Exception of type Error will be raised with the proper message
*/
function findByUserLoginId(paramList){
 	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
/**
* This Method is responsible to fetch the users on the basis of their First Name.
* It will send a request to the server which will search the user in the db (tableName: users and userdetail) on the basis of their first name.
* The attribute first name of the current object (this) will be used via assessors (getters) to search the Column Values in db table (tableName : users and userdetail).
* @serverAction: findByFirstName
* @param: paramList
* @return: It will return an array consisting UserWidget class object.
* @exception :In case the execution of method fails, an Exception of type Error will be raised with the proper message
*/
function findByFirstName(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	this.arrPagination = resultXMLToArray(resultInJSON, 'Pagination');
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
/**
* This method is responsible to fetch the users on the basis of their Last Name.
* It will send a request to the server which will search the user in the db (tableName: users and userdetail)
* on the basis of their last name. The attribute last name of the current object (this) will be used via assessors
* (getters) to search the Column Values in db table (tableName : users and userdetail).
* @serverAction: findByLastName
* @param: paramList
* @return: It will return an array consisting UserWidget class object.
* @exception: In case the execution of method fails, an Exception of type Error will be raised with the proper message
*/
function findByLastName(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	this.arrPagination = resultXMLToArray(resultInJSON, 'Pagination');
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
/**
* This method is responsible to fetch the users on the basis of their Gender.
* It will send a request to the server which will search the user in the db (tableName: users and userdetail)
* on the basis of Gender. The attribute Gender of the current object (this) will be used via assessors (getters)
* to search the Column Values in db table (tableName : users and userdetail).
* @serverAction: findByGender
* @param :paramList
* @return:It will return an array consisting UserWidget class object.
* @throw:In case the execution of method fails, an Exception of type Error will be raised with the proper message
*/
function findByGender(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
 /**
* This method is responsible to fetch the users on the basis of the email Id.
* It will send a request to the server which will search the user in the db (tableName: users and userdetail) on the basis of their email Id.
* The attribute email Id of the current object (this) will be used via assessors (getters) to search the Column Values in db table (tableName : users and userdetail).
* @serverAction: findByEmailId
* @param: paramList
* @return: It will return an array consisting UserWidget class object.
* @exceptin: In case the execution of method fails, an Exception of type Error will be raised with the proper message
*/
function findByEmailId(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	this.arrPagination = resultXMLToArray(resultInJSON, 'Pagination');

	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
 /**
 * This method is responsible to fetch all buddy groups exist in the database.
 * It will send a request to the server which will fetch all the buddy groups in the db (tableName: buddygroup).
 * @ServerAction: findAllBuddyGroup
 * @pamram: paramList
 * @return:It will return an array consisting of buddy group names along with their buddy group id.
 * @exception :In case the execution of method fails, an Exception of type Error will be raised with the proper message.
 */
function findAllBuddyGroups(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
	//alert("sendRequest===="+UserWidget.prototype.response);
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}


/**
* This method is responsible to fetch the users on the basis of Status.
* It will send a request to the server which will search the user in the db (tableName: users and userdetail)
* on the basis of status. The attribute status of the current object (this) will be used via assessors (getters)
* to search the Column Values in db table (tableName : users and userdetail).
* @serverAction: findByStatus
* @param : paramList : contains the values of attributes which will be set in current (this) Object
* @return :It will return an array consisting UserWidget class object.
* throws:In case the execution of method fails, an Exception of type Error will be raised with the proper message
*/
function findByStatus(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
/**
* This method is responsible to fetch the users on the basis of the city.
* It will send a request to the server which will search all the users in the db (tableName: users and userdetail) on the basis of the city.
* The attribute city name of the current object (this) will be used via assessors (getters) to search the Column Values in db table (tableName : users and userdetail).
* @serverAction: findByCity
* @param: paramList
* @return: It will return an array consisting UserWidget class object.
* @exceptin:In case the execution of method fails, an Exception of type Error will be raised with the proper message
*/
function findByCity(paramList){
    this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	this.arrPagination = resultXMLToArray(resultInJSON, 'Pagination');
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
/**
* This method is responsible to fetch the users on the basis of their State.
* It will send a request to the server which will search the user in the db (tableName: users and userdetail)
* on the basis of state. The attribute state of the current object (this) will be used via assessors (getters)
* to search the Column Values in db table (tableName : users and userdetail).
* @serverAction: findByState
* @param :paramList
* @return:It will return an array consisting UserWidget class object.
* @throw: In case the execution of method fails, an Exception of type Error will be raised with the proper message
*/
function findByState(paramList){
 	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
/**
* This method is responsible to fetch the users on the basis of the country name.
* It will send a request to the server which will search all the users in the db (tableName: users and userdetail) on the basis of the country.
* The attribute country name of the current object (this) will be used via assessors (getters) to search the Column Values in db table (tableName : users and userdetail).
* @serverAction: findByCountry
* @param:paramList
* @return:It will return an array consisting UserWidget class object.
* @exception:In case the execution of method fails, an Exception of type Error will be raised with the proper message
*/
function findByCountry(paramList){
    this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
/**
* This method is responsible to fetch the users on the basis of zipCode.
* It will send a request to the server which will search the user in the db (tableName: users and userdetail)
* on the basis of zipCode. The attribute zipCode of the current object (this) will be used via assessors (getters)
* to search the Column Values in db table (tableName: users and userdetail).
* @serverAction: findByZipCode
* @param: paramList : contains the values of attributes which will be set in current (this) Object
* @return: It will return an array consisting UserWidget class object.
* @exception: In case the execution of This method fails, an Exception of type Error will be raised with the proper message
*/
function findByZipCode(paramList){
   	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
/**
 * This method used for Add and Remove group to the particular user
 * This This method will send a request to the server and Add/Remove all the Groups from the db for the particular Users
 * This method will also convert the result XML from the server in JSON entity array, Values from this array can be
 * fetched using the getters Method of the attribute.Response key of the Array will be true (executes as expected)
 * or false (Error / Exception accured), depending on the manipulation on the server.
 * @serverAction addRemoveGroups
 * @param {Object} paramList
 * @return JSON
 */
function addRemoveGroups(paramList){
   	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}



/**
 * This method is responsible to add a new buddy group to a particular User for example Business, Friend
 * This method will send a request to the server and Add buddy Groups from the db for the particular Users
 * Method will also convert the result XML from the server in JSON entity array, Values from this array can be
 * fetched using the getters Method of the attribute.Response key of the Array will be true (executes as expected)
 * or false (Error / Exception accured), depending on the manipulation on the server.
 * @serverAction addBuddyGroup
 * @param {Object} paramList
 * @return JSON
 */
function addBuddyGroup(paramList)
{
    this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}

/**
 * TThis method is responsible to update the existing buddy group of a particular user (i.e. Business,Friends etc)
 * This method will send a request to the server and update the buddy groups name in the database a particular User.
 * Method will also convert the result XML from the server in JSON entity array, Values from this array can be
 * fetched using the getters Method of the attribute.Response key of the Array will be true (executes as expected)
 * or false (Error / Exception accured), depending on the manipulation on the server.
 * @serverAction editBuddyGroup
 * @param {Object} paramList
 * @return JSON
 */
function editBuddyGroup(paramList)
{
    this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
/*
function moveBuddyGroup(paramList)
{
    this.util.setContent(paramList);
	this.util.sendRequest();
	//alert(UserWidget.prototype.response);
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
*/
/**
 * This method is responsible to remove the existing buddy group  of a particular user  (i.e. Business,Friends etc).
 * This method will send a request to the server and remove buddy groups from the db for the particular Users.
 * Method will also convert the result XML from the server in JSON entity array, Values from this array can be
 * fetched using the getters Method of the attribute.Response key of the Array will be true (executes as expected)
 * or false (Error / Exception accured), depending on the manipulation on the server.
 * @serverAction removeBuddyGroup
 * @param {Object} paramList ( userId, buddyCategoryId )
 * @return JSON
 */
function removeBuddyGroup(paramList)
{
    this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}

/*
function subscribeForStatus(paramList)
{
	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}

function unsubscribeForStatus(paramList)
{
	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}	*/

/**
 * This method is responsible to fetch all invitations send by other users to add in his/her buddy list.
 * This method will send a request to the server and fetch all “pending” invitations from the database (userbuddyrelation) for the particular Users.
 * Method will also convert the result XML from the server in JSON entity array, Values from this array can be
 * fetched using the getters Method of the attribute.Response key of the Array will be true (executes as expected)
 * or false (Error / Exception accured), depending on the manipulation on the server.
 * @serverAction getInvitedBuddyList
 * @param {Object} paramList
 * @return JSON
 */
function getInvitedBuddyList(paramList)
{
	externalCallback=paramList.callBackMethod;
	this.util.setContent(paramList);
	this.util.setLoad('getInvitedBuddyList_CallBackFunction');
	//this.util.sendPollRequest_invitedBuddyList();
 	this.util.sendPollRequest();
}
function getInvitedBuddyList_CallBackFunction(type, data, evt)
{
	UserWidget.prototype.response = data;
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);

	//displayCallback_InvitedBuddyList(resultArray);
	eval(externalCallback+"(resultArray)");
	UserWidget.prototype.response = data;
}

/**
 * This method is responsible to accept invitation send by other user to add in his/her buddy list.
 * Once user accepts the invitation, the sender will add in the buddy list in both sides.
 * This method will send a request to the server and fetch invited users list from the db for the particular Users
 * Method will also convert the result XML from the server in JSON entity array, Values from this array can be
 * fetched using the getters Method of the attribute.Response key of the Array will be true (executes as expected)
 * or false (Error / Exception accured), depending on the manipulation on the server.
 * @serverAction acceptedBuddyInvitation
 * @param {Object} paramList
 * @return JSON
 */
function acceptedBuddyInvitation(paramList)
{
	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}

/**
 * This method is responsible to reject invitation send by other user to add in his/her buddy list.
 * If the user rejects invitation, the sender will not be added in the user buddy list and will remain exist on
 * The sender buddy list with status “Reject”.
 * This method will send a request to the server and update the record in the database (table: userbuddyrelation) for the particular users
 * Method will also convert the result XML from the server in JSON entity array, Values from this array can be
 * fetched using the getters Method of the attribute.Response key of the Array will be true (executes as expected)
 * or false (Error / Exception accured), depending on the manipulation on the server.
 * @serverAction rejectedBuddyInvitation
 * @param {Object} paramList
 * @return JSON
 */
function rejectedBuddyInvitation(paramList)
{
	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}

/**
 * This method fetches all buddies list, who has accepted the invitation sent by a particular user.
 * This method will send a request to the server and fetch the records from the database (table: userbuddyrelation) for the particular users
 * Method will also convert the result XML from the server in JSON entity array, Values from this array can be
 * fetched using the getters Method of the attribute.Response key of the Array will be true (executes as expected)
 * or false (Error / Exception accured), depending on the manipulation on the server.
 * @serverAction rejectedBuddyInvitation
 * @param {Object} paramList (userid)
 * @return JSON
 */
function getSentInvitationStatus(paramList)
{
	externalCallbackInvite=paramList.callBackMethod;
  	this.util.setContent(paramList);
  	this.util.setLoad('getSentInvitationStatusCallBackFunction');
 	//this.util.sendPollRequest_getSentInvitationStatus();
 	this.util.sendPollRequest();
}


/*
 * Callback Method for getSentInvitationStatus
 */
function getSentInvitationStatusCallBackFunction(type, data, evt)
{
	UserWidget.prototype.response = data;
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	displayCallback_SentInvitations(resultArray);
}

/**
 * This method will update the field IsUserNotified to 1 in userbuddyrelation user table.
 * This method will send a request to the server and updaet the records in the database (table: userbuddyrelation) for the particular users
 * Method will also convert the result XML from the server in JSON entity array, Values from this array can be
 * fetched using the getters Method of the attribute.Response key of the Array will be true (executes as expected)
 * or false (Error / Exception accured), depending on the manipulation on the server.
 * @serverAction rejectedBuddyInvitation
 * @param {Object} paramList
 * @return JSON
 */
function setUserNotificationFlagToOne(paramList)
{
	this.util.setContent(paramList);
	this.util.sendRequest();
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}


function getAllSecretQuestion(paramList)
{
	this.util.setContent(paramList);
	this.util.sendRequest();
	//alert(UserWidget.prototype.response);
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}


/**
* prepares result in the form of boolean or array of user entity objects.
* @param object objJson
* @return boolean/Array of User objects
*/
function jsonToResultUser( objJson ){
	if(typeof(objJson) == "undefined")
		return;
	var userArray = new Array();             // User Objects array to be returned
	var objResult = objJson.RESPONSE.Result; // Assign result reference of objJson

	if(objResult == "true")
		return true;
	else if(objResult == "false")
		return false;
	else if (objResult == null || !objResult.User){  //no user is returned
		return userArray;
	}
	/* populate User Object array from json */
	var noOfUsers = objResult.User.length; // find the no of users

	/* if only one user is in result Json, treat it seperate */
	if (isNaN(noOfUsers))
	{
		noOfUsers = 1;
		var arrObjTemp = new Array();
		arrObjTemp[0] = objResult.User;
		objResult.User = arrObjTemp;
	}
	/* if more than one users are in result Json */
	for (var loopIndex = 0; loopIndex < noOfUsers; loopIndex++)
	{
		var objJsonUser = objResult.User[loopIndex];
		var objUser = new UserWidget();
		objUser.setUserId(objJsonUser.userId);
		objUser.setUserLoginId(objJsonUser.userLoginId);
		objUser.setType(objJsonUser.type);
		objUser.setFirstName(objJsonUser.firstName);
		objUser.setLastName(objJsonUser.lastName);
		objUser.setGender(objJsonUser.gender);
		objUser.setFax(objJsonUser.fax);
		objUser.setDob(objJsonUser.dob);
		objUser.setEmailId(objJsonUser.emailId);
		objUser.setContactNo(objJsonUser.contactNo);
		objUser.setGroupId(objJsonUser.groupId);
		objUser.setStatus(objJsonUser.status);
		objUser.setStreetAddress1(objJsonUser.streetAddress1);
		objUser.setStreetAddress2(objJsonUser.streetAddress2);
		objUser.setCity(objJsonUser.city);
		objUser.setState(objJsonUser.state);
		objUser.setCountry(objJsonUser.country);
		objUser.setZipCode(objJsonUser.zipCode);
        objUser.setBuddyCategoryId(objJsonUser.buddyCategoryId);
        objUser.setBuddyCategoryName(objJsonUser.buddyCategoryName);
        objUser.setBuddyStatus(objJsonUser.buddyStatus);

        objUser.setQuestion(objJsonUser.question);
        objUser.setQuestionId(objJsonUser.questionId);
        objUser.setAnswer(objJsonUser.answer);
		 objUser.setUserAccessTime(objJsonUser.userAccessTime);

		userArray[loopIndex] = objUser;
	}

	return userArray;
}
/**
* set the result of call back function.
* @param type , data, evt
* @return Array of respnse objects
*/
function setStatusCallBackFunction(type, data, evt){
	//alert(data);
	UserWidget.prototype.response = data;
}

function checkUserAccess(paramList)
{
    //alert("paramList of checkUserAccesss");
	externalCallback=paramList.callBackMethod;
	this.util.setContent(paramList);
	this.util.setLoad('checkAccessCallBackFunction');
	this.util.sendPollRequest();
}

function checkAccessCallBackFunction(type, data, evt)
{
    //alert("Alert= thsi is="+data);
	UserWidget.prototype.response = data;
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	//eval(externalCallback+"(resultArray)");
	UserWidget.prototype.response = data;
}
function checkUserAvailable(paramList){

    //alert("checkUserAvailable");
	this.util.setContent(paramList);
	this.util.sendRequest();
    //alert(UserWidget.prototype.response);
	var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
function checkForAlreadyLoginByUserId(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
  //alert(UserWidget.prototype.response);
    var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
function checkForAlreadyLoginByUserLoginId(paramList){
	//alert("ParamList");
	this.util.setContent(paramList);
	this.util.sendRequest();
	//alert(UserWidget.prototype.response);
    var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}
function checkIfAlreadyLogin(paramList){
	this.util.setContent(paramList);
	this.util.sendRequest();
	//alert(UserWidget.prototype.response);
       var resultInJSON = resultXMLToJson(UserWidget.prototype.response);
	var resultArray = jsonToResultUser(resultInJSON);
	return resultArray;
}