	/************************************************************************
	*	File Name: 			inboxmessage.js									*
	*	Author Name: 		Nabeel Bin Ezad									*
	*	Description:		Used for on message javascript functionality	*	
	*	Created Date:		20 June 2008.									*
	*	Modified Date: 		05 Nov 2008.		    						*
	*	Last Modified By:	Ramish Hashmi	 								*
	*																		*
	*************************************************************************/	
	var	objEditorInstance;
	var yPos;
	/************************************************************************
	*
	*	Function Name:	ComposeNewMessageHtml									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/		
	function ComposeNewMessageHtml(pIntUserId,pIntCompanyId)
	{
		 yPos = document.documentElement.scrollTop;
		var url = 'GUIService/MessageService.php?action=composehtml&uid='+pIntUserId+'&compid='+pIntCompanyId; 			
		document.getElementById("divDashBoard").innerHTML="<img src=ImageFiles/indicator_medium.gif>";
		var myRequest= new Ajax.Request(
						url, 
						{   
							method: 'post',
							onSuccess: function(transport) 
							{      
								window.scroll(0,yPos);
								var strResponse=transport.responseText;
								strResponse=strResponse.split("+");
								document.getElementById("divDashBoard").innerHTML=strResponse[0];
								LoadToList(strResponse[1]);
							} 
						}); 
	}
	/************************************************************************
	*
	*	Function Name:	parseString									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/	
	var CheckedMsgLista=new Array();
	function parseString(charEmailList,result)
	{
		var lenght=charEmailList.length;
		var flag=0;
		var begin;
		var end;
		for(var index=0;index<lenght;index++)
		{
			if(charEmailList.charAt(index)=='<')
			{
				flag=1;
				begin=index;
			}
				
			else if(charEmailList.charAt(index)=='>' && flag==1)
			{
			
				flag=0;
				end=index;
			
				if (end==lenght-1)
				{
					result=result+charEmailList.substring(begin+1,end);
				}
				else
				{
					result=result+charEmailList.substring(begin+1,end)+',';
				}	
			}
			
		}
	
		return result;
	}

	/************************************************************************
	*
	*	Function Name:	LoadToList									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/		
	var customarray=new Array;
	var collection=new Array;
	function LoadToList(pStrContact)
	{

		var strContact=pStrContact;
		strContact=strContact.split(",");

		for(i=0;i<strContact.length;i++)
		{
			var strContacta=strContact[i];
			strContacta=strContacta.split(" ");
			var strFirstName=strContacta[0];
			var strLastName=strContacta[1];
			var strEmailAddress=strContacta[2];
			
			customarray[i]="\""+strFirstName+ " "+ strLastName+"\" <"+strEmailAddress+">";
			collection[i]="\""+strFirstName+ " "+ strLastName+"\" <"+strEmailAddress+">";
		}
	}
	/************************************************************************
	*
	*	Function Name:	SendMessage									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/		
	function SendMessage(pIntUserId,pIntCompanyId,pIntParentId)
	{
			if(CheckSendMessageSetting())
			{
				
				var result="";
				strNewEmailAddress=document.getElementById("txtTo").value;
				strNewEmailAddress="<"+strNewEmailAddress+">";
				result=parseString(strNewEmailAddress,result);
				CheckedMsgLista = result;
	
	
				var url = 'GUIService/MessageService.php?action=sendmessage&uid='+pIntUserId+'&companyid='+pIntCompanyId;
				var strTo=document.getElementById('txtTo').value;
				var strSubject=document.getElementById('txtEmailSubject').value;
				
				var strMessageBody=document.getElementById('txtEmailBody').value;
				var par='strTo='+CheckedMsgLista+'&subject='+strSubject+'&body='+strMessageBody+'&parentid='+pIntParentId;
				document.getElementById("divDashBoard").innerHTML="<img src=ImageFiles/indicator_medium.gif>";
				var myRequest= new Ajax.Request(
					url, 
				{   
					method: 'post',
					parameters:par,
					onSuccess: function(transport) 
					{     
						var strHtml='';
						//document.getElementById("divDashBoard").innerHTML=strHtml;
						
						if(transport.responseText==1)
						{
							
							var strHtml="<table border=0 cellspacing=0 cellpadding=0 width=700>";
							strHtml+="<tr>";
							strHtml+="<td align=center height=30></td>";
							strHtml+="</tr>";
							strHtml+="<tr>";
							strHtml+="<td align=center height=30><span class=BodyTextMessage>Your message has been sent.</span></td>";
							strHtml+="</tr>";
							strHtml+="<tr>";
							strHtml+="<td align=center height=30></td>";
							strHtml+="</tr>";
							strHtml+="<tr>";
							strHtml+="<td align=center>";
							strHtml+='<a href="#" onclick="backToDashboard()">';
							strHtml+='<img border=0 src="../../IncludeFiles/CSS/images/backtoboard-button.jpg"  onMouseOver= "this.src =\'../../IncludeFiles/CSS/images/backtoboard-hover.jpg\'" onMouseOut= "this.src =\'../../IncludeFiles/CSS/images/backtoboard-hover.jpg\'"">	</a>';
							strHtml+="</td>";
							strHtml+="</tr>";
							strHtml+="</table>";
							document.getElementById("divDashBoard").innerHTML=strHtml;
						}
						else
						{
							var strHtml="<table border=0 cellspacing=0 cellpadding=0 width=700>";
							strHtml+="<tr>";
							strHtml+="<td align=center height=30></td>";
							strHtml+="</tr>";
							strHtml+="<tr>";
							strHtml+="<td align=center height=30><span class=ErrorMessage>Error.</span></td>";
							strHtml+="</tr>";
							strHtml+="<tr>";
							strHtml+="<td align=center height=30></td>";
							strHtml+="</tr>";
							strHtml+="<tr>";
							strHtml+="<td align=center><input type=button onclick=backToDashboard(); value='Back to Dashboard'></td>";
							strHtml+="</tr>";
							strHtml+="</table>";
							document.getElementById("divDashBoard").innerHTML=strHtml;
						}
						
					} 
				});	
			}
	}
	/************************************************************************
	*
	*	Function Name:	SendMessage									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/	
	function CheckSendMessageSetting()
	{
		if(document.getElementById('txtTo').value=="")
		{
			document.getElementById('DivToMsg').innerHTML='<span class="ErrorMessage">Required Field</span>';
			document.getElementById('txtTo').focus();
			return false;
		}
		return true;
	}
	/************************************************************************
	*
	*	Function Name:	DeleteMessageById									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/		
	function DeleteMessageById(pIntMessageId,pIntUserId)
	{
		var url = 'GUIService/MessageService.php?action=deletemessage&msgid='+pIntMessageId+'&uid='+pIntUserId; 			
		document.getElementById("DivUserMessage").innerHTML="<img src=ImageFiles/indicator_medium.gif>";
		var myRequest= new Ajax.Request(
						url, 
						{   
							method: 'post',
							onSuccess: function(transport) 
							{      
								
								document.getElementById("DivUserMessage").innerHTML=transport.responseText;
							} 
						}); 
	}
	/************************************************************************
	*
	*	Function Name:	MassDeleteMessages									
	*	Author Name: 	Adil Khan
	*																		
	*************************************************************************/		
	function MassDeleteMessages(pIntUserId, pIntCompany, pIntPanel)
	{		
		var pIntMessageId = "";
		var chckBoxCntr = 0;
		var valFilled = "";
		
		for( i=0; i< document.frmInbox.chkEmails.length; i++ )
		{	if(document.frmInbox.chkEmails[i].checked == true)
			{	//pIntMessageId[ chckBoxCntr++ ] = document.frmInbox.chkEmails[i].value;
				pIntMessageId = valFilled + document.frmInbox.chkEmails[i].value + ", ";
			}
		}
		
		var url = 'GUIService/MessageService.php?action=deletemessage&msgid='+pIntMessageId+'&uid='+pIntUserId; 						
		//document.getElementById("DivUserMessage").innerHTML="<img src=ImageFiles/indicator_medium.gif>";
		
		var myRequest= new Ajax.Request(
						url, 
						{   
							method: 'post',
							onSuccess: function(transport) 
							{    alert(pIntPanel);  
								if( pIntPanel > 0 )
									GetAllMssgs(pIntUserId, pIntCompany,1);
								else
									document.getElementById("DivUserMessage").innerHTML=transport.responseText;
							} 
						}); 
	}
	/************************************************************************
	*
	*	Function Name:	GetUserDetailByUserId									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/			
	function GetUserDetailByUserId(pIntFromUserId)
	{
	
		var url = 'GUIService/UserInfoService.php?action=AllUserInfo';
		var par = 'userId='+pIntFromUserId;
		var myRequest= new Ajax.Request(
						url, 
						{   
							method: 'post',
							parameters:par,
							onSuccess: function(transport) 
							{      
								document.getElementById("divDashBoard").innerHTML=transport.responseText;
							} 
						});
	}
	/************************************************************************
	*
	*	Function Name:	GetUserSentMessageByUserId									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/			
	function GetUserSentMessageByUserId(pIntUserId)
	{
		yPos = document.documentElement.scrollTop;
		var url = 'GUIService/MessageService.php?action=usersent&uid='+pIntUserId; 			
		document.getElementById("DivUserMessage").innerHTML="<img src=ImageFiles/indicator_medium.gif>";
		var myRequest= new Ajax.Request(
						url, 
						{   
							method: 'post',
							onSuccess: function(transport) 
							{      
								//window.scroll(0,yPos);
								document.getElementById("DivUserMessage").innerHTML=transport.responseText;
							} 
						}); 	
	}
	/************************************************************************
	*
	*	Function Name:	GoToInbox									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/			
	function GoToInbox(pIntUserId,pIntCompanyId)
	{	
		 yPos = document.documentElement.scrollTop;
		var url = 'GUIService/MessageService.php?action=backinbox&uid='+pIntUserId+'&compid='+pIntCompanyId; 			
		document.getElementById("DivUserMessage").innerHTML="<img src=ImageFiles/indicator_medium.gif>";
		
		var myRequest= new Ajax.Request(
						url, 
						{   
							method: 'post',
							onSuccess: function(transport) 
							{      		
								// window.scroll(0,yPos);
								document.getElementById("DivUserMessage").innerHTML=transport.responseText;
							} 
						}); 	
	}
	/************************************************************************
	*
	*	Function Name:	ReplyMessageHtml									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/		
	function ReplyMessageHtml(pIntUserId,pIntCompanyId,pIntMessageId,pIntToId,pStrSubject,pStrName,pStrUserName)
	{
		var url = 'GUIService/MessageService.php?action=replyhtml&uid='+pIntUserId+'&compid='+pIntCompanyId+'&msgid='+pIntMessageId; 			
		document.getElementById("DivUserMessage").innerHTML="<img src=ImageFiles/indicator_medium.gif>";
		var par='toid='+pIntToId+'&subject='+pStrSubject+'&name='+pStrName+'&uname='+pStrUserName;
		var myRequest= new Ajax.Request(
						url, 
						{   
							method: 'post',
							parameters:par,
							onSuccess: function(transport) 
							{      		
								document.getElementById("divDashBoard").innerHTML=transport.responseText;
							} 
						}); 	
	}
	/************************************************************************
	*
	*	Function Name:	EmailTemplateHtml									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/		
	function GetEmailTemplateHtml(pIntUserId,pIntCompanyId)
	{
		var url = 'GUIService/SettingService.php?action=temphtml&uid='+pIntUserId+'&compid='+pIntCompanyId; 			
		var myRequest= new Ajax.Request(
						url, 
						{   
							method: 'post',
							onSuccess: function(transport) 
							{      		
									document.getElementById("divDashBoard").innerHTML=transport.responseText;
									/*var strResponse=transport.responseText;
									strResponse=strResponse.split("+");
									document.getElementById("divDashBoard").innerHTML=strResponse[0];
									document.getElementById("DivEmailBody").innerHTML=strResponse[1];*/
							} 
						}); 	
	}

	function FCKeditor_OnComplete( editorInstance )
	{	
		objEditorInstance=editorInstance;
	}
	/************************************************************************
	*
	*	Function Name:	SaveEmailTemplateSetting									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/		
	function SaveEmailTemplateSetting(pIntUserId,pIntCompanyId)
	{
		
			if(CheckEmailTemplateSetting())
			{
				var strEmailSubject=document.getElementById("txtEmailSubject").value;
				var strEmailBody=objEditorInstance.GetXHTML(true);
				var intTypeId=document.getElementById("cmbTemplate").value;
				var par='&subject='+strEmailSubject+'&body='+strEmailBody+'&type='+intTypeId;
				var url = 'GUIService/SettingService.php?action=saveemailtemp&uid='+pIntUserId+'&compid='+pIntCompanyId; 			
				var myRequest= new Ajax.Request(
								url, 
								{   
									method: 'post',
									parameters:par,
									onSuccess: function(transport) 
									{      		
											document.getElementById("divDashBoard").innerHTML=transport.responseText;
									} 
								}); 	
			}
	}
	function CheckEmailTemplateSetting()
	{
		
		if(document.getElementById("txtSubject").value=="")
		{
				
			document.getElementById("divTempNameMsg").innerHTML="<span class=ErrorMessage>Field Required</span>";
			return false;
		}
		return true;
	}
	/************************************************************************
	*
	*	Function Name:	GetEmailTemplateById									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/		
	function GetEmailTemplateById(pIntUserId,pIntCompanyId)
	{
		var intTypeId=document.getElementById("cmbTemplate").value;
		var url = 'GUIService/SettingService.php?action=gettemp&uid='+pIntUserId+'&compid='+pIntCompanyId+'&type='+intTypeId; 			
		var myRequest= new Ajax.Request(
						url, 
						{   
							method: 'post',
							onSuccess: function(transport) 
							{      		
									//document.getElementById("divDashBoard").innerHTML=transport.responseText;
									//window.location="index.php?q=programmanager";
									var strResponse=transport.responseText;
									document.getElementById("divDashBoard").innerHTML=strResponse[0];
									document.getElementById("DivEmailBody").innerHTML=strResponse[1];
							} 
						}); 	
		
		
	}
	
	 /************************************************************************
	*
	*	Function Name:	GetUserGroupsUserId									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/	

	function GetUserGroupsByUserId(pIntUserId,pIntCompanyId,pIntStatus)
  	{
	   yPos = document.documentElement.scrollTop;
	   document.getElementById("divDashBoard").innerHTML="<img src=ImageFiles/indicator_medium.gif>";
	   var url = 'GUIService/MessageService.php?action=usergroups&userId='+pIntUserId+'&compId='+pIntCompanyId+'&sort='+pIntStatus;
	   var myRequest= new Ajax.Request(
		url, 
		{   
		  onSuccess: function(transport) 
		  {   
		  	  window.scroll(0,yPos);
			 document.getElementById("divDashBoard").innerHTML=transport.responseText;
		  }  
	  });		
	}
	
	/************************************************************************
	*
	*	Function Name:	AddGroupHtml									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/	

	function AddGroupHtml(pIntUserId,pIntCompanyId)
  	{
	   document.getElementById("divDashBoard").innerHTML="<img src=ImageFiles/indicator_medium.gif>";
	   var url = 'GUIService/MessageService.php?action=addGroup&userId='+pIntUserId+'&compId='+pIntCompanyId;
	   var myRequest= new Ajax.Request(
		url, 
		{   
		  onSuccess: function(transport) 
		  {     
			 document.getElementById("divDashBoard").innerHTML=transport.responseText;
		  }  
	  });		
	}
	/************************************************************************
	*
	*	Function Name:	SaveGroup									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/		
	function SaveGroup(pIntUserId,pIntCompanyId)
	{
		if(CheckGroupSetting())
		{
			var strGroupName=document.getElementById("txtGroupName").value;
			var par='groupname='+strGroupName;
			var url = 'GUIService/MessageService.php?action=savegroup&uid='+pIntUserId+'&compid='+pIntCompanyId; 			
			var myRequest= new Ajax.Request(
							url, 
							{   
								method: 'post',
								parameters:par,
								onSuccess: function(transport) 
								{      		
									document.getElementById("divDashBoard").innerHTML=transport.responseText;
								} 
							}); 	
			
		}
	}
	/************************************************************************
	*
	*	Function Name:	CheckGroupSetting									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/	
	function CheckGroupSetting()
	{
	
		if(document.getElementById('txtGroupName').value=="")
		{
			document.getElementById('DivJobGroupeqMsg').innerHTML='<span class="ErrorMessage">Required Field</span>';
			document.getElementById('txtGroupName').focus();
			return false;
		}
		else
		{

			if(CheckStringLength(document.getElementById('txtGroupName').value))
			{
				document.getElementById('DivJobGroupeqMsg').innerHTML="";
			}
			else
			{
				document.getElementById('DivJobGroupeqMsg').innerHTML='<span class="ErrorMessage">String length too large. Only 255 characters allowed</span>';		
				document.getElementById('txtGroupName').focus();
				return false;	
			}
		}
		return true;
	}
	/************************************************************************
	*
	*	Function Name:	DeleteGroup									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/	
	function DeleteGroup(pIntUserId,pIntCompanyId,pIntGroupId)
	{
			if(confirm("Are you sure you want to delete"))
			{
				document.getElementById("divDashBoard").innerHTML="<img src=ImageFiles/indicator_medium.gif>";
				var url = 'GUIService/MessageService.php?action=deletegroup&groupid='+pIntGroupId+'&uid='+pIntUserId+'&compid='+pIntCompanyId; 			
				var myRequest= new Ajax.Request(
				url, 
				{   
					method: 'post',
					onSuccess: function(transport) 
					{      		
							document.getElementById("divDashBoard").innerHTML=transport.responseText;
					} 
				}); 	
			}
	}
	/************************************************************************
	*
	*	Function Name:	CheckGroupSetting									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/	
	function CheckGroupSetting()
	{
	
		if(document.getElementById('txtGroupName').value=="")
		{
			document.getElementById('DivJobGroupeqMsg').innerHTML='<span class="ErrorMessage">Required Field</span>';
			document.getElementById('txtGroupName').focus();
			return false;
		}
		else
		{

			if(CheckStringLength(document.getElementById('txtGroupName').value))
			{
				document.getElementById('DivJobGroupeqMsg').innerHTML="";
			}
			else
			{
				document.getElementById('DivJobGroupeqMsg').innerHTML='<span class="ErrorMessage">String length too large. Only 255 characters allowed</span>';		
				document.getElementById('txtGroupName').focus();
				return false;	
			}
		}
		return true;
	}
	/************************************************************************
	*
	*	Function Name:	UpdateGroupHtml									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/	

	function UpdateGroupHtml(pIntUserId,pIntCompanyId,pStrGroupName,pIntGroupId)
  	{
		
	   document.getElementById("divDashBoard").innerHTML="<img src=ImageFiles/indicator_medium.gif>";
	   var url = 'GUIService/MessageService.php?action=updateGroup&userId='+pIntUserId+'&compId='+pIntCompanyId;
	   var par='groupname='+pStrGroupName+'&groupid='+pIntGroupId;
	   var myRequest= new Ajax.Request(
		url, 
		{   
		method: 'post',
          parameters:par,			
		  onSuccess: function(transport) 
		  {     
			 document.getElementById("divDashBoard").innerHTML=transport.responseText;
		  }  
	  });		
	   
	}
	/************************************************************************
	*
	*	Function Name:	UpdateGroup									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/		
	function UpdateGroup(pIntUserId,pIntCompanyId,pIntGroupId)
	{
		
		if(CheckGroupSetting())
		{
			//document.getElementById("divDashBoard").innerHTML="<img src=ImageFiles/indicator_medium.gif>";	
			var strGroupName=document.getElementById("txtGroupName").value;
			var par='groupname='+strGroupName+'&groupid='+pIntGroupId;
			
			var url = 'GUIService/MessageService.php?action=updatesavegroup&uid='+pIntUserId+'&compid='+pIntCompanyId; 			
			var myRequest= new Ajax.Request(
							url, 
							{   
								method: 'post',
								parameters:par,
								onSuccess: function(transport) 
								{      		
										document.getElementById("divDashBoard").innerHTML=transport.responseText;
										//GetUserGroupsByUserId(pIntUserId,pIntCompanyId);
								} 
							}); 	
			
		}
		
	}

		 /************************************************************************
	*
	*	Function Name:	GetUserGroupsUserId									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/	

	function GetGroupContactList(pIntUserId,pIntCompanyId,pIntGroupId)
  	{
	   document.getElementById("divDashBoard").innerHTML="<img src=ImageFiles/indicator_medium.gif>";
	   var url = 'GUIService/MessageService.php?action=groupcontacts&userId='+pIntUserId+'&compId='+pIntCompanyId+'&groupid='+pIntGroupId;
	   var myRequest= new Ajax.Request(
		url, 
		{   
		  onSuccess: function(transport) 
		  {     
			 document.getElementById("divDashBoard").innerHTML=transport.responseText;
		  }  
	  });		
	}
	/************************************************************************
	*
	*	Function Name:	DeleteContact									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/	
	function DeleteContact(pIntUserId,pIntCompanyId,pIntContactId,pIntGroupId)
	{
			if(confirm("Are you sure you want to delete"))
			{
				document.getElementById("divDashBoard").innerHTML="<img src=ImageFiles/indicator_medium.gif>";
				var url = 'GUIService/MessageService.php?action=deletecontact&contactid='+pIntContactId+'&userid='+pIntUserId+'&compid='+pIntCompanyId+'&groupid='+pIntGroupId; 			
				var myRequest= new Ajax.Request(
				url, 
				{   
					method: 'post',
					onSuccess: function(transport) 
					{      		
							document.getElementById("divDashBoard").innerHTML=transport.responseText;
					} 
				}); 	
			}
	}
	/************************************************************************
	*
	*	Function Name:	AddGroupContactHtml									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/	

	function AddGroupContactHtml(pIntUserId,pIntCompanyId,pIntGroupId)
  	{
		
	   document.getElementById("divDashBoard").innerHTML="<img src=ImageFiles/indicator_medium.gif>";
	   var url = 'GUIService/MessageService.php?action=addGroupContact&userId='+pIntUserId+'&compId='+pIntCompanyId+'&groupid='+pIntGroupId;
	   var myRequest= new Ajax.Request(
		url, 
		{   
		  onSuccess: function(transport) 
		  {     
			 document.getElementById("divDashBoard").innerHTML=transport.responseText;
		  }  
	  });
	 
	}
	/************************************************************************
	*
	*	Function Name:	SaveGroupContact									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/	
	
	function SaveGroupContact(pIntUserId,pIntCompanyId,pIntGroupId)
	{
		
			var arrContact=new Array();
			var intCounter=0;
			
			for(var i=document.getElementById('cmbContactList').options.length-1;i>=0;i--)
			{
				if(document.getElementById('cmbContactList').options[i].selected)
				{
					arrContact[intCounter]=document.getElementById('cmbContactList').options[i].value;
					intCounter++;
				}	
			}	
			
			if(intCounter==0)
			{
				document.getElementById("DivJobGroupeqMsg").innerHTML="Select atleast one user";
				document.getElementById("cmbContactList").focus();
				return;
			}
			
			var par='contactlist='+arrContact;
			var url = 'GUIService/MessageService.php?action=savegroupcontact&uid='+pIntUserId+'&compid='+pIntCompanyId+'&groupid='+pIntGroupId; 			
			var myRequest= new Ajax.Request(
							url, 
							{   
								method: 'post',
								parameters:par,
								onSuccess: function(transport) 
								{      		
									document.getElementById("divDashBoard").innerHTML=transport.responseText;
								} 
							}); 	
			
	}
	/************************************************************************
	*
	*	Function Name:	AddNewTemplateHtml									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/	

	function AddNewTemplateHtml(pIntUserId,pIntCompanyId)
  	{
	   document.getElementById("divDashBoard").innerHTML="<img src=ImageFiles/indicator_medium.gif>";
	   var url = 'GUIService/SettingService.php?action=addtemphtml&userId='+pIntUserId+'&compId='+pIntCompanyId;
	   var myRequest= new Ajax.Request(
		url, 
		{   
		  onSuccess: function(transport) 
		  {     
		
			var strResponse=transport.responseText;
			strResponse=strResponse.split("+");
			document.getElementById("divDashBoard").innerHTML=strResponse[0];
			document.getElementById("DivTempEmailBody").innerHTML=strResponse[1];
		  }  
	  });
	 
	}
	
	/************************************************************************
	*
	*	Function Name:	SaveEmailTemplate									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/	

	function SaveEmailTemplate(pIntUserId,pIntCompanyId)
  	{
		
		if(CheckEmailTemplateSetting())
		{
	    	var strEmailSubject=document.getElementById("txtSubject").value;
			var strEmailDescription=document.getElementById("txtEmailDescription").value;
			var strEmailBody=objEditorInstance.GetXHTML(true);
		
		var par='&subject='+strEmailSubject+'&body='+strEmailBody+'&description='+strEmailDescription;
		var url = 'GUIService/SettingService.php?action=saveemailtemp&uid='+pIntUserId+'&compid='+pIntCompanyId; 			
		var myRequest= new Ajax.Request(
						url, 
						{   
							method: 'post',
							parameters:par,
							onSuccess: function(transport) 
							{      		
									document.getElementById("divDashBoard").innerHTML=transport.responseText;
							} 
						}); 	
		}
	   
	}
	/************************************************************************
	*
	*	Function Name:	DeleteTemplate									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/	
	function DeleteTemplate(pIntUserId,pIntCompanyId,pIntTemplateId)
	{
			if(confirm("Are you sure you want to delete"))
			{
					var url = 'GUIService/SettingService.php?action=deleteemailtemp&uid='+pIntUserId+'&compid='+pIntCompanyId+'&tempid='+pIntTemplateId; 			
					var myRequest= new Ajax.Request(
						url, 
						{   
							method: 'post',
							onSuccess: function(transport) 
							{      		
									document.getElementById("divDashBoard").innerHTML=transport.responseText;
							} 
						}); 	
			}
	}
	/************************************************************************
	*
	*	Function Name:	UpdateEmailTemplate									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/	
	function UpdateEmailTemplate(pIntUserId,pIntCompanyId,pIntTemplateId)
	{
			var url = 'GUIService/SettingService.php?action=updatetemplatehtml&uid='+pIntUserId+'&compid='+pIntCompanyId+'&tempid='+pIntTemplateId; 			
					var myRequest= new Ajax.Request(
						url, 
						{   
							method: 'post',
							onSuccess: function(transport) 
							{      		
								var strResponse=transport.responseText;
								strResponse=strResponse.split("+");
								document.getElementById("divDashBoard").innerHTML=strResponse[0];
								document.getElementById("DivTempEmailBody").innerHTML=strResponse[1];
							} 
						}); 		
	}
	/************************************************************************
	*
	*	Function Name:	UpdateEmailTemplate									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/	

	function EditEmailTemplate(pIntUserId,pIntCompanyId,pIntTemplateId)
  	{
		if(CheckEmailTemplateSetting())
		{
			
			var strEmailSubject=document.getElementById("txtSubject").value;
			var strEmailBody=objEditorInstance.GetXHTML(true);
			var strEmailDescription=document.getElementById("txtDescription").value;
            
				
			
			var par='&subject='+strEmailSubject+'&body='+strEmailBody+'&tempid='+pIntTemplateId+'&description='+strEmailDescription;
			var url = 'GUIService/SettingService.php?action=updatetemp&uid='+pIntUserId+'&compid='+pIntCompanyId; 			
			
			var myRequest= new Ajax.Request(
							url, 
							{   
								method: 'post',
								parameters:par,
								onSuccess: function(transport) 
								{      		
										document.getElementById("divDashBoard").innerHTML=transport.responseText;
								} 
							}); 	
			
		}
	}
	/************************************************************************
	*
	*	Function Name:	GetMassEmailHtml									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/		
	function GetMassEmailHtml(pIntUserId,pIntCompanyId)
	{
		var url = 'GUIService/SettingService.php?action=massemailhtml&uid='+pIntUserId+'&compid='+pIntCompanyId; 			
		var myRequest= new Ajax.Request(
						url, 
						{   
							method: 'post',
							onSuccess: function(transport) 
							{      		
									document.getElementById("divDashBoard").innerHTML=transport.responseText;
							} 
						}); 	
	}
	
	/************************************************************************
	*
	*	Function Name:	GetMassEmailHtml									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/		
	
	function GetEmailTemplateBody()
	{
		var intEmailTemplate=document.getElementById("cmbTemplate").value;	
		var strResponse=intEmailTemplate;
		strResponse=strResponse.split("+");
		intEmailTemplate=strResponse[0];
		document.getElementById("DivEmailTemplate").innerHTML="<img src=ImageFiles/indicator_medium.gif>";
	   var url = 'GUIService/SettingService.php?action=emailtemplatebody&templateid='+intEmailTemplate;
	   var myRequest= new Ajax.Request(
		url, 
		{   
		  onSuccess: function(transport) 
		  {     
				document.getElementById("DivEmailTemplate").innerHTML=transport.responseText;
				document.getElementById("DivErrEmailTemplate").innerHTML='';
		  }  
	  });
	}
	/************************************************************************
	*
	*	Function Name:	GetGroupsContact
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/		
	
	function GetGroupsContact()
	{
		
		var intGroupId=document.getElementById("cmbEmailGroup").value;	
		document.getElementById("DivGroupContact").innerHTML="<img src=ImageFiles/indicator_medium.gif>";
	   var url = 'GUIService/SettingService.php?action=emailgroupcontact&groupid='+intGroupId;
	   var myRequest= new Ajax.Request(
		url, 
		{   
		  onSuccess: function(transport) 
		  {     
		
			document.getElementById("DivGroupContact").innerHTML=transport.responseText;
			document.getElementById("DivErrEmailGroup").innerHTML='';
		  }  
	  });
	}
	
	/************************************************************************
	*
	*	Function Name:	GetMassEmailHtml									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/		
	function SendMassEmail(pIntUserId,pIntCompanyId)
	{
		if(CheckEmailSendSetting())
		{
		
			var strEmailSubject=document.getElementById("cmbTemplate").value;	
			var strResponse=strEmailSubject;
			strResponse=strResponse.split("+");
			strEmailSubject=strResponse[1];
			
			var arrContact=new Array();
			var intCounter=0;
			var intContactLength = document.frmContactList.chkContacts.length;
				
				for (i = 0; i < intContactLength; i++) 
				{
						if (document.frmContactList.chkContacts[i].checked)
						{
							//strFunctionalArea = strFunctionalArea + document.form1.functionalArea[i].value + ",";
							arrContact[intCounter]=document.frmContactList.chkContacts[i].value;
							intCounter++;
						}
				}
			
		   var strEmailBody=objEditorInstance.GetXHTML(true);
		 	document.getElementById("divDashBoard").innerHTML="<img src=ImageFiles/indicator_medium.gif>";		 
		   var par='&subject='+strEmailSubject+'&body='+strEmailBody+'&arrcontact='+arrContact;
		  
		   var url = 'GUIService/SettingService.php?action=sendmassemail&uid='+pIntUserId+'&compid='+pIntCompanyId; 			
		   var myRequest= new Ajax.Request(
							url, 
							{   
								method: 'post',
								parameters:par,
								onSuccess: function(transport) 
								{      		
									//document.getElementById("divDashBoard").innerHTML=transport.responseText;
									window.location="index.php?q=programmanager";
								} 
							}); 	
		}
	}
	/************************************************************************
	*
	*	Function Name:	CheckEmailSendSetting									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/		

	function CheckEmailSendSetting()
	{
			var strEmailSubject=document.getElementById("cmbTemplate").value;	
			var strResponse=strEmailSubject;
			strResponse=strResponse.split("+");
			strEmailSubject=strResponse[0];
			if(strEmailSubject==-1)
			{
					document.getElementById("DivErrEmailTemplate").innerHTML='<span class="ErrorMessage">Required Field</span>';
					return false;
			}
			else
			{
					document.getElementById("DivErrEmailTemplate").innerHTML='';
					
			}
			if(document.getElementById("cmbEmailGroup").value==-1)
			{
					document.getElementById("DivErrEmailGroup").innerHTML='<span class="ErrorMessage">Required Field</span>';
					return false;
			}
			else
			{
				document.getElementById("DivErrEmailGroup").innerHTML='';
			}
			var intContactLength = document.frmContactList.chkContacts.length;
			var intStatus=0;
			for (i = 0; i < intContactLength; i++) 
			{
					if (document.frmContactList.chkContacts[i].checked)
					{
						intStatus=1;
					}
			}
			if(intStatus==0)
			{
				document.getElementById("DivErrEmailGroup").innerHTML='<span class="ErrorMessage">Select atleast one contact</span>';
				return false;
			}
			else
			{
				document.getElementById("DivErrEmailGroup").innerHTML='';
			}
			return true;
			
	}
	/************************************************************************
	*
	*	Function Name:	UncheckAll									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/		

	function UncheckAll()
	{
		var intContactLength = document.frmContactList.chkContacts.length;
		if(document.frmContactList.chkAll.checked)
		{
			for (i = 0; i < intContactLength; i++) 
			{
				if (document.frmContactList.chkContacts[i].checked==false)
				{
					document.frmContactList.chkContacts[i].checked=true;		
				}
			}
		}
		else
		{
			for (i = 0; i < intContactLength; i++) 
			{
					if (document.frmContactList.chkContacts[i].checked)
					{
						document.frmContactList.chkContacts[i].checked=false;		
					}
			}
		}
	}
	
	/************************************************************************
	*
	*	Function Name:	PaggingGroups									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/		
	function PaggingGroups(pIntUserId,pIntStartIndex,pIndeEndIndex,pIntPageNo,pIntTotalPage,pStatus,pIntTotalRecord,pIntLimit,pIntDashBoard,pIntCompanyId)
	{
		if(pStatus==2)
		{
				pIntPageNo=pIntPageNo-1;
				pIntStartIndex=pIntStartIndex-pIntLimit;
				pIndeEndIndex=pIntLimit;
		}
		else
		{
			if(pIntPageNo==pIntTotalPage)
			{
				pIntStartIndex=pIntTotalRecord-pIntLimit;
				pIndeEndIndex=5;
			}
			else
			{
				pIntPageNo=pIntPageNo+1;
				pIntStartIndex=pIntStartIndex+pIntLimit;
				pIndeEndIndex=pIntLimit;
			}	
		}
		
		if(pStatus==4)
		{
			pIntStartIndex=pIntTotalPage*pIntLimit-pIntLimit;	
			
		}
		document.getElementById("divDashBoard").innerHTML="<img src=ImageFiles/indicator_medium.gif>"; 
		var url = 'GUIService/MessageService.php?action=pagegroups&pStart='+pIntStartIndex+'&pEnd='+pIndeEndIndex+'&uid='+pIntUserId+'&pPid='+pIntPageNo+'&pStatus='+pIntDashBoard+'&compid='+pIntCompanyId; 
		var myRequest= new Ajax.Request(
						url, 
						{   
							method: 'post',
							onSuccess: function(transport) 
							{ 
								document.getElementById("divDashBoard").innerHTML=transport.responseText;
							} 
						}); 
	}
	/************************************************************************
	*
	*	Function Name:	PaggingGroupsContact									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/		
	function PaggingGroupsContact(pIntUserId,pIntStartIndex,pIndeEndIndex,pIntPageNo,pIntTotalPage,pStatus,pIntTotalRecord,pIntLimit,pIntDashBoard,pIntCompanyId,pIntGroupId,pIntSort)
	{
		if(pStatus==2)
		{
				pIntPageNo=pIntPageNo-1;
				pIntStartIndex=pIntStartIndex-pIntLimit;
				pIndeEndIndex=pIntLimit;
		}
		else
		{
			if(pIntPageNo==pIntTotalPage)
			{
				pIntStartIndex=pIntTotalRecord-pIntLimit;
				pIndeEndIndex=5;
			}
			else
			{
				pIntPageNo=pIntPageNo+1;
				pIntStartIndex=pIntStartIndex+pIntLimit;
				pIndeEndIndex=pIntLimit;
			}	
		}
		
		if(pStatus==4)
		{
			pIntStartIndex=pIntTotalPage*pIntLimit-pIntLimit;	
			
		}
		document.getElementById("divDashBoard").innerHTML="<img src=ImageFiles/indicator_medium.gif>"; 
		var url = 'GUIService/MessageService.php?action=pagegroupscontact&pStart='+pIntStartIndex+'&pEnd='+pIndeEndIndex+'&uid='+pIntUserId+'&pPid='+pIntPageNo+'&pStatus='+pIntDashBoard+'&compid='+pIntCompanyId+'&groupid='+pIntGroupId+'&pSort='+pIntSort; 
		var myRequest= new Ajax.Request(
						url, 
						{   
							method: 'post',
							onSuccess: function(transport) 
							{ 
								document.getElementById("divDashBoard").innerHTML=transport.responseText;
							} 
						}); 
	}
	
	/************************************************************************
	*
	*	Function Name:	PaggingTemplate									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/		
	function PaggingTemplate(pIntUserId,pIntStartIndex,pIndeEndIndex,pIntPageNo,pIntTotalPage,pStatus,pIntTotalRecord,pIntLimit,pIntDashBoard,pIntCompanyId)
	{
		if(pStatus==2)
		{
				pIntPageNo=pIntPageNo-1;
				pIntStartIndex=pIntStartIndex-pIntLimit;
				pIndeEndIndex=pIntLimit;
		}
		else
		{
			if(pIntPageNo==pIntTotalPage)
			{
				pIntStartIndex=pIntTotalRecord-pIntLimit;
				pIndeEndIndex=5;
			}
			else
			{
				pIntPageNo=pIntPageNo+1;
				pIntStartIndex=pIntStartIndex+pIntLimit;
				pIndeEndIndex=pIntLimit;
			}	
		}
		
		if(pStatus==4)
		{
			pIntStartIndex=pIntTotalPage*pIntLimit-pIntLimit;	
			
		}
		document.getElementById("divDashBoard").innerHTML="<img src=ImageFiles/indicator_medium.gif>"; 
		var url = 'GUIService/SettingService.php?action=pagetemplate&pStart='+pIntStartIndex+'&pEnd='+pIndeEndIndex+'&uid='+pIntUserId+'&pPid='+pIntPageNo+'&pStatus='+pIntDashBoard+'&compid='+pIntCompanyId; 
		var myRequest= new Ajax.Request(
						url, 
						{   
							method: 'post',
							onSuccess: function(transport) 
							{ 
								document.getElementById("divDashBoard").innerHTML=transport.responseText;
							} 
						}); 
	}
	/************************************************************************
	*
	*	Function Name:	BackAddNewTemplate									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/		
	function BackAddNewTemplate(pIntUserId,pIntCompanyId)
	{
		var url = 'GUIService/SettingService.php?action=temphtml&uid='+pIntUserId+'&compid='+pIntCompanyId; 			
		var myRequest= new Ajax.Request(
						url, 
						{   
							method: 'post',
							onSuccess: function(transport) 
							{      		
									document.getElementById("divDashBoard").innerHTML=transport.responseText;
									/*var strResponse=transport.responseText;
									strResponse=strResponse.split("+");
									document.getElementById("divDashBoard").innerHTML=strResponse[0];
									document.getElementById("DivEmailBody").innerHTML=strResponse[1];*/
							} 
						}); 
	}

	/************************************************************************
	*
	*	Function Name:	GoToToolBarSetting									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/		
	function GoToToolBarSetting(pIntUserId,pIntCompanyId)
	{
		var url = 'GUIService/SettingService.php?action=gotosetting&uid='+pIntUserId+'&compid='+pIntCompanyId; 			
		var myRequest= new Ajax.Request(
						url, 
						{   
							method: 'post',
							onSuccess: function(transport) 
							{      	
									document.getElementById("divDashBoard").innerHTML=transport.responseText;
							} 
						}); 
	}
	/************************************************************************
	*
	*	Function Name:	MessageDetail									
	*	Author Name: 	Nabeel Bin Ezad
	*																		
	*************************************************************************/		
	function MessageDetail(pIntUserId,pIntCompanyId,pIntMessageId,pIntToId,pStrSubject,pStrName,pStrUserName)
	{
		var url = 'GUIService/MessageService.php?action=messagedetail&uid='+pIntUserId+'&compid='+pIntCompanyId+'&msgid='+pIntMessageId; 			
		document.getElementById("DivUserMessage").innerHTML="<img src=ImageFiles/indicator_medium.gif>";
		var par='toid='+pIntToId+'&subject='+pStrSubject+'&name='+pStrName+'&uname='+pStrUserName;
		var myRequest= new Ajax.Request(
						url, 
						{   
							method: 'post',
							parameters:par,
							onSuccess: function(transport) 
							{      		
								document.getElementById("divDashBoard").innerHTML=transport.responseText;
							} 
						}); 	
	}
	/************************************************************************
	*
	*	Function Name:	SaveSingleGroupContact									
	*	Author Name: 	Ramish Hashmi
	*																		
	*************************************************************************/		

	function SaveSingleGroupContact(pIntManagerId,pIntUserId,pIntCompanyId,pIntGroupId)
	{
		var par='contactlist='+pIntUserId;
		var url = 'GUIService/MessageService.php?action=savesinglegroupcontact&uid='+pIntManagerId+'&compid='+pIntCompanyId+'&groupid='+pIntGroupId; 			
		var xPos = document.documentElement.scrollTop;
		window.scroll(0,xPos);
		document.getElementById("DivGroupAdd").innerHTML="<img src=ImageFiles/indicator_medium.gif>"; 
		var myRequest= new Ajax.Request(
					url, 
					{   
						method: 'post',
						parameters:par,
						onSuccess: function(transport) 
						{  
							if(transport.responseText==1)
							{
								window.scroll(0,xPos);	
								document.getElementById("DivGroupAdd").innerHTML="Candidate added to group";
								xPos=0;
							}
							else
							{
								window.scroll(0,xPos);	
								document.getElementById("DivGroupAdd").innerHTML="Candidate can't be added to group";
								xPos=0;
							}
							
						} 
					}); 	
	}
	/************************************************************************
	*
	*	Function Name:	SortInbox									
	*	Author Name: 	Ramish Hashmi
	*																		
	*************************************************************************/		

	function SortInbox(pIntUserId,pIntCompanyId,pIntStartIndex,pIntEndIndex,pIntStatus,pIntPageNo,pIntSort)
	{
	
		var url = 'GUIService/MessageService.php?action=sortedinbox&uid='+pIntUserId+'&compid='+pIntCompanyId+'&pStart='+pIntStartIndex+'&pEnd='+pIntEndIndex+'&pStatus='+pIntStatus+'&pPage='+pIntPageNo+'&pSort='+pIntSort; 			
		var xPos = document.documentElement.scrollTop;
		window.scroll(0,xPos);
		document.getElementById("DivUserMessage").innerHTML="<img src=ImageFiles/indicator_medium.gif>"; 
		var myRequest= new Ajax.Request(
					url, 
					{   
						method: 'post',
						onSuccess: function(transport) 
						{  
								window.scroll(0,xPos);	
								document.getElementById("DivUserMessage").innerHTML=transport.responseText;
								xPos=0;
							
						} 
					}); 	
		
	}
	/************************************************************************
	*
	*	Function Name:	SortEmailGroups									
	*	Author Name: 	Ramish Hashmi
	*																		
	*************************************************************************/
	function SortEmailGroups(pIntUserId,pIntStartIndex,pIntEndIndex,pIntStatus,pIntPageNo,pIntCompanyId,pIntSort)
	{
		var url = 'GUIService/MessageService.php?action=pagegroups&uid='+pIntUserId+'&compid='+pIntCompanyId+'&pStart='+pIntStartIndex+'&pEnd='+pIntEndIndex+'&pStatus='+pIntStatus+'&pPid='+pIntPageNo+'&pSort='+pIntSort; 			
		var xPos = document.documentElement.scrollTop;
		window.scroll(0,xPos);
		document.getElementById("divDashBoard").innerHTML="<img src=ImageFiles/indicator_medium.gif>"; 
		var myRequest= new Ajax.Request(
					url, 
					{   
						method: 'post',
						onSuccess: function(transport) 
						{  
								window.scroll(0,xPos);	
								document.getElementById("divDashBoard").innerHTML=transport.responseText;
								xPos=0;
							
						} 
					}); 	
		
	}
	/************************************************************************
	*
	*	Function Name:	SortGroupContacts									
	*	Author Name: 	Ramish Hashmi
	*																		
	*************************************************************************/

	function SortGroupContacts(pIntUserId,pIntStartIndex,pIntEndIndex,pIntStatus,pIntPageNo,pIntCompanyId,pIntGroupId,pIntSort)
	{
		var url = 'GUIService/MessageService.php?action=pagegroupscontact&pStart='+pIntStartIndex+'&pEnd='+pIntEndIndex+'&uid='+pIntUserId+'&pPid='+pIntPageNo+'&pStatus='+pIntStatus+'&compid='+pIntCompanyId+'&groupid='+pIntGroupId+'&pSort='+pIntSort; 
		var xPos = document.documentElement.scrollTop;
		window.scroll(0,xPos);
		document.getElementById("divDashBoard").innerHTML="<img src=ImageFiles/indicator_medium.gif>"; 
		var myRequest= new Ajax.Request(
					url, 
					{   
						method: 'post',
						onSuccess: function(transport) 
						{  
								window.scroll(0,xPos);	
								document.getElementById("divDashBoard").innerHTML=transport.responseText;
								xPos=0;
							
						} 
					}); 	
		
		
	}