//$Id$
function Collaboration(){}

Collaboration.handleUserList = function(chid, list)
{
	//DumperAlert(list);
}

Collaboration.handleMessage = function(chid, uname, zuid, dname, msg)
{
	//dname = sender
	//alert("chid="+chid+" sender="+dname);
	//DumperAlert(msg);
}

Collaboration.handlePresence = function(chid, uname, zuid, dname, status)
{
	//dname = user
	//alert("chid="+chid+" user="+dname+" status="+status);
}


Collaboration.join = function(chid)
{
	WebMessanger.joinCollab(chid);
}

Collaboration.quit = function(chid)
{
	WebMessanger.quit(chid);
}

Collaboration.serverup = function()
{

}

Collaboration.serverdown = function()
{

}

Collaboration.handleZohoMessage = function(prd,msg,url,urlstring,category,sender,att,params)
{
    if(prd=="FM")
    {
	setTimeout(function(){showBubble(msg,category)},2)
	return true;
    }
    else
    {
	return false;
    }
}

Collaboration.handleCustomMessage = function(msg)
{

}

Collaboration.handleCrossProductMessage = function(prd, msg)
{

}

Collaboration.onConnect = function()
{

}

Collaboration.openURL= function(url,urlstring,attachments,prd)
{
    /*if(prd=="FM")
    {
	if(attachments["purpose"] == "eMailToAuthor")
	{
	    console.log(attachments);
	}
	return false;
    }*/
	return true;
}

Collaboration.handleCollabAdd=function(uname,dname,zuid,time,chid)
{
	/*
	uname=user Login Name
	dname=DisplayName
	time=time of the message in ms
	chid=chat ID
	*/
	//callback when a new user is added in a collaboration using addMember API with the info of the user who added this user in the collaboration
}

Collaboration.handleCollabDelete=function(uname,dname,zuid,time,chid)
{
	/*
	uname=user Login Name
	dname=DisplayName
	time=time of the message in ms
	chid=chat ID
	*/
	//callback when a new user is added in a collaboration using deleteMember API with the info of the user who deleted this user in the collaboration
}

Collaboration.handleUserAdd=function(chid,userObj)
{
	/*
	Structure of userobj
	userobj[0]["uname"] = username
	userobj[0]["status"] = zoho presence
	userobj[0]["name"] = Display Name
	userobj[0]["cstatus"] = collab status
	userobj[0]["pstatus"] = current product status
	....
	....
	....
	userobj[n]["uname"] = username
	userobj[n]["status"] = zoho presence
	userobj[n]["name"] = Display Name
	userobj[n]["cstatus"] = collab status
	userobj[n]["pstatus"] = current product status
	*/
	//callback for addMember API to the existing CollabUsers with the newly added userInfo as userObj
}

Collaboration.handleUserDeleted=function(chid,userObj)
{
	/*
	Structure of userobj
	userobj[0]["uname"] = username
	userobj[0]["status"] = zoho presence
	userobj[0]["name"] = Display Name
	userobj[0]["cstatus"] = collab status
	userobj[0]["pstatus"] = current product status
	....
	....
	....
	userobj[n]["uname"] = username
	userobj[n]["status"] = zoho presence
	userobj[n]["name"] = Display Name
	userobj[n]["cstatus"] = collab status
	userobj[n]["pstatus"] = current product status
	*/
	//callback for DeleteMember API to the existing CollabUsers with the deleted userInfo as userObj
}

Collaboration.handleIsOnline=function(statusobj)
{
	/*This is a callback function for the WebMessanger.isOnline function
		The statusobj in the following structure
		statusobj[uname1] = status1
		statusobj[uname2] = status2
	*/
	updateStatus(statusobj);
}

Collaboration.handleLogout=function(reason)
{
	setTimeout(function()
    {
        $.get('/cleardomain.do','',function(){window.location.href=window.location.href;})
    },5);
	 //wmsLogin.show(WebMessanger.uname);
}

Collaboration.goOffline=function()
{

}

Collaboration.handleChatNotifyMessage=function(chid,sender,msgObj)
{
}

Collaboration.getPageTitle=function()
{
    //Don't do any heavy operations here, just return a value of ur variable which holds the current updated Page Title (for ex) 5 Unread, Opened Tickets etc....
    // return false for default implementation by WMS Api
    return false;
}

Collaboration.handleWmsDisable=function(reason)
{
    setTimeout(function()
    {
        $.get('/cleardomain.do','',function(){window.location.href=window.location.href;})
    },5);
}

function WmsContactImpl(){}


WmsContactImpl.handlePresence=function(zuid,uname,dname,scode,statusmsg)
{
	//called for any status change to any of the Contacts
	//Update Forum UI with the changed Status
	/*0->OFFLINE
	1->ONLINE
	3->BUSY
	4->IDLE
	*/
    setTimeout(function(){
	updatePresence(zuid, uname, scode);
	//updatePresenceForSinglePost(zuid,uname,scode);
    },2)

}

WmsContactImpl.handleAddressBook=function()
{
}

WmsContactImpl.handleInvite=function(zuid,uname,dname)
{
    //called for the user when a contact request to add in chat
}

WmsContactImpl.notifyInvite=function(zuid,uname,dname)
{
    //notification callback for the user when he sends the invitation to add contact to all the services he logged in
}

WmsContactImpl.handleAccept=function(zuid,uname,dname,scode,statusmsg)
{
    //called for the user when a contact accepts his request to chat
}

WmsContactImpl.notifyAccept=function(zuid,uname,dname,scode,statusmsg)
{
    //notification callback when an user accepts an invitation sent by him to all the services he logged in
}

WmsContactImpl.handleReject=function(zuid,uname,dname)
{
    //called when an invited contacts for this user rejects the requets
}

WmsContactImpl.notifyRemove=function(zuid,uname,dname)
{
    //notification callback when an user removes/rejects a contact to all the services he logged in
}

WmsContactImpl.handleDelete=function(zuid,uname,dname)
{
    //called when a contact deletes this user from his contacts list
}

WmsContactImpl.handleContactUpdated=function()
{
}

WmsContactImpl.handleStatusMessage=function(status,scode)
{
	//callback for WebMessanger.getStatusMessage
}

WmsContactImpl.handeAllStatusMessages=function()
{
	//callback for WebMessanger.getAllStatusMessage
}

WmsContactImpl.handleHideContactsUI=function()
{
}

WmsContactImpl.handleShowContactsUI=function()
{
}

WmsContactImpl.handleGetContacts=function()
{
	//get Contacts from WMS Client APi and Populate the Status UI
	var dataOb = WmsContacts.getZohoContacts();
        if($('#topicListMainContainer').is(':visible') || $('#allForums_MainContentCont').is(':visible'))
        {
            setPresenceInTopicList(dataOb);
            if($('#singleForumHeaderView').is(':visible'))
            {
                var currForumId = $('#singleForumHeaderView').attr('forumId');
                setPresence(dataOb,"moderatorsChatList_"+currForumId);

            }
        }
        else if($('#SinglePostContainer').is(':visible'))
        {
            var forumTopicId = $('#SinglePostContainer').attr('forumtopicid');
            setPresenceInTopicList(dataOb,forumTopicId);
        }
        else if($('#myAreaParentContainer').is(':visible'))
        {
            if($('#recentActivityContent').is(':visible'))
            {
                setPresenceInMyArea(dataOb,"current_recentActivity_List");
                setPresence(dataOb,"followingUserDetails");
                setPresence(dataOb,"followersUserDetails");
            }
            else if($('#watchListInnerContent').is(':visible'))
            {
                setPresenceInMyArea(dataOb,"userChat_watchTopics");
            }
            else if($('#privateMsgInnerContent').is(':visible'))
            {
                setPresenceInMyArea(dataOb,"userChat_inbox");
            }
        }
        else if($('#userProfileMainContainer').is(':visible'))
        {   
            var $userProfileMainContainer = $('#userProfileMainContainer');
            var authorId = $userProfileMainContainer.attr("authorId");
            var authorName = $userProfileMainContainer.attr("authorName");
            if(typeof WmsContacts != "undefined" && ch == true)
            {
                var authStatus = WmsContacts.status(authorId);
                if(authStatus === false)
                {
                        authStatus = 9;
                }
                manageUserChatStatus("userOnlineStatus_"+authorName,authStatus,authorName);
            }
        }
}

WmsContactImpl.handleMPReject=function(protocol,contactname,loginname)
{
}

WmsContactImpl.handleMPAccept=function(protocol,contactname,loginname)
{
}

WmsContactImpl.handleMPDelete=function(protocol,contactname,loginname)
{
}

WmsContactImpl.handleMPAdd=function(protocol,contactname,loginname)
{
}

WmsContactImpl.handleMPInvite=function(protocol,contactname,loginname)
{
}

WmsContactImpl.handleLogin=function(loginname,status,statusmsg,protocol)
{
}

WmsContactImpl.handleLogout=function(loginname,status,statusmsg,protocol)
{
}

WmsContactImpl.handleGetAccounts=function(accountslist)
{
}

WmsContactImpl.handleInvitations=function(invitearr)
{
      //bulk invitations, array of zuids
}