var mymarquee = null;
var timer = 8000;
function xxx()
{
	if ( xxx.colLength ) return;
	mymarquee = document.getElementById("myMarquee");
	if ( mymarquee )
	{
		var col = mymarquee.getElementsByTagName("DIV");
		xxx.colLength = col.length ;
		xxx.col = col;
		window.setTimeout("zzzz()", timer);
	}
}
function zzzz()
{
	var colLength = xxx.colLength;
	var col = xxx.col ;
	var src = col[0];
	var clipHeight = mymarquee.clientHeight;
	
	if ( !clipHeight ) clipHeight = 22;
	xxx.maxTop = (col.length-1) * clipHeight;
	var maxTop = -xxx.maxTop ;
	var thisTop = src.style.pixelTop;
	
	if ( thisTop == maxTop ) thisTop = 0;
	else thisTop = thisTop-22;
	for ( var i = 0 ; i < colLength ; i++ )
	{
		col[i].style.top = thisTop+'px';
	}
	window.setTimeout("zzzz()", timer);
}
function isnull(arg)
{
	arg = arg+'';
	return (arg == '' || arg == 'null' || arg == 'undefined');
}
function nvl()
{
	for (var i=0; i<arguments.length; i++) {
		if (!isnull(arguments[i])) return arguments[i];
	}
	return null;
}

//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
var oDoc	= window.document;	
var oAll	= window.document.all;	
var oHddn	= window.document.getElementsByTagName("INPUT");
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	
window.windowTop	= window;
try
{
	if(window.top.dialogArguments && window.top.dialogArguments.window)
	{
		window.windowTop	= window.top.dialogArguments.window;
	}
}
catch(e){}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
window.onbeforeunload		= loading;
window.onload				= init;
//oDoc.attachEvent("onkeydown",f9);
	
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function searchRegulations()
{
	var f = document.Form1;
	var fld = f.fldRegulationsSearch;
	if(fld.value=='')
	{
		alert(vldEmptyEntry);
		return ;
	}
	if(isNaN(fld.value))
	{
		alert(vldNotANumber);
		return ;
	}
	var loc = String(location.toString());
	var t1=[],t2=[],t3=[];
	if (loc.indexOf('search')!=-1)
	{
		t1 = loc.split('?');
		t2 = t1[1].split('&');
		for(var i=0;i<t2.length;i++)
		{
			if(t2[i].indexOf('search')!=-1)
			{
				t3 = t2.splice(i,1);
				break;
			}
		}
		t1[1] = t2.join('&');
		loc = t1.join('?');
	}
	var url = loc + "&search=" + fld.value;
	
	window.location.href=url;
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function url2(url)		{	window.location.href	= url;			}
function open2(url)		{	window.open(url,"win");					}
function ws(arg)		{	window.windowTop.status	= arg;			}
function loading(arg)	
{	
	arg				= !arg?"loading ...":arg;
	ws(arg);	
}
function done()			{	ws("Done")								};
function setfocus()		
{
	if(window.windowTop)	window.windowTop.focus();
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function init()
{
	if(	init.active)	return;
		init.active	=	true;
	
	try
	{							// 144 search FORM
		if(window.initKSForm && !window.NoKSForm)	initKSForm();	
		
		setfocus();
		done();
	}
	catch(e){ws("init() "+e.description)}
	
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function isNone(o)
{
	if(o)
	{
		if(o.style.display=="none")			return true;	
		if(o.className.indexOf("none")>=0)	return true;	
		else								return false;
	} 
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function none(o)
{
	if(o) o.style.display		= "none";	
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function block(o)
{
	if(o) o.style.display		= "block";	
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function blocknone(o,bFirst)
{	
	try
	{
		if(o)
		{
			if(bFirst || o.style.display=="none" || o.className.indexOf("none")>=0)	
			{
					block(o);
					o.className	= o.className.replace(/none/gim,"");					
			}
			else	none(o);						
		}
	}
	catch(e){ws("blocknone() "+e.description)}
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function visible(obj)
{
	if(obj) obj.style.visibility 	= "visible";	
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function hidden(obj)
{
	if(obj) obj.style.visibility	= "hidden";	
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function classOff(o)
{
	o.className	= o.className.replace(/_on/gi,"_off");
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function classOn(o)
{
	o.className	= o.className.replace(/_off/gi,"_on");
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function dbg(O)
{
	if(typeof(O)=="string"||typeof(O)=="number"){alert(O);return;}
	
	var arr	=	[];
	
	for(var o in O){arr.push(o);} arr.sort(); alert(arr.join("; "));
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function CInt(vle,dflt)
{
    var str		= trim(vle);
    var strd	= trim(dflt);
    
	var intg	= parseInt(str,10);
	var intd	= parseInt(strd,10);
	
		intd	= (isNaN(intd)?0:intd);
    
	return (isNaN(intg)?intd:intg);
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function CStr(vle,dflt)
{
       dflt += "";
    if(dflt=="undefined") dflt = "";
    if(dflt=="null")      dflt = "";

       vle += "";
    if(vle=="undefined") return dflt;
    if(vle=="null")      return dflt;
    
    return vle;
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function trim(vle)
{
        var trm = CStr(vle);
    return  trm.replace(/(^\s*)|(\s*$)/g, "");
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function trimEnd(vle,sep)
{
    var trm = trim(vle);
    var chr = trim(sep)==""?",":sep;

   if(trm=="")					return trm;
    
	var ln	= trm.length;
	
	if(trm.substr(ln)==chr)		return trm.substr(0,ln-1);
	else						return trm;
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function queryString()
{
	this.obj				= {};
	this.querystring		= window.location.href.toLowerCase();
	this.defaultTemplate	= "templates";
	
	if(this.querystring.indexOf("?")<0)
	{
		this.script			= this.querystring;
		return;
	}
	
	this.script				= this.querystring.split("?")[0];
	var arr					= this.querystring.split("?")[1].split("&");
	
	
	for(var j=0; j<arr.length; j++)
	{
		if(!arr[j])					continue;
		if(trim(arr[j])=="")		continue;
	
		this.obj[arr[j].split("=")[0]]	= arr[j].split("=")[1];
	}
	
}
//'''''''''''''
/*
function queryString.prototype.getVirtualPath(tmplName)
{
	var tmpl	= trim(tmplName)==""?this.defaultTemplate:tmplName;
	var vpath	= "";
	
	if(this.querystring.indexOf(tmpl)>0)	vpath = this.querystring.toLowerCase().split(tmpl)[0];
	else									vpath = this.querystring.toLowerCase().split(this.defaultTemplate)[0];

	return vpath;
}
*/
//'''''''''''''
/*
function queryString.prototype.getQueryString()
{
	return this.querystring.split("?")[1];
}
*/
//'''''''''''''
/*
function queryString.prototype.getParameter(name)
{
	return this.obj[name];
}
*/
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function filedownload(url)
{
/*
	var qs			= new queryString();
	var vpath		= qs.getVirtualPath("hot.aspx");
	var query		= qs.getQueryString();

	var saveas		=  vpath+"Shared/Library/saveasdialog.asp?doc=";

	url2(saveas+url);
	*/
}
//'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function printProblems(o)
{
	window.print();
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function getXMLData(xmlpath)
{
	try
	{
		xmlhttp	= new ActiveXObject("Microsoft.XMLHTTP");
		
		xmlhttp.onreadystatechange	= HandleStateChange;
		xmlhttp.Open("GET", xmlpath, false);
		xmlhttp.Send();
	}
	catch (e){"getXMLData() "+ws("getXMLData() "+e.description);}
	
	xmlhttp = null;

	return;

//'''''''''''''''''''''''''
	function HandleStateChange()
	{
		if(xmlhttp.readyState==4)
		{
		}
	}
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function postXMLData(xmlpath, xmldoc)
{
	try
	{
		window.result				= "";

		xmlhttp	= new ActiveXObject("Microsoft.XMLHTTP");
		
		xmlhttp.onreadystatechange	= HandleStateChange;
		xmlhttp.Open("POST", xmlpath, false);
		xmlhttp.setRequestHeader("Content-Type", "text/xml; charset='utf-8' ");
		xmlhttp.Send(xmldoc);
	}
	catch (e){"postXMLData() "+ws("postXMLData() "+e.description);}
	
	xmlhttp = null;

	return;

//'''''''''''''''''''''''''
	function HandleStateChange()
	{
		if(xmlhttp.readyState==4)
		{
			if(xmlhttp.responseText)	window.result	= xmlhttp.responseText;
		}
	}
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function startOrder(url)
{
	var newclient	= oAll["clientNewRadio"].checked;
	var oldclient	= oAll["clientOldRadio"].checked;
	
	if(newclient)	url2(url+"&order="+1);
	else			url2(url+"&order="+0);
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function getRelationPackages(docid,doctype)
{
/*
	var	popup		= {"window":window};
	var qs			= new queryString();
	var vpath		= qs.getVirtualPath();
	var query		= qs.getQueryString();

//	var url			=  vpath+"Templates/TV_SALES/AddPackageForm.aspx?"+query+"&docid="+docid+"&doctype="+doctype.toLowerCase();
	var url			=  "AddPackageForm.aspx?"+query+"&docid="+docid+"&doctype="+doctype.toLowerCase();
	
//	window.open(url);
	var res			= window.showModalDialog(url,popup,"dialogHeight:350px; dialogWidth:300px; status:no; help:no; resizable:yes;");

	if(res)
	{
		url			=  vpath+"Templates/TV_SALES/AddItems.aspx";
		
		postXMLData(url, res);
		done();
		
		//alert(window.result);
	
		if(window.result.indexOf("error:")>=0)
		{
			alert(window.result);
		}
		else
		{
			if(window.result!=null)	url2(qs.querystring);
		}
	}
	else
	{
		done();
	}
	*/
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function closeCourse()
{
	window.returnValue 	= false;
	
	self.close();	
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function addPackages2Order()
{
	var packages			= "";
	var xmldoc				= "";
	var course				= oHddn["courseId"].value;
	var courseid			= course.split(":")[0];
	var doctype				= course.split(":")[1];
	var checkedPackageCount	= 0;	
	var maxPackagesCount	= oHddn["packageMaxCount"].value;
		maxPackagesCount	= CInt(maxPackagesCount,0);
	
	for(var j=0; j<oHddn.length; j++)
	{
		if(oHddn[j].type!="checkbox")	continue;
		if(!oHddn[j].checked)			continue;
		
		packages	+= oHddn[j].docId+":"+oHddn[j].doctype+",";
		
		++checkedPackageCount;
	}
		packages	+= course;
		xmldoc		= "<data><row>"+packages+"</row><mode>"+doctype+"</mode><course>"+courseid+"</course></data>";
	
	if(checkedPackageCount!=maxPackagesCount)	return;
	
	if(trim(packages)!="")	window.returnValue 	= xmldoc;
	else					window.returnValue 	= false;
	
	self.close();
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function getClientChoice(o,type,mode)
{
	var xmldoc		= "";
	var items		= "";
	var arr	= [];
	
	type			= trim(type);
	mode			= trim(mode);
	
	for(var j=0; j<o.length; j++)
	{
		var chks	= o[j].childNodes;
		if(!chks || chks.length==0)		continue;
		
		switch(type)
		{
			case "checked":
			
					if(chks[0].checked)
					{
						arr.push(chks[0].docId);	
					}
			break;
			default:
			
						arr.push(chks[0].docId);	
			break;
		}
	}
	items			= trim(arr.join(","));
	
	if(items!="")
	{
		xmldoc		= "<data><row>"+items+"</row><mode>"+mode+"</mode></data>";
	}
	return xmldoc;
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function checkBoxChanged(o)
{
	var checkedPackageCount	= 0;	
	var maxPackagesCount	= oHddn["packageMaxCount"].value;
		maxPackagesCount	= CInt(maxPackagesCount,0);
		
	for(var j=0; j<oHddn.length; j++)
	{
		try
		{
			if(oHddn[j].type!="checkbox")	continue;
			if(!oHddn[j].checked)			continue;
			
			++checkedPackageCount;
			
			if(checkedPackageCount>=maxPackagesCount)
			{
				clickLock();
				
				break;
			}
			clickUnLock();
		}
		catch(e)
		{
			ws("checkBoxChanged() "+e.description);
		}
	}
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function clickLock()
{
	for(var j=0; j<oHddn.length; j++)
	{
		try
		{
			if(oHddn[j].type!="checkbox")	continue;
			if(oHddn[j].checked)			continue;
			
			oHddn[j].disabled				= "disabled";
		}
		catch(e)
		{
			ws("clickLock() "+e.description);
		}
	}
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function clickUnLock()
{
	for(var j=0; j<oHddn.length; j++)
	{
		try
		{
			if(oHddn[j].type!="checkbox")	continue;
			if(oHddn[j].checked)			continue;	
			
			oHddn[j].disabled				= "";
		}
		catch(e)
		{
			ws("clickUnLock() "+e.description);
		}
	}
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function browse2(docid,doctype,sale)
{
/*
	var qs			= new queryString();
	var vpath		= qs.getVirtualPath();
	
	if(sale)
	{
		var url		= "Templates/TV_SALES/popUp.aspx";
			url		= vpath.replace("hot.aspx",url);
			url		+="&from=sale&docid="+docid+"&doctype="+doctype.toLowerCase();
	}
	else
	{	
		var url		=  "popUp.aspx?from=sale&docid="+docid+"&doctype="+doctype.toLowerCase();
	}

	var newwin		= openWindow(url,290,320," status=no,toolbar=no,menubar=no,location=no,resizable=no ","newwin");
	
	if(newwin)		newwin.focus();
	*/
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function add2Order(doctype)
{
/*
	var ids			= getClientChoice(oAll["_itembox_"],"checked",doctype.toLowerCase());

	if(trim(ids)=="")	{done(); return;}
	
	var qs			= new queryString();
	var vpath		= qs.getVirtualPath();

//	var url			=  vpath+"Templates/TV_SALES/AddItems.aspx";
	var url			=  "AddItems.aspx";
	
	postXMLData(url, ids);

	if(window.result.indexOf("error:")>=0)
	{
		alert(window.result);
		done();
	}
	else
	{
		url2(qs.querystring);
	}
	*/
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function deleteOrder()
{
/*
	var ids			= getClientChoice(oAll["_paybox_"],"checked");

	if(trim(ids)=="")	{done(); return;}
	
	var qs			= new queryString();
	var vpath		= qs.getVirtualPath();

//	var url			=  vpath+"Templates/TV_SALES/RemoveFromOrder.aspx";
	var url			=  "RemoveFromOrder.aspx";
	
	postXMLData(url, ids);

	if(window.result.indexOf("error:")>=0)
	{
		alert(window.result);
		done();
	}
	else
	{
		url2(qs.querystring);
	}
	*/
}

//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function getChannelList()
{
/*
	var qs			= new queryString();
	var vpath		= qs.getVirtualPath("hot.aspx");

//	var url			=  vpath+"Templates/TV_SALES/GetChannelList.aspx";
	var url			=  "Templates/TV_SALES/GetChannelList.aspx";
	
	newwin			= openWindow(url,290,320," status=no,toolbar=no,menubar=no,location=no,resizable=no ","newwin");
*/
}

//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

function serviceSearchExec()
{
	var searchInput		= trim(oAll.serviceInput.value);
	var searchSelect	= oAll.serviceSelect.value;
	var url				= oAll.Header_searchSections.searchPageURL;
		url			   += "&Search="+searchInput+"&Category="+searchSelect;

	if(checkSearchField(searchInput))
	{
			url2(url);
	}
	else	oAll.serviceInput.focus();
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
///////////////////////////////////////////////////
function openWindow(sUrl,iHeight,iWidth,sParams,sName)
{
	sParams				= !sParams?" status=no,toolbar=no,menubar=no,location=no ":sParams;
	sName				= !sName?"_blank":sName;
	
	var size			= "";
	try
	{
		iHeight			= parseInt(iHeight);
		iWidth			= parseInt(iWidth);
		
		var bFullSize	= false;
		
		if(iWidth>window.screen.width)		bFullSize	= true;
		if(iHeight>window.screen.height)	bFullSize	= true;
		
		if(bFullSize)						size = "full=yes";
		else								size = "height="+iHeight+",width="+iWidth;
	}
	catch(e){}
	
	//return window.open(sUrl,sName,size+","+sParams);
	var win1 = window.open(sUrl,sName,size+","+sParams);
}
///////////////////////////////////////////////////
function goToSearchResults()
{
	var searchInput = document.getElementById("Header_searchText");
	var searchSelect = document.getElementById("Header_searchSections");
	if(checkSearchField(searchInput.value)){
		document.location.href = searchSelect.searchPageURL+"&Search="+searchInput.value.replace(/(^\s+)|(\s+$)/g,'')+"&Category="+searchSelect.value
		return;
	}
	else{
		searchInput.focus();
		return;
	}
}
///////////////////////////////////////////////////
function goToPressSearchResults()
{
	var searchInput = document.getElementById("Header_searchText");
	var searchSelect = document.getElementById("Header_searchSections");
	if(checkSearchField(searchInput.value))
	{
		document.location.href = searchSelect.searchPageURL+"&Search="+searchInput.value.replace(/(^\s+)|(\s+$)/g,'');//+"&Category="+searchSelect.value
		return;
	}
	else{
		searchInput.focus();
		return;
	}
}
function checkSearchField(str)
{
	var sSearchWord = str;
	
	var validSearch = true;
	var notValidStr = "";
	if (String(sSearchWord) == '')
	{
		validSearch = false;
		notValidStr = MSG.CLIENT_MSG_EMPTY_SEARCH_CRITERIA;
	}
	if (String(sSearchWord) == '""')
	{
		validSearch = false;
		notValidStr = MSG.CLIENT_MSG_EMPTY_SEARCH_CRITERIA;
	}
	if (sSearchWord != '' && sSearchWord.length < 2 )
	{
		validSearch = false;
		notValidStr = MSG.CLIENT_MSG_SHORT_SEARCH_CRITERIA;
	}
	//if (sSearchWord == '"' || sSearchWord == '.' || sSearchWord == '`') {
	//	validSearch = false;
	//	notValidStr = MSG.CLIENT_MSG_INVALID_SEARCH_CRITERIA+"\n\".'";
	//}
	var regEx = new RegExp("([\\.\\@\\%\\~\\!\\#\\&\\<\\>\\=\\/\\;\\$\\(\\)\\*\\+\\[\\\\\\]\\^\\{\\|\\}])","igm");
	if (sSearchWord.match(regEx) != null)
	{
		notValidStr = MSG.CLIENT_MSG_INVALID_SEARCH_CRITERIA+"\n@%~.!#&-_=<>;$()*+[\]^{|}";
		validSearch = false;
	}
	if(!validSearch)
	{
		alert(notValidStr);
		return false;
	}
	else return true;
}


//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function multiColorMark(searchString,o)
{
	try
	{
		if(!o)						return;
		if(searchString=="")		return;
		
		var colors		= ["#FFF8B2","#FFF8B2","#FFF8B2","#FFF8B2","#FFF8B2"];
		
		searchString	= searchString.replace(/\+/gim," ");
		
		var arr			= searchString.split(" ");

		for(var j=0; j<arr.length; j++)
		{
			//if(trim(arr[j])=="")	continue;
			
			if(trim(arr[j]).length < 2) continue;
			
			markText(arr[j],o,colors[j%4]);
		}
	}
	catch(e){throw new Error(" multiColorMark() "+e.description)}
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
//*	Mark text in a given object
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function markText(sText,oObject,sColor)
{
	
	// the color of the markup
	if(!sColor) sColor='yellow';
	
	// create first level objects
	var aPreviusObjects = [oObject];

	// while previus level has items
	while(aPreviusObjects.length>0)
	{
		// current level items
		var aLevelObjects = [];
		
		// loop previus level items
		for(var iPrevIndex in aPreviusObjects)
		{
		
			// get current level items
			var oNodes = aPreviusObjects[iPrevIndex].childNodes;
			
			// collect text nodes
			var aLevelTextNodes=[];
			
			// loop current level items
			for(var iCurrIndex=0;iCurrIndex<oNodes.length;iCurrIndex++)
			{
			
				// get item reference
				var oItem = oNodes.item(iCurrIndex);
				
				// if text node
				if(oItem.nodeName=='#text')
				{
					aLevelTextNodes.push(oItem);
				}
				else
				{
					// not text node add to current level item array
					aLevelObjects.push(oItem);
				}
			}	
			
			// loop all text nodes
			for(var iTextIndex in aLevelTextNodes)
			{
				// get item reference
				var oItem = aLevelTextNodes[iTextIndex];
				
				// search string first index
				var iFoundIndex = -1;
				
				// if text node contains search string
				if((iFoundIndex=String(oItem.nodeValue).indexOf(sText))>-1)
				{
					// loop while more instances
					while(iFoundIndex>-1)
					{
						
						// get start text node
						oItem = oItem.splitText(iFoundIndex);
						
						// create a span and insert before found text
						var oSpan =	document.createElement("SPAN");
						oSpan.style.background=sColor;
						oItem.parentNode.insertBefore(oSpan,oItem);
						
						// slice remaining text and insert to span
						var oSearchItem = oItem.splitText(sText.length);
						oSpan.appendChild(oItem);
						oItem = oSearchItem;
						
						// search on remaining text
						iFoundIndex=String(oItem.nodeValue).indexOf(sText);

					}
				}
			}
		}
		
		// set previus level item array
		aPreviusObjects = aLevelObjects;
	}
}

//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
var ActiveSearchResultsCategory = null;
var ActivesearchResultsContainerID = -1;
function SearchResultsCategory_OnMouseOver(obj){
	if(ActiveSearchResultsCategory != null && obj == ActiveSearchResultsCategory) return;
	obj.className = "sr_bg_on"
}
function SearchResultsCategory_OnMouseOut(obj){
	if(ActiveSearchResultsCategory != null && obj == ActiveSearchResultsCategory) return;
	obj.className = "sr_bg";
}
function SearchResultsCategory_OnClick(obj,ind){
	
	if(ActiveSearchResultsCategory != null && obj == ActiveSearchResultsCategory)
	{
		document.all["documents_container_"+ActivesearchResultsContainerID].style.display = "none";
		document.all["bullet_container_"+ActivesearchResultsContainerID].className = "sr_category_bullet";
		ActiveSearchResultsCategory = null
		ActivesearchResultsContainerID = -1
	}
	else
	{
		if(ActiveSearchResultsCategory != null){
			ActiveSearchResultsCategory.className = "sr_bg";
			if(ActivesearchResultsContainerID != -1)
			{
				document.all["documents_container_"+ActivesearchResultsContainerID].style.display = "none";
			}
			document.all["bullet_container_"+ActivesearchResultsContainerID].className = "sr_category_bullet";
		}
		
		obj.className = "sr_bg_on";
		document.all["documents_container_"+ind].style.display = "";
		document.all["bullet_container_"+ind].className = "sr_category_bullet_on";
		
		
		
		ActivesearchResultsContainerID = ind
		ActiveSearchResultsCategory = obj;
	}
	
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function f9(ev)
{

	if(event.keyCode==120)
	{
		try
		{
			if(nw)	nw.close();
		}
		catch(e){}
		
		nw	= window.open("","newwin");
		nw.document.write(document.documentElement.outerHTML);
		nw.focus();
	}
	
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

function OpenTab(num,id,selectedCell)
{
	var prefix			= "TelephoneDocViewTemplate1_";
	var suffixLink		= "LinkTab";	
	var suffixCell		= "CellTab";
	var selectedDiv		= prefix + "selectedDiv";	
	var	currCell;
	
	for (i = 0 ; i < tablesArr.length ; i++)
	{
		var currTbl		= document.getElementById(tablesArr[i]);
		var currCellId	= prefix + suffixCell + i;
		currCell	= document.getElementById(currCellId);			
		if (i == num)
		{
			currTbl.className	= 'Visible';
			if (currCell != null)
			{
				currCell.className	= 'TabCellBG_Selected';
			}
			var selectedLink = prefix + suffixLink + i;
			document.getElementById(selectedDiv).innerText = document.getElementById(selectedLink).innerText;
		}
		else
		{
			currTbl.className = 'NonVisible';
			if (currCell != null)
			{
				currCell.className	= 'TabCellBG';
			}
		}
	}	
	
	done();
}
function SelectState(obj)
{
	var app = "Mirs";
	var ddl = document.getElementById(obj);
	if ( ddl )
	{
		selectedValue = ddl.value;
		if ( selectedValue > 0 )
		{
			var url = "/"+app+"/"+selectedValue+"-he/Mirs.aspx";
			location.href = url;
		}
	}
}

