
if(!this.PluginAPIMgr) {
	this.PluginAPIMgr = new Object();
}

PluginAPIMgr ={
    MoIPPlugin :null,
    CameraPlugin : null,
	sefPlugin : null,
	TvPlugin : null,	
	NTVPlugin : null,
	WindowPlugin : null,
	NNaviPlugin : null,
	CameraState : 0,
	AUIPlugin : null,
	RecognitionPlugin: null,
	ExWidgetInterfacePlugin:null,
	PreviewScreen : null,
	RecognitionPluginAvailable : true,
	IsStartedPreview : false
	//TempData : 0,
		
}

PluginAPIMgr.initPluginAPI=function()
{
    alert("##mini##***** PluginAPIMgr.initPluginAPI()");
    var HTMLSTRING ="";
    
	if(document.getElementById('EmpSkype')==null)
    	HTMLSTRING += "<OBJECT id='EmpSkype' border=0 classid='clsid:SAMSUNG-INFOLINK-SEF' style='opacity:0.0;background-color:#000000;width:0px;height:0px;'></OBJECT>";
	if(document.getElementById('EmpCamera')==null)
    	HTMLSTRING += "<OBJECT id='EmpCamera' border=0 classid='clsid:SAMSUNG-INFOLINK-SEF' style='opacity:0.0;background-color:#000000;width:0px;height:0px;'></OBJECT>";
    if(document.getElementById('sefTVPlugin')==null)
    	HTMLSTRING += "<OBJECT id='sefTVPlugin' border=0 classid='clsid:SAMSUNG-INFOLINK-SEF' style='opacity:0.0;background-color:#000000;width:0px;height:0px;'></OBJECT>";
    if(document.getElementById('PluginOjectSef')==null)
    	HTMLSTRING += "<OBJECT id='PluginOjectSef' border=0 classid='clsid:SAMSUNG-INFOLINK-SEF' style='opacity:0.0;background-color:#000000;width:0px;height:0px;'></OBJECT>";
    if(document.getElementById('sefWindowPlugin')==null)
    	HTMLSTRING += "<OBJECT id='sefWindowPlugin' border=0 classid='clsid:SAMSUNG-INFOLINK-SEF' style='opacity:0.0;background-color:#000000;width:0px;height:0px;'></OBJECT>";       	
    if(document.getElementById('pluginOjectSefNNavi')==null)
    	HTMLSTRING += "<OBJECT id='pluginOjectSefNNavi' border=0 classid='clsid:SAMSUNG-INFOLINK-SEF' style='opacity:0.0;background-color:#000000;width:0px;height:0px;'></OBJECT>";    	
    if(HTMLSTRING!="")
    	$("body").append(HTMLSTRING);
    	
    this.MoIPPlugin = document.getElementById('EmpSkype');	
	this.CameraPlugin = document.getElementById('EmpCamera');
	this.TvPlugin = document.getElementById('sefTVPlugin');
	this.NTVPlugin = document.getElementById('PluginOjectSef');	
	this.WindowPlugin = document.getElementById('sefWindowPlugin');
	this.NNaviPlugin = document.getElementById('pluginOjectSefNNavi');
	
	this.MoIPPlugin.Open("Skype", "1.000", "Skype");
	this.CameraPlugin.Open("Camera", "1.000", "Camera");
	this.TvPlugin.Open("TV","1.000","TV");
	this.NTVPlugin.Open("Screen","1.000","TV");
	this.WindowPlugin.Open("Window", "1.002", "Window");
	this.NNaviPlugin.Open("NNavi","1.009","NNavi");
}


PluginAPIMgr.closePluginAPI=function()
{
    alert("##mini##***** PluginAPIMgr.closePluginAPI()");

	this.MoIPPlugin.Close();	
	this.CameraPlugin.Close();
	this.TvPlugin.Close();
	this.NTVPlugin.Close();
	this.WindowPlugin.Close();
	this.NNaviPlugin.Close();
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////// <<<<< ExternalWidgetInterface  API >>>>> ////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

PluginAPIMgr.SetMyStorageInfo = function(info)
{
	alert("##mini##PluginAPIMgr.SetMyStorageInfo");
	
	var result = this.ExWidgetInterfacePlugin.Execute("WriteWidgetData", "SkypeInfo" , info, String(info.length));
	this.MoIPPlugin.Execute("BackupWidgetData"); 
}

PluginAPIMgr.GetMyStorageInfo = function()
{
	alert("##mini##PluginAPIMgr.GetMyStorageInfo");
	
	var result = this.ExWidgetInterfacePlugin.Execute("ReadWidgetData", "SkypeInfo");
	
	return result;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////// <<<<< Voice Recognition  API >>>>> ///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

PluginAPIMgr.GetCurrentVoiceLanguage = function()
{
	var msg = this.RecognitionPlugin.Execute("GetCurrentVoiceLanguage");
	alert("***** PluginAPIMgr.GetCurrentVoiceLanguage() " +msg);
	return msg;
}

PluginAPIMgr.GetOnlineContacts = function()
{
	alert("***** PluginAPIMgr.GetOnlineContacts() ");
	var msg = this.MoIPPlugin.Execute("GetOnlineContacts");
	
	return msg;
}
PluginAPIMgr.GetSkypeNameWithDisplayName = function (name) {
  	alert("***** PluginAPIMgr.GetSkypeNameWithDisplayName() ");
	var msg = this.MoIPPlugin.Execute("GetSkypeNameWithDisplayName", name);
	
	return msg;
}



///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////// <<<<< FACE Recognition  API >>>>> ////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
PluginAPIMgr.GetVersionOfFaceRecogPlugin = function() 
{
	var msg =this.RecognitionPlugin.Execute("GetEngineVersion");
	alert("##mini##***** PluginAPIMgr.GetVersionOfFaceRecogPlugin() : "+ msg);	
	return parseFloat(msg);
}

PluginAPIMgr.InitializeFace = function()
{
	alert("##mini##***** PluginAPIMgr.InitializeFace() ");
	
	this.RecognitionPlugin.Execute("InitializeFace", "Skype");
	
	this.MoIPPlugin.Execute("RestoreWidgetData");	
}

PluginAPIMgr.SubscribeFaceRecogEvent = function()
{
	alert("##mini##***** PluginAPIMgr.SubscribeFaceRecogEvent() ");
}

PluginAPIMgr.UnsubscribeFaceRecogEvent = function()
{
	alert("##mini##***** PluginAPIMgr.UnsubscribeFaceRecogEvent() ");
	
	this.RecognitionPlugin.Execute("UnsubscribeEvent", "MESSAGE_RECOGNITION_FACE", "Skype");
}

PluginAPIMgr.StartFaceRecognitionAll = function()
{
	alert("##mini##***** PluginAPIMgr.StartFaceRecognitionAll() ");
	
	this.RecognitionPlugin.Execute("StartFaceRecognitionAll");
}

PluginAPIMgr.StopFaceRecognition = function()
{
	alert("##mini##***** PluginAPIMgr.StopFaceRecognition() ");
	
	this.RecognitionPlugin.Execute("StopFaceRecognition");
}

PluginAPIMgr.StartFaceDetection = function()
{
	alert("##mini##***** PluginAPIMgr.StartFaceDetection() ");
	
	this.RecognitionPlugin.Execute("StartFaceDetection");
}

PluginAPIMgr.StopFaceDetection = function()
{
	alert("##mini##***** PluginAPIMgr.StopFaceDetection() ");
	
	this.RecognitionPlugin.Execute("StopFaceDetection");
}

PluginAPIMgr.StartFaceTraining = function(detect_info)
{
	alert("##mini##***** PluginAPIMgr.StartFaceTraining() ");
	
	this.RecognitionPlugin.Execute("StartFaceTraining", detect_info);
}

PluginAPIMgr.StopFaceTraining = function()
{
	alert("##mini##***** PluginAPIMgr.StopFaceTraining() ");
	
	this.RecognitionPlugin.Execute("StopFaceTraining");
}

PluginAPIMgr.EraseFace = function(id)
{
	alert("##mini##***** PluginAPIMgr.EraseFace() ");
	
	this.RecognitionPlugin.Execute("EraseFace", String(id));
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////// <<<<< CAMERA  API >>>>> ////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

PluginAPIMgr.SyncCameraState = function()
{	
	msg = this.CameraPlugin.Execute("GetCameraState");
	
	alert("##mini##***** PluginAPIMgr.SyncCameraState() -> return : " + msg);
	    
	this.CameraState = parseInt(msg);
}

PluginAPIMgr.GetCameraState = function()
{	
	alert("##mini##***** PluginAPIMgr.GetCameraState() -> return : " + this.CameraState);	   
	return this.CameraState;
}

PluginAPIMgr.SetCameraState = function(state)
{		   

	if (state > ENUM_CAM_STATE.CAM_STATE_PLAYING)
	{
		alert("##mini##input state error");	  
		return;
	}

	this.CameraState = state;
}

PluginAPIMgr.StartRecord = function()
{	
	//msg = this.CameraPlugin.StartRecord();
	alert("##mini##***** PluginAPIMgr.StartRecord() ");

}

PluginAPIMgr.StartPreview = function(startX,startY,width,height)
{
	alert("##mini##PluginAPIMgr.StartPreview");
	if(this.IsStartedPreview == false)
	{
		this.IsStartedPreview = true;
		this.CameraPlugin.Execute("SetUsecase","1");
		this.CameraPlugin.Execute("SetCamProperty","12","0");
		this.CameraPlugin.Execute("SetCamProperty","43","1");
		this.CameraPlugin.Execute("SetCamVideoDisplaySize",String(startX),String(startY),String(width),String(height));
		this.CameraPlugin.Execute("SetCamProperty","0","5000000");
		this.CameraPlugin.Execute("SetCamProperty","1","30");
		this.CameraPlugin.Execute("SetCamProperty","3","1280","720");
		this.CameraPlugin.Execute("StartCamVideo","1","2");		
	}
}

PluginAPIMgr.StartMyVideo = function(startX,startY,width,height)
{
	alert("##mini##PluginAPIMgr.StartMyVideo");		
	this.CameraPlugin.Execute("SetUsecase","0");
	this.CameraPlugin.Execute("SetCamVideoDisplaySize",String(startX),String(startY),String(width),String(height));	
	this.CameraPlugin.Execute("StartCamVideo","2","4");
	//this.CameraPlugin.Execute("SetCamProperty","2","1");
}

// PluginAPIMgr.StartPreview_1366x768 = function()
// {
	// alert("##mini##PluginAPIMgr.StartPreview");		
	// this.CameraPlugin.Execute("SetUsecase","1");
	// this.CameraPlugin.Execute("SetCamVideoDisplaySize","227","126","912","513");
	// this.CameraPlugin.Execute("SetCamProperty","0","5000000");
	// this.CameraPlugin.Execute("SetCamProperty","1","30");
	// this.CameraPlugin.Execute("SetCamProperty","3","1280","720");
	// this.CameraPlugin.Execute("StartCamVideo","1","2");
// }

 
PluginAPIMgr.StopPreview = function()
{
	if(this.IsStartedPreview == true)
	{
		alert("##mini##PluginAPIMgr.StopPreview");	
		this.CameraPlugin.Execute("StopCamVideo");
		this.CameraPlugin.Execute("SetUsecase","2");
		
		this.IsStartedPreview = false;
	}

}

PluginAPIMgr.Zoom = function(nlevel)
{
	this.CameraPlugin.Execute("SetCamProperty","7",String(nlevel), "0");
}

PluginAPIMgr.TakeSnapShot = function()
{
	alert("##mini##PluginAPIMgr.TakeSnapShot");
	this.CameraPlugin.Execute("CaptureCamVideo");
	this.CameraPlugin.Execute("PauseCamVideo");
}

PluginAPIMgr.isAutoFocusEnable = function()
{
	var msg = this.CameraPlugin.Execute("SetCamProperty","11","0");
	alert("##mini##PluginAPIMgr.isAutoFocusEnable : "+msg);
	return parseInt(msg);
};

PluginAPIMgr.StartCameraForFaceRecognition = function(startX,startY,width,height)
{
	alert("##mini##PluginAPIMgr.StartCameraForFaceRecognition");		
	//this.CameraPlugin.Execute("SetUsecase","0");
	this.CameraPlugin.Execute("SetCamProperty",ENUM_CAM_PROPERTY.CAM_PROPERTY_SIGNAL_TYPE,"0");
	this.CameraPlugin.Execute("SetCamProperty",ENUM_CAM_PROPERTY.CAM_PROPERTY_MIRROR,"0");
	this.CameraPlugin.Execute("SetCamProperty",ENUM_CAM_PROPERTY.CAM_PROPERTY_LOCAL_MIRROR,"1");
	this.CameraPlugin.Execute("SetCamVideoDisplaySize",String(startX),String(startY),String(width),String(height));
	this.CameraPlugin.Execute("SetCamProperty",ENUM_CAM_PROPERTY.CAM_PROPERTY_BITRATE,"5000000");
	this.CameraPlugin.Execute("SetCamProperty",ENUM_CAM_PROPERTY.CAM_PROPERTY_FRAMERATE,"30");
	this.CameraPlugin.Execute("SetCamProperty",ENUM_CAM_PROPERTY.CAM_PROPERTY_DIMENSION,"1280","720");
	this.CameraPlugin.Execute("StartCamVideo","1","2");
}

PluginAPIMgr.StopCameraForFaceRecognition = function()
{
	alert("##mini##PluginAPIMgr.StopCameraForFaceRecognition");
	this.CameraPlugin.Execute("StopCamVideo");
	this.CameraPlugin.Execute("SetCamProperty",ENUM_CAM_PROPERTY.CAM_PROPERTY_SIGNAL_TYPE,"1");
	//this.CameraPlugin.Execute("SetUsecase","2");	
}

PluginAPIMgr.isRecognitionEnable = function()
{
	var msg = this.CameraPlugin.Execute("GetCamCapability", ENUM_CAM_CAPABILITY.CAM_CAPABILITY_SIGNAL_TYPE);
	alert("##mini##PluginAPIMgr.isRecognitionEnable : "+msg);
	return parseInt(msg);
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////// <<<<< PIG API >>>>>//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

PluginAPIMgr.ChangeSource = function()
{
	alert("##mini##Start ChangeSource");
	this.sefPlugin.Execute("SetPreviousSource");
	alert("##mini##End ChangeSource");	
}

PluginAPIMgr.SetPIG = function(x, y, w, h)
{	
	alert("##mini##==== PluginAPIMgr.SetPIG(): x = "+x+", y = "+y+", w = "+w+", h = "+h);
	ret = this.sefPlugin.Execute("SetScreenRect", x, y, w, h);   
	alert("##mini##End SetPIG");
	return parseInt(ret);
}	

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///// AUI ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

PluginAPIMgr.PlayAudio=function(keyCode) 
{
	return;
	
	switch(keyCode)
	{
		case sf.key.UP:
			this.AUIPlugin.Execute("PlayAudio", ENUM_AUDIO_TYPE.AUDIO_TYPE_UP);
		break;
		case sf.key.DOWN:
			this.AUIPlugin.Execute("PlayAudio", ENUM_AUDIO_TYPE.AUDIO_TYPE_DOWN);
			break;
		case sf.key.LEFT:
			this.AUIPlugin.Execute("PlayAudio", ENUM_AUDIO_TYPE.AUDIO_TYPE_LEFT);
			break;
		case sf.key.RIGHT:
			this.AUIPlugin.Execute("PlayAudio", ENUM_AUDIO_TYPE.AUDIO_TYPE_RIGHT);
			break;
			
		case sf.key.ENTER:
             this.AUIPlugin.Execute("PlayAudio", ENUM_AUDIO_TYPE.AUDIO_TYPE_SELECT);
			break;
            
        case sf.key.RETURN:
			 this.AUIPlugin.Execute("PlayAudio", ENUM_AUDIO_TYPE.AUDIO_TYPE_BACK);
			break;
            
        case sf.key.EXIT:
            this.AUIPlugin.Execute("PlayAudio", ENUM_AUDIO_TYPE.AUDIO_TYPE_BACK);
			break;
	}
}

PluginAPIMgr.PlayAudioByIndex=function(Index) 
{
	return;
	
	if(Index > 0 && Index < ENUM_AUDIO_TYPE.AUDIO_TYPE_MAX)
	{
		this.AUIPlugin.Execute("PlayAudio", Index);
	}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///// Regognition ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

PluginAPIMgr.IsGestureRecognitionEnabled=function() 
{
	if(this.RecognitionPluginAvailable ==false)
	{
		return;
	}
	
	var result = this.RecognitionPlugin.Execute("IsGestureRecognitionEnabled");
	alert("##mini##***** PluginAPIMgr.IsGestureRecognitionEnabled()  : " + result);
	
	return parseInt(result);
}

PluginAPIMgr.EnableGestureRecognition=function() 
{
	if(this.RecognitionPluginAvailable ==false)
	{
		return;
	}
	
	alert("##mini##***** PluginAPIMgr.EnableFaceRecognition()   ");
	this.RecognitionPlugin.Execute("EnableGestureRecognition");
	
	//this.IsGestureRecognitionEnabled();
}

PluginAPIMgr.DisableGestureRecognition=function() 
{
	if(this.RecognitionPluginAvailable ==false)
	{
		return;
	}
	
	alert("##mini##***** PluginAPIMgr.DisableGestureRecognition()   ");
	this.RecognitionPlugin.Execute("DisableGestureRecognition");
	
	//this.IsGestureRecognitionEnabled();
}



///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////// <<<<< SKYPE API >>>>>///////////////////////////////////////////////////////////////////////////////////// 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

PluginAPIMgr.WidgetHandleIncomingCall = function(flag)
{
	alert("##mini##***** PluginAPIMgr.WidgetHandleIncomingCall()  : " + flag);
	
	if(this.MoIPPlugin != null)
	{
		msg = this.MoIPPlugin.Execute("WidgetHandleIncomingCall", String(flag));
    	return msg;
	}
}

PluginAPIMgr.GetSkypeWidgetMode = function()
{	
    alert("##mini##***** PluginAPIMgr.GetSkypeWidgetMode()");
	if(this.MoIPPlugin != null)
	{
		msg = this.MoIPPlugin.Execute("GetSkypeWidgetMode");
    	return msg;
	}
}


PluginAPIMgr.SetSkypeWidgetState = function(state)
{	
    alert("##mini##***** PluginAPIMgr.SetSkypeWidgetState()  : " + state);
	if(this.MoIPPlugin != null)
	{
		msg = this.MoIPPlugin.Execute("SetSkypeWidgetState", String(state));
    	return msg;
	}
}

PluginAPIMgr.GetSkypeState = function()
{	
	msg = this.MoIPPlugin.Execute("GetSkypeState"); 
	alert("##mini##***** PluginAPIMgr.GetSkypeState() -> return : " + msg);
	    
	return parseInt(msg);
}

PluginAPIMgr.IsSkypeSupportMultitasking = function()
{
	if(this.MoIPPlugin != null)
	{
		msg = this.MoIPPlugin.Execute("IsSkypeSupportMultitasking");
		alert("##mini##***** PluginAPIMgr.IsSkypeSupportMultitasking() : "+msg );
    	return parseInt(msg);
	}
}

PluginAPIMgr.ImgFolderExist = function()
{	
	msg = this.MoIPPlugin.Execute("ImgFolderExist"); 
	alert("##mini##***** PluginAPIMgr.ImgFolderExist() -> return : " + msg);
	    
	return parseInt(msg);
}


PluginAPIMgr.GetLoginState = function()
{	  
	msg = this.MoIPPlugin.Execute("GetLoginState");  
	alert("##mini##***** PluginAPIMgr.GetLoginState() -> return : " + msg);

    return msg;
}

PluginAPIMgr.GetTVModel = function()
{
	msg = this.MoIPPlugin.Execute("GetTVModel");
	alert("##mini##***** PluginAPIMgr.GetTVModel() -> return : " + msg);
	
	return msg;
}

PluginAPIMgr.SetRemoteInputType= function(type_enum)
{
	alert("##mini##***** PluginAPIMgr.SetRemoteInputType()  : " + type_enum);
	if(type_enum)
	{
		this.MoIPPlugin.Execute("SetRemoteInputType",type_enum);
	}
	else
	{
		this.MoIPPlugin.Execute("SetRemoteInputType");
	}
}

PluginAPIMgr.ShowConnectingWnd = function()
{
	this.MoIPPlugin.Execute("ShowConnectingWnd");
}

PluginAPIMgr.HideConnectingWnd = function()
{
	this.MoIPPlugin.Execute("HideConnectingWnd");
}

PluginAPIMgr.IsInCall = function()
{
	msg = this.MoIPPlugin.Execute("IsInCall");
	alert("##mini##***** PluginAPIMgr.IsInCall() -> return : " + msg);
	
	return parseInt(msg);
}

PluginAPIMgr.IsCallMemberVideoAvailable = function()
{
	msg = this.MoIPPlugin.Execute("IsCallMemberVideoAvailable");
	alert("##mini##***** PluginAPIMgr.IsCallMemberVideoAvailable() -> return : " + msg);
	
	return parseInt(msg);
}

PluginAPIMgr.IsWidgetActivatedByAnswer = function()
{
	msg = this.MoIPPlugin.Execute("IsWidgetActivatedByAnswer");
	alert("##mini##***** PluginAPIMgr.IsWidgetActivatedByAnswer() -> return : " + msg);
	
	return parseInt(msg);
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////  Login, Register, Logout  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

PluginAPIMgr.SetLoginMode = function(mode)
{	
    alert("##mini##***** PluginAPIMgr.SetLoginMode() : " +mode);

	msg = this.MoIPPlugin.Execute("SetLoginMode", String(mode));
}

PluginAPIMgr.GetLoginMode = function()
{
	msg = this.MoIPPlugin.Execute("GetLoginMode");		
	return parseInt(msg);
}

PluginAPIMgr.GetLastLoginID = function(Index)
{		
	msg = this.MoIPPlugin.Execute("GetLastLoginID",String(Index));		
	return msg;
}

PluginAPIMgr.IsAutoSignInSet = function()
{	
    msg = this.MoIPPlugin.Execute("IsAutoSignInSet");
    
     alert("##mini##***** PluginAPIMgr.IsAutoSignInSet()", msg );
     
     if(msg =="0")
     {
            return false;
     }
     else
     {
            return true;
     }     
}

PluginAPIMgr.IsAutoStartSet = function()
{
	msg = this.MoIPPlugin.Execute("GetAutoStart");
    alert("##mini##***** PluginAPIMgr.IsAutoSignInSet()", msg );
     if(msg =="0")
     {
            return false;
     }
     else
     {
            return true;
     } 
}


PluginAPIMgr.SetAutoSignIn = function(b_auto_signin)
{
    alert("##mini##***** PluginAPIMgr.SetAutoSignIn() : " + b_auto_signin)
    if(b_auto_signin==true)
    {
        msg =  this.MoIPPlugin.Execute("SetAutoSignIn", "1");
     }
     else
     {
        msg =  this.MoIPPlugin.Execute("SetAutoSignIn", "0");
     }
}

PluginAPIMgr.SetAutoStart = function(b_auto_start)
{
    alert("##mini##***** PluginAPIMgr.SetAutoStart() : " + b_auto_start)
    if(b_auto_start==true)
    {
        msg =  this.MoIPPlugin.Execute("SetAutoStart", "1");
     }
     else
     {
        msg =  this.MoIPPlugin.Execute("SetAutoStart", "0");
     }
}


PluginAPIMgr.IsDefaultAccountAvailable = function()
{
    msg =  this.MoIPPlugin.Execute("IsDefaultAccountAvailable");
    alert("##mini##***** PluginAPIMgr.IsDefaultAccountAvailable() : "+msg)
    return parseInt(msg);
}

PluginAPIMgr.AutoLogin = function()
{
    alert("##mini##***** PluginAPIMgr.AutoLogin()")
	msg =  this.MoIPPlugin.Execute("Login",PluginAPIMgr.GetLastLoginID(), "", "1" );    
    return msg;
}

PluginAPIMgr.Login = function()
{	
    alert("##mini##***** PluginAPIMgr.Login()" + g_Data.DATA_SIGNIN_INPUT_INFO.id +" : "+ g_Data.DATA_SIGNIN_INPUT_INFO.pwd);
   
	if(g_Data.DATA_SIGNIN_INPUT_INFO.save_pwd == true)
	{
		msg = this.MoIPPlugin.Execute("Login",g_Data.DATA_SIGNIN_INPUT_INFO.id, g_Data.DATA_SIGNIN_INPUT_INFO.pwd, "1");
	}
	else
	{
		msg = this.MoIPPlugin.Execute("Login",g_Data.DATA_SIGNIN_INPUT_INFO.id, g_Data.DATA_SIGNIN_INPUT_INFO.pwd, "0");
	}	
}

PluginAPIMgr.Register = function()
{	
    alert("##mini##***** PluginAPIMgr.Register()" + g_Data.DATA_CREATE_ACCOUNT_INPUT_INFO.id +" : "+ g_Data.DATA_CREATE_ACCOUNT_INPUT_INFO.pwd);
	var flag1 ="0";
	var flag2 ="0";
	
	if(g_Data.DATA_CREATE_ACCOUNT_INPUT_INFO.save_pwd == true )
	{
		flag1="1";	
	}
	
	if(g_Data.DATA_CREATE_ACCOUNT_INPUT_INFO.news == true)
	{
		flag2="1";
	}
	    
	msg = this.MoIPPlugin.Execute("Register",g_Data.DATA_CREATE_ACCOUNT_INPUT_INFO.id, g_Data.DATA_CREATE_ACCOUNT_INPUT_INFO.pwd, g_Data.DATA_CREATE_ACCOUNT_INPUT_INFO.email, flag1+flag2);
}

PluginAPIMgr.Logout = function(clearPwd)
{	
    alert("##mini##***** PluginAPIMgr.Logout() clearPwd : " +clearPwd);

	msg = this.MoIPPlugin.Execute("Logout", String(clearPwd));
}

PluginAPIMgr.GetLogoutReason = function()
{	
	msg = this.MoIPPlugin.Execute("GetLogoutReason");
    alert("##mini##***** PluginAPIMgr.GetLogoutReason() : "+ msg);
    return parseInt(msg);
}

PluginAPIMgr.NormalizeIdentityForNewAccount = function(s_id)
{
   	msg = this.MoIPPlugin.Execute("NormalizeIdentityForNewAccount",s_id);
    alert("##mini##***** PluginAPIMgr.NormalizeIdentityForNewAccount() : " + msg );
    return msg;
}

PluginAPIMgr.ValidatePasswd = function(s_id, s_pwd)
{
   	msg = this.MoIPPlugin.Execute("ValidatePasswd",s_id, s_pwd);
    alert("##mini##***** PluginAPIMgr.ValidatePasswd() : " + msg );
    return parseInt(msg);
}

PluginAPIMgr.ValidatePasswdWithoutID = function(s_pwd)
{
   	msg = this.MoIPPlugin.Execute("ValidatePasswdWithoutID", s_pwd);
    alert("##mini##***** PluginAPIMgr.ValidatePasswdWithoutID() : " + msg );
    return parseInt(msg);
}

PluginAPIMgr.IsValidEmail = function(s_email)
{
	msg = this.MoIPPlugin.Execute("IsValidEmail",s_email);
    alert("##mini##***** PluginAPIMgr.IsValidEmail() : " + msg );
    return parseInt(msg);
}

PluginAPIMgr.GetSuggestedSkypeNameList = function()
{
    return this.MoIPPlugin.Execute("GetSuggestedSkypeNameList");

}

PluginAPIMgr.SetCameraCheckDisable = function(b_auto_start)
{
    alert("##mini##***** PluginAPIMgr.SetCameraCheckDisable() : " + b_auto_start)
    if(b_auto_start==true)
    {
        msg =  this.MoIPPlugin.Execute("SetCameraCheckDisable", "1");
     }
     else
     {
        msg =  this.MoIPPlugin.Execute("SetCameraCheckDisable", "0");
     }
}

PluginAPIMgr.GetCameraCheckDisable = function()
{
	msg = this.MoIPPlugin.Execute("GetCameraCheckDisable");
    alert("##mini##***** PluginAPIMgr.GetCameraCheckDisable()", msg );
     if(msg =="0")
     {
            return false;
     }
     else
     {
            return true;
     } 
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////  Account  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

PluginAPIMgr.GetAccountInfo = function(PROPERTY)
{	
    alert("##mini##***** PluginAPIMgr.GetAccountInfo() -> property :" + PROPERTY);
	msg = this.MoIPPlugin.Execute("GetAccountInfo", String(PROPERTY));
    alert("##mini##***** PluginAPIMgr.GetAccountInfo() -> return : " + msg);
    
    return msg;    
}

PluginAPIMgr.GetMyDisplayName = function ()
{		
	var full_name = PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_FULLNAME);
    var skype_name = PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_SKYPENAME);
    var display_name= "";
    
     if(full_name.length == 0)
    {
       display_name = skype_name;
    }
    else
    {
        display_name = full_name;
    }
	g_Data.SetMyAccountDisplayName(display_name);
	return  display_name;
	
}

PluginAPIMgr.GetMySkyeName = function(){
	
	var skype_name = PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_SKYPENAME);
	g_Data.SetMyAccountSkypeName(skype_name);
	
	return skype_name;
}


PluginAPIMgr.GetMyMoodMsg = function ()
{
    var mood_msg = PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_MOOD_TEXT);

    return  mood_msg;
}

PluginAPIMgr.GetMyFullName = function ()
{
    var full_name = PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_FULLNAME);

    return  full_name;
}

PluginAPIMgr.GetMyEmail = function ()
{
    var email = PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_EMAILS);

    return  email;
}

PluginAPIMgr.GetMyAvataImage = function ()
{
    var avata_image = PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_AVATAR_IMAGE);
	if(avata_image.length == 0)
	{
		avata_image = g_Image.IMAGE_DEFAULT_AVATAR_BLANK_128;
	}
	else{
		
		avata_image = avata_image + g_Data.GetImgSuffixPath();
		alert("##mini##GetMyAvataImage = " + avata_image);
	}
	
	g_Data.SetMyAccountAvataImage(avata_image);

    return  avata_image;
}

PluginAPIMgr.GetMyAvataImageForMain = function ()
{
    var avata_image = PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_AVATAR_IMAGE);
	if(avata_image.length == 0)
	{
	/*
		var gender = PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_GENDER);
			if(gender =="1")
			{
				avata_image = g_Image.IMAGE_VOICE_CALL_DEFAULT_AVATA_MALE;
			}
			else if(gender =="2")
			{
			   avata_image = g_Image.IMAGE_VOICE_CALL_DEFAULT_AVATA_FEMALE;
			}
			else
			{
			   avata_image =g_Image.IMAGE_VOICE_CALL_DEFAULT_AVATA_NO_GENDER;
			}*/
	
		avata_image = g_Image.IMAGE_CHANGE_PICTURE_AVATAR;

	}
	else{
		
		avata_image = avata_image + g_Data.GetImgSuffixPath();
		alert("##mini##GetMyAvataImageForMain = " + avata_image);
		
	}

    return  avata_image;
}

PluginAPIMgr.GetMyAvataImageForCall = function ()
{
    var avata_image = PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_AVATAR_IMAGE);
	if(avata_image.length == 0)
	{
	/*
		var gender = PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_GENDER);
			if(gender =="1")
			{
				avata_image = g_Image.IMAGE_VOICE_CALL_DEFAULT_AVATA_MALE;
			}
			else if(gender =="2")
			{
			   avata_image = g_Image.IMAGE_VOICE_CALL_DEFAULT_AVATA_FEMALE;
			}
			else
			{
			   avata_image =g_Image.IMAGE_VOICE_CALL_DEFAULT_AVATA_NO_GENDER;
			}*/
	
		avata_image = g_Image.IMAGE_CHANGE_PICTURE_AVATAR;

	}
	else{
		
		avata_image = avata_image + g_Data.GetImgSuffixPath();
		alert("##mini##GetMyAvataImageForCall = " + avata_image);
}		

    return  avata_image;
}

PluginAPIMgr.GetMyAvataImageForChat = function ()
{
    var avata_image = PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_AVATAR_IMAGE);
	if(avata_image.length == 0)
	{
		/*
		var gender = PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_GENDER);
				if(gender == "1") {
					avata_image = g_Image.IMAGE_LIST_MAIN_ONLY_MY_DEFAULT_AVATA_MALE;
				} else if(gender == "2") {
					avata_image = g_Image.IMAGE_LIST_MAIN_ONLY_MY_DEFAULT_AVATA_FEMALE;
				} else {*/
		
			avata_image = g_Image.IMAGE_CHANGE_PICTURE_AVATAR;
	//	}
	}
	else{
		
		avata_image = avata_image + g_Data.GetImgSuffixPath();
		alert("##mini##GetMyAvataImageForChat = " + avata_image);
		
	}

    return  avata_image;
}

PluginAPIMgr.GetMyOnlineStateImage = function()
{
    var  availability = PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_AVAILABILITY);
    var  availability_image = "";
    
    switch(parseInt(availability))
    {
        case ENUM_ACCOUNT_AVAILABILITY.UNKNOWN:
        case ENUM_ACCOUNT_AVAILABILITY.OFFLINE:
        case ENUM_ACCOUNT_AVAILABILITY.NOT_AVAILABLE:
            availability_image = g_Image.IMAGE_CONFERENCE_CALL_OFFLINE; 
		 break;
		 	  
		case ENUM_ACCOUNT_AVAILABILITY.CONNECTING:	
			availability_image = g_Image.IMAGE_CONFERENCE_CALL_ONLINE;
        break;
		
		case ENUM_ACCOUNT_AVAILABILITY.INVISIBLE:
			availability_image = g_Image.IMAGE_CONFERENCE_CALL_INVISIBLE;   
        break;
        
       case ENUM_ACCOUNT_AVAILABILITY.ONLINE:
           availability_image = g_Image.IMAGE_CONFERENCE_CALL_ONLINE;   
        break;
        
       case ENUM_ACCOUNT_AVAILABILITY.AWAY:
            availability_image = g_Image.IMAGE_CONFERENCE_CALL_AWAY;  
        break;
        
       case ENUM_ACCOUNT_AVAILABILITY.DO_NOT_DISTURB:
            availability_image = g_Image.IMAGE_CONFERENCE_CALL_DONOTDISTURB;  
        break;
        
       case ENUM_ACCOUNT_AVAILABILITY.SKYPE_ME:
            availability_image = g_Image.IMAGE_CONFERENCE_CALL_ONLINE;  
        break;  
        
        default:
            availability_image = g_Image.IMAGE_CONFERENCE_CALL_OFFLINE;   
        break;      
    }

    return  availability_image;
}

PluginAPIMgr.GetMyOnlineState = function()
{
	var  availability = PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_AVAILABILITY);
    var  availability_value =parseInt(availability);
	var  result =availability_value;
	
	if(availability_value != ENUM_ACCOUNT_AVAILABILITY.INVISIBLE 
	&& availability_value != ENUM_ACCOUNT_AVAILABILITY.ONLINE
	&& availability_value != ENUM_ACCOUNT_AVAILABILITY.AWAY
	&& availability_value != ENUM_ACCOUNT_AVAILABILITY.DO_NOT_DISTURB)
	{
		result = ENUM_ACCOUNT_AVAILABILITY.OFFLINE;
	}

    return  result;	
}

PluginAPIMgr.GetMyCredit = function()
{
	var balance = PluginAPIMgr.GetMyBalance();
    var balance_currency = PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_SKYPEOUT_BALANCE_CURRENCY);
    
    var credit = balance+" "+ balance_currency;
    
    return credit;
}

PluginAPIMgr.GetMyBalance = function()
{
	var balance = PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_SKYPEOUT_BALANCE);
    var int_balance = parseInt(balance);
    balance = (parseInt(int_balance)) / 100 ;
	
	return balance;
}


PluginAPIMgr.GetAccountCapability = function(property){
	
	return this.MoIPPlugin.Execute("GetAccountCapability", String(property));
}
PluginAPIMgr.GetAccountCapabilityExpireDate = function(type)
{
    msg = this.MoIPPlugin.Execute("GetAccountCapabilityExpireDate", type );
    alert("##mini##***** PluginAPIMgr.GetAccountCapabilityExpireDate() -> result :" + msg);
    return msg;
}

PluginAPIMgr.GetMyProvince = function ()
{
    var province = PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_PROVINCE);

    return  province;
}

PluginAPIMgr.GetMyCity = function ()
{
    var city = PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_CITY);

    return  city;
}

PluginAPIMgr.GetMyGender = function ()
{
    var gender = PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_GENDER);
    
    return gender;
    
}

PluginAPIMgr.GetMyBirthDay= function ()
{
    var birth_day= PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_BIRTHDAY);
    
    return  birth_day;
}

PluginAPIMgr.GetMyVoiceMailExpireDate = function(type)
{
    var vm_expire_date = PluginAPIMgr.GetAccountCapabilityExpireDate(ENUM_CONTACT_CAPABILITY.CAPABILITY_VOICEMAIL );
    return  vm_expire_date;
}

PluginAPIMgr.SetProp= function(PROPERTY, set_value)
{
     alert("##mini##***** PluginAPIMgr.SetProp() : " + PROPERTY+ "value : "+set_value );
    msg = this.MoIPPlugin.Execute("SetProp", String(PROPERTY), set_value);

}


PluginAPIMgr.GetMyHomePhone= function ()
{
    var home_phone= PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_PHONE_HOME);
    
    return  home_phone;
}

PluginAPIMgr.GetMyOfficePhone= function ()
{
    var office_phone= PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_PHONE_OFFICE);
    
    return  office_phone;
}

PluginAPIMgr.GetMyMobilePhone= function ()
{
    var mobile_phone= PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_PHONE_MOBILE);
    
    return  mobile_phone;
}

PluginAPIMgr.SetAvailability = function(setIndex)
{
     alert("##mini##***** PluginAPIMgr.SetAvailability() -> property :" + setIndex);
    this.MoIPPlugin.Execute("SetAvailability",String(setIndex));
}

PluginAPIMgr.SetMyAvatar = function(ImgPath)
{
    PluginAPIMgr.SetProp(ENUM_ACCOUNT_PROPERTY.P_AVATAR_IMAGE, ImgPath);
}

PluginAPIMgr.GetMyCountryCode = function()
{
    var country_code = PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_COUNTRY);
    //alert("##mini##***** PluginAPIMgr.GetMyCountryCode() -> result :" + country_code);
    return  country_code;
}

PluginAPIMgr.GetMyCountryPrefix = function()
{
    var country_code = PluginAPIMgr.GetMyCountryCode();
    return PluginAPIMgr.GetISOCountryPrefix(country_code);
}

PluginAPIMgr.GetMyCountryName = function(code)
{
    var country_code="";
	if(code==null)
		country_code = PluginAPIMgr.GetMyCountryCode();
	else
		country_code = code;
    return PluginAPIMgr.GetISOCountryName(country_code);
}

PluginAPIMgr.GetMyCountryFlag = function(code)
{
   if(code==null)
		country_code = PluginAPIMgr.GetMyCountryCode();
	else
		country_code = code;
	if(country_code.length > 0)
	{
		return g_Image.base_flag_image_path + country_code.toUpperCase() + ".png" ;
	}
	else
	{
		return "" ;
	}   
}

PluginAPIMgr.GetISOCountryName= function(country_code)
{

	var LangCode = ResMgr.GetCurSkypeLanguageCode();
		
	return this.MoIPPlugin.Execute("GetISOCountryName", country_code, LangCode);
		
}

PluginAPIMgr.GetISOCountryPrefix= function(country_code)
{
    msg = this.MoIPPlugin.Execute("GetISOCountryPrefix", country_code);
    
    alert("##mini##***** PluginAPIMgr.GetISOCountryPrefix() : " + msg );
    return msg;
}

PluginAPIMgr.NormalizeIdentity = function(phone_number)
{
    msg = this.MoIPPlugin.Execute("NormalizeIdentity", phone_number);
    
    alert("##mini##***** PluginAPIMgr.NormalizeIdentity() : " + msg );
    return msg;
}

PluginAPIMgr.IsEmergencyCall = function(phone_number)
{
    msg = this.MoIPPlugin.Execute("IsEmergencyCall", phone_number);
    
    alert("##mini##***** PluginAPIMgr.IsEmergencyCall() : " + msg );
    return parseInt(msg);
}

PluginAPIMgr.GetLocalNumber = function(phone_number)
{
   var local_number = this.MoIPPlugin.Execute("GetLocalNumber", phone_number);
    
    alert("##mini##***** PluginAPIMgr.GetLocalNumber() : " + local_number );
    return local_number;
}

PluginAPIMgr.FindCountryCodeByNumber = function(phone_number)
{
   var country_code = this.MoIPPlugin.Execute("FindCountryCodeByNumber", phone_number);
    
    alert("##mini##***** PluginAPIMgr.FindCountryCodeByNumber() : " + country_code );
    return country_code;
}

PluginAPIMgr.GetAccountCapability = function(type)
{
    msg = this.MoIPPlugin.Execute("GetAccountCapability", type);
   
   alert("##mini##***** PluginAPIMgr.GetAccountCapability() : " + msg );
    return msg;
}

PluginAPIMgr.SetMoodMsg = function(mood_msg) {
	alert("##mini##***** PluginAPIMgr.SetMoodMsg()  :" + mood_msg);
	PluginAPIMgr.SetProp(ENUM_ACCOUNT_PROPERTY.P_MOOD_TEXT, mood_msg);
}

PluginAPIMgr.SetFullName = function(full_name) {
	alert("##mini##***** PluginAPIMgr.SetFullName()  :" + full_name);
	PluginAPIMgr.SetProp(ENUM_ACCOUNT_PROPERTY.P_FULLNAME, full_name);
}

PluginAPIMgr.SetEmail = function(email) {
	alert("##mini##***** PluginAPIMgr.SetEmail()  :" + email);
	PluginAPIMgr.SetProp(ENUM_ACCOUNT_PROPERTY.P_EMAILS, email);
}

PluginAPIMgr.SetCountryCode = function(country_code) {
	alert("##mini##***** PluginAPIMgr.SetCountryCode()  :" + country_code);
	PluginAPIMgr.SetProp(ENUM_ACCOUNT_PROPERTY.P_COUNTRY, country_code);
}

PluginAPIMgr.SetHomePhone = function(home_phone) {
	alert("##mini##***** PluginAPIMgr.SetHomePhone()  :" + home_phone);
	PluginAPIMgr.SetProp(ENUM_ACCOUNT_PROPERTY.P_PHONE_HOME, home_phone);
}

PluginAPIMgr.SetOfficePhone = function(office_phone) {
	alert("##mini##***** PluginAPIMgr.SetOfficePhone()  :" + office_phone);
	PluginAPIMgr.SetProp(ENUM_ACCOUNT_PROPERTY.P_PHONE_OFFICE, office_phone);
}

PluginAPIMgr.SetMobilePhone = function(mobile_phone) {
	alert("##mini##***** PluginAPIMgr.SetMobilePhone()  :" + mobile_phone);
	PluginAPIMgr.SetProp(ENUM_ACCOUNT_PROPERTY.P_PHONE_MOBILE, mobile_phone);
}

PluginAPIMgr.SetProvince = function(province) {
	alert("##mini##***** PluginAPIMgr.SetProvince()  :" + province);
	PluginAPIMgr.SetProp(ENUM_ACCOUNT_PROPERTY.P_PROVINCE, province);
}

PluginAPIMgr.SetCity = function(city) {
	alert("##mini##***** PluginAPIMgr.SetCity()  :" + city);
	PluginAPIMgr.SetProp(ENUM_ACCOUNT_PROPERTY.P_CITY, city);
}

PluginAPIMgr.SetGender = function(gender_code) {
	alert("##mini##***** PluginAPIMgr.SetGender()  :" + gender_code);
	PluginAPIMgr.SetProp(ENUM_ACCOUNT_PROPERTY.P_GENDER, gender_code);
	//0 =null, 1=man 2=femail
}

PluginAPIMgr.SetBirthDate = function(birth_day) {
	alert("##mini##***** PluginAPIMgr.SetBirthDate()  :" +birth_day);
	PluginAPIMgr.SetProp(ENUM_ACCOUNT_PROPERTY.P_BIRTHDAY, birth_day);
}
/////////////////////////////////////////////
PluginAPIMgr.ChangePassword = function() {
	alert("##mini##***** PluginAPIMgr.ChangePassword() old : " + g_Data.DATA_CHANGE_PWD_INPUT_INFO.old_pwd + " new :  " + g_Data.DATA_CHANGE_PWD_INPUT_INFO.new_pwd);
	msg = this.MoIPPlugin.Execute("ChangePassword", g_Data.DATA_CHANGE_PWD_INPUT_INFO.old_pwd, g_Data.DATA_CHANGE_PWD_INPUT_INFO.new_pwd);
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////  Contact List ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

PluginAPIMgr.GetContactPropWithName = function(Name,ContactProp)
{
	return this.MoIPPlugin.Execute("GetContactPropWithName",Name,String(ContactProp));		
}

PluginAPIMgr.GetAvatarPath = function(Name){
	
	var Avatar = PluginAPIMgr.GetContactPropWithName(Name, ENUM_CONTACT_PROPERTY.P_AVATAR_IMAGE);
	alert("##mini##GetAvatarPath = " + Avatar);
	
	if(Name == "echo123"){
		
		return g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_TEST_CALL;
	}	
	else if(Avatar){
		return Avatar + g_Data.GetImgSuffixPath();
	}
	else if(PluginAPIMgr.GetContactPropWithName(Name,ENUM_CONTACT_PROPERTY.P_PSTNNUMBER)){
		
		return g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_PSTN;
	}
	else{
		
		var Gender = PluginAPIMgr.GetContactPropWithName(Name, ENUM_CONTACT_PROPERTY.P_GENDER);
		
		if(Gender == "1"){
			
			return g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_MALE;
		}
		else if(Gender == "2"){
			
			return g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_FEMALE;
		}
		else {
			
			return g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_NO_GENDER;				
		}		
	} 
}

PluginAPIMgr.GetAvatarType = function(Name){
	
	var Avatar = PluginAPIMgr.GetContactPropWithName(Name, ENUM_CONTACT_PROPERTY.P_AVATAR_IMAGE);
	
	if(Name == "echo123"){
		
		return ENUM_CONTACT_AVATA_TYPE.TEST_CALL;
	}	
	else if(Avatar){
		
		return ENUM_CONTACT_AVATA_TYPE.ONES_IMAGE;
	}
	else if(PluginAPIMgr.GetContactPropWithName(Name,ENUM_CONTACT_PROPERTY.P_PSTNNUMBER)){
		
		return ENUM_CONTACT_AVATA_TYPE.PSTN;
	}
	else{
		
		var Gender = PluginAPIMgr.GetContactPropWithName(Name, ENUM_CONTACT_PROPERTY.P_GENDER);
		
		if(Gender == "1"){
			
			return ENUM_CONTACT_AVATA_TYPE.MALE;
		}
		else if(Gender == "2"){
			
			return ENUM_CONTACT_AVATA_TYPE.FEMALE;
		}
		else {			
			return ENUM_CONTACT_AVATA_TYPE.NO_GENDER;				
		}		
	} 
}


PluginAPIMgr.GetContactPropWithIndex = function(nIndex,ContactProp)
{
	return this.MoIPPlugin.Execute("GetContactPropWithIndex", String(nIndex) ,String(ContactProp));
}

PluginAPIMgr.GetIndexOfContact = function(Name)
{
	return this.MoIPPlugin.Execute("GetIndexOfContact", Name);	
}

PluginAPIMgr.GetContactNameWithIndex = function(nIndex)
{   
    var skype_name = PluginAPIMgr.GetContactPropWithIndex(nIndex,ENUM_CONTACT_PROPERTY.P_SKYPENAME);   
	
    if(skype_name.length >0)
    {
        return skype_name;
    }
    else
    {
        var pstn_number = PluginAPIMgr.GetPSTNNumberWithIndex( nIndex)
        return pstn_number;
    }
}

PluginAPIMgr.GetPSTNNumberWithIndex = function(nIndex)
{
	return PluginAPIMgr.GetContactPropWithIndex(nIndex,ENUM_CONTACT_PROPERTY.P_PSTNNUMBER);

}

PluginAPIMgr.GetNameWithIndex = function(nIndex)
{
	var name = PluginAPIMgr.GetContactPropWithIndex(nIndex,ENUM_CONTACT_PROPERTY.P_DISPLAYNAME);
	
	if (name) {
		return name;
	}
		
	name = PluginAPIMgr.GetContactNameWithIndex(nIndex);

	if (name) {
		return name;
	}
	
	name = PluginAPIMgr.GetContactPropWithIndex(nIndex,ENUM_CONTACT_PROPERTY.P_PSTNNUMBER);

	if (name) {
		return name;
	}
	
	return " ";	
	 
}

PluginAPIMgr.GetContactAvailabilityWithName = function(Name)
{
	return PluginAPIMgr.GetContactPropWithName(Name,ENUM_CONTACT_PROPERTY.P_AVAILABILITY);
}

PluginAPIMgr.GetContactAvailabilityWithIndex = function(nIndex)
{
	return PluginAPIMgr.GetContactPropWithIndex(nIndex,ENUM_CONTACT_PROPERTY.P_AVAILABILITY);
}

/* no use
PluginAPIMgr.GetHomePhoneNumberWithIndex = function(nIndex)
{
		return PluginAPIMgr.GetContactPropWithIndex(nIndex,ENUM_CONTACT_PROPERTY.P_PHONE_HOME);
	}

PluginAPIMgr.GetOfficePhoneNumberWithIndex = function(nIndex)
	{
	return PluginAPIMgr.GetContactPropWithIndex(nIndex,ENUM_CONTACT_PROPERTY.P_PHONE_OFFICE );    
	}	
    
PluginAPIMgr.GetMobilePhoneNumberWithIndex = function(nIndex)
{
	return PluginAPIMgr.GetContactPropWithIndex(nIndex,ENUM_CONTACT_PROPERTY.P_PHONE_MOBILE );   
}*/


PluginAPIMgr.GetHomePhoneNumberWithName = function(Name)
{
	alert("##mini##PluginAPIMgr.GetHomePhoneNumberWithName");
	return PluginAPIMgr.GetContactPropWithName(Name,ENUM_CONTACT_PROPERTY.P_PHONE_HOME);    
}

PluginAPIMgr.GetOfficePhoneNumberWithName = function(Name)
{
	return PluginAPIMgr.GetContactPropWithName(Name,ENUM_CONTACT_PROPERTY.P_PHONE_OFFICE );    
}

PluginAPIMgr.GetMobilePhoneNumberWithName = function(Name)
{
	return PluginAPIMgr.GetContactPropWithName(Name,ENUM_CONTACT_PROPERTY.P_PHONE_MOBILE );   
}

PluginAPIMgr.GetAssignedPhoneNumberWithName = function(Identity,prop)
{
	var property;
	switch(prop)
	{
		case 2:
			property = ENUM_CONTACT_PROPERTY.P_ASSIGNED_PHONE1_LABEL;
			break;		
		case 3:
			property = ENUM_CONTACT_PROPERTY.P_ASSIGNED_PHONE2;
			break;		
		case 4:
			property = ENUM_CONTACT_PROPERTY.P_ASSIGNED_PHONE2_LABEL;
			break;		
		case 5:
			property = ENUM_CONTACT_PROPERTY.P_ASSIGNED_PHONE3;
			break;		
		case 6:
			property = ENUM_CONTACT_PROPERTY.P_ASSIGNED_PHONE3_LABEL;
			break;
		case 1:				
		default:
			property = ENUM_CONTACT_PROPERTY.P_ASSIGNED_PHONE1;
			break;		
		
	}
	
	if(prop%2 == 0) {
		var LabelName = PluginAPIMgr.GetContactPropWithName(Identity,String(property));
		alert("##mini##GetAssignedPhoneNumberWithName.LabelName = " + LabelName);
		if(LabelName == 1)
			return "mobile";
		else if(LabelName == 2)
			return "office";
		else if(LabelName == 3)
			return "home";
		else if(LabelName == 4)
			return "other";
		else
			return LabelName;
	}
	else	
	return PluginAPIMgr.GetContactPropWithName(Identity,String(property));   
}

PluginAPIMgr.GetPhoneNumberCnt = function (TargetIdentity, WithUsrPhn) {

	var AssignedLabel = null;
	var AssignedNumber = null;
	var Count = 0;

	if(WithUsrPhn == true) {
		AssignedLabel = PluginAPIMgr.GetHomePhoneNumberWithName(TargetIdentity);
		if(AssignedLabel != null && AssignedLabel != "none" && AssignedLabel != 0) {
			AssignedLabel = null;
			Count++;
		}

		AssignedLabel = PluginAPIMgr.GetOfficePhoneNumberWithName(TargetIdentity);	
		if(AssignedLabel != null && AssignedLabel != "none" && AssignedLabel != 0) {
			AssignedLabel = null;
			Count++;
		}

		AssignedLabel = PluginAPIMgr.GetMobilePhoneNumberWithName(TargetIdentity);
		if(AssignedLabel != null && AssignedLabel != "none" && AssignedLabel != 0) {
			AssignedLabel = null;
			Count++;
		}
		alert("##mini##PluginAPIMgr.GetPhoneNumberCnt(WithUsrPhn : true) = " + Count);
	}
	
	for(var i=1; i<7; i++) {

		AssignedNumber = PluginAPIMgr.GetAssignedPhoneNumberWithName(TargetIdentity,i);
		AssignedLabel = PluginAPIMgr.GetAssignedPhoneNumberWithName(TargetIdentity,++i);

		if(AssignedLabel != null && AssignedLabel != "none" && AssignedLabel != 0) {
				Count++;
		}
		AssignedNumber = null;
		AssignedLabel = null;
	}

	alert("##mini##PluginAPIMgr.GetPhoneNumberCnt = " + Count);
	return Count;
}

PluginAPIMgr.SetAssignedPhoneNumber = function(Identity,prop,PhoneLabel,PhoneNumber)
{	
	return this.MoIPPlugin.Execute("SetAssignedPhoneNumber",Identity ,String(prop), PhoneLabel, PhoneNumber); 
}

PluginAPIMgr.GetContactList = function(ContactName)
{ 
	return this.MoIPPlugin.Execute("GetContactList",ContactName,"5","0");   	  
}

PluginAPIMgr.GetLiveContactList = function(StartIndex)
{ 
	return this.MoIPPlugin.Execute("GetContactListWithoutCallMember", StartIndex + "" , "4");
}


PluginAPIMgr.GetContactListInPopupMode = function(StartIndex)
{ 
	return this.MoIPPlugin.Execute("GetContactListWithoutUnauthorizedContacts", StartIndex + "" , "5");
}

PluginAPIMgr.GetLiveContactListInPopupMode = function(StartIndex)
{ 
	return this.MoIPPlugin.Execute("GetContactListWithoutCallMemberAndUnauthorizedContacts", StartIndex + "" , "4");
}


PluginAPIMgr.GetNumberOfContacts = function()
{   
	var NumOfContact = this.MoIPPlugin.Execute("GetNumOfContacts");
	if( NumOfContact == null)
	{
		return 0;
	}
	else {
		return parseInt(NumOfContact);
	}		
}

PluginAPIMgr.GetNumberOfContactsInPopupMode = function()
{     
	
	var NumOfContact = this.MoIPPlugin.Execute("GetNumOfContactsWithoutUnauthorizedContacts");
	
	if(NumOfContact == null)
	{
		return 0;
	}
	else {
		
		return parseInt(NumOfContact);
	}		
}

PluginAPIMgr.BlockContact = function(Name,RemoveOption)
{ 
	var option;
	
	if(RemoveOption){
		
		option = '1';
	}
	else{
		
		option = '0';
	}
	    
	this.MoIPPlugin.Execute("Block", Name,option);
}

PluginAPIMgr.UnblockContact = function(Name)
{     
	this.MoIPPlugin.Execute("Unblock", Name);
}

PluginAPIMgr.RemoveContact = function(Name)
{     
	this.MoIPPlugin.Execute("Remove", Name);
}

PluginAPIMgr.AuthorizeContact = function(Name)
{
     msg =  this.MoIPPlugin.Execute("Authorize", Name);
}

PluginAPIMgr.RejectAndBlock = function(Name, Block)
{
     msg =  this.MoIPPlugin.Execute("RejectAndBlock", Name, Block);
}


PluginAPIMgr.RenameContact = function(ContactName,Display)
{     
	this.MoIPPlugin.Execute("Rename", ContactName,Display);
}

PluginAPIMgr.GetBlockList = function()
{     
	return this.MoIPPlugin.Execute("GetBlockedContactList");
}

PluginAPIMgr.IsMyBuddy = function(Identity)
{	    
	var result = this.MoIPPlugin.Execute("IsMyBuddy",Identity);
	
	if(result == '1'){
		return true;
	}
	else{
		return false;
	}	
}


PluginAPIMgr.HasVoiceMailCapability = function(Identity)
{	    
	var result = this.MoIPPlugin.Execute("HasVoiceMailCapability",Identity);
	
	if(result == '1'){
		return true;
	}
	else{
		return false;
	}	
}


PluginAPIMgr.GetContactAvataImage = function(Name)
{    
	var Avatar_image = PluginAPIMgr.GetContactPropWithName(Name,ENUM_CONTACT_PROPERTY.P_AVATAR_IMAGE);
	
	if(Avatar_image.length ==0 || Name == "echo123")
	{	
		if(Name == "echo123"){
		
			Avatar_image = g_Image.IMAGE_DEFAULT_AVATAR_TEST_CALL_128;
			
		}
		else if(Name.charAt(0) == '+'){
		
			Avatar_image = g_Image.IMAGE_DEFAULT_AVATAR_PSTN_128;
		}
		else
		{
			Avatar_image = g_Image.IMAGE_DEFAULT_AVATAR_BLANK_128;	
		}
	}
	else
	{
		Avatar_image = Avatar_image + g_Data.GetImgSuffixPath();
	}
	
	return Avatar_image;
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////  History List ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

PluginAPIMgr.GetHistoryList = function(Index)
{ 
	return this.MoIPPlugin.Execute("GetHistoryListIncludingTimestamp", "" + Index , "5", "0");	
}
 
PluginAPIMgr.GetNumberOfHistorys = function()
{     
	return this.MoIPPlugin.Execute("GetNumOfHistories");
}

PluginAPIMgr.GetHistoryPropWithIndex = function(nIndex,HistoryProp)
{
    return this.MoIPPlugin.Execute("GetHistoryPropWithIndex",""+ nIndex ,""+HistoryProp);
}

PluginAPIMgr.GetHistoryNameWithIndex = function(nIndex)
{
	return this.MoIPPlugin.Execute("GetHistoryPropWithIndex" ,"" + nIndex ,"" + ENUM_HISTORY_PROPERTY.P_SKYPENAME);   
	
}

//for displayname....
PluginAPIMgr.GetHistoryParticipantsWithIndex = function(nIndex)
{	
    var Participants = this.MoIPPlugin.Execute("GetHistoryPropWithIndex",""+ nIndex ,"" + ENUM_HISTORY_PROPERTY.P_PARTICIPANTS);
	
	var DisplayName = "";
    var NamesNumber = 0;

	var Array = Participants.split(',');
	
	for (var j=0; j < Array.length; j++) {
			
		NamesNumber++;
        
		if( NamesNumber == Array.length){
            DisplayName = DisplayName + PluginAPIMgr.GetChatMemberDisplayName(Array[j]);
        }
        else{
            DisplayName = DisplayName + PluginAPIMgr.GetChatMemberDisplayName(Array[j]) + ", ";
        }			            
	}
		
	alert("##mini##DisplayName --> " + DisplayName);
	
	return DisplayName;

}

PluginAPIMgr.GetHistoryPropWithTimeStamp = function(sTimeStamp,HistoryProp)
{
	return this.MoIPPlugin.Execute("GetHistoryPropWithTimestamp",sTimeStamp ,"" + HistoryProp);   
	
}
PluginAPIMgr.GetIndexOfHistory = function(sTimeStamp)
{
	return this.MoIPPlugin.Execute("GetHistoryIndexWithTimestamp",sTimeStamp);   
	
}

PluginAPIMgr.PlayHistoryVoicemail = function(nIndex)
{
    return this.MoIPPlugin.Execute("PlayVoicemail", "" + nIndex);
}

PluginAPIMgr.StopHistoryVoicemail = function(nIndex)
{
	return this.MoIPPlugin.Execute("StopVoicemail" , "" + nIndex );   
	
}

PluginAPIMgr.RemoveHistory = function(Index)
{     
	this.MoIPPlugin.Execute("DeleteHistory", "" + Index);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////  Country List    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


PluginAPIMgr.GetCountryList = function(LangCode)
{ 	
	return this.MoIPPlugin.Execute("GetCountryList" , LangCode);	
}

PluginAPIMgr.GetCountryWithIndex = function(nIndex){

	return PluginAPIMgr.GetContactPropWithIndex(nIndex,ENUM_CONTACT_PROPERTY.P_COUNTRY );
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///// Chat List ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


PluginAPIMgr.GetChatList = function(Index)
{ 
	return this.MoIPPlugin.Execute("GetChatListWithIndex", "" + Index , '6', '0');	
}

PluginAPIMgr.GetNumberOfChatList = function()
{     
	return this.MoIPPlugin.Execute("GetNumOfChatList");
	
}

PluginAPIMgr.GetChatPropertyWithIndex = function(Index,Prop)
{     
	return this.MoIPPlugin.Execute("GetChatProperty", String(Index), String(Prop) );
	
}

PluginAPIMgr.GetTotalNumOfUnReadChats = function()
{ 
	var NumOfMessage = this.MoIPPlugin.Execute("GetTotalNumOfUnReadChats");
		    
	return parseInt(NumOfMessage);
	
}

PluginAPIMgr.GetTotalNumOfUnReadMessages = function()
{ 
	var NumOfMessage = this.MoIPPlugin.Execute("GetTotalNumOfUnReadMessages");
		    
	return parseInt(NumOfMessage);
	
}

PluginAPIMgr.RemoveChat = function(ChatName)
{     
	return this.MoIPPlugin.Execute("LeaveChat", ChatName);
	
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////  Call   ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

PluginAPIMgr.GetPreviousPhoneNumberList = function()
{ 
	return this.MoIPPlugin.Execute("GetSkypeOutHistoryList");
}

PluginAPIMgr.AnswerWithVideo = function()
{
    this.MoIPPlugin.Execute("AnswerWithVideo");
}

PluginAPIMgr.AnswerWithVoice = function()
{
    this.MoIPPlugin.Execute("AnswerWithVoice");
}


PluginAPIMgr.CreateCall = function()
{
    alert("##mini##***** PluginAPIMgr.CreateCall() -> callee_name :" + g_Data.DATA_CREATE_CALL_INPUT_INFO.callee_name + " call_type : " +g_Data.DATA_CREATE_CALL_INPUT_INFO.call_type);
	var result = this.MoIPPlugin.Execute("CreateCall",g_Data.DATA_CREATE_CALL_INPUT_INFO.callee_name , String(g_Data.DATA_CREATE_CALL_INPUT_INFO.call_type));
	alert("##mini##***** PluginAPIMgr.CreateCall() result -> "+result);
	return parseInt(result);
}

PluginAPIMgr.DisconnectCall = function(endType)
{
     alert("##mini##***** PluginAPIMgr.DisconnectCall()");
     if(endType)
     {
     	this.MoIPPlugin.Execute("CallEnd", "1");
     }
     else
     {
     	this.MoIPPlugin.Execute("CallEnd", "0");
     }
	 
}

PluginAPIMgr.RejectCall = function()
{
     alert("##mini##***** PluginAPIMgr.RejectCall()");
     this.MoIPPlugin.Execute("RejectCall");
}

PluginAPIMgr.GetCallType = function()
{   
     msg =  this.MoIPPlugin.Execute("GetCallType");
     
      alert("##mini##***** PluginAPIMgr.GetCallType() : " + msg);
      
      return  msg;
}

PluginAPIMgr.GetCallInfo= function()
{
    msg =  this.MoIPPlugin.Execute("GetCallInfo");
	
	alert("##mini##***** PluginAPIMgr.GetCallInfo() : " + msg);
	          
    return msg;
}

PluginAPIMgr.IsConference = function()
{   
     msg =  this.MoIPPlugin.Execute("IsConference");
     
     alert("##mini##***** PluginAPIMgr.IsConference() : " + msg);
      
     return parseInt(msg);
}

PluginAPIMgr.IsSendingVideo = function()
{   
     msg =  this.MoIPPlugin.Execute("IsSendingVideo");
     
      alert("##mini##***** PluginAPIMgr.IsSendingVideo() : " + msg);
      
     return parseInt(msg);
}

PluginAPIMgr.SetMainVideoRect = function(x, y, w, h)
{   
    alert("##mini##***** PluginAPIMgr.SetMainVideoRect() " );
    
    //this.MoIPPlugin.Execute("SetExtVideoDisplaySize", String(x), String(y), String(w), String(h));
    
	msg =  this.CameraPlugin.Execute("SetExtVideoDisplaySize", String(x), String(y), String(w), String(h));		
}

PluginAPIMgr.SetSubVideoRect = function(x, y, w, h)
{   
    alert("##mini##***** PluginAPIMgr.SetSubVideoRect() " );
    	
    //this.MoIPPlugin.Execute("SetCamVideoDisplaySize", String(x), String(y), String(w), String(h));
    
	msg =  this.CameraPlugin.Execute("SetCamVideoDisplaySize", String(x), String(y), String(w), String(h));	
}

PluginAPIMgr.SetCameraLightMode = function()
{
	alert("##mini##***** PluginAPIMgr.SetCameraLightMode() " );
	this.MoIPPlugin.Execute("SetCameraLightMode");
}

PluginAPIMgr.SetCallingViewRect = function(x, y, w, h)
{   
    alert("##mini##***** PluginAPIMgr.SetCallingViewRect() " );
    this.MoIPPlugin.Execute("SetCallingPreviewRect", String(x), String(y), String(w), String(h));
}

PluginAPIMgr.SetNormalRecvRect = function(x, y, w, h)
{   
    alert("##mini##***** PluginAPIMgr.SetNormalRecvRect() " );
    this.MoIPPlugin.Execute("SetNormalRecvRect", String(x), String(y), String(w), String(h));
}

PluginAPIMgr.SetNormalPreviewRect = function(x, y, w, h)
{   
    alert("##mini##***** PluginAPIMgr.SetNormalPreviewRect() " );
    this.MoIPPlugin.Execute("SetNormalPreviewRect", String(x), String(y), String(w), String(h));
}

PluginAPIMgr.SetTVRect = function(x, y, w, h)
{   
    alert("##mini##***** PluginAPIMgr.SetTVRect() " );
    this.MoIPPlugin.Execute("SetTvViewRect", String(x), String(y), String(w), String(h));    
}

PluginAPIMgr.SetTVRecvRect = function(x, y, w, h)
{   
    alert("##mini##***** PluginAPIMgr.SetTVRecvRect() " );
    this.MoIPPlugin.Execute("SetTvRecvRect", String(x), String(y), String(w), String(h));    
}

PluginAPIMgr.SetTVPreviewRect = function(x, y, w, h)
{   
    alert("##mini##***** PluginAPIMgr.SetTVPreviewRect() " );
    this.MoIPPlugin.Execute("SetTvPreviewRect", String(x), String(y), String(w), String(h));    
}

PluginAPIMgr.SetNormalRecvRect = function(x, y, w, h)
{   
    alert("##mini##***** PluginAPIMgr.SetDefaultRecvRect() " );
    
    this.MoIPPlugin.Execute("SetNormalRecvRect", String(x), String(y), String(w), String(h));
}

PluginAPIMgr.SetNormalPreviewRect = function(x, y, w, h)
{   
    alert("##mini##***** PluginAPIMgr.SetDefaultPreviewRect() " );
    	
    this.MoIPPlugin.Execute("SetNormalPreviewRect", String(x), String(y), String(w), String(h));
}

PluginAPIMgr.SetMicVolume = function(value)
{   
    alert("##mini##***** PluginAPIMgr.SetMicVolume() " );
    this.CameraPlugin.Execute("SetMicVolume", String(value));
    this.MoIPPlugin.Execute("SetMicVolume", String(value));
}

PluginAPIMgr.SetSpeakerVolume = function(value)
{   
    alert("##mini##***** PluginAPIMgr.SetSpeakerVolume() " );
     msg =  this.MoIPPlugin.Execute("SetSpeakerVolume", String(value));
}

PluginAPIMgr.GetMicVolume = function()
{       
     msg =  this.MoIPPlugin.Execute("GetMicVolume");
     
     alert("##mini##***** PluginAPIMgr.GetMicVolume() : "+ msg );

     return parseInt(msg);
}

PluginAPIMgr.GetSpeakerVolume = function()
{       
     msg =  this.MoIPPlugin.Execute("GetSpeakerVolume");
     
     alert("##mini##***** PluginAPIMgr.GetSpeakerVolume() : "+ msg );
     
     return parseInt(msg);
}


PluginAPIMgr.SetAutoVolumeControl = function(value)
{   
    alert("##mini##***** PluginAPIMgr.SetAutoVolumeControl() " );
    if(value== true)
    {
        msg =  this.MoIPPlugin.Execute("SetAutoVolumeControl", "1");
    }
    else
    {
        msg =  this.MoIPPlugin.Execute("SetAutoVolumeControl", "0");
    }
}


PluginAPIMgr.GetAutoVolumeControl = function()
{       
     msg =  this.MoIPPlugin.Execute("GetAutoVolumeControl");
     
     alert("##mini##***** PluginAPIMgr.GetAutoVolumeControl() : "+ msg );

     return parseInt(msg);
}

PluginAPIMgr.SetCallMixVolume = function(value)
{   
    alert("##mini##***** PluginAPIMgr.SetCallMixVolume() " );
	this.MoIPPlugin.Execute("SetCallMixVolume", String(value));
}

PluginAPIMgr.GetCallMixVolume = function()
{       
     msg =  this.MoIPPlugin.Execute("GetCallMixVolume");
     
     alert("##mini##***** PluginAPIMgr.GetCallMixVolume() : "+ msg );
     
     return parseInt(msg);
}

PluginAPIMgr.SetTVMixVolume = function(value)
{   
    alert("##mini##***** PluginAPIMgr.SetTVMixVolume() " );
    this.MoIPPlugin.Execute("SetTVMixVolume", String(value));
}

PluginAPIMgr.GetTVMixVolume = function()
{       
     msg = this.MoIPPlugin.Execute("GetTVMixVolume");
     
     alert("##mini##***** PluginAPIMgr.GetTVMixVolume() : "+ msg );
     
     return parseInt(msg);
}

PluginAPIMgr.MuteMic = function(flagOn)
{
	alert("##mini##PluginAPIMgr.MuteMic >>" + flagOn);

    if(flagOn == true)
    {
        msg =  this.MoIPPlugin.Execute("MuteMic", "1");
        ProcMgr.CallInfo.IsMicMute = true;
    }
    else
    {
        msg =  this.MoIPPlugin.Execute("MuteMic", "0");
        ProcMgr.CallInfo.IsMicMute = false;
    }
}


PluginAPIMgr.Hold = function(b_hold)
{   
    alert("##mini##***** PluginAPIMgr.Hold() " );
    if(b_hold==true)
    {
        msg =  this.MoIPPlugin.Execute("Hold", "1");
    }
    else
    {
        msg =  this.MoIPPlugin.Execute("Hold", "0");
    }
}

PluginAPIMgr.StartSendVideo = function()
{   
    alert("##mini##***** PluginAPIMgr.StartSendVideo() " );
	this.MoIPPlugin.Execute("StartSendVideo");
	this.SetCameraLightMode();
}


PluginAPIMgr.StopSendVideo = function()
{   
    alert("##mini##***** PluginAPIMgr.StopSendVideo() " );
     msg =  this.MoIPPlugin.Execute("StopSendVideo");
}

PluginAPIMgr.StopSendMyVideo = function()
{   
    alert("##mini##***** PluginAPIMgr.StopSendMyVideo() " );
	msg =  this.MoIPPlugin.Execute("StopSendMyVideo");
}

PluginAPIMgr.StopCamVideo = function()
{
	alert("##mini##PluginAPIMgr.StopCamVideo");	
	this.CameraPlugin.Execute("StopCamVideo");	
}

PluginAPIMgr.SendDTMF = function(number)
{   
    alert("##mini##***** PluginAPIMgr.SendDTMF() " );
     msg =  this.MoIPPlugin.Execute("SendDTMF", String(number));
}

PluginAPIMgr.GetNumOfCallMembers = function()
{   
     msg =  this.MoIPPlugin.Execute("GetNumOfCallMembers");
     
      alert("##mini##***** PluginAPIMgr.GetNumOfCallMembers() : " + msg);
      
      return  parseInt(msg);
}

PluginAPIMgr.LeaveVoicemail = function()
{
    alert("##mini##***** PluginAPIMgr.LeaveVoicemail() -> callee_name :" +  g_Data.DATA_VOICE_MAIL_INPUT_INFO.callee_name);
     msg =  this.MoIPPlugin.Execute("LeaveVoicemail", g_Data.DATA_VOICE_MAIL_INPUT_INFO.callee_name);
}

PluginAPIMgr.CancelVoicemail= function()
{
    alert("##mini##***** PluginAPIMgr.CancelVoicemail() ");
    msg =  this.MoIPPlugin.Execute("CancelVoicemail");
}

PluginAPIMgr.BlockIncomingCall= function()
{
    alert("##mini##***** PluginAPIMgr.BlockIncomingCall() ");
    msg =  this.MoIPPlugin.Execute("BlockIncomingCall");
}

PluginAPIMgr.UnblockIncomingCall= function(index)
{
    alert("##mini##***** PluginAPIMgr.UnblockIncomingCall() -> "+index);
    msg =  this.MoIPPlugin.Execute("UnblockIncomingCall", index);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////  Call Member  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

PluginAPIMgr.GetCallMemberInfo = function(call_member_index, property )
{
   alert("##mini##***** PluginAPIMgr.GetCallMemberInfo() -> property :" + property);
    
   msg =  this.MoIPPlugin.Execute("GetCallMemberInfo", call_member_index, property);
   
   alert("##mini##***** PluginAPIMgr.GetCallMemberInfo() -> return  :" + msg); 
   
   return msg;
}

PluginAPIMgr.GetCallMemberID = function(index)
{
    if(index)
    {
        return this.MoIPPlugin.Execute("GetCallMemberIdentity", String(index)); //PluginAPIMgr.GetCallMemberInfo( index, ENUM_CALL_MEMBER_PROPERTY.P_IDENTITY);
     }
     else
     {
        return this.MoIPPlugin.Execute("GetCallMemberIdentity", "0");
     }
}

PluginAPIMgr.GetCallMemberDisplayName = function(index)
{
    if(index)
    {
        msg = this.MoIPPlugin.Execute("GetCallMemberDisplayName", String(index));
    }
    else
    {
         msg = this.MoIPPlugin.Execute("GetCallMemberDisplayName", "0");
    }
     
     if(msg.length==0)
     {
         msg = PluginAPIMgr.GetCallMemberID(index); 
     }
     
     return msg;
}

PluginAPIMgr.GetCallMemberAvataImage= function(index)
{
	var Avatar_image = null;
	var call_memeber_id = PluginAPIMgr.GetCallMemberID(index);

    if(index)
    {
        Avatar_image = this.MoIPPlugin.Execute("GetCallMemberAvatarPath", String(index));
    }
    else
    {
        Avatar_image = this.MoIPPlugin.Execute("GetCallMemberAvatarPath", "0");
    }
    
	if(Avatar_image.length ==0 || call_memeber_id == "echo123")
	{	
		if(call_memeber_id == "echo123"){
		
			Avatar_image = g_Image.IMAGE_VOICE_CALL_DEFAULT_AVATA_TEST_CALL;
		}
		else if(PluginAPIMgr.GetContactPropWithName(call_memeber_id,ENUM_CONTACT_PROPERTY.P_PSTNNUMBER)){
		
			Avatar_image = g_Image.IMAGE_VOICE_CALL_DEFAULT_AVATA_PSTN;
		}
		else
		{
			var Gender = PluginAPIMgr.GetContactPropWithName(call_memeber_id, ENUM_CONTACT_PROPERTY.P_GENDER);
			
			if(Gender == "1"){
				
				Avatar_image = g_Image.IMAGE_VOICE_CALL_DEFAULT_AVATA_MALE;
			}
			else if(Gender == "2"){
				
				Avatar_image = g_Image.IMAGE_VOICE_CALL_DEFAULT_AVATA_FEMALE;
			}
			else {			
				Avatar_image = g_Image.IMAGE_VOICE_CALL_DEFAULT_AVATA_NO_GENDER;				
			}		
		} 
	}
	else
	{
		Avatar_image = Avatar_image + g_Data.GetImgSuffixPath();
	}
	
    alert("##mini##***** PluginAPIMgr.GetCallMemberAvataImage() -> return  :" + Avatar_image); 
   return Avatar_image;
}

PluginAPIMgr.GetConferenceCallMemberAvataImage= function(index)
{
	var Avatar_image = null;
	var call_memeber_id = PluginAPIMgr.GetCallMemberID(index);

    if(index)
    {
        Avatar_image = this.MoIPPlugin.Execute("GetCallMemberAvatarPath", String(index));
    }
    else
    {
        Avatar_image = this.MoIPPlugin.Execute("GetCallMemberAvatarPath", "0");
    }
	
	if(Avatar_image.length == 0 || call_memeber_id == "echo123")
	{	
		
		if(call_memeber_id == "echo123"){
		
			Avatar_image = g_Image.IMAGE_DEFAULT_AVATAR_TEST_CALL_86;
		}
		else if(PluginAPIMgr.GetContactPropWithName(call_memeber_id,ENUM_CONTACT_PROPERTY.P_PSTNNUMBER)){
		
			Avatar_image = g_Image.IMAGE_DEFAULT_AVATAR_PSTN_86;
		}
		else
		{
			Avatar_image = g_Image.IMAGE_DEFAULT_AVATAR_BLANK_86;	
		} 
	}
	else
	{
		Avatar_image = Avatar_image + g_Data.GetImgSuffixPath();
	}
	
    alert("##mini##***** PluginAPIMgr.GetConferenceCallMemberAvataImage() -> return  :" + Avatar_image); 
   return Avatar_image;
}

PluginAPIMgr.GetConferenceCallMemberOnlineState = function(index)
{
	var onlineState = null;
    if(index)
    {
        onlineState = this.MoIPPlugin.Execute("GetCallMemberOnlineState", String(index));
    }
    else
    {
         onlineState = this.MoIPPlugin.Execute("GetCallMemberOnlineState", "0");
    }

	return parseInt(onlineState);
}


PluginAPIMgr.GetCallMemberMoodMsg = function (index)
{
     if(index)
    {
         var call_memeber_id = PluginAPIMgr.GetCallMemberID(index);
     }
     else
     {
        var call_memeber_id = PluginAPIMgr.GetCallMemberID( 0);
     }
     
    var mood_msg =PluginAPIMgr.GetContactPropWithName(call_memeber_id, ENUM_CONTACT_PROPERTY.P_MOOD_TEXT);

     alert("##mini##***** PluginAPIMgr.GetCallMemberMoodMsg() -> return  :" + mood_msg); 
    return  mood_msg;
}

PluginAPIMgr.GetCallMemberType = function()
{
    return parseInt(PluginAPIMgr.GetCallMemberInfo( 0, ENUM_CALL_MEMBER_PROPERTY.P_TYPE));
}

PluginAPIMgr.GetCallStatus = function()
{
    return PluginAPIMgr.GetCallMemberInfo( 0, ENUM_CALL_MEMBER_PROPERTY.P_STATUS);
}

PluginAPIMgr.GetCallMemberOnlineStateImage = function(index)
{ 
     if(index)
    {
         var call_memeber_id = PluginAPIMgr.GetCallMemberID(index);
     }
     else
     {
        var call_memeber_id = PluginAPIMgr.GetCallMemberID( 0);
     }
     
    var  availability = PluginAPIMgr.GetContactPropWithName(call_memeber_id, ENUM_CONTACT_PROPERTY.P_AVAILABILITY);
    var  availability_image = "";
    
    switch(parseInt(availability))
    {
        case ENUM_CONTACT_AVAILABILITY.ONLINE:
        case ENUM_CONTACT_AVAILABILITY.ONLINE_FROM_MOBILE:
            availability_image = g_Image.IMAGE_ONLINE_STATUS_PRESENCE_ONLINE;   
            break;

        case ENUM_CONTACT_AVAILABILITY.OFFLINE:
        case ENUM_CONTACT_AVAILABILITY.NOT_AVAILABLE_FROM_MOBILE:
            availability_image = g_Image.IMAGE_ONLINE_STATUS_PRESENCE_OFFLINE;   
            break;

        case ENUM_CONTACT_AVAILABILITY.AWAY :
        case ENUM_CONTACT_AVAILABILITY.AWAY_FROM_MOBILE:
            availability_image = g_Image.IMAGE_ONLINE_STATUS_PRESENCE_AWAY;   
            break;

        case ENUM_CONTACT_AVAILABILITY.DO_NOT_DISTURB :
        case ENUM_CONTACT_AVAILABILITY.DO_NOT_DISTURB_FROM_MOBILE:
            availability_image = g_Image.IMAGE_ONLINE_STATUS_PRESENCE_DO_NOT_DISTURB;   
            break;

        case ENUM_CONTACT_AVAILABILITY.OFFLINE_BUT_CF_ABLE :
        case ENUM_CONTACT_AVAILABILITY.OFFLINE_BUT_VM_ABLE:
            availability_image =  g_Image.IMAGE_ONLINE_STATUS_PRESENCE_AVAILABLE;   
            break;

        case ENUM_CONTACT_AVAILABILITY.PENDINGAUTH  :
        case  ENUM_CONTACT_AVAILABILITY.UNKNOWN:
            availability_image =  g_Image.IMAGE_ONLINE_STATUS_PRESENCE_OFFLINE;   
            break;

        case ENUM_CONTACT_AVAILABILITY.BLOCKED  :
        case  ENUM_CONTACT_AVAILABILITY.BLOCKED_SKYPEOUT:
            availability_image =  g_Image.IMAGE_ONLINE_STATUS_PRESENCE_BLOCKED;   
            break;

        case ENUM_CONTACT_AVAILABILITY.SKYPE_ME :
            availability_image =   g_Image.IMAGE_ONLINE_STATUS_PRESENCE_AVAILABLE;   
            break;

        default:
            availability_image = g_Image.IMAGE_ONLINE_STATUS_PRESENCE_OFFLINE;   
            break;      
    }

    return  availability_image;
}

PluginAPIMgr.isConferenceCallMemberFinised= function(index)
{	
	if(index)
    {
        var msg = this.MoIPPlugin.Execute("GetCallMemberStatus", String(index));
    }
    else
    {
         var msg = this.MoIPPlugin.Execute("GetCallMemberStatus", "0");
    }
	
	if(parseInt(msg) == ENUM_CALL_MEMBER_STATUS.FINISHED
	|| parseInt(msg) == ENUM_CALL_MEMBER_STATUS.CANCELLED
	|| parseInt(msg) == ENUM_CALL_MEMBER_STATUS.FAILED
	|| parseInt(msg) == ENUM_CALL_MEMBER_STATUS.MISSED  
	|| parseInt(msg) == ENUM_CALL_MEMBER_STATUS.REFUSED 
	|| parseInt(msg) == ENUM_CALL_MEMBER_STATUS.BUSY
	|| parseInt(msg) == ENUM_CALL_MEMBER_STATUS.DROPPED)
	{
		alert("##mini##***** PluginAPIMgr.isConferenceCallMemberFinised() --> result : true" );
		return true;
	}
	else
	{
		alert("##mini##***** PluginAPIMgr.isConferenceCallMemberFinised() --> result : false" );
		return false;	
	}	
}

PluginAPIMgr.isConferenceCallMemberCalling= function(index)
{
	if(index)
    {
        var msg = this.MoIPPlugin.Execute("GetCallMemberStatus", String(index));
    }
    else
    {
         var msg = this.MoIPPlugin.Execute("GetCallMemberStatus", "0");
    }
	
	if(parseInt(msg) == ENUM_CALL_MEMBER_STATUS.ROUTING
	|| parseInt(msg) == ENUM_CALL_MEMBER_STATUS.EARLYMEDIA
	|| parseInt(msg) == ENUM_CALL_MEMBER_STATUS.RINGING_OUT
	|| parseInt(msg) == ENUM_CALL_MEMBER_STATUS.RINGING_IN  )
	{
		alert("##mini##***** PluginAPIMgr.isConferenceCallMemberCalling() --> result : true" );
		return true;
	}
	else
	{
		alert("##mini##***** PluginAPIMgr.isConferenceCallMemberCalling() --> result : false" );
		return false;	
	}	
}

PluginAPIMgr.ConferenceCallMemberStatus= function(index)
{	
	if(index)
    {
        var msg = this.MoIPPlugin.Execute("GetCallMemberStatus", String(index));
    }
    else
    {
         var msg = this.MoIPPlugin.Execute("GetCallMemberStatus", "0");
    }
	
	return parseInt(msg);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////  Add Contact  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

PluginAPIMgr.SearchNewContact = function(contact_name)
{   
     alert("##mini##***** PluginAPIMgr.SearchNewContact() --> contact_name " + contact_name );
     msg =  this.MoIPPlugin.Execute("SearchNewContact", contact_name);
}

PluginAPIMgr.SearchContactProfile = function(contact_name)
{   
     alert("##mini##***** PluginAPIMgr.SearchContactProfile() --> contact_name " + contact_name );
     msg =  this.MoIPPlugin.Execute("SearchContactProfile", contact_name);
	 g_Data.SetSearchedContactName(contact_name);
}

PluginAPIMgr.GetSearchList = function()
{ 
	return this.MoIPPlugin.Execute("GetSearchedContactList");  
}
		
PluginAPIMgr.GetProfileInfo = function(ContactName)
{ 
	return this.MoIPPlugin.Execute("GetSearchedProfileInfo");  
}

PluginAPIMgr.AddContact = function(skype_name, hello_msg)
{   
     msg =  this.MoIPPlugin.Execute("AddContact", skype_name, hello_msg);
}

PluginAPIMgr.AddSkypeOutContact = function(phone_number, diplay_name)
{   
     msg =  this.MoIPPlugin.Execute("AddSkypeOutContact", phone_number, diplay_name);
}

PluginAPIMgr.IsBlocked = function(skype_name)
{   
     msg =  this.MoIPPlugin.Execute("IsBlocked", skype_name);
     
    alert("##mini##***** PluginAPIMgr.IsBlocked() --> result : " + msg );
     return parseInt(msg);
}

PluginAPIMgr.IsMyBuddy = function(skype_name)
{   
     msg =  this.MoIPPlugin.Execute("IsMyBuddy", skype_name);
     
    alert("##mini##***** PluginAPIMgr.IsMyBuddy() --> result : " + msg );
     return parseInt(msg);
}

PluginAPIMgr.IsMyName = function(skype_name)
{   
    var my_skype_name = PluginAPIMgr.GetMySkyeName();
     if(my_skype_name == skype_name)
     {
        msg= "1";
     }
     else
     {
        msg= "0";
     }
     
    alert("##mini##***** PluginAPIMgr.IsMyName() --> result : " + msg );
     return parseInt(msg);
}

PluginAPIMgr.IsAutoVideoReceive = function()
{
	var value = parseInt(this.MoIPPlugin.Execute("GetAutoVideoReceive"));
	var is_receive = false;
	
	if(value==0)
	{
		is_receive = false;
	}
	else if(value==2)
	{
		is_receive = true;
	}
	else if(value==1)
	{
		var call_member_name = PluginAPIMgr.GetCallMemberID(); 
		var is_my_buddy = PluginAPIMgr.IsMyBuddy(call_member_name);
		if(is_my_buddy==1)
		{
			is_receive = true;
		}
		else
		{
			is_receive = false;
		}
	}
	
	alert("##mini##***** PluginAPIMgr.IsAutoVideoReceive() --> result : " + is_receive );
	return is_receive;	
}

PluginAPIMgr.StartReceiveVideo = function()
{
	alert("##mini##***** PluginAPIMgr.StartReceiveVideo() ");
	msg =  this.MoIPPlugin.Execute("StartRecvVideo");
}

PluginAPIMgr.StopReceiveVideo = function()
{
	alert("##mini##***** PluginAPIMgr.StopReceiveVideo() ");
	msg =  this.MoIPPlugin.Execute("StopRecvVideo");
}

PluginAPIMgr.OpenExtVideo = function()
{
	alert("##mini##***** PluginAPIMgr.OpenExtVideo() ");
	msg =  this.MoIPPlugin.Execute("OpenExtVideo");
}

PluginAPIMgr.CloseExtVideo = function()
{
	alert("##mini##***** PluginAPIMgr.CloseExtVideo() ");
	msg =  this.MoIPPlugin.Execute("CloseExtVideo");
}

PluginAPIMgr.OpenExtAudio = function()
{
	alert("##mini##***** PluginAPIMgr.OpenExtAudio() ");
	msg =  this.MoIPPlugin.Execute("OpenExtAudio");
}

PluginAPIMgr.CloseExtAudio = function()
{
	alert("##mini##***** PluginAPIMgr.CloseExtAudio() ");
	msg =  this.MoIPPlugin.Execute("CloseExtAudio");
}




//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////  Chat ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

PluginAPIMgr.OpenChatWithContact = function(skype_name)
{
     msg =  this.MoIPPlugin.Execute("OpenChatWithContact", skype_name);

}

PluginAPIMgr.OpenChat = function(chat_name)
{
     msg =  this.MoIPPlugin.Execute("OpenChatWithChatName", chat_name);
}

PluginAPIMgr.GetNumOfMessages = function()
{
    msg =  this.MoIPPlugin.Execute("GetNumOfMessages");
	alert("##mini##***** PluginAPIMgr.GetNumOfMessages() --> " + msg );
	return parseInt(msg);
}

PluginAPIMgr.GetMessages= function(start_index, end_index)
{
	alert("##mini##***** PluginAPIMgr.GetMessage() --> start_index : " + start_index + ", end_index : "+end_index );
	msg = this.MoIPPlugin.Execute("GetMessages", String(start_index), String(end_index));
	
    alert("##mini##***** PluginAPIMgr.GetMessage() --> " + msg );
    return msg
}


PluginAPIMgr.SendMessage= function(send_msg)
{
    alert("##mini##***** PluginAPIMgr.SendMessage() --> " + send_msg );
    msg =  this.MoIPPlugin.Execute("SendMessage", send_msg);
}


PluginAPIMgr.CloseChat = function()
{
     msg =  this.MoIPPlugin.Execute("CloseChat");

}

PluginAPIMgr.GetCurrentChatProperty = function(index)
{
	msg =  this.MoIPPlugin.Execute("GetCurrentChatProperty", String(index));
	
	return msg;
}

PluginAPIMgr.GetChatMemberDisplayName = function(skype_name)
{
    alert("##mini##***** PluginAPIMgr.GetChatMemberDisplayName() --> " + skype_name );
    msg =  PluginAPIMgr.GetContactPropWithName (skype_name, ENUM_CONTACT_PROPERTY.P_DISPLAYNAME );
	
	if(msg.length > 0)
	{
		return msg;
	}
	else
	{
		return skype_name;	
	}
}

PluginAPIMgr.isMultiChat = function(index)
{
	msg =  PluginAPIMgr.GetCurrentChatProperty(ENUM_CHAT_PROPERTY.P_TYPE);
	
	if(parseInt(msg)==ENUM_CHAT_TYPE.MULTICHAT)
	{
		return true;
	}
	else
	{
		return false;
	}	
}

PluginAPIMgr.GetChatMemberAvataImage = function(Name)
{    
	var Avatar_image = PluginAPIMgr.GetContactPropWithName(Name,ENUM_CONTACT_PROPERTY.P_AVATAR_IMAGE);
	
	if(Name == "echo123"){
		
		Avatar_image = g_Image.IMAGE_CHAT_DEFAULT_AVATA_TEST_CALL;
	}
	else if(Avatar_image.length ==0)
	{	
		if(PluginAPIMgr.GetContactPropWithName(Name,ENUM_CONTACT_PROPERTY.P_PSTNNUMBER)){
		
			Avatar_image = g_Image.IMAGE_CHAT_DEFAULT_AVATA_PSTN;
		}
		else
		{
			var Gender = PluginAPIMgr.GetContactPropWithName(Name, ENUM_CONTACT_PROPERTY.P_GENDER);
			
			if(Gender == "1"){
				
				Avatar_image = g_Image.IMAGE_CHAT_DEFAULT_AVATA_MALE;
			}
			else if(Gender == "2"){
				
				Avatar_image = g_Image.IMAGE_CHAT_DEFAULT_AVATA_FEMALE;
			}
			else {			
				Avatar_image = g_Image.IMAGE_CHAT_DEFAULT_AVATA_NO_GENDER;				
			}		
		} 
	}
	else
	{
		Avatar_image = Avatar_image + g_Data.GetImgSuffixPath();
	}
	
	return Avatar_image;
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////  Options ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

PluginAPIMgr.GetAutoStart = function()
{
    alert("##mini##***** PluginAPIMgr.GetAutoStart()");
    if(Boolean(parseInt(this.MoIPPlugin.Execute("GetAutoStart"))))
    {
        return SID_ON;
    }
    else
    {
        return SID_OFF;
    }
}

PluginAPIMgr.GetDisplayNoty = function()
{
    alert("##mini##***** PluginAPIMgr.GetDisplayNoty()");
    if(Boolean(parseInt(this.MoIPPlugin.Execute("IsNotificationEnabled"))))
    {
        return SID_ON;
    }
    else
    {
        return SID_OFF;
    }
}

PluginAPIMgr.SetDisplayNoty = function(value)
{
	alert("##mini##***** PluginAPIMgr.SetDisplayNoty()  : " + value);
	this.MoIPPlugin.Execute("SetNotificationEnable", value);
}

PluginAPIMgr.SetDisplayNotyValue = function(state)
{	
    alert("##mini##***** PluginAPIMgr.SetDisplayNotyValue()  : " + state);
    if(state === SID_ON)
        this.SetDisplayNoty("1");
    else
        this.SetDisplayNoty("0");
}

PluginAPIMgr.SetAutoVideoReceive = function(state)
{	
    alert("##mini##***** PluginAPIMgr.SetAutoVideoReceive()  : " + state);
    var bEnable = false;
    var bAnyone = false;
    /*
    var iNone = 0;
    var iAnyone = 1;
    var iFromContactList = 2;
    */
    if(state === IDWS_MOIP_SETTING_NONE)
    {
        bEnable = "0";
        bAnyone = "0";
        alert("##mini##Value: " + IDWS_MOIP_SETTING_NONE);
    }
    else if(state === TV_SID_PEOPLE_IN_MY_CONTACT_LIST_ONLY)
    {
        bEnable = "1";
        bAnyone = "0";
        alert("##mini##Value: " + TV_SID_PEOPLE_IN_MY_CONTACT_LIST_ONLY);
    }
    else if(state === IDWS_MOIP_SETTING_ANYONE)
    {
        bEnable = "1";
        bAnyone = "1";
        alert("##mini##Value: " + IDWS_MOIP_SETTING_ANYONE);
    }

	msg = this.MoIPPlugin.Execute("SetAutoVideoReceive", bEnable, bAnyone);
}

PluginAPIMgr.GetAutoVideoReceive = function()
{
    var retValue = IDWS_MOIP_SETTING_NONE;

    alert("##mini##***** PluginAPIMgr.GetAutoVideoReceive()");
    var value = parseInt(this.MoIPPlugin.Execute("GetAutoVideoReceive"));
    alert("##mini##Value: " + value);
    switch(value)
    {
        case 0:
            retValue = IDWS_MOIP_SETTING_NONE;
            break;
        case 1:
            retValue = TV_SID_PEOPLE_IN_MY_CONTACT_LIST_ONLY;
            break;
		
		case 2:
            retValue = IDWS_MOIP_SETTING_ANYONE;
            break;
    }
    return retValue;
}

PluginAPIMgr.SetVideoAdvert = function(state)
{	
    alert("##mini##***** PluginAPIMgr.SetVideoAdvert()  : " + state);
    var val = "0";

    if(state === IDWS_MOIP_SETTING_NONE)
    {
        val = "0";
    }
    else if(state === TV_SID_PEOPLE_IN_MY_CONTACT_LIST_ONLY)
    {
        val = "1";
    }
	this.MoIPPlugin.Execute("SetVideoAdvert", val);
}

PluginAPIMgr.GetVideoAdvert = function()
{
    alert("##mini##***** PluginAPIMgr.GetVideoAdvert()");
    var value = this.MoIPPlugin.Execute("GetVideoAdvert");
    if(value === "1")
        return TV_SID_PEOPLE_IN_MY_CONTACT_LIST_ONLY;
    else 
        return IDWS_MOIP_SETTING_NONE;
}

PluginAPIMgr.SetAutoFocus= function(value)
{
	alert("##mini##***** PluginAPIMgr.SetAutoFocus()  : " + value);
	this.MoIPPlugin.Execute("SetAutoFocus", value);
}

PluginAPIMgr.SetAutoFocusValue = function(state)
{	
    alert("##mini##***** PluginAPIMgr.SetAutoFocusValue()  : " + state);
    if(state === SID_ON)
        this.SetAutoFocus("1");
    else
        this.SetAutoFocus("0");
}

PluginAPIMgr.GetAutoFocus = function(){
	alert("##mini##***** PluginAPIMgr.GetAutoFocus()");
	return this.MoIPPlugin.Execute("GetAutoFocus");
}

PluginAPIMgr.GetAutoFocusValue = function(){
	alert("##mini##***** PluginAPIMgr.GetAutoFocusValue()");
	
	if(Boolean(parseInt(this.GetAutoFocus())))
    {
        return SID_ON;
    }
    else
    {
        return SID_OFF;
    }	 
}

PluginAPIMgr.SetCallForward = function(state)
{	
    alert("##mini##***** PluginAPIMgr.SetCallForward()  : " + state);
    if(state === SID_ON)
        this.MoIPPlugin.Execute("SetCallForward", "1");
    else
        this.MoIPPlugin.Execute("SetCallForward", "0");
}

PluginAPIMgr.GetCallForward = function()
{
    alert("##mini##***** PluginAPIMgr.GetCallForward()");
    if(Boolean(parseInt(this.MoIPPlugin.Execute("GetCallForward"))))
        return SID_ON;
    else
        return SID_OFF;
}

PluginAPIMgr.SetCallForwardTimer = function(timeout)
{	
    alert("##mini##***** PluginAPIMgr.SetCallForwardTimer()  : " + timeout);
	this.MoIPPlugin.Execute("SetCallForwardTimer", timeout);
}

PluginAPIMgr.GetCallForwardTimer = function()
{
    alert("##mini##***** PluginAPIMgr.GetCallForwardTimer()");
    return this.MoIPPlugin.Execute("GetCallForwardTimer");
}

PluginAPIMgr.SetVoicemailForward = function(state)
{	
    alert("##mini##***** PluginAPIMgr.SetVoicemailForward()  : " + state);
    if(state === SID_ON)
        this.MoIPPlugin.Execute("SetVoicemailForward", "1");
    else
        this.MoIPPlugin.Execute("SetVoicemailForward", "0");
}

PluginAPIMgr.GetVoicemailForward = function()
{
    alert("##mini##***** PluginAPIMgr.GetVoicemailForward()");
    if(Boolean(parseInt(this.MoIPPlugin.Execute("GetVoicemailForward"))))
        return SID_ON;
    else
        return SID_OFF;
}

PluginAPIMgr.SetVoicemailForwardTimer = function(timeout)
{	
    alert("##mini##***** PluginAPIMgr.SetVoicemailForwardTimer()  : " + timeout);
	this.MoIPPlugin.Execute("SetVoicemailForwardTimer", timeout);
}

PluginAPIMgr.GetVoicemailForwardTimer = function()
{
    alert("##mini##***** PluginAPIMgr.GetVoicemailForwardTimer()");
    return this.MoIPPlugin.Execute("GetVoicemailForwardTimer");
}

PluginAPIMgr.SetVoicemailForReject = function(state)
{	
    alert("##mini##***** PluginAPIMgr.SetVoicemailForReject()  : " + state);
    if(state === SID_ON)
        this.MoIPPlugin.Execute("SetVoicemailForReject", "1");
    else
        this.MoIPPlugin.Execute("SetVoicemailForReject", "0");
}

PluginAPIMgr.GetVoicemailForReject = function()
{
    alert("##mini##***** PluginAPIMgr.GetVoicemailForReject()");
    if(Boolean(parseInt(this.MoIPPlugin.Execute("GetVoicemailForReject"))))
        return SID_ON;
    else
        return SID_OFF;
}

PluginAPIMgr.SetVoicemailInBusy = function(state)
{	
    alert("##mini##***** PluginAPIMgr.SetVoicemailInBusy()  : " + state);
    if(state === SID_ON)
        this.MoIPPlugin.Execute("SetVoicemailInBusy", "1");
    else
        this.MoIPPlugin.Execute("SetVoicemailInBusy", "0");
}

PluginAPIMgr.GetVoicemailInBusy = function()
{
    alert("##mini##***** PluginAPIMgr.GetVoicemailInBusy()");
    if(Boolean(parseInt(this.MoIPPlugin.Execute("GetVoicemailInBusy"))))
        return SID_ON;
    else
        return SID_OFF;
}

PluginAPIMgr.SetCallAllowPolicy = function(state)
{	
    alert("##mini##***** PluginAPIMgr.SetCallAllowPolicy()  : " + state);
    if(state === IDWS_MOIP_SETTING_ANYONE)
        this.MoIPPlugin.Execute("SetCallAllowPolicy", "1");
    else
        this.MoIPPlugin.Execute("SetCallAllowPolicy", "0");
}

PluginAPIMgr.GetCallAllowPolicy = function()
{
    alert("##mini##***** PluginAPIMgr.GetCallAllowPolicy()");
    if(this.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_SKYPE_CALL_POLICY) == "1")
        return IDWS_MOIP_SETTING_ANYONE;
    else
        return TV_SID_PEOPLE_IN_MY_CONTACT_LIST_ONLY;
}

PluginAPIMgr.SetChatAllowPolicy = function(state)
{	
    alert("##mini##***** PluginAPIMgr.SetChatAllowPolicy()  : " + state);
    if(state === IDWS_MOIP_SETTING_ANYONE)
        this.MoIPPlugin.Execute("SetChatAllowPolicy", "1");
    else
        this.MoIPPlugin.Execute("SetChatAllowPolicy", "0");
}

PluginAPIMgr.GetChatAllowPolicy = function()
{
    alert("##mini##***** PluginAPIMgr.GetChatAllowPolicy()");
    if(this.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_CHAT_POLICY) == "1")
        return IDWS_MOIP_SETTING_ANYONE;
    else
        return TV_SID_PEOPLE_IN_MY_CONTACT_LIST_ONLY;
}

PluginAPIMgr.SetCallForwardNumbers = function(numbers)
{	
    alert("##mini##***** PluginAPIMgr.SetCallForwardNumbers()  : " + numbers);
    //todo serialization of phone numbers 
	this.MoIPPlugin.Execute("SetCallForwardNumbers", numbers);
}

PluginAPIMgr.GetCallForwardNumbers = function()
{
    alert("##mini##***** PluginAPIMgr.GetCallForwardNumbers()");
    var rawData = this.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_OFFLINE_CALLFORWARD);
    return rawData;
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////  Video Snapshot ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


PluginAPIMgr.SaveSnapShot = function()
{
	alert("##mini##PluginAPIMgr.SaveSnapShot");
	this.MoIPPlugin.Execute("SaveSnapShot");
}

PluginAPIMgr.DeleteSnapShot = function(nIndex)
{
	alert("##mini##PluginAPIMgr.DeleteSnapShot");
	this.MoIPPlugin.Execute("DeleteSnapShot","" + nIndex);	
}

PluginAPIMgr.GetSnapShotPathList = function()
{
	alert("##mini##PluginAPIMgr.GetSnapShotPathList");	
	return this.MoIPPlugin.Execute("GetSnapShotPathList");
}

PluginAPIMgr.GetNumOfSnapShot = function()
{
	alert("##mini##PluginAPIMgr.GetNumOfSnapShot");		
	return parseInt(this.MoIPPlugin.Execute("GetNumOfSnapShot"));
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////  OSD Timer  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

PluginAPIMgr.StartOSDTimer = function(time, callBackFn, index)
{
	alert('PluginAPIMgr.StartOSDTimer -- ' + index);
	g_Data.SetOSDTimerCallBackFn(callBackFn, index);
	this.MoIPPlugin.Execute("StartOSDTimer", time, String(index+5));
}

PluginAPIMgr.RestartOSDTimer = function(time , index)
{	
	alert('PluginAPIMgr.RestartOSDTimer -- ' + index);
	this.MoIPPlugin.Execute("RestartOSDTimer", time, String(index+5));
}

PluginAPIMgr.StopOSDTimer = function(index)
{
	alert('PluginAPIMgr.StopOSDTimer -- ' + index);
	g_Data.SetOSDTimerCallBackFn(null, index);
	this.MoIPPlugin.Execute("StopOSDTimer" , String(index+5));
}


////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////    TOOL /////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////


PluginAPIMgr.GetCameraLightMode = function()
{
	alert("##mini##PluginAPIMgr.GetCameraLightMode");
	//return this.TempData;
	return parseInt(this.MoIPPlugin.Execute("GetCameraLightMode"));
}

PluginAPIMgr.SaveCameraLightMode = function(value)
{
	alert("##mini##PluginAPIMgr.SaveCameraLightMode -- " + value);
	//this.TempData = value;
	this.MoIPPlugin.Execute("SaveCameraLightMode" , String(value));
}

PluginAPIMgr.SetCameraLightMode = function()
{
	this.MoIPPlugin.Execute("SetCameraLightMode");
}

/*
   horizontal  : size of pannel width
   vertical : size of pannel height
   frequency : support frequency
   scan : scan mode
   aspect : aspect ratio

 */

PluginAPIMgr.GetPanelResolution = function()
{
	var resolutionJOSNString =  this.TvPlugin.Execute("GetPanelResolution");
	var resolution = eval( '('+ resolutionJOSNString  + ')' );
	
	alert("##mini##horizontal : "+ resolution.horizontal);
	alert("##mini##vertical: "+ resolution.vertical);
	alert("##mini##frequency: "+ resolution.frequency);
	alert("##mini##scan: "+ resolution.scan);
	alert("##mini##aspect: "+ resolution.aspect);

	WndMgr.SetResolutionInfo(resolution.horizontal,resolution.vertical,resolution.frequency,resolution.scan,resolution.aspect);

}


PluginAPIMgr.SetPreviousSource = function()
{
	this.sefPlugin.Execute("SetPreviousSource");
}

PluginAPIMgr.SetMediaSource = function()
{
	var result = this.sefPlugin.Execute("SetSource", "43");
	alert("##mini##==== PluginAPIMgr.SetMediaSource(): result = " + result);
}

PluginAPIMgr.StartAudio = function()
{
	this.MoIPPlugin.Execute("StartAudio");
}

PluginAPIMgr.SetSourceMode = function(b_sourceMode)
{
    if(b_sourceMode == true)
    {
        msg =  this.MoIPPlugin.Execute("SetSourceMode", "1");
     }
     else
     {
        msg =  this.MoIPPlugin.Execute("SetSourceMode", "0");
     }
}


PluginAPIMgr.IsCallInProgress= function()
{
	msg = this.MoIPPlugin.Execute("IsCallInProgress");
	alert("##mini##***** PluginAPIMgr.IsCallInProgress() -> return : " + msg);
	
	return parseInt(msg);
}

PluginAPIMgr.FaceTracking = function(bTurnOn)
{
	alert("##mini##***** PluginAPIMgr.FaceTracking -- " + bTurnOn);
	var turn_flag = '0';
	
	if(bTurnOn == true)
	{
		turn_flag = '1';
	}

	this.CameraPlugin.Execute("FaceTracking", turn_flag);
}

PluginAPIMgr.GetDBAutoTracking = function()
{
	return parseInt(this.MoIPPlugin.Execute("GetDBAutoTracking"));
}

//add by minseok(130604)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////  NTV - DualView  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
 * PluginAPIMgr.GetScreenViewMode 
 * Check Screen View Mode
 * 0 - Single View
 * 1 - Dual View
 */
PluginAPIMgr.GetScreenViewMode = function(){
	alert("##mini##***** PluginAPIMgr.GetScreenViewMode()");
	return this.NTVPlugin.Execute("GetScreenViewMode");
	//return 1;
}

PluginAPIMgr.GetModelConfig = function(){

	msg = this.NNaviPlugin.Execute("GetServiceConfig");

	alert("##mini##***** GetServiceConfig = " + msg);	
	var sevice_config = eval('('+msg +')');
	
	return sevice_config.Model;
}

PluginAPIMgr.ConvetFHDfromUD = function(turnOn){

	//UD to full HD
	if(turnOn == true)
	{
		alert("##mini##***** PluginAPIMgr.ConvetFHDfromUD() turn on");	
		this.WindowPlugin.Execute("SetScreenRect",'3','3','954','534');
	}
	else
	{
		alert("##mini##***** PluginAPIMgr.ConvetFHDfromUD() turn off");
		this.WindowPlugin.Execute("SetScreenRect",'-1','0','0','0');
	}
}

PluginAPIMgr.SubVideoMute = function(){
	
	alert("##mini##***** PluginAPIMgr.SubVideoMute");
	
	this.WindowPlugin.Execute("SetWindow",'1');
	this.WindowPlugin.Execute("Show", '0');
	this.WindowPlugin.Execute("SetWindow",'0');
}

