/*
	strRequest : request url
	type :	1	= general chat script
			<>1 = Agent Typeing pull

*/

function sendRequest( strRequest, type, num)
{
	try
{
	var head, script;
	head = document.getElementsByTagName('head').item(0);
	script = document.createElement('script');
	script.src = strRequest;
	script.type = 'text/javascript';
	script.defer = true;
	if( type == 1 )
		script.id = 'ChatScript' + num;
	else
		script.id = 'TChatScript'+num;

	void(head.appendChild(script));
}catch(e){}
} 


function setResponse( strResponse )
{
	var head, script;
	head = document.getElementsByTagName('head').item(0);
	script = document.createElement('script');
	script.text = strResponse;
	script.type = 'text/javascript';
	script.defer = true;
	script.id = 'ChatScript';
	void(head.appendChild(script));
	//alert( strResponse );
	head.removeChild(script);
}


var browser = navigator.appName;
var version = parseInt(navigator.appVersion);
var nn = (browser=="Netscape" && version >= 5 )? true:false;
var ie = (navigator.userAgent.indexOf("MSIE")!=-1 && version>=4)? true:false;
if(!ie&&!nn)alert('This application is known to work in\nInternet Explorer v6\nNetscape Navigator v7\n it may not work for you..!')

document.TabScript = "";
function SetTabScript()
{
	try
	{
		o("divTabList").innerHTML = document.TabScript;
	}catch(err){}
}

function ReplaceAll(sourceString, searchString, replaceString)
{
	var endIndex=0;
	var TempStr = "";

	endIndex = sourceString.indexOf(searchString);
	try
	{
		while( endIndex > -1)
		{
			TempStr += sourceString.substring(0, endIndex);
			TempStr += replaceString;
			sourceString = sourceString.substring( endIndex + searchString.length, sourceString.length );
			endIndex = sourceString.indexOf(searchString);
		}
	}
	catch(e)
	{}
	endIndex = sourceString.length;

	TempStr += sourceString.substring(0,endIndex);
	return TempStr;
}



function o(what)
{
	return document.getElementById(what)
}

function CloseWindow()
{
	window.close();
}

function MM_findObj(n, d)
{ //v4.0
  	var p,i,x;
    	if(!d)
  		d=document;
	if((p=n.indexOf("?"))>0&&parent.frames.length)
	{
    	d=parent.frames[n.substring(p+1)].document;
    	n=n.substring(0,p);
    }
  	if(!(x=d[n])&&d.all)
  		x=d.all[n];
  	if(d.forms != null)
  	{
  		for (i=0;!x&&i<d.forms.length;i++)
  			x=d.forms[i][n];
  	}
  for(i=0;!x&&d.layers&&i<d.layers.length;i++)
  	x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById)
  	x=document.getElementById(n); return x;
}

function setScroll()
{
	try
	{
		objTranscriptPGBody = MM_findObj( 'TranscriptPGBody',window.top.frames.item(1) );
		objTranscriptPGBody.scrollTop = TranscriptPGBody.scrollHeight;
	}
	catch(errormsg)
	{}
}

function setFocus()
{
	if( window.parent.document.WindowBlured )
	{
		window.focus();
	}
}

function removeScript(num,type)
{
	try
	{
		if( type == 1 )
		{
			head=document.getElementsByTagName('head').item(0);
			old=document.getElementById('ChatScript'+num);
			if(old)head.removeChild(old);
		}
		else
		{
			head=document.getElementsByTagName('head').item(0);
			Told=document.getElementById('TChatScript'+num);
			if(Told)head.removeChild(Told);
		}
	}
	catch(errormsg)
	{}
}




function resizeLogo()
{
/*	var MaxW = 400;
	var MaxH = 75;
	var objImg;

	objImg = MM_findObj("imgLocLogo")

	if( objImg != null )
	{
		if( objImg.width > MaxW )
		{
			objImg.width = MaxW;
		}
		if( objImg.height > MaxH )
		{
			objImg.height = MaxH;
		}
	}*/
}
//resizeLogo();