var messageType="";

var bslHeight=0;
var bslMaxHeight=0;

var bslOutDivId="";
var bslInDivId="";
var bslIncHeight=10;
var objindiv=0;
var objoutdiv=0;
function showDiv(id)
{
	document.getElementById(id).style.visibility="visible";
	document.getElementById(id).style.display='block';
	return true;
}
function hideError()
{
	document.getElementById("error").style.visibility="hidden";
	//document.getElementById('error').style.display='none';
	return true;
}
var flag;
function bslIncDiv(id)
{
	
	if(bslHeight>=bslMaxHeight)
	{
		showDiv(bslInDivId);
		return true;
	}
	bslHeight=bslHeight+bslIncHeight;
	e=document.getElementById(id);
	e.style.height = bslHeight + 'px';
	t=setTimeout("bslIncDiv('"+id+"');",0);
}
function displayDiv(outid,inid,height)
{
	if(height=="" ||height=="undefined")
		height=20;
	bslInDivId=inid;
	bslOutDivId=outid;
	bslMaxHeight=height;
	bslHeight=0;
	bslIncDiv(bslOutDivId);
	bslIncDiv(bslInDivId);

}
function displayDivWork(outid,inid,height)
{
	if(height=="" ||height=="undefined")
		height=20;
	if(objoutdiv||objindiv)
	{
		hideDiv(objoutdiv.id,objindiv.id);
	}

	objoutdiv=document.getElementById(outid);
	objindiv=document.getElementById(inid);
	
	bslInDivId=inid;
	bslOutDivId=outid;
	bslMaxHeight=height;
	bslHeight=0;
	bslIncDiv(bslOutDivId);
	bslIncDiv(bslInDivId);

}
function getHeight(id)
{
	e=document.getElementById(id);
	h=e.style.height;
	height=parseInt(h.substr(0,(h.length)-2));
	return height;	
}
function hideDiv(outdiv,indiv)
{
	
	document.getElementById(indiv).style.visibility="hidden";
	document.getElementById(indiv).style.display='none';
	e=document.getElementById(indiv);
	e.style.height = 0 + 'px';
	e=document.getElementById(outdiv);
	e.style.height = 0 + 'px';
	bslHeight=0;
	return true;
}
function selectMsgType(msgtype,outdiv,indiv)
{
	messageType=msgtype;
	displayUserList(outdiv,indiv,msgtype);
	
}

function displayUserList(outdiv,indiv,optname)
{

	if(messageType=="")
	{
		alert("Error in message type selection!");
		return false;
	}

	var parameters="optflag="+optname+"&msgtype="+messageType;	
	
	if(document.getElementById('dptid'))
	{
		
		parameters=parameters+"&dptid="+document.getElementById('dptid').options[document.getElementById('dptid').selectedIndex].value+"&dptname="+document.getElementById('dptid').options[document.getElementById('dptid').selectedIndex].text;
	}
	if(document.getElementById('fileid'))
	{
		
		parameters=parameters+"&fileid="+document.getElementById('fileid').options[document.getElementById('fileid').selectedIndex].value;
	}
	
	//alert(parameters);
	
	xmlHttp_html=GetXmlHttpObject();
	if(document.getElementById('loader'))
	document.getElementById('loader').style.visibility='visible';

	xmlHttp_html.open("POST","byajax/getmessageuserdetails.php",true);

	xmlHttp_html.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

	xmlHttp_html.setRequestHeader("Content-length", parameters.length);
    xmlHttp_html.setRequestHeader("Connection", "close");
	xmlHttp_html.send(parameters); 
		
	document.getElementById(indiv).innerHTML="";
	xmlHttp_html.onreadystatechange=sendRequest;
	
	function sendRequest()
	{
		var getdata="";
      if(xmlHttp_html.readyState==4)
        {	
			if(xmlHttp_html.status==200)
			{
				getdata=xmlHttp_html.responseText;
				//alert(getdata);
				if(getdata=='ERROR')
				{
					getdata='Error on server.';
				}
				else
				{					
					var dataArr=getdata.split("~");
					if(dataArr.length==1)
						dataArr[1]=20;
					displayDiv(outdiv,indiv,dataArr[1]);
					getdata=dataArr[0];
				}
				if(document.getElementById('loader'))
					document.getElementById('loader').style.visibility='hidden';
				document.getElementById(indiv).innerHTML=getdata;
			}
			else
				alert("Error: On loading page");
		}
		
	}
	
		
	}


	
	


function showOther(obj)
{
	if(!obj.checked)
	{

	}
	else if(obj.checked)
	{
		
		//ideDiv('outdiv','indiv');
		displayUserList('outdiv','indiv','other');
	}
	
	
}
