/**
 * @author espre.team
 */

/**
 * menu click functions
 */

var playerLeft=370;
var playerTop=120;
var captureLeft=300;
var playerWidth=340;
var playerHeight=300;
var lastPlayerLeft=playerLeft;
var lastPlayerTop=playerTop;
var playersInARow=2;
var playersHorizSpace=10;
var playersVertSpace=50;
var noOfOpenPlayers=1;		// numbers of players visible on page
var captureWindowVMB = null ;
var isCaptureStarted=false;
var navthrough = false;
var isCapturedBefore = false;



function resetPositions(){
	var playerLeft=370;
	var playerTop=160;
	var captureLeft=720;
	var playerWidth=340;
	var playerHeight=300;
	var lastPlayerLeft=playerLeft;
	var lastPlayerTop=playerTop;	
}


var clipCOllectorSettingsWindow=null;
var videoSettingsWindow=null;
var cameraSettingsWindow=null;
var microPhoneSettingsWindow=null;
var playListWidgetWindow=null;
var captureWindow=null;
var userPresenceWindow=null;
var sendMailToUserWindow=null;
var saveAndEncodeNameWindow=null;
var dhtmlWindowArray=[];

var lastKeyCode = null ;

//dhtmlWindowArray[0]='clipCOllectorSettingsWindow';
/*

dhtmlWindowArray[0]='inboxMessageListWindow' ;
dhtmlWindowArray[1]='videoSettingsWindow';
dhtmlWindowArray[2]='cameraSettingsWindow';
dhtmlWindowArray[3]='microPhoneSettingsWindow';
dhtmlWindowArray[4]='playListWidgetWindow';
dhtmlWindowArray[5]='captureWindow';
dhtmlWindowArray[6]='userPresenceWindow';
dhtmlWindowArray[7]='sendMailToUserWindow';
dhtmlWindowArray[8]='saveAndEncodeNameWindow';

*/

function closeAllWindows(){
	
	for(var i=0;i<dhtmlWindowArray.length;i++){
			try{
				var winRerence = eval(dhtmlWindowArray[i])
				winRerence.hide();		
			}catch(e)
			{
				
			}
			
	}	
	closeAllPlayers();	
}

/*
function home(){
	closeAllWindows();
	var windowsToOpen=[];
	//windowsToOpen[0]='userPresenceWindow';
	windowsToOpen[1]='playListWidgetWindow';
	windowsToOpen[2]=_playerWinNames['player1'];
	showWindows(windowsToOpen);
	
	//resetPositions();
	noOfOpenPlayers=1;
	//userPresenceWindow.moveTo(0,playerTop);
	playListWidgetWindow.moveTo(captureLeft,playerTop);
	_playerWinNames['player1'].moveTo(playerLeft,playerTop);	
}
*/


/*

function showWindows(winArray){
	
	for(var i=0;i<winArray.length;i++){
			try{
				var winReference = eval(winArray[i]);
				winReference.show();		
			}catch(e)
			{
				
			}
	}
}

*/

/*
function buddy_list(){
	if(userPresenceWindow!=null){
		//userPresenceWindow.show();
	}
}

function smallPlayer(){
	
	_playerWinNames['player1'].show();
}
*/


/*
* This function get execute while click the button on top of the page
*/


var ifSelfPreview = false ;

function activeDiv(playerFlag, divID){

//alert(navigateWhileCapturing());

if( ! navigateWhileCapturing() )
{	var isNavigate = false;
	
}else{  var isNavigate =  true;
}

//alert(isNavigate);

if(isNavigate){



//alert("active div called");
hideDiv("myMessage");
hideDiv("setting");
hideDiv("conference");
hideDiv("home");
hideDiv("usersDIV");
hideDiv("profile");
hideDiv("memberDetail");

if(playerFlag)
{
	stopAllPlayers();	
	hideAllPlayersDiv();
}

if(divID){
}
else{
	divID = "home"
}

//alert(divID);
showDiv(divID);

var messageButton = "nav_messages.gif";
var confButton = "nav_conferences.gif";
var settingButton = "nav_settings.gif";
var homeButton = "nav_home.gif";
var userButton = "nav_users.gif";

var imgDir = "images";

var isUserAdmin = false;

var paramList = "userLoginId:'1'";
var contMessage = new Controller('getLoggedInUserInfo','UserWidget',paramList);
var returnMessageArray = contMessage.getResult();
if(returnMessageArray[0].getType() == 'UserAdmin')
{	isUserAdmin = true;
}

switch(divID)
{
	case "myMessage": messageButton = "nav_messages_ON.gif"; MM_showHideLayers('inboxtab','','show','senttab','','hide','unsenttab','','hide','inboxcss','','show','newcss','','hide','fwdMsg','','hide','list_and_player','','show');  navthrough = true; showInboxMessageList();  break;
	//case "conference": confButton = "nav_conferences_ON.gif";  break;
	case "setting": settingButton = "nav_settings_ON.gif"; MM_showHideLayers('record_css','','hide','encodecss','','show','livecss','','hide');getDefualtEncoderParameter(); break;

	case "usersDIV": userButton = "nav_users_ON.gif"; MM_showHideLayers('userlist','','show','adduser','','hide'); getAllUsers(); break;
	case "profile": MM_showHideLayers('edit_user_Detail','','show','change_password','','hide'); editProfile(cuurentUserId()); break;
	
	default : homeButton = "nav_home_ON.gif"; break;
}

var adminHTMLstr = "";
if(isUserAdmin)
{
	adminHTMLstr = "<a href='#'><img border='0' src='"+imgDir+'/'+userButton+"'  onclick=\"activeDiv(true, 'usersDIV')\"  class='handcursor'></a>";
}
//+confButton+"'  onclick=\"activeDiv(true, 'conference')\" class='handcursor'>";
var buttonHTMLstr = "<img border='0' src='"+imgDir+'/'+homeButton+"' onclick=\"activeDiv(true, 'home')\" class='handcursor'><img border='0' src='"+imgDir+'/'+messageButton+"'  onclick=\"activeDiv(true, 'myMessage')\" class='handcursor'><img border='0' src='"+imgDir+'/'+settingButton+"'  onclick=\"activeDiv(true, 'setting')\" class='handcursor'>"+adminHTMLstr;


var ObjStatusDiv = document.getElementById("buttonDiv");
ObjStatusDiv.innerHTML = buttonHTMLstr ;
}

}




function clickClose(){
	//alert('currentFocusedPlayer'+currentFocusedPlayer);
	if(_playerWinNames[currentFocusedPlayer]!=null && typeof(_playerWinNames[currentFocusedPlayer]!='undefined')){
	_playerWinNames[currentFocusedPlayer].hide();
	noOfOpenPlayers--;
	}
}

/*
function clickPlay(){
	if(globalPlayListData!=null){
		populateFloatingPlayListDiv(globalPlayListData);
		JSFX_FloatTopDiv("floatingPlayListDiv");				// to float the div
	}
}
*/


/**
 * show one more player on the page
 */

 /*
function morePlayers(){
	
	if(noOfOpenPlayers==0){
		lastPlayerLeft="200"; //playerLeft;
		lastPlayerTop="300"; //playerTop;
		
	}  //This code will be of no use, can be removed.
	
	
	
	if(noOfOpenPlayers<10){
		
		if(noOfOpenPlayers%playersInARow==0){
			if(noOfOpenPlayers==0){
				lastPlayerLeft=20;
				lastPlayerTop=lastPlayerTop;;
			}else{
				lastPlayerLeft=20;
				lastPlayerTop=lastPlayerTop+playerHeight+playersVertSpace;	
			}
			
		}

		var newPlayer = 'player'+(++noOfOpenPlayers);
		//alert(noOfOpenPlayers);
		playListWidgetWindow.moveTo(0,playerTop);
		userPresenceWindow.minimize();
		lastPlayerLeft=lastPlayerLeft+playerWidth+playersHorizSpace;
		_playerWinNames[newPlayer].show();
		//_playerWinNames[newPlayer].moveTo(lastPlayerLeft,lastPlayerTop);		

	}
	else{
		//alert('You can not open more than 10 players!!');
	}
}
*/

/*
function onClosePlayer(){	
			
}
*/

/*
function minimizeAllPlayers(){
	
	for(var playerIndex=0;playerIndex<noOfOpenPlayers;playerIndex++){
		_playerWinNames[playerNameByIndex[playerIndex]].minimize();
	}
}
*/

/*
function showAllPlayers(){
	closeAllPlayers();
	try{
		captureWindow.hide();	
	}catch(e){
			alert(e);
	}
	for(var playerIndex in _playerWinNames){
		if(playerIndex=='contains' || playerIndex=='indexOf' )
			continue;
	//_playerWinNames[playerIndex].show();
	morePlayers();
	}
}
*/

/*
function closeAllPlayers(){
	for(var playerIndex=0;playerIndex<noOfOpenPlayers;playerIndex++){
		_playerWinNames[playerNameByIndex[playerIndex]].hide();
	}
	noOfOpenPlayers=0;
	playerLeft=370;
	playerTop=160;
}
*/

/*
function closeAllPlayersExceptFirst(){
	for(var playerIndex=0;playerIndex<noOfOpenPlayers;playerIndex++){
		if(playerNameByIndex[playerIndex]!='player1')
			_playerWinNames[playerNameByIndex[playerIndex]].hide();
	}
	noOfOpenPlayers=1;
}
*/

/*
function smallCapture(){
	var wi=300;
	var h=300;
	
	var camWidth=160;
	var camHeight=128;
	var paramList="height:'"+camHeight+"'"+ ", width:'"+camWidth+"'";
	var cont = new Controller('CaptureWidget_setCaptureParameters', 'CaptureWidget', paramList,'cw1');
	
	minimizeAllPlayers();
	
	//closeAllPlayersExceptFirst();
	//_playerWinNames['player1'].show();
	captureWindow.setSize(wi,h);
	playListWidgetWindow.minimize();
	captureWindow.show();
	invoke_Preview();
}
*/

/*
function mediumCapture(){
	var wi=400;
	var h=300;
	
	var camWidth=176;
	var camHeight=144;
	var paramList="height:'"+camHeight+"'"+ ", width:'"+camWidth+"'";
	var cont = new Controller('CaptureWidget_setCaptureParameters', 'CaptureWidget', paramList,'cw1');
	captureWindow.setSize(wi,h);

	minimizeAllPlayers();	
	//closeAllPlayersExceptFirst();
	//_playerWinNames['player1'].show();
	playListWidgetWindow.minimize();	
	captureWindow.show();
	invoke_Preview();	
}
*/

/*
function largeCapture(){
	var wi=500;
	var h=300;
	var camWidth=320;
	var camHeight=240;
	var paramList="height:'"+camHeight+"'"+ ", width:'"+camWidth+"'";
	var cont = new Controller('CaptureWidget_setCaptureParameters', 'CaptureWidget',paramList,'cw1');
	
	minimizeAllPlayers();
	//closeAllPlayersExceptFirst();
	//_playerWinNames['player1'].show();
	
	captureWindow.setSize(wi,h);
	playListWidgetWindow.minimize();
	captureWindow.show();
	invoke_Preview();
}
*/

/*
function openWindow_saveAndEncodeNameWindow(){
	saveAndEncodeNameWindow= dhtmlwindow.open("ClipName", "ajax", "../widgets/capture/template/SaveAndEncodeName.htm", "ClipName", "width=250px,height=100pX,left=900px,top="+playerTop+",resize=1,scrolling=1", "recal")
}
*/

function cameraSettingsCapture(){
	minimizeAllPlayers();
	playListWidgetWindow.minimize();
	captureWindow.show();
	captureWindow.moveTo(playerLeft,playerTop);
	cameraSettingsWindow=dhtmlwindow.open("cameraSettings", "ajax", "../widgets/capture/template/CaptureVideoSettingsTemplate.htm", "Camera Settings", "width=409px,height=130px,left="+captureLeft+",top="+playerTop+",resize=1,scrolling=1", "recal");
	alert("Loading ......");
	hideDiv('videoParameterDiv');
	showDiv('cameraSettingsDiv');
	createGroup(); //this will create the Group label on the cameraSettingsDiv, using the group1 div
 	createRadioButtons();
}

function microphoneSettingsCapture(){

	minimizeAllPlayers();
	playListWidgetWindow.minimize();
	captureWindow.show();
	captureWindow.moveTo(playerLeft,playerTop);
	microPhoneSettingsWindow=dhtmlwindow.open("microPhoneSettings", "ajax", "../widgets/capture/template/CaptureMicroPhoneSettingsTemplate.htm", "MicroPhone Settings", "width=430px,height=150px,left="+captureLeft+",top="+playerTop+",resize=1,scrolling=1", "recal");
	alert("Loading....");
	createMicrophoneGroup();
	createRadioButtonsForMicroPhone();
}

function optionalSettingsCapture(){
	
	
	newVideoOptionalSettings();
	getDefaultValuesForVideo();
	//openwindow_VideoSettings();	
}


function myLibrary(){
	
	closeAllWindows();
	
	var windowsToOpen=[];
	windowsToOpen[0]='userPresenceWindow';
	//windowsToOpen[1]=_playerWinNames['player1'];
	showWindows(windowsToOpen);
	
	
	userPresenceWindow.moveTo(0,playerTop);
	//_playerWinNames['player1'].moveTo(playerLeft,playerTop);
	openwindow_PlayList();
	playListWidgetWindow.show();
}


/*
function newClipCollection(){
	//alert('newClipCollection');
	_playerWinNames['player1'].minimize();
	playListWidgetWindow.minimize();
	captureWindow.moveTo(playerLeft,playerTop);
	clipCOllectorSettingsWindow=dhtmlwindow.open("clipSettings", "ajax", "../widgets/capture/template/CaptureProjectSettingsTemplate.htm", "Clip Collector", "width=374px,height=440px,left="+captureLeft+",top="+playerTop+",resize=1,scrolling=1", "recal");	
	//getDefaultValuesProject();
}
*/

/*
function newVideoOptionalSettings(){
	
	minimizeAllPlayers();
	playListWidgetWindow.minimize();
	captureWindow.show();
	captureWindow.moveTo(playerLeft,playerTop);
	videoSettingsWindow=dhtmlwindow.open("videoSettings", "ajax", "../widgets/capture/template/CaptureVideoSettingsTemplate.htm", "Video Settings", "width=250px,height=260px,left="+captureLeft+",top="+playerTop+",resize=1,scrolling=1", "recal");	
}
*/

/*
function openClipWindow(){
	hideDiv('playerSettingsDiv');
	showDiv('addClipsForEncode');
	var clipCollectorWidth=400;
	var clipCollectorHeight=180;
	clipCOllectorSettingsWindow.setSize(clipCollectorWidth,clipCollectorHeight);
}
*/

var currentClipCollector=null;			//global

/*
function applyClipCollectorsSettings(){
	
	
	//set_project_parameters();
	currentClipCollector=create_clip_collector();
	
	openClipWindow();
	createCheckedListBox();
	arrIndex =0;
}
*/

/*
function applyVideoSettings(){
	set_capture_parameters();
	videoSettingsWindow.hide();
	captureWindow.show();
	invoke_Preview();
}
*/

/**
 * adds a clip to the clip collector
 */

 /*
function add_clip(){
	var clipName=$('clipName').value;				// get clip name from UI
	var clipFile=$('clipFile').value;				// get clip path from UI
	
	$('clipName').value='';							// reset clip name & clip path text boxes 
	$('clipFile').value='';
	addIemToCheckedListBox(clipName,clipFile,'favorites');
	//save_collection();	
}
*/


var itemTextArray = new Array();//
var itemImageArray = new Array(); //["home", "favorites", "fontsize", "search"];
var clipPathArray = new Array();
var checkedList = '';
var arrIndex = 0;		

/*
function addIemToCheckedListBox(clipName,clipPath,imageName){
	itemTextArray[arrIndex]= clipName;
	clipPathArray[arrIndex]= clipPath;
	itemImageArray[arrIndex]= imageName;
	checkedList.setItemText(itemTextArray);
	checkedList.setItemImage(itemImageArray);
	var itemcount = arrIndex+1;
	checkedList.setItemCount(itemcount);
	checkedList.refresh();
	arrIndex++;
}
*/

/*
function createCheckedListBox(){
		
		checkedList = new AW.UI.CheckedList;
		checkedList.setId("checkedList1");
		checkedList.setSize(310, 100);
		checkedList.setItemText(itemTextArray);
		checkedList.setItemImage(itemImageArray);
		checkedList.setItemCount(0);
		checkedList.refresh();
}
*/


var group = '';
var microphoneGroup = '';
var radio = '';
var microphoneradio = '';

/*
function createGroup(){
	//alert("Inside");
	group = new AW.UI.Group;
	group.setId("group1");
	group.setControlText("Avilable Devices");
	group.setControlImage("favorites");
	group.refresh();
	//alert("OutSide");		
}
*/

var cameraTextArray = '';
var microPhoneTextArray = '';

/*
function createRadioButtons(){
	var cont = new Controller('CaptureWidget_getDefaultCaptureParameters','CaptureWidget','','cw1');
	var defaultValuesArray = cont.getResult();
	cameraTextArray = defaultValuesArray['videoDevice'];
	var itemImageArray = ["search","search","search"];
	radio = new AW.UI.Radio;
	//radio.setId("radio1");
	radio.setSize(200, 70);
	radio.setItemText(cameraTextArray);
	radio.setItemImage(itemImageArray);
	radio.setItemCount(cameraTextArray.length);
	radio.setSelectedItems([0]);
	//radio.refresh();
	
	group.setContent("videoDevices",radio);
	group.refresh();
}
*/

/*
function createMicrophoneGroup(){
	microphoneGroup = new AW.UI.Group;
	microphoneGroup.setId("group2");
	microphoneGroup.setControlText("Avilable Devices");
	microphoneGroup.setControlImage("favorites");
	microphoneGroup.refresh();		
}
*/


/*
function createRadioButtonsForMicroPhone(){
	var cont = new Controller('CaptureWidget_getDefaultCaptureParameters','CaptureWidget','','cw1');
	var defaultValuesArray = cont.getResult();
	microPhoneTextArray = defaultValuesArray['audioDevice'];
	var itemImageArray = ["search","search","search"];
	microphoneradio = new AW.UI.Radio;
	//microphoneradio.setId("radio2");
	microphoneradio.setSize(200, 50);
	microphoneradio.setItemText(microPhoneTextArray);
	microphoneradio.setItemImage(itemImageArray);
	microphoneradio.setItemCount(microPhoneTextArray.length);
	microphoneradio.setSelectedItems([0]);
	microphoneradio.refresh();
	
	microphoneGroup.setContent("AudioSettings",microphoneradio);
	microphoneGroup.refresh();
}
*/

function applyCameraSettings(){
	var selectedItemIndex = radio.getSelectedItems();
	var selectedItem = cameraTextArray[selectedItemIndex];
	var paramList="videoDevice:'" +selectedItem+"'";
	var cont = new Controller('CaptureWidget_setCaptureParameters','CaptureWidget',paramList,'cw1');
	invoke_Preview();
	cameraSettingsWindow.hide();
} 


function applyMicrophoneSettings(){
	var selectedItemIndex =  microphoneradio .getSelectedItems();
	var selectedItem = microPhoneTextArray[selectedItemIndex];
	var paramList="audioDevice:'" +selectedItem+"'";
	var cont = new Controller('CaptureWidget_setCaptureParameters','CaptureWidget',paramList,'cw1');
	invoke_Preview();
	microPhoneSettingsWindow.hide();
} 


	/**
	 * array holding player window references
	 */
	var _playerWinNames=[];				// global array

	_playerWinNames['player1']=null;			// playerName:div id
	_playerWinNames['player2']=null;
	_playerWinNames['player3']=null;
	_playerWinNames['player10']=null;
	
	
	/**
	 * array holding player names by index
	 */
	
	var playerNameByIndex=[];
	var playerNameByIndexLength=0;
	for(var playerIndex in _playerWinNames){
		if(playerIndex=='contains' || playerIndex=='indexOf' )
			continue;
		playerNameByIndex[playerNameByIndexLength++]=playerIndex;
	}
	
	delete playerNameByIndexLength;


function openPlayers(){
	
	//debugger;

	var playerNo=1;
	var leftOpenValue=playerLeft;
	for(var playerIndex in _playerWinNames){
		if(playerIndex=='contains' || playerIndex=='indexOf')
			continue;
		var TemplatePath = "../widgets/player/template/PlayerTemplate"+ playerNo +".htm"
		var playerName='player'+playerNo;
		var showPlayerName = 'Player >>' + playerNo; 
		_playerWinNames[playerIndex]=dhtmlwindow.open(playerName, "ajax", TemplatePath, playerName, "width=340px,height=300px,left="+leftOpenValue+",top="+playerTop+",resize=1,scrolling=0", "recal","Player")
		playerNo++;
		leftOpenValue = leftOpenValue + 340;
	}
		
	
	hideOtherPlayers();
}

function hideOtherPlayers(){
		
		for(var playerIndex in _playerWinNames){
		  /* if(playerIndex=='contains' || playerIndex=='indexOf' || playerIndex=='player1')
			 continue;
		   */
		_playerWinNames[playerIndex].hide();
		
	}
}

function openwindow_userPresence(w,h){	
	//userPresenceWindow=dhtmlwindow.open("UserPresence", "ajax", "template/UserPresenceTemplate.htm", "Members", "width=225px,height=400pX,left=0px,top="+playerTop+",resize=1,scrolling=1", "recal")
	//alert("_getLoggedInUserInfo");
	_getLoggedInUserInfo();
	//userPresenceWindow.hide();
}

function openWindow_saveAndEncodeNameWindow(){
	
	try{
		getCaptureTime(); //Used to calculate the capture video time
		hideDiv('divForCaptureProgress');	
	}catch(e)
	{
		alert("Error in OpenWindow_Save and Encode"+e);
	}
	
	var savetop = playerTop + 150;
	saveAndEncodeNameWindow= dhtmlwindow.open("ClipName", "ajax", "../widgets/capture/template/SaveAndEncodeName.htm", "ClipName", "width=220px,height=65pX,left=725px,top="+savetop+",resize=1,scrolling=1", "recal")
}

/*
function sendMailAfterCapture(){
	
	var toAccountId = document.getElementById("_sendTo").value;
	var mailSubject = document.getElementById("_sendMailSubject").value;
	var mailBody = document.getElementById("_sendMailBody").value;
	
	
	
	
	var cont = new Controller('CaptureWidget_getDefaultProjectParameters','CaptureWidget','','cw1'); //Used for getting the ProjectName (Recently Created)
	var defaultValuesArray = cont.getResult();
	var project_Name = defaultValuesArray['projectName'];
	if(project_Name){ //Checks whether the project has been created or not
	var folderPath = 'file:/C:/meprojects/';
	var messagePath = folderPath + project_Name + '/video_s1.dat.sdl';
	}
	else{
		alert("NO Project Exists");
	}
	
	
	var paramList = "accountId:'espre',toAccountId:'"+toAccountId+"',mailSubject:'"+mailSubject+"',msgUrl:'"+messagePath+"',msgText:'"+mailBody+"',msgSize:100,msgDuration:20";
	
	var cont = new Controller('sendVideoMail','VideoMail',paramList);
		
		if(cont.result==true)
			alert("Mail has been sent successfully");
	sendMailToUserWindow.hide();
}
*/

/*
function callPlayMethodofPlayer(messagePath,currentWindow){

		try{
			var pName=_playerWinNames[currentWindow];
			pName.play_video(messagePath);
		}catch(errObj){
			alert(errObj.message);
		}
}
*/

/**
 * callback called when all actors initialized properly
 */


function allActorsStarted(){
	
	window.status = "All Actors ready";	
	
	
	hideDiv('loader');

	locaderDiv = document.getElementById('loader');
	document.body.removeChild(locaderDiv);

	showDiv('mainTable');


	pollingForTextChat();

	//hideDiv('loadingDiv');
	//userPresenceWindow.show();
	//playListWidgetWindow.show();
}



function initialActors(){	
	hideDiv('mainTable');
	showDiv('loader');


	
	activeDiv(false, "home");

	init_capture();
	createStatusArr();
	 //_getLoggedInUserInfo();
	openwindow_userPresence();


	resetChat();
	
	//openPlayers();		
	
	// keep this commeted only to run new player skin
	//openwindow_PlayList();
	//openwindow_Capture();

	//openwindowVideoMessage(); //used in video messaging
	initVideoWidgets();
	
	
	//setTimeout('allActorsStarted()',12000);
}

/*
function addOption(selectbox,text,value ){
		var optn = document.createElement("OPTION");
		optn.text = text;
		optn.value = value;
		selectbox.options.add(optn);
	}
*/
	
var encode_progress_bar=null;
/**
 * encode the project
 */

/*
function get_clip_collector_Encoder_Progress(){
	var encoderProgress = currentClipCollector.getEncodeProgress();
	edata = encoderProgress/100;
	if(encoderProgress>=100){
		clearTimeout(encoderTimer);
		hideDiv('clipCollectorEncoderProgress');
		showDiv('uploadImg');
	}
	encode_progress_bar.setPercent(edata);	
	var encoderTimer=setTimeout('get_clip_collector_Encoder_Progress()',1000);
}
*/

/**
 * populates the floating div with message name
 */

 /*
function populateFloatingPlayListDiv(playList){
	var ObjStatusDiv = document.getElementById("floatingPlayListDiv");
	var tableStr = '<TABLE  align=\"center\" border=\"0\">';
	var tableEnd = '</TABLE>';
	var tableData = '';
		tableData +="<SELECT name='lstDropDown_playList' id='lstDropDown_playList' style='' onKeyDown='fnKeyDownHandler(this, event);' onKeyUp='fnKeyUpHandler_A(this, event); return false;' onKeyPress = 'return fnKeyPressHandler_A(this, event);'  onChange='fnChangeHandler_A(this, event);playSelectedMessage(this);' ondblclick ='hideDiv(\'floatingPlayListDiv\')';onselect='playSelectedMessage(this)'>";
		tableData +="<OPTION >   </OPTION>";
	for(i=0;i<playList.length;i++)
	{ 
		tableData +="<option value='" + playList[i].getMessagePath() + "'>" + playList[i].getMessageName() + "</option>";
	}
		tableData += "</SELECT><img id='clikToPlay' border='0' src=\"images/play.png\" >";
		statusHTMLstr = tableStr + tableData + tableEnd;
		ObjStatusDiv.innerHTML = statusHTMLstr;
}
*/


/* Functions added by vikas 7-31-2007 */
 function showInboxMessageList(){
	
	
	if( ! navthrough )
    {
		if( ! navigateWhileCapturing() )
		{	var isNavigate = false;
			
		}else{  var isNavigate =  true;
		}
	
	}
	else{ var isNavigate =  true; navthrough = false;
	}


	//alert(isNavigate);

	if(isNavigate){
	
		stopAllPlayers();
		hideAllPlayersDiv();

		showPlayerAppletDiv();
		getInboxMails();
		showForwardSuggestion();
		 highlightedDivId = null;
		return true;
	}else{ return false;
	}

}


function showSentMessageList()
{
  
  if( ! navigateWhileCapturing() )
	{	var isNavigate = false;
		
	}else{  var isNavigate =  true;
	}

	//alert(isNavigate);

	if(isNavigate){
	  stopAllPlayers();
	  hideAllPlayersDiv();
	  showPlayerAppletDiv();
	  getSentMails();
	  highlightedDivId = null;
	return true;
	}else{ return false;
	}
}

function showUnSentMessageList()
{
   
   if( ! navigateWhileCapturing() )
	{	var isNavigate = false;
		
	}else{  var isNavigate =  true;
	}

	//alert(isNavigate);

	if(isNavigate){
	   stopAllPlayers();
	   hideAllPlayersDiv();
	   showPlayerAppletDiv();
	   getUnsentMails();
	    highlightedDivId = null;
	return true;
	}else{ return false;
	}
}

function showNewMessageWindow()
{
	if(ifSelfPreview)
    {
		//if(confirm('This action will stop self preview.'))
		//changeCamStatus(cuurentUserId(),'False');//to change camalive status and close the self view	
		//closeChatWindow("selfview");  // To close self view window if open
		//else
		//	return false;

		showAlertMessage("You will have to stop self preview first than clik on new tab.");	return false;
	}
	if(!ifVideoDeviceAttached() )
	{	
		//alert("There is no Capture video device attached to your computer!");
		showAlertMessage("There is no Capture video device attached to your computer!");
		return false;
	}
	
	enable_disable_icons(1,0,0);
	hideAllPlayersDiv();
	stopAllPlayers();
	showSuggestion();
	//stop_player_vmb('player1');
	//hideDiv('edmeutilplayerforcapture');
	showCaptureAppletDiv();
	isCaptureStarted=true;
	return true;

}

function showTabDisplay(type)
{
	objImage = document.getElementById("tabImageDisplay");

	if(type == "inbox")
	{		
		objImage.src = "images/tab_inbox.gif";
	}
	else if(type == "new")
	{
		objImage.src = "images/tab_new.gif";
	}
	else if(type == "sent")
	{
		objImage.src = "images/tab_sent.gif";
	}
	else if(type == "unsent")
	{
		objImage.src = "images/tab_unsent.gif";
	}
}


function error_span(errorObject,errorMessage)
{
	errorObject.style.visibilty='visible';
	errorObject.style.display='';
	errorObject.innerHTML='<div class="errormsg" >'+errorMessage+'</div>';
}/*document.onkeypress = assignKeyCode;


function assignKeyCode()
{
	if( window.event.keyCode == 13 )
		{
			lastKeyCode = '13'
		}
	else lastKeyCode = null ;

}
*/