/****************************************
File : ajex.js
Created By : Surendra Singh
Created on : 24-March-2009
Description : ajax function
included in : All 
Modified on : 
Modified by : 
Modified Desc :
Powered By : Zenfosys IT Services Pvt. Ltd.
***********************************************************************************************/
// this is the default handle function of ajax, very imporatnt for ajax and is a part of it
function GetXmlHttpObject(handler)
{ 
var objXmlHttp=null

if (navigator.userAgent.indexOf("Opera")>=0)
{
objXmlHttp=new XMLHttpRequest()
objXmlHttp.onload=handler
objXmlHttp.onerror=handler 
return objXmlHttp
}
if (navigator.userAgent.indexOf("MSIE")>=0)
{ 
var strName="Msxml2.XMLHTTP"
if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
{
strName="Microsoft.XMLHTTP"
} 
try
{ 
objXmlHttp=new ActiveXObject(strName)
objXmlHttp.onreadystatechange=handler 
return objXmlHttp
} 
catch(e)
{ 
alert("Error. Scripting for ActiveX might be disabled") 
return 
} 
} 
if (navigator.userAgent.indexOf("Mozilla")>=0)
{
objXmlHttp=new XMLHttpRequest()
objXmlHttp.onload=handler
objXmlHttp.onerror=handler 
return objXmlHttp
}
} 


//////////////////this function is used for menu back/////////////////////
function menu_back()
{
	//alert(j);
	var tt="";
	var uu="";
	var grp_id=document.getElementById("hidden_group_id").value;
	var frm =document.getElementById("operation").value; 
	c=document.getElementById("counter").value;
	for(i=1;i<c;i++)
	{
		if(document.getElementById("radiobutton"+i).checked==true)
		  {
			  tt=tt +document.getElementById("radiobutton"+i).value+",";
			  
		  }
		  if(document.getElementById("radiobutton"+i).checked==false)
		  {
			  uu=uu +document.getElementById("radiobutton"+i).value+",";
			  
		  }
	}
	alert(tt);
	alert(uu);
		var url="menu_rights/show_menu_rights.php?group_id="+grp_id+"&opr="+frm+"&check_id="+tt+"&uchek_id="+uu;
		//alert(url);
		xmlHttp=GetXmlHttpObject(get_menu)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	
} 
function get_menu() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(xmlHttp.responseText);
		document.getElementById("assign_group").innerHTML=xmlHttp.responseText 
	}
} 
/////////////////////////////////////////////////////////////////

// this function is used in create_menu.php for display sequence
function child_sequence(id)
{
	
	if (id>-1)
	{ 
		var url="menu_rights/sequence.php?pid="+id;
		//alert(url);
		xmlHttp=GetXmlHttpObject(show_sequence)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	else
	{ 
		document.getElementById("sequense_no").innerHTML=""
	} 
} 
function edit_child_sequence(id)
{
	
	if (id>-1)
	{ 
		var url="edit_sequence.php?mid="+id;
		//alert(url);
		xmlHttp=GetXmlHttpObject(show_sequence)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	else
	{ 
		document.getElementById("sequense_no").innerHTML=""
	} 
} 
function show_sequence() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("sequense_no").innerHTML=xmlHttp.responseText 
	}
} 
// this function is used in menu_rights.php for assign menu item
function assign_sub_menu(grp_id,submenu_id,frm)
{
	
	if (grp_id>0)
	{ 
		var url="menu_rights/show_menu_rights.php?group_id="+grp_id+"&opr="+frm+"&sub_id="+submenu_id;
		//alert(url);
		xmlHttp=GetXmlHttpObject(assign_sub_menu_items)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	else
	{ 
		document.getElementById("assign_group").innerHTML=""
	} 
} 

function assign_sub_menu_items() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("assign_group").innerHTML=xmlHttp.responseText 
	}
} 
// this function is used in menu_rights.php for assign menu item
function assign_menu(grp_id,frm)
{
	
	if (grp_id>0)
	{ 
		var url="menu_rights/show_menu_fram.php?group_id="+grp_id+"&opr="+frm;
		//alert(url);
		xmlHttp=GetXmlHttpObject(assign_menu_items)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	else
	{ 
		document.getElementById("assign_group").innerHTML=""
	} 
} 

function assign_menu_items() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("assign_group").innerHTML=xmlHttp.responseText 
	}
} 
// this function is used in view_branch.php for geting branch list
function get_branch(com_id,m_i_d)
{
	if (com_id>=0)
	{ 
	
		var url="Company_Master/view_branch_body.php?company_id="+com_id+"&mid="+m_i_d;
		//alert(url);
		xmlHttp=GetXmlHttpObject(list_branch)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	else
	{ 
		document.getElementById("view_branch").innerHTML=""
	} 
} 

function list_branch() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("view_branch").innerHTML=xmlHttp.responseText 
	}
} 

function get_user(m_i_d)
{
	//alert(grp_id);
	
	type_search=document.getElementById("type_all_search").value;
	search_data=document.getElementById("search_alltext").value;
	group_id=document.getElementById("grp_id").value;
	email=document.getElementById("email_id").value;
	
	
		var url="user_management/view_user_div.php?group_id="+group_id+"&mid="+m_i_d+"&type_all_search="+type_search+"&search_alltext="+search_data+"&email_id="+email;
	//alert(url);
		xmlHttp=GetXmlHttpObject(list_user)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	
} 

function list_user() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("view_user").innerHTML=xmlHttp.responseText 
	}
} 

// this function is used in showicon.php for geting branch  name 
function create_sess()
{
	company_id=document.getElementById("company_name1").value;
	branch_id=document.getElementById("branch1").value;
	//alert(company_id);
	if (company_id>0 && branch_id>0)
	{ 
		var url="create_sess.php?company_id="+company_id+"&branch_id="+branch_id;
		//alert(url);
		xmlHttp=GetXmlHttpObject(create_sess_company_branch)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	else
	{ 
		//document.getElementById("branch_name").innerHTML=""
	} 
} 

function create_sess_company_branch() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		if(xmlHttp.responseText == 1)
		{
			location.replace('home.php');
		}
		//document.getElementById("branch_name").innerHTML=xmlHttp.responseText 
	}
} 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// this function is used in showicon.php for geting branch  name 
function get_company_branch(str)
{
	if (str> 0)
	{ 
		var url="branch_name.php?company_id="+str;
		//alert(url);
		xmlHttp=GetXmlHttpObject(get_branch_name)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	else
	{ 
		document.getElementById("branch_name").innerHTML=""
	} 
} 

function get_branch_name() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(xmlHttp.responseText);
		document.getElementById("branch_name").innerHTML=xmlHttp.responseText 
	}
} 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function get_dep_chn(str)
{
//str=document.assign_depthd.department.value;
//alert(str);
if (str > 0)
{ 
var url="support_system/get_manager_of_company.php?company_id="+str;
//alert(url);
xmlHttp=GetXmlHttpObject(get_dep_change)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
} 
else
{ 
document.getElementById("company_manager").innerHTML=""
} 
} 

function get_dep_change() 
{ 
 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
//alert(xmlHttp.responseText);
document.getElementById("company_manager").innerHTML=xmlHttp.responseText 
}
} 


// this function is used in view_all_users.php to delete user
function user_delete(userid,m_id)
{ 
	if(confirm("Are You Sure To Delete ?"))
		{  
			if (userid>0)
			{ 
				var url="user_management/view_user_div.php?uid="+userid+"&mid="+m_id;
				//alert(url);
				xmlHttp=GetXmlHttpObject(list_user_paging)
				xmlHttp.open("GET", url , true)
				xmlHttp.send(null)
			} 
			 
		}
		
	
} 


function delete_user_mast() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
//	alert(xmlHttp.responseText);	
			document.getElementById("view_user").innerHTML=xmlHttp.responseText 
		
	}
} 
//******************************************
// this function is used in create_user.php for geting employee name and designation field
function get_emp_name_desig()
{

str=document.create_user.group_type.value;
if (str > 0)
{ 
var url="user_management/emp_name_desig.php?grp_id="+str;
xmlHttp=GetXmlHttpObject(get_emp_field)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
} 
else
{ 
document.getElementById("emp_name_designation").innerHTML=""
} 
} 

function get_emp_field() 
{ 
 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
//alert(xmlHttp.responseText);
document.getElementById("emp_name_designation").innerHTML=xmlHttp.responseText 
}
} 
//******************************************
//******************************************

// this function is used in create_user.php for geting branch  name and department field
function get_com_brname_deptname()
{
str=document.create_user.company_name.value;
//alert(str);
if (str > 0)
{ 
var url="user_management/branch_dept.php?company_id="+str;
xmlHttp=GetXmlHttpObject(get_brname_deptname)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
} 
else
{ 
document.getElementById("dept_braanch").innerHTML=""
} 
} 

function get_brname_deptname() 
{ 
 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
//alert(xmlHttp.responseText);
document.getElementById("dept_braanch").innerHTML=xmlHttp.responseText 
}
} 
//******************************************
//******************************************
// this function is used in create_user.php to check login id already exist
function check_loginid()
{ 
str=document.create_user.login_id.value;
if (str)
{ 
var url="user_management/check_already_exist.php?logid="+str;
xmlHttp=GetXmlHttpObject(getleft_loginid)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
} 
else
{ 
//document.getElementById("logid").innerHTML=""
} 
} 

function getleft_loginid() 
{ 
 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{

if(xmlHttp.responseText == 1)
{
	alert("Login Id Already Exists !!");
	document.create_user.login_id.select();
	document.create_user.login_id.focus();
}
//document.getElementById("logid").innerHTML=xmlHttp.responseText 
}
} 


/////////////////////////////////////////

function dep_name_changed()
{
str=document.assign_depthd.department.value;
//alert(str);
if (str > 0)
{ 
var url="support_system/assign_dep.php?dept_id="+str;
//alert(url);
xmlHttp=GetXmlHttpObject(get_dep_name_change)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
} 
else
{ 
document.getElementById("deptname").innerHTML=""
} 
} 

function get_dep_name_change() 
{ 
 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
//alert(xmlHttp.responseText);
document.getElementById("deptname").innerHTML=xmlHttp.responseText 
}
} 
////////////////pankaj code start assign operater//////////////////////////////
function opp_name_changed()
{
str=document.assign_deptopp.department.value;
//alert(str);
if (str > 0)
{ 
var url="support_system/assign_operator.php?dept_id="+str;
//alert(url);
xmlHttp=GetXmlHttpObject(get_dep_opp_name_change)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
} 
else
{ 
document.getElementById("opp_name").innerHTML=""
} 
} 

function get_dep_opp_name_change() 
{ 
 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
//alert(xmlHttp.responseText);
document.getElementById("opp_name").innerHTML=xmlHttp.responseText 
}
} 
/////////////////////pankaj code end////////////////////////
///////////////////////////////////////////////////////////////////////
function check_depart()
{ 
str=document.create_deptmnt.department_name.value;
if (str)
{ 
var url="support_system/check_dept_exist.php?dept_name="+str;

xmlHttp=GetXmlHttpObject(getleft_deptid)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
} 
else
{ 
//document.getElementById("logid").innerHTML=""
} 
} 

function getleft_deptid() 
{ 
 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{

if(xmlHttp.responseText == 1)
{
	
	alert("Department Already Exists !!");
	document.create_deptmnt.department_name.select();
	document.create_deptmnt.department_name.focus();
}
//document.getElementById("logid").innerHTML=xmlHttp.responseText 
}
} 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**/
function branch_delete(branch_id,page_n)
{ 
	if(confirm("Are You Sure To Delete This Branch?"))
		{  
			if (branch_id>0)
			{ 
				var url=page_n+"?branch_id="+branch_id;
				//alert(url);
				xmlHttp=GetXmlHttpObject(delete_company_branch)
				xmlHttp.open("GET", url , true)
				xmlHttp.send(null)
			} 
			else
			{ 
				//document.getElementById("logid").innerHTML=""
			} 
		}
	
} 
function delete_company_branch() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{//alert(xmlHttp.responseText);
		if(xmlHttp.responseText == 1)
		{
			alert("Branch Record Deleted Successfully");
			branch_paging(0);
		}
		//document.getElementById("logid").innerHTML=xmlHttp.responseText 
	}
} 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function company_del(companyid,page_n)
{ 

	if(confirm("Are You Sure To Delete This Company ?"))
		{  
			if (companyid>0)
			{ 
				var url=page_n+"?companyid="+companyid;
				//alert(url);
				xmlHttp=GetXmlHttpObject(delete_company_mast)
				xmlHttp.open("GET", url , true)
				xmlHttp.send(null)
			} 
			else
			{ 
				//document.getElementById("logid").innerHTML=""
			} 
		}
	
} 
function delete_company_mast() 
{ 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{//alert(xmlHttp.responseText);
		if(xmlHttp.responseText == 1)
		{
			
			alert("Company Record Deleted Successfully");
			show_company_list(0);
		}
		//document.getElementById("logid").innerHTML=xmlHttp.responseText 
	}
} 





function openuserdiv66(uid,gid,page_n){
     emailwindow=dhtmlmodal.open('UserBox', 'iframe', page_n+'?id='+uid+'&group_id='+gid, 'Edit User', 'width=850px,height=440px,center=1,resize=1,scrolling=1')

} //End "opennewsletter" function
///////////////////////////////////////////////////////////////
function openuser_detail_div66(uid,gid){
         //alert(uid);
		 //alert(gid);
	emailwindow=dhtmlmodal.open('UserBox', 'iframe', 'user_management/view_user_detail_div.php?id='+uid+'&group_id='+gid, 'User Details', 'width=850px,height=440px,center=1,resize=1,scrolling=1')

} //En
///////////////////////////////////////////////////////////////
function company_show(cid,page_n){
       
	emailwindow=dhtmlmodal.open('UserBox', 'iframe', page_n+'?cid='+cid, 'Edit Company', 'width=850px,height=440px,center=1,resize=1,scrolling=1')

}
function company_detail_show(cid){
         //alert(cid);
		 //alert(gid);
	emailwindow=dhtmlmodal.open('UserBox', 'iframe', 'Company_Master/view_company_div.php?cid='+cid, 'Company Details', 'width=850px,height=440px,center=1,resize=1,scrolling=1')

}
function company_show(cid){
         //alert(cid);
		 //alert(gid);
	emailwindow=dhtmlmodal.open('UserBox', 'iframe', 'Company_Master/edit_company_div.php?cid='+cid, 'Company Details', 'width=850px,height=440px,center=1,resize=1,scrolling=1')

}
function branch_detail_show(bid,cid){
         //alert(cid);
		//alert(bid);
	emailwindow=dhtmlmodal.open('UserBox', 'iframe', 'Company_Master/view_branch_detail_div.php?bid='+bid+'&cid='+cid, 'Branch Details', 'width=850px,height=440px,center=1,resize=1,scrolling=1')

}
function branch_show(bid,cid,page_n){
      emailwindow=dhtmlmodal.open('UserBox', 'iframe', page_n+'?bid='+bid+'&cid='+cid, 'Branch Details', 'width=850px,height=440px,center=1,resize=1,scrolling=1')

}


///////////////////////Paging User///////////////////////////////
// this function is used in view_all_users.php for geting user list
function get_user_paging(qry,col,j,m_i_d)
{
	//k=document.getElementById("grp_id").value;
	
	//k=document.getElementById("grp_id").value;
	type_search=document.getElementById("type_all_search").value;
	search_data=document.getElementById("search_alltext").value;
	group_id=document.getElementById("grp_id").value;
	email=document.getElementById("email_id").value;
	
	
	//alert(k);
	//j=document.getElementById("pagenumber").value;
	if (j>=0)
	{ 
var url="user_management/view_user_div.php?group_id="+group_id+"&mid="+m_i_d+"&type_all_search="+type_search+"&search_alltext="+search_data+"&email_id="+email+"&pageNum_rr="+j+"&selectme="+j+"&qry="+qry+"&column_val="+col;
		//alert(url);
		xmlHttp=GetXmlHttpObject(list_user_paging)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	else
	{ 
		document.getElementById("view_user").innerHTML=""
	} 
} 

function list_user_paging() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("view_user").innerHTML=xmlHttp.responseText 
	}
}
/////////////////////////////For Paging List of Company////////////////////////////////////////////////////////////////////

function show_company_list(j)
{
	//alert(j);
		str=document.getElementById("mid_value").value;//hidden field value on view_company_details.php
		//alert(str);
		var url="right_panel.php?mid="+str+"&pageNum_rr="+j+"&selectme="+j;
		//alert(url);
		xmlHttp=GetXmlHttpObject(total_company)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	
} 

function total_company() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(xmlHttp.responseText);
		document.getElementById("right_panel").innerHTML=xmlHttp.responseText 
	}
} 
/////////////////////////////////////////////////////////////////////////////////////////////////
// this function is used in header_menubar.php where parent menu names are called and is used only for left panel page
function functLeft(str)
{ 
	if (str > 0)
	{ 
		s=document.getElementById("hiddens").value;
		var url="home_middle.php?mid="+str+"&div_show="+s;
		//alert(url);
		xmlHttp=GetXmlHttpObject(getleft_paneldata)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	else
	{ 
		document.getElementById("left_panel").innerHTML=""
	} 
} 



function welcome_funct(str,tno)
{ 
	if (str > 0)
	{ 
		var url="home_middle.php?mid="+str+"&tno="+tno;
		//alert(url);
		xmlHttp=GetXmlHttpObject(getleft_paneldata)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	else
	{ 
		document.getElementById("left_panel").innerHTML=""
	} 
} 

function getleft_paneldata() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
	document.getElementById("left_panel").innerHTML=xmlHttp.responseText 
	}
} 
//******************************************
// this function is used in header_menubar.php where parent menu names are called and is used only for right panel page
function functRight(str)
{ 

//alert('right');
	if (str > 0)
	{ 
		//document.getElementById("right_panel").innerHTML=""
		s=document.getElementById("hiddens").value;
		var url="right_panel.php?mid="+str+"&div_show="+s;
		//alert(url);
		xmlHttp=GetXmlHttpObject(getright_paneldata)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	else
	{ 
		document.getElementById("right_panel").innerHTML=""
	} 
} 
function getright_paneldata() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(xmlHttp.responseText);
		document.getElementById("right_panel").innerHTML=xmlHttp.responseText 
	}
} 
//******************************************
/////////////////////THIS FUNCTION IS FOR MENU RIGHTS PAGE///////////////////
function menurightsfunct(str)
{ 
	if (str >= 0)
	{ 
		var url="menu_rights/show_menu_rights.php?group_id="+str;
		xmlHttp=GetXmlHttpObject(getright_paneldata)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	else
	{ 
		document.getElementById("right_panel").innerHTML=""
	} 
}
// this function is used for paging of branch call in commonfunction_branch.php
function branch_paging(j,m_i_d)
{
		//alert(j);
		str=document.getElementById("company_id").value;
		var url="Company_Master/view_branch_body.php?company_id="+str+"&pageNum_rr="+j+"&selectme="+j+"&mid="+m_i_d;
		//alert(url);
		xmlHttp=GetXmlHttpObject(branch_name_paging)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	
} 

function branch_name_paging() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(xmlHttp.responseText);
		document.getElementById("view_branch").innerHTML=xmlHttp.responseText 
	}
} 
///////////////////////Paging User & sorting///////////////////////////////
// this function is used in view_all_users.php for geting user list
function get_user_sorting(col,j,m)
{
	
	   old_col=document.getElementById("column_id").value;//hidden field on view_user-div.php.define which query is previously execute for sorting

	   var qry;
	   var flag=0;
	   if(col==1)// if start when first column is clicked for sorting
	   {
		  if(old_col==1 && col==1)
		   {
			  qry="order by lm.login_id desc";
			  col=-1;
			   flag=1;
		   }
		   if(old_col==-1 && col==1)
		   {
			  qry="order by lm.login_id";
			  col=1;
			   flag=1;
		   }
		   if(flag==0 && old_col<=0)
		   {
			  qry="order by lm.login_id";
			  col=1;    
		   }
		    if(flag==0 && old_col>=0)
		   {
			  qry="order by um.fname desc";
			  col=-1;
		   }
	   }// if end when first column is clicked for sorting
	   if(col==2)// if start when second column is clicked for sorting
	   {
		  if(old_col==2 && col==2)
		   {
			  qry="order by um.fname desc";
			  col=-2;
			  flag=1;
		   }
			if(old_col==-2 && col==2)
		   {
			  qry="order by um.fname";
			  col=2;
			  flag=1;
			  
		   }
		   if(flag==0 && old_col<=0)
		   {
			  qry="order by um.fname";
			  col=2;
		   }
		   if(flag==0 && old_col>=0)
		   {
			  qry="order by um.fname desc";
			  col=-2;
		   }
		   
	   }// if end when second column is clicked for sorting
		
	
	//k=document.getElementById("grp_id").value;
	type_search=document.getElementById("type_all_search").value;
	search_data=document.getElementById("search_alltext").value;
	group_id=document.getElementById("grp_id").value;
	email=document.getElementById("email_id").value;
	
	
	//	var url="user_management/view_user_div.php?group_id="+group_id+"&mid="+m_i_d+"&type_all_search="+type_search+"&search_alltext="+search_data+"&email_id="+email;

	
	
	
	
	if (j>=0)
	{ 
		var url="user_management/view_user_div.php?group_id="+group_id+"&mid="+m+"&type_all_search="+type_search+"&search_alltext="+search_data+"&email_id="+email+"&pageNum_rr="+j+"&selectme="+j+"&qry="+qry+"&column_val="+col;
		//alert(url);
		xmlHttp=GetXmlHttpObject(list_user_sorting)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	else
	{ 
		document.getElementById("view_user").innerHTML=""
	} 
} 

function list_user_sorting() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("view_user").innerHTML=xmlHttp.responseText 
	}
}
/////////////////////////////Category Delete Code Start////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function category_del(cate_id,page_n)
{ 
	if(confirm("Are You Sure To Delete This Category?"))
		{  
			if (cate_id>0)
			{ 
				var url=page_n+"?category_id="+cate_id;
				xmlHttp=GetXmlHttpObject(delete_category_mast)
				xmlHttp.open("GET", url , true)
				xmlHttp.send(null)
			} 
			
		}
	
} 
function delete_category_mast() 
{ 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		if(xmlHttp.responseText == 1)
		{
			alert("Category Record Deleted Successfully");
			show_company_list(0);
		}
		
	}
} 
/////////////////////////////Category Delete Code Start////////////////////////////////////////////////////////////////

////////////////////////////////To open category detail div without editable mode//////////////////////////
function category_show(cat_d){
        
	emailwindow=dhtmlmodal.open('UserBox', 'iframe', 'Company_Master/category_detail_div.php?cat_id='+cat_d, 'Category Details', 'width=850px,height=440px,center=1,resize=1,scrolling=1')

}
////////////////////////////////To open category detail div with editable mode////////////////////////////
function category_edit(cat_d,page_n){
       
	emailwindow=dhtmlmodal.open('UserBox', 'iframe', page_n+'?cat_id='+cat_d, 'Edit Category', 'width=850px,height=440px,center=1,resize=1,scrolling=1')

}
////////////////////////////Tip Layer//////////////////////
function getposOffset(overlay, offsettype){
//alert(overlay);
var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
var parentEl=overlay.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function overlay(curobj, subobjstr, opt_position){
//alert("rohit");
if (document.getElementById){
var subobj=document.getElementById(subobjstr)
subobj.style.display=(subobj.style.display!="block")? "block" : "none"
var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
subobj.style.left=xpos+"px"
subobj.style.top=ypos+"px"
return false
}
else
return true
}

function overlayclose(subobj){
document.getElementById(subobj).style.display="none"
}
//////////////////////////////////////////////////////////////////////////////
function hide_left_pannel(str)
{ 
	//alert(str);
	if (str > 0)
	{ 
		var url="home_middle.php?mid="+str+"&div_show=1";
		//alert(url);
		xmlHttp=GetXmlHttpObject(hideleft_paneldata)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	else
	{ 
		document.getElementById("left_panel").innerHTML=""
	} 
} 
function show_left_pannel(str)
{ 
	//alert(str);
	if (str > 0)
	{ 
		var url="home_middle.php?mid="+str+"&div_show=0";
		//alert(url);
		xmlHttp=GetXmlHttpObject(hideleft_paneldata)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	else
	{ 
		document.getElementById("left_panel").innerHTML=""
	} 
} 

function hideleft_paneldata() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
	document.getElementById("left_panel").innerHTML=xmlHttp.responseText 
	}
} 

function check_support_depart()
{ 
	str=document.getElementById("department_name").value;
	if (str)
	{ 
		var url="support_system/check_support_dept_already_exist.php?dept_name="+str;
		//alert(url);
		xmlHttp=GetXmlHttpObject(checkSupportDpt)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	else
	{ 
	   //document.getElementById("logid").innerHTML=""
	} 
} 

function checkSupportDpt() 
{ 
 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{

if(xmlHttp.responseText == 1)
{
	alert("Department Already Exists !!");
	document.getElementById("department_name").select();
	
	
}
//document.getElementById("logid").innerHTML=xmlHttp.responseText 
}
} 

function support_dept_paging(j,mid)
{

	var url="right_panel.php?pageNum_rr="+j+"&selectme="+2+"&mid="+mid;	
xmlHttp=GetXmlHttpObject(support_dept_paging_2)
		//alert(url);
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
}
function support_dept_paging_2() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(xmlHttp.responseText);
		document.getElementById("right_panel").innerHTML=xmlHttp.responseText 
	}
}
function support_catagory_paging(j,mid)
{

	var url="right_panel.php?pageNum_rr="+j+"&selectme="+2+"&mid="+mid;	
xmlHttp=GetXmlHttpObject(support_catagory_p)
		//alert(url);
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
}

function support_catagory_p() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(xmlHttp.responseText);
		document.getElementById("right_panel").innerHTML=xmlHttp.responseText 
	}
}
function support_category_edit(cat_d,page){
         //alert(cid);
		 //alert(page);
	emailwindow=dhtmlmodal.open('UserBox', 'iframe', page+'?cat_id='+cat_d, 'Edit Category', 'width=850px,height=440px,center=1,resize=1,scrolling=1')

}
function delete_support_category(cate_id,mid,page_n)
{ 
	if(confirm("Are You Sure To Delete This Category?"))
		{  
			if (cate_id>0)
			{ 
				var url=page_n+"?category_id="+cate_id+"&mid="+mid;
				xmlHttp=GetXmlHttpObject(delete_support_category_mast)
				xmlHttp.open("GET", url , true)
				xmlHttp.send(null)
			} 
			
		}
	
} 
function delete_support_category_mast() 
{ 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		alert("Deleted Successfully");
		document.getElementById("right_panel").innerHTML=xmlHttp.responseText 
				
	}
} 
function support_department_edit(cat_d, page_n){
      
	emailwindow=dhtmlmodal.open('UserBox', 'iframe', page_n+'?dept_id='+cat_d, 'Edit Department', 'width=850px,height=440px,center=1,resize=1,scrolling=1')

}
function delete_support_department(dept_id,mid,page_n)
{ 
	if(confirm("Are You Sure To Delete This Category?"))
		{  
			if (dept_id>0)
			{ 
				var url=page_n+"?department_id="+dept_id+"&mid="+mid;
				xmlHttp=GetXmlHttpObject(delete_support_category_mast)
				xmlHttp.open("GET", url , true)
				xmlHttp.send(null)
			} 
			
		}
	
} 


////////////////////////////////Code Start for submitt form through ajax//////////////////////////////////////////

   var http_request = false;
   function makePOSTRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
      if (http_request.readyState == 4)
	  {
         if (http_request.status == 200)
		 {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('right_panel').innerHTML = result;            
         }
		 else
		 {
            //alert(http_request.responseText);
			alert('There was a problem with the request.');
         }
      }
   }
   
   function get(obj) {
       var poststr = "login_id=" + escape(encodeURI(
document.getElementById("login_id").value )) +"&password=" +
escape(encodeURI( document.getElementById("password").value )) +"&first_name=" +
escape(encodeURI( document.getElementById("first_name").value )) +"&last_name=" +
escape(encodeURI( document.getElementById("last_name").value )) +"&sex=" +
escape(encodeURI( document.getElementById("sex").value )) +"&merital_status=" +
escape(encodeURI( document.getElementById("merital_status").value )) +"&email_id=" +
escape(encodeURI( document.getElementById("email_id").value )) +"&alteremail_id=" +
escape(encodeURI( document.getElementById("alteremail_id").value )) +"&per_address=" +
escape(encodeURI( document.getElementById("per_address").value )) +"&present_address=" +
escape(encodeURI( document.getElementById("present_address").value )) +"&menu=" +
escape(encodeURI( document.getElementById("menu").value )) +"&mid=" +
escape(encodeURI( document.getElementById("menu_id").value )) +"&phone_no=" +
escape(encodeURI( document.getElementById("phone_no").value )) +"&mob_no=" +
escape(encodeURI( document.getElementById("mob_no").value ))+"&fax_no=" +
escape(encodeURI( document.getElementById("fax_no").value ))+"&domain_name=" +
escape(encodeURI( document.getElementById("domain_name").value ))+"&city=" +
escape(encodeURI( document.getElementById("city").value ))+"&state=" +
escape(encodeURI( document.getElementById("state").value ))+"&country=" +
escape(encodeURI( document.getElementById("country").value ))+"&com_client=" +
escape(encodeURI( document.getElementById("com_client").value ));

	  /*var poststr = "mytextarea1=" + encodeURI( document.getElementById("mytextarea1").value ) +
                    "&mytextarea2=" + encodeURI( document.getElementById("mytextarea2").value );*/
      makePOSTRequest('right_panel.php', poststr);
   }
////////////////////////////////Code end for submitt form through ajax//////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////////
function create_ticket(obj) {
       var poststr = "subject=" + escape(encodeURI(
document.getElementById("subject").value )) +"&department=" +
escape(encodeURI( document.getElementById("department").value )) +"&category=" +
escape(encodeURI( document.getElementById("category").value )) +"&attachment=" +
escape(encodeURI( document.getElementById("attachment").value )) +"&priority=" +
escape(encodeURI( document.getElementById("priority").value )) +"&message=" +
escape(encodeURI( document.getElementById("message").value )) +"&hidden_client_id=" +
escape(encodeURI( document.getElementById("hidden_client_id").value )) +"&mid=" +
escape(encodeURI( 152 )) +"&menu=" +
escape(encodeURI( document.getElementById("menu").value ));
//alert(poststr);
	  /*var poststr = "mytextarea1=" + encodeURI( document.getElementById("mytextarea1").value ) +
                    "&mytextarea2=" + encodeURI( document.getElementById("mytextarea2").value );*/
      makePOSTRequest('right_panel.php', poststr);
   }
////////////////////////////////////////////////////////////////////////////////////////////////////////////

function get_depart_cat(dept_id)
{ 
		var url="guest/dept_catagory.php?dept_id="+dept_id;
		//alert(url);
		xmlHttp=GetXmlHttpObject(get_catrtrt)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		
} 
function get_catrtrt() 
{ 
    
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(xmlHttp.responseText);
		document.getElementById("show_department_cat").innerHTML=xmlHttp.responseText 
	}
}



function get_change_pass_window(ch_oice)
{
   
	if (ch_oice=='Y')
	{ 
		
		var url="change_passward.php";
		xmlHttp=GetXmlHttpObject(get_change_pass)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	else
	{ 
		document.getElementById("change_pass_div").innerHTML=""
	} 
} 

function get_change_pass() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("change_pass_div").innerHTML=xmlHttp.responseText 
	}
}
function check_old_pass_exist(old_pass)
{
  
	if (old_pass=="")
	{ 
	 alert("Please Enter Old Password");
	 document.getElementById("old_pass").focus();
	 return false;
	}
	else
	{
		user_id=document.getElementById("my_db_id").value;
		var url="check_old_pass_true.php?pass_val="+old_pass+"&u_id="+user_id;
		xmlHttp=GetXmlHttpObject(get_check_old_pass)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	
} 

function get_check_old_pass() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(xmlHttp.responseText);
		if(xmlHttp.responseText==0)
		{
			  alert("Your Old Password Not Correct");
			  document.getElementById("old_pass").focus();
			  
		}
		else
		{
		   document.getElementById("new_pass").focus();	
		}
		//document.getElementById("change_pass_div").innerHTML=xmlHttp.responseText 
	}
}

function menu_edit_show(mid,page_n)
{
	
	//alert(pid);
	emailwindow=dhtmlmodal.open('UserBox', 'iframe', page_n+'?mid='+mid, 'Menu Edit Details', 'width=850px,height=440px,center=1,resize=1,scrolling=1')

}
function menu_delete(menud,id,j,page_n)
{ 
	if(confirm("Are You Sure To Delete This Menu?"))
	{  
		if (menud > 0)
		{ 
				var url=page_n+"?del_m_i_d="+menud+"&mid="+id+"&pageNum_rr="+j+"&selectme="+j;
				xmlHttp=GetXmlHttpObject(menu_delete_mast)
				xmlHttp.open("GET", url , true)
				xmlHttp.send(null)
		} 
			
	}
} 

function menu_delete_mast() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("right_panel").innerHTML=xmlHttp.responseText 
	}
}

function show_menu_list(j,str)
{
	
		var url="right_panel.php?mid="+str+"&pageNum_rr="+j+"&selectme="+j;
		//alert(url);
		xmlHttp=GetXmlHttpObject(show_menu_list_page)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	
} 

function show_menu_list_page() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(xmlHttp.responseText);
		document.getElementById("right_panel").innerHTML=xmlHttp.responseText 
	}
} 
function comapny_department_edit(c_dept,page_n){
       	emailwindow=dhtmlmodal.open('UserBox', 'iframe', page_n+'?dept_id='+c_dept, 'Edit Department', 'width=850px,height=440px,center=1,resize=1,scrolling=1')

}
function delete_company_department(dept_id,mid,page_n)
{ 
	if(confirm("Are You Sure To Delete This Category?"))
		{  
			if (dept_id>0)
			{ 
				var url=page_n+"?department_id="+dept_id+"&mid="+mid;
				//alert(url);
				xmlHttp=GetXmlHttpObject(delete_company_dept_mast)
				xmlHttp.open("GET", url , true)
				xmlHttp.send(null)
			} 
			
		}
	
} 
function delete_company_dept_mast() 
{ 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		alert("Deleted Successfully");
		document.getElementById("right_panel").innerHTML=xmlHttp.responseText 
				
	}
}

function company_dept_paging(j,mid)
{

	var url="right_panel.php?pageNum_rr="+j+"&selectme="+2+"&mid="+mid;	
xmlHttp=GetXmlHttpObject(company_dept_paging_2)
		//alert(url);
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
}
function company_dept_paging_2() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(xmlHttp.responseText);
		document.getElementById("right_panel").innerHTML=xmlHttp.responseText 
	}
}

function get_report_user(user_id,from_d,to_d,t_ype)
{ 
    var url="project_management/search_report_detail.php?emp_id="+user_id+"&type1="+t_ype+"&f_date="+from_d+"&t_date="+to_d;
	//alert(url);
	div_id="show_hide_user_rec"+user_id;
	xmlHttp=GetXmlHttpObject(report_serch_window)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)	
}
function report_serch_window() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(xmlHttp.responseText);
		document.getElementById(div_id).innerHTML=xmlHttp.responseText 
	}
}

function get_emp_detail_date_wise_rec(for_date)
{ 
   
	var url="project_management/report_summary.php?current_date="+for_date;
	//alert(url);
	xmlHttp=GetXmlHttpObject(result_emp_detail_rec)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
	
	
}

function result_emp_detail_rec() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("search_note_list").innerHTML=xmlHttp.responseText 
	}
}

function show_project_preview(u_r_l)
{
 emailwindow=dhtmlmodal.open('UserBox', 'iframe',u_r_l, 'Print Preview', 'width=800px,height=600px,center=1,resize=1,scrolling=1')
	
}

function user_report_detail_show(emp_id,d_t)//show detail of project div without editable mode
{
	emailwindow=dhtmlmodal.open('UserBox', 'iframe', 'project_management/user_popup_report_main.php?empid='+emp_id+'&dated='+d_t, 'Reports  Details', 'width=850px,height=440px,center=1,resize=1,scrolling=1')

}

function get_emp_popup_paging(j,emp_id)
{ 
    	
	fd=document.getElementById("hidden_from").value;
	td=document.getElementById("hidden_to").value;
	var url="user_popup_report_div.php?empid="+emp_id+"&pageNum_rr="+j+"&selectme="+j+"&from_date="+fd+"&todate="+td;
	//alert(url);
	xmlHttp=GetXmlHttpObject(total_report_paging)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
	
	
}
function total_report_paging() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(xmlHttp.responseText);
		document.getElementById("emp_popup_single").innerHTML=xmlHttp.responseText 
	}
}
function get_emp_popup_deted(j,emp_id)
{ 
    	
	fd=document.getElementById("from_date").value;
	td=document.getElementById("to_date").value;
	var url="user_popup_report_div.php?empid="+emp_id+"&pageNum_rr="+j+"&selectme="+j+"&from_date="+fd+"&todate="+td;
	//alert(url);
	xmlHttp=GetXmlHttpObject(total_get_emp_popup_deted)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
	
	
}
function total_get_emp_popup_deted() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(xmlHttp.responseText);
		document.getElementById("emp_popup_single").innerHTML=xmlHttp.responseText 
	}
}
function funct_add(str)
{ 
	if (str > 0)
	{ 
		
		var url="right_panel.php?mid="+str;
		//alert(url+'hello');
		if(document.getElementById("comp_id"))
		{
		c=document.getElementById("comp_id").value;
		url=url+"&comp="+c;
		}
		xmlHttp=GetXmlHttpObject(funct_add_div)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	else
	{ 
	  document.getElementById("right_panel").innerHTML=""
	} 
} 
function funct_add_div() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
	  //alert(xmlHttp.responseText)
	 document.getElementById("right_panel").innerHTML=xmlHttp.responseText 
	}
}

function get_group_member(grop_id,m_i_d)
{
	var url="right_panel.php?mid="+m_i_d+"&grp_id="+grop_id;
	xmlHttp=GetXmlHttpObject(get_group_member_select1)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}

function get_group_member_select1() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
	  document.getElementById("right_panel").innerHTML=xmlHttp.responseText 
	}
} 


function get_depart_cat_guest(dept_id)
{ 
		var url="dept_catagory.php?dept_id="+dept_id;
		//alert(url);
		xmlHttp=GetXmlHttpObject(get_catrtrt_guest)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		
} 
function get_catrtrt_guest() 
{ 
    
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(xmlHttp.responseText);
		document.getElementById("show_department_cat").innerHTML=xmlHttp.responseText 
	}
}


/////////////////////////////////////////code for user rights//////////////////////////////////////////////////////

		function sel_user_group(grp_id)
		{
			//alert(grp_id);
			
				var url="user_right/show_user_div.php?group_id="+grp_id;
				//alert(url);
				xmlHttp=GetXmlHttpObject(list_user_group)
				xmlHttp.open("GET", url , true)
				xmlHttp.send(null)
			
		} 
		
		function list_user_group() 
		{ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{
				document.getElementById("assign_user_div").innerHTML=xmlHttp.responseText 
			}
		} 
		
		function assign_user( grp_id,u_id,frm)
		{
			//alert(u_id);
			
				var url="user_right/show_user_frm.php?user_id="+u_id+"&opr="+frm+"&group_id="+grp_id;;
				//alert(url);
				xmlHttp=GetXmlHttpObject(view_all_user_group)
				xmlHttp.open("GET", url , true)
				xmlHttp.send(null)
			
		} 
		
		function view_all_user_group() 
		{ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{
				document.getElementById("list_user_div").innerHTML=xmlHttp.responseText 
			}
		} 
//////////////////////////////////////////////////////////////////////////////////////////////////		


//////////////////////////////////////////////code for branch table sorting///////////////////////////////////////////////////
function branch_sorting(col,j,m,com_id)
{
	   
	   old_col=document.getElementById("column_id").value;//hidden field on view_user-div.php.define which query is previously execute for sorting
	 
	   var qry;
	   var flag=0;
	   if(col==1)// if start when first column is clicked for sorting
	   {
		  if(old_col==1 && col==1)
		   {
			  qry="order by branch_name desc";
			  col=-1;
			   flag=1;
		   }
		   if(old_col==-1 && col==1)
		   {
			  qry="order by branch_name";
			  col=1;
			   flag=1;
		   }
		   if(flag==0 && old_col<=0)
		   {
			  qry="order by branch_name";
			  col=1;    
		   }
		    if(flag==0 && old_col>=0)
		   {
			  qry="order by branch_name desc";
			  col=-1;
		   }
	   }// if end when first column is clicked for sorting
	 
	
	if (j>=0)
	{ 
		var url="Company_Master/view_branch_body.php?pageNum_rr="+j+"&selectme="+j+"&qry="+qry+"&column_val="+col+"&mid="+m+"&company_id="+com_id;
		//alert(url);
		xmlHttp=GetXmlHttpObject(list_branch_sorting)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	else
	{ 
		document.getElementById("view_branch").innerHTML=""
	} 
} 

function list_branch_sorting() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("view_branch").innerHTML=xmlHttp.responseText 
	}
}
/////////////////////////////////////////code for Department Table Sorting//////////////////////////////////////////////////
function department_sorting(col,j,m)
{
	  
	   old_col=document.getElementById("column_id").value;//hidden field on view_user-div.php.define which query is previously execute for sorting
	
	   var qry;
	   var flag=0;
	   if(col==1)// if start when first column is clicked for sorting
	   {
		  if(old_col==1 && col==1)
		   {
			  qry="order by dept_name desc";
			  col=-1;
			   flag=1;
		   }
		   if(old_col==-1 && col==1)
		   {
			  qry="order by dept_name ";
			  col=1;
			   flag=1;
		   }
		   if(flag==0 && old_col<=0)
		   {
			  qry="order by dept_name ";
			  col=1;    
		   }
		    if(flag==0 && old_col>=0)
		   {
			  qry="order by dept_name  desc";
			  col=-1;
		   }
	   }// if end when first column is clicked for sorting
	 
	//alert(qry);
   // alert(col);
   // alert(j);
	//k=document.getElementById("grp_id").value;
	//alert(k);
	//j=document.getElementById("pagenumber").value;
	if (j>=0)
	{ 
		var url="right_panel.php?pageNum_rr="+j+"&selectme="+j+"&qry="+qry+"&column_val="+col+"&mid="+m;
		//alert(url);
		xmlHttp=GetXmlHttpObject(list_depart_sorting)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	else
	{ 
		document.getElementById("right_panel").innerHTML=""
	} 
} 

function list_depart_sorting() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("right_panel").innerHTML=xmlHttp.responseText 
	}
}

////////////////////////////////////////////////sorting by company name////////////////////////////////////////////////
function company_sorting(col,j,m)
{
	   //col used for which column is clicked
	   //j used for on which page no is column clicked
	   old_col=document.getElementById("column_id").value;//hidden field on view_user-div.php.define which query is previously execute for sorting
	   //if old_col value<0  query order by desc
	   // if old_col value>0 qyery order by asc
	   // default old_col value >0;
	   //alert(old_col);
	   var qry;
	   var flag=0;
	   if(col==1)// if start when first column is clicked for sorting
	   {
		  if(old_col==1 && col==1)
		   {
			  qry="order by company_name  desc";
			  col=-1;
			   flag=1;
		   }
		   if(old_col==-1 && col==1)
		   {
			  qry="order by company_name";
			  col=1;
			   flag=1;
		   }
		   if(flag==0 && old_col<=0)
		   {
			  qry="order by company_name";
			  col=1;    
		   }
		    if(flag==0 && old_col>=0)
		   {
			  qry="order by company_name desc";
			  col=-1;
		   }
	   }// if end when first column is clicked for sorting
	 
	//alert(qry);
   // alert(col);
   // alert(j);
	//k=document.getElementById("grp_id").value;
	//alert(k);
	//j=document.getElementById("pagenumber").value;
	if (j>=0)
	{ 
		var url="right_panel.php?pageNum_rr="+j+"&selectme="+j+"&qry="+qry+"&column_val="+col+"&mid="+m;
		//alert(url);
		xmlHttp=GetXmlHttpObject(list_comp_sorting);
		xmlHttp.open("GET", url , true);
		xmlHttp.send(null);
	} 
	else
	{ 
		document.getElementById("right_panel").innerHTML=""
	} 
} 

function list_comp_sorting() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("right_panel").innerHTML=xmlHttp.responseText 
	}
}
function category_sorting(col,j,m)
{
	   //col used for which column is clicked
	   //j used for on which page no is column clicked
	   old_col=document.getElementById("column_id").value;//hidden field on view_user-div.php.define which query is previously execute for sorting
	   //if old_col value<0  query order by desc
	   // if old_col value>0 qyery order by asc
	   // default old_col value >0;
	   //alert(old_col);
	   var qry;
	   var flag=0;
	   if(col==1)// if start when first column is clicked for sorting
	   {
		  if(old_col==1 && col==1)
		   {
			  qry="order by cat_name desc";
			  col=-1;
			   flag=1;
		   }
		   if(old_col==-1 && col==1)
		   {
			  qry="order by cat_name";
			  col=1;
			   flag=1;
		   }
		   if(flag==0 && old_col<=0)
		   {
			  qry="order by cat_name";
			  col=1;    
		   }
		    if(flag==0 && old_col>=0)
		   {
			  qry="order by cat_name desc";
			  col=-1;
		   }
	   }// if end when first column is clicked for sorting
	 
	//alert(qry);
   // alert(col);
   // alert(j);
	//k=document.getElementById("grp_id").value;
	//alert(k);
	//j=document.getElementById("pagenumber").value;
	if (j>=0)
	{ 
		var url="right_panel.php?pageNum_rr="+j+"&selectme="+j+"&qry="+qry+"&column_val="+col+"&mid="+m;
		//alert(url);
		xmlHttp=GetXmlHttpObject(list_depart_sorting);
		xmlHttp.open("GET", url , true);
		xmlHttp.send(null);
	} 
	else
	{ 
		document.getElementById("right_panel").innerHTML=""
	} 
} 

function list_depart_sorting() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("right_panel").innerHTML=xmlHttp.responseText 
	}
}




/////////////////////////////////////codefor news letter operation/////////////////////////////////
function sel_fun_group(id)
{
	 
	var url="add_email_group_div.php?work=edit&grp_id="+id;
		alert(url);
		xmlHttp=GetXmlHttpObject(show_sequence_group)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
} 
function show_sequence_group() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("edit_grp").innerHTML=xmlHttp.responseText 
	}
} 
/////////////////////code for Escalation
function mng_detail_esca(e_id)//show detail of project div without editable mode
{
	//alert(e_id);
  emailwindow=dhtmlmodal.open('UserBox', 'iframe', 'escalation/manage_escalation.php?mng_id='+e_id, 'Edit Managed Escalation', 'width=650px,height=340px,center=1,resize=1,scrolling=1')

}
function delete_mng_esca(str,e_id)
	{ 
	if(confirm("Are You Sure To Delete This Record?"))
		{  
			var url="right_panel.php?mid="+str+"&mng_esc_del="+e_id;
			//alert(url);
			xmlHttp=GetXmlHttpObject(delete_mng_esc)
			xmlHttp.open("GET", url , true)
			xmlHttp.send(null)
		
		}
	
    } 
function delete_mng_esc() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("right_panel").innerHTML=xmlHttp.responseText 
	}
}

function esc_edit(e_id)//show detail of project div without editable mode
{
	//alert(e_id);
  emailwindow=dhtmlmodal.open('UserBox', 'iframe', 'escalation/edit_escalation.php?esc_id='+e_id, 'Edit Escalation Level', 'width=650px,height=340px,center=1,resize=1,scrolling=1')

}
function esc_delete(str,e_id)
	{ 
	if(confirm("Are You Sure To Delete This Record?"))
		{  
			var url="right_panel.php?mid="+str+"&esc_del="+e_id;
			//alert(url);
			xmlHttp=GetXmlHttpObject(delete_esc)
			xmlHttp.open("GET", url , true)
			xmlHttp.send(null)
		
		}
	
    } 
function delete_esc() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("right_panel").innerHTML=xmlHttp.responseText 
	}
}

function show_escalationt_list(j)
{
	
	var url="escalation/list_mng_esca_div.php?pageNum_rr="+j+"&selectme="+j;
	//alert(url);
		xmlHttp=GetXmlHttpObject(show_escalation_search)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	
} 

function show_escalation_search() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(xmlHttp.responseText);
		document.getElementById("list_mng_esca_div").innerHTML=xmlHttp.responseText 
	}
} 


///////////////////////////////////////////////////

// this function is used in create_user.php to check login id already exist
function check_support_catt()
{ 
cat=document.getElementById("category_name").value;
dept=document.getElementById("department_id").value;
if(dept=='')
{
	  alert('First Select Department');
	  document.getElementById("department_id").focus();
	  return false;
}
if (cat)
{ 
var url="support_system/check_support_cat_already_exist.php?dept_id="+dept+"&cat_name="+cat;
//alert(url);
xmlHttp=GetXmlHttpObject(checkCat)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
} 
 
} 

function checkCat() 
{ 
 //alert(xmlHttp.responseText);
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{

if(xmlHttp.responseText == 1)
{
	alert("Category  Already Exists !!");
	document.getElementById("category_name").select();
	
}

}
} 
function check_b1()
{
if(document.getElementById("sel_user").value='')
{
alert("select User");
return false;
}
}


///////////////////////////////// assign company

function get_emp_company_name(id,mid)
{
	//alert("surendra");
	
	//alert(str);
if (id > 0)
{ 
	var url="Company_Master/assign_emp_company.php?emp_id="+id+"&mid="+mid;
	//alert(url);
	xmlHttp=GetXmlHttpObject(get_gne_comp)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
} 
else
{ 
document.getElementById("assign_company_emp").innerHTML=""
} 
} 

function get_gne_comp() 
{ 
 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
//alert(xmlHttp.responseText);
document.getElementById("assign_company_emp").innerHTML=xmlHttp.responseText 
}
}

function movethis_group(fbox,tbox) {
var arrFbox = new Array();
var arrTbox = new Array();
var arrLookup = new Array();
var i;
for (i = 0; i < tbox.options.length; i++) {
arrLookup[tbox.options[i].text] = tbox.options[i].value;
arrTbox[i] = tbox.options[i].text;
}
var fLength = 0;
var tLength = arrTbox.length;
for(i = 0; i < fbox.options.length; i++) {
arrLookup[fbox.options[i].text] = fbox.options[i].value;
if (fbox.options[i].selected && fbox.options[i].value != "") {
arrTbox[tLength] = fbox.options[i].text;

   
	



tLength++;

}
else {
arrFbox[fLength] = fbox.options[i].text;
fLength++;
   }
}

arrFbox.sort();
arrTbox.sort();
fbox.length = 0;
tbox.length = 0;
var c;
for(c = 0; c < arrFbox.length; c++) {
var no = new Option();
no.value = arrLookup[arrFbox[c]];
no.text = arrFbox[c];
fbox[c] = no;
}
for(c = 0; c < arrTbox.length; c++) {
var no = new Option();
no.value = arrLookup[arrTbox[c]];
no.text = arrTbox[c];
tbox[c] = no;
  
  }

var finalval;
for (i = 0; i < document.form1.associate0.options.length; i++)
{   
	//if(document.form1.associate0.options[i].value)
	//{
	if(finalval)
	{
	finalval +=','+document.form1.associate0.options[i].value;
	}
	else
	{
	finalval = document.form1.associate0.options[i].value;
	}
}
//alert(i);
document.form1.associate0.value = finalval;



document.form1.head_id.value = finalval;
//alert(finalval);


}


function get_branch_company(id,mid)
{
	//alert("surendra");
	
	//alert(str);
if (id > 0)
{ 
	var url="Company_Master/assign_emp_branch.php?emp_id="+id+"&mid="+mid;
	//alert(url);
	xmlHttp=GetXmlHttpObject(get_gne_comp12)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
} 
else
{ 
document.getElementById("assign_branch_emp").innerHTML=""
} 
} 

function get_gne_comp12() 
{ 
 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
//alert(xmlHttp.responseText);
document.getElementById("assign_branch_emp").innerHTML=xmlHttp.responseText 
}
}

function delete_support_category_sub(cate_id,mid,page_n)
{ 
	if(confirm("Are You Sure To Delete This Sub Category?"))
		{  
			if (cate_id>0)
			{ 
				var url=page_n+"?category_id="+cate_id+"&mid="+mid+"&delete=delete";
				//alert(url)
				xmlHttp=GetXmlHttpObject(delete_support_category_mast_sub)
				xmlHttp.open("GET", url , true)
				xmlHttp.send(null)
			} 
			
		}
	
} 
function delete_support_category_mast_sub() 
{ 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		alert("Deleted Successfully");
		//alert(xmlHttp.responseText)
		//document.getElementById("right_panel").innerHTML=xmlHttp.responseText 
				
	}
} 


function get_emp_name_desig1(id)
{

str=document.edit_user.group_type.value;
if (str > 0)
{ 
var url="emp_name_desig.php?grp_id="+str+"&emp_id="+id;
xmlHttp=GetXmlHttpObject(get_emp_field)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
} 
else
{ 
document.getElementById("emp_name_designation").innerHTML=""
} 
} 

function check_loginid22()
{ 
str=document.edit_user.login_id.value;
if (str)
{ 
var url="check_already_exist.php?logid="+str;
xmlHttp=GetXmlHttpObject(getleft_loginid22)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
} 
else
{ 
//document.getElementById("logid").innerHTML=""
} 
} 
function getleft_loginid22() 
{ 
 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{

if(xmlHttp.responseText == 1)
{
	alert("Login Id Already Exists !!");
	document.edit_user.login_id.select();
	document.edit_user.login_id.focus();
}
//document.getElementById("logid").innerHTML=xmlHttp.responseText 
}
} 




function show_esc(id,service)
{
	
	if (id && service)
	{ 
		if(document.getElementById("menu").value=='edit_manage_escalation')
		{
				
		
			var url="escalation_le.php?tic_type="+id+"&serv_id="+service;
	
		}else
		{
		var url="escalation/escalation_le.php?tic_type="+id+"&serv_id="+service;
		}
	//alert(url);
		xmlHttp=GetXmlHttpObject(show_es)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	else
	{ 
		document.getElementById("show_escalation").innerHTML=""
	} 
} 
function show_es() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("show_escalation").innerHTML=xmlHttp.responseText 
	}
} 


function unlockUser(url){
	
	xmlHttp=GetXmlHttpObject(unlockUs)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
	
	}

function unlockUs() 
{ 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{	
		if(xmlHttp.responseText!='Error')
		document.getElementById(xmlHttp.responseText).innerHTML='';
		else alert('Due to some problem user not unlocked!');
	}
	
}
////////////////////////////////////////
function delete_asset_group(cate_id,mid,page_n,ad)
{ 
	if(confirm("Are you sure to delete"))
		{  
			if(ad=='delete_group' && cate_id<=6)
			{
				alert('This group is not allowed to be deleted');
				return false;
			}
			
			if (cate_id>0)
			{ 
				var url=page_n+"?asset_group_id="+cate_id+"&mid="+mid+"&asset_del="+ad;
				xmlHttp=GetXmlHttpObject(delete_support_category_mast)
				xmlHttp.open("GET", url , true)
				xmlHttp.send(null)
			} 
			
		}
	
} 
function delete_support_category_mast() 
{ 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		alert("Deleted successfully...");
		document.getElementById("right_panel").innerHTML=xmlHttp.responseText 
				
	}
} 

function check_asset_data(val,tab,fie,edit,pre)
{ 
if(document.getElementById("department").value=='')
 {
 	alert('Please select department ')
	
	
	return false;
 }
 if(pre==val)
 {
 return false
 }
 var dept=document.getElementById("department").value

 var url2=''
 if(edit)
 {
  url2="../";
 }
var url=url2+"user_management/validating_name.php?value="+val+"&table_name="+tab+"&field_name="+fie+"&dep="+dept;
//alert(url);
xmlHttp=GetXmlHttpObject(Assetcheck)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
 
 
} 
function Assetcheck() 
{ 
//alert(xmlHttp.responseText);
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{

if(xmlHttp.responseText == 1)
{
	alert("  Already Exists !!");
	document.getElementById("category_name").value='';
	document.getElementById("category_name").focus();
	
}

}
} 

function ItemDropDown(aid,i)
{
	var sep="";
	if (aid>=0)
	{ 
	if(i!='')
	{
	sep="../"
	}
		var url=sep+"user_management/opration.php?AcID="+aid;
		//alert(url)
	xmlHttp=GetXmlHttpObject(function(){ItDEROP(aid)});
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	else
	{ 
		document.getElementById("itmes").innerHTML=""
	} 
} 

function ItDEROP(aid) 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		
		document.getElementById("itmes").innerHTML=xmlHttp.responseText 
		
		
	}
} 