		function GetXmlHttpObject(handler)
		{
		var objXmlHttp=null

		if (navigator.userAgent.indexOf("Opera")>=0)
		{
		alert("This example doesn't work in Opera")
		return
		}
		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
		}
		}

		var url = "http://insight.dzherelo.org/include/getagents.php?param="; // The server-side scripts
		var url_arch = "http://insight.dzherelo.org/include/getagents_arch.php?param="; // The server-side scripts
		var url_arch_manager = "http://insight.dzherelo.org/include/getagents_arch_manager.php?param="; // The server-side scripts
		var url_arch_site = "http://insight.dzherelo.org/include/getagents_arch_site.php?param="; // The server-side scripts
		var url_moroz = "http://insight.dzherelo.org/include/getagents_moroz.php?param="; // The server-side scripts
		var url_manager = "http://insight.dzherelo.org/include/getagents_manager.php?param="; // The server-side scripts
		var url_nar = "http://insight.dzherelo.org/include/getagents_nar.php?param="; // The server-side scripts
		var url_clients = "http://insight.dzherelo.org/include/getagents_clients.php?param="; // The server-side scripts
		var url_site = "http://insight.dzherelo.org/include/getagents_site.php?param="; // The server-side scripts

		var pattern = /\r\n|\r|\n/g;

		function getagents(column,direc,sorts) {
				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET",url + escape(column) + "&mode=list&dir=" + direc +"&select="+sorts+ "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function getagents_arch(column,direc) {
				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET",url_arch + escape(column) + "&mode=list&dir=" + direc + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function getagents_arch_site(column,direc) {
				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET",url_arch_site + escape(column) + "&mode=list&dir=" + direc + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function getagents_arch_manager(column,direc) {
				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET",url_arch_manager + escape(column) + "&mode=list&dir=" + direc + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function getagents_moroz(column,direc) {
				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET",url_moroz + escape(column) + "&mode=list&dir=" + direc + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function getagents_manager(column,direc,sorts) {
				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET",url_manager + escape(column) + "&mode=list&dir=" + direc +"&select="+sorts+ "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}
		
		function getagents_nar(column,direc,sorts) {
				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET",url_nar + escape(column) + "&mode=list&dir=" + direc +"&select="+sorts+ "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function getagents_clients(column,direc) {
				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET",url_clients + escape(column) + "&mode=list&dir=" + direc + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function getagents_site(column,direc) {
				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET",url_site + escape(column) + "&mode=list&dir=" + direc + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function getSelectedIndexes (oListbox) {
  				var arrIndexes = new Array;
  				for (var i=0; i < oListbox.options.length; i++)
  				{
      					if (oListbox.options[i].selected) arrIndexes.push(i+1);
  				}
  				return arrIndexes;
		}

/*
designer_sel
*/
		function changesel_comby(id,bys,dates)
		{
		// alert("http://insight.dzherelo.org/include/getagents"+bys+".php?select="+id+"&mode=list&param=end"+dates+"_date&dir=&rand=" + myRandom);
				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents"+bys+".php?select="+id+"&mode=list&param=end"+dates+"_date&dir=&rand=" + myRandom, true);
				xmlHttp.send(null);
		}
		function changesel_comby_st(id,bys,dates)
		{
		// alert("http://insight.dzherelo.org/"+bys+"?select_st="+id+"&mode=list&param=end"+dates+"_date&dir=&rand=" + myRandom);
				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET","http://insight.dzherelo.org/"+bys+"?select_st="+id+"&mode=list&param=end"+dates+"_date&dir=&rand=" + myRandom, true);
				xmlHttp.send(null);
		}
		function changesel_comby_ma(id,bys,dates)
		{
		// alert("http://insight.dzherelo.org/"+bys+"?select_ma="+id+"&mode=list&param=end"+dates+"_date&dir=&rand=" + myRandom);
				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET","http://insight.dzherelo.org/"+bys+"?select_ma="+id+"&mode=list&param=end"+dates+"_date&dir=&rand=" + myRandom, true);
				xmlHttp.send(null);
		}



		function select_work()
		{
				alert("tt");
		}

		function saveRecord(mode,id,param,dir,sorts)
		{
			client = document.getElementById("txtclient").value;
			work = document.getElementById("txtwork").value;
			designer = document.getElementById("txtdesigner");
			designerss = document.getElementById("txtdesigner");
			curator = document.getElementById("txtcurator").value;
			state = document.getElementById("txtstate").value;
			extra = document.getElementById("txtextra").value;
			start_work_date = document.getElementById("txtstart_work_date").value;
			end_work_date = document.getElementById("txtend_work_date").value;

			extra = extra.replace(pattern,"<br>");
			work = work.replace(pattern,"<br>");

				var designerz = [];
					j=0;
					for (var i = 0; i < designerss.length; i++ ) {
						if(designerss[i].selected == true){
    						designerz[j] = designerss[i].value;
						j++;
						}
 					}

				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents.php?uid="+id+"&client="+client+"&select="+sorts+"&work="+work+"&designer="+designerz+"&curator="+curator+"&state="+state+"&extra="+extra+"&start_work_date="+start_work_date+"&end_work_date="+end_work_date+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function updateRecord(mode,id,param,dir,sorts)
		{
			state = document.getElementById("txtstate").value;
			extra = document.getElementById("txtextra").value;

				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents.php?uid="+id+"&select="+sorts+"&state="+state+"&extra="+extra+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}
		function saveRecordPr(mode,id,param,dir,sorts,pr)
		{
			// state = document.getElementById("txtstate").value;

				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents.php?uid="+id+"&select="+sorts+"&prior="+pr+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function saveNewRecord(mode,param,dir,sorts)
		{
			//uid = document.getElementById("txtId").value;

			client = document.getElementById("txtclient").value;
			work = document.getElementById("txtwork").value;
			designer = document.getElementById("txtdesigner");
			designerss = document.getElementById("txtdesigner");
			curator = document.getElementById("txtcurator").value;
			state = document.getElementById("txtstate").value;
			extra = document.getElementById("txtextra").value;
			start_work_date = document.getElementById("txtstart_work_date").value;
			end_work_date = document.getElementById("txtend_work_date").value;
// 			designerz = getSelectedIndexes(designer);

			extra = extra.replace(pattern,"<br>");
			work = work.replace(pattern,"<br>");

				var designerz = [];
					j=0;
					for (var i = 0; i < designerss.length; i++ ) {
						if(designerss[i].selected == true){
    						designerz[j] = designerss[i].value;
						j++;
						}
 					}
// alert(designerz);

		if ( client.length == 0 || work.length == 0 || designer.length == 0 )
		{
			alert("Please enter value for all the fields");

		}
		else
		{
				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents.php?client="+client+"&select="+sorts+"&work="+work+"&designer="+designerz+"&curator="+curator+"&start_work_date="+start_work_date+"&end_work_date="+end_work_date+"&state="+state+"&extra="+extra+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}
		}

		function newRecord(mode,param,dir,sorts)
		{
				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents.php?mode="+mode+"&select="+sorts+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function manipulateRecord(mode,id,param,dir,sorts)
		{
		if (mode == "delete"){
		if ( confirm("Are you sure you want to "+mode+" record ?") != 1 )
		{
			return false;
		}
		}

				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
// 				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents.php?id="+id+"&select="+designerz+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents.php?id="+id+"&select="+sorts+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

// ***************************************************************************************************
		function saveRecordCl(mode,id,param,dir,sorts)
		{
			short = document.getElementById("txtshort").value;
			titles = document.getElementById("txttitle").value;

				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_clients.php?uid="+id+"&select="+sorts+"&short="+short+"&titles="+titles+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function updateRecordCl(mode,id,param,dir,sorts)
		{
			short = document.getElementById("txtshort").value;
			titles = document.getElementById("txttitle").value;

				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_clients.php?uid="+id+"&select="+sorts+"&short="+short+"&titles="+titles+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}
 
		function saveNewRecordCl(mode,param,dir,sorts)
		{
			//uid = document.getElementById("txtId").value;

			short = document.getElementById("txtshort").value;
			titles = document.getElementById("txttitle").value;

		if ( short.length == 0 || titles.length == 0 )
		{
			alert("Please enter value for all the fields");

		}
		else
		{
				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_clients.php?short="+short+"&select="+sorts+"&titles="+titles+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}
		}

		function newRecordCl(mode,param,dir,sorts)
		{
				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_clients.php?mode="+mode+"&select="+sorts+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function manipulateRecordCl(mode,id,param,dir,sorts)
		{
		if (mode == "delete"){
		if ( confirm("Are you sure you want to "+mode+" record ?") != 1 )
		{
			return false;
		}
		}

				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
// 				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents.php?id="+id+"&select="+designerz+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_clients.php?id="+id+"&select="+sorts+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

// ***************************************************************************************************
// manager_id, client, project, work, designer, manager, start_work_date, end_work_date, close_work_date, state, FO, pay, akt_naklad, doverenost, nalog, extra, podrad, FO_podrad, pay_podrad, akt_naklad_podrad, doverenost_podrad, nalog_podrad, extra_podrad, moroz, arch
// ***************************************************************************************************
		function saveRecord_manager(mode,id,param,dir,sorts)
		{
			client = document.getElementById("txtclient").value;
			work = document.getElementById("txtwork").value;
			designer = document.getElementById("txtdesigner").value;
			curator = document.getElementById("txtcurator").value;
			start_work_date = document.getElementById("txtstart_work_date").value;
			close_work_date = document.getElementById("txtclose_work_date").value;
			state = document.getElementById("txtstate").value;
			extra = document.getElementById("txtextra").value;
			// podrad = document.getElementById("txtpodrad").value;
			// extra_podrad = document.getElementById("txtextra_podrad").value;
			
			extra = extra.replace(pattern,"<br>");
			work = work.replace(pattern,"<br>");
			// podrad = podrad.replace(pattern,"<br>");
			// extra_podrad = extra_podrad.replace(pattern,"<br>");

				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				// xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_manager.php?uid="+id+"&client="+client+"&select="+sorts+"&work="+work+"&designer="+designer+"&curator="+curator+"&start_work_date="+start_work_date+"&close_work_date="+close_work_date+"&state="+state+"&extra="+extra+"&podrad="+podrad+"&extra_podrad="+extra_podrad+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_manager.php?uid="+id+"&client="+client+"&select="+sorts+"&work="+work+"&designer="+designer+"&curator="+curator+"&start_work_date="+start_work_date+"&close_work_date="+close_work_date+"&state="+state+"&extra="+extra+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function updateRecord_manager(mode,id,param,dir,sorts)
		{
			state = document.getElementById("txtstate").value;
			extra = document.getElementById("txtextra").value;
			
			extra = extra.replace(pattern,"<br>");

				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_manager.php?uid="+id+"&select="+sorts+"&state="+state+"&extra="+extra+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function saveNewRecord_manager(mode,param,dir,sorts)
		{
			//uid = document.getElementById("txtId").value;

			client = document.getElementById("txtclient").value;
			work = document.getElementById("txtwork").value;
			designer = document.getElementById("txtdesigner").value;
			curator = document.getElementById("txtcurator").value;
			start_work_date = document.getElementById("txtstart_work_date").value;
			close_work_date = document.getElementById("txtclose_work_date").value;
			state = document.getElementById("txtstate").value;
			extra = document.getElementById("txtextra").value;
			// podrad = document.getElementById("txtpodrad").value;
			// extra_podrad = document.getElementById("txtextra_podrad").value;
			
			extra = extra.replace(pattern,"<br>");
			work = work.replace(pattern,"<br>");
			// podrad = podrad.replace(pattern,"<br>");
			// extra_podrad = extra_podrad.replace(pattern,"<br>");

				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				// xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_manager.php?client="+client+"&select="+sorts+"&work="+work+"&designer="+designer+"&curator="+curator+"&start_work_date="+start_work_date+"&close_work_date="+close_work_date+"&state="+state+"&extra="+extra+"&podrad="+podrad+"&extra_podrad="+extra_podrad+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_manager.php?client="+client+"&select="+sorts+"&work="+work+"&designer="+designer+"&curator="+curator+"&start_work_date="+start_work_date+"&close_work_date="+close_work_date+"&state="+state+"&extra="+extra+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function newRecord_manager(mode,param,dir,sorts)
		{
				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_manager.php?mode="+mode+"&select="+sorts+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function manipulateRecord_manager(mode,id,param,dir,sorts)
		{
		if (mode == "delete"){
		if ( confirm("Are you sure you want to "+mode+" record ?") != 1 )
		{
			return false;
		}
		}

				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
// 				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents.php?id="+id+"&select="+designerz+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_manager.php?id="+id+"&select="+sorts+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

// ***************************************************************************************************
// manager_id, client, project, work, designer, manager, start_work_date, end_work_date, close_work_date, state, FO, pay, akt_naklad, doverenost, nalog, extra, podrad, FO_podrad, pay_podrad, akt_naklad_podrad, doverenost_podrad, nalog_podrad, extra_podrad, moroz, arch
// ***************************************************************************************************
		function saveRecord_nar(mode,id,param,dir,sorts)
		{
			client = document.getElementById("txtclient").value;
			work = document.getElementById("txtwork").value;
			designer = document.getElementById("txtdesigner").value;
			curator = document.getElementById("txtcurator").value;
			start_work_date = document.getElementById("txtstart_work_date").value;
			close_work_date = document.getElementById("txtclose_work_date").value;
			state = document.getElementById("txtstate").value;
			extra = document.getElementById("txtextra").value;
			// podrad = document.getElementById("txtpodrad").value;
			// extra_podrad = document.getElementById("txtextra_podrad").value;
			
			extra = extra.replace(pattern,"<br>");
			work = work.replace(pattern,"<br>");
			// podrad = podrad.replace(pattern,"<br>");
			// extra_podrad = extra_podrad.replace(pattern,"<br>");

				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				// xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_manager.php?uid="+id+"&client="+client+"&select="+sorts+"&work="+work+"&designer="+designer+"&curator="+curator+"&start_work_date="+start_work_date+"&close_work_date="+close_work_date+"&state="+state+"&extra="+extra+"&podrad="+podrad+"&extra_podrad="+extra_podrad+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_nar.php?uid="+id+"&client="+client+"&select="+sorts+"&work="+work+"&designer="+designer+"&curator="+curator+"&start_work_date="+start_work_date+"&close_work_date="+close_work_date+"&state="+state+"&extra="+extra+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function updateRecord_nar(mode,id,param,dir,sorts)
		{
			state = document.getElementById("txtstate").value;
			extra = document.getElementById("txtextra").value;
			
			extra = extra.replace(pattern,"<br>");

				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_nar.php?uid="+id+"&select="+sorts+"&state="+state+"&extra="+extra+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function saveNewRecord_nar(mode,param,dir,sorts)
		{
			//uid = document.getElementById("txtId").value;

			client = document.getElementById("txtclient").value;
			work = document.getElementById("txtwork").value;
			designer = document.getElementById("txtdesigner").value;
			curator = document.getElementById("txtcurator").value;
			start_work_date = document.getElementById("txtstart_work_date").value;
			close_work_date = document.getElementById("txtclose_work_date").value;
			state = document.getElementById("txtstate").value;
			extra = document.getElementById("txtextra").value;
			// podrad = document.getElementById("txtpodrad").value;
			// extra_podrad = document.getElementById("txtextra_podrad").value;
			
			extra = extra.replace(pattern,"<br>");
			work = work.replace(pattern,"<br>");
			// podrad = podrad.replace(pattern,"<br>");
			// extra_podrad = extra_podrad.replace(pattern,"<br>");

				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				// xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_manager.php?client="+client+"&select="+sorts+"&work="+work+"&designer="+designer+"&curator="+curator+"&start_work_date="+start_work_date+"&close_work_date="+close_work_date+"&state="+state+"&extra="+extra+"&podrad="+podrad+"&extra_podrad="+extra_podrad+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_nar.php?client="+client+"&select="+sorts+"&work="+work+"&designer="+designer+"&curator="+curator+"&start_work_date="+start_work_date+"&close_work_date="+close_work_date+"&state="+state+"&extra="+extra+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function newRecord_nar(mode,param,dir,sorts)
		{
				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_nar.php?mode="+mode+"&select="+sorts+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function manipulateRecord_nar(mode,id,param,dir,sorts)
		{
		if (mode == "delete"){
		if ( confirm("Are you sure you want to "+mode+" record ?") != 1 )
		{
			return false;
		}
		}

				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
// 				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents.php?id="+id+"&select="+designerz+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_nar.php?id="+id+"&select="+sorts+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

// ***************************************************************************************************
// ***************************************************************************************************
// client,site,designer,curator,start_site_date,end_site_date,state,extra,url_site , moroz, arch
// ***************************************************************************************************
		function saveRecord_site(mode,id,param,dir,sorts)
		{
// alert ('client,site,designer,curator,start_site_date,end_site_date,state,extra,url_site');
			client = document.getElementById("txtclient").value;
			site = document.getElementById("txtsite").value;
			designer = document.getElementById("txtdesigner").value;
			curator = document.getElementById("txtcurator").value;
			start_site_date = document.getElementById("txtstart_site_date").value;
			end_site_date = document.getElementById("txtend_site_date").value;
			state = document.getElementById("txtstate").value;
			extra = document.getElementById("txtextra").value;
// 			url_site = document.getElementById("txturl_site").value;

			extra = extra.replace(pattern,"<br>");
			site = site.replace(pattern,"<br>");
			


// 		alert ('client,site,designer,curator,start_site_date,end_site_date,state,extra,url_site');

				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_site.php?uid="+id+"&client="+client+"&select="+sorts+"&site="+site+"&designer="+designer+"&curator="+curator+"&start_site_date="+start_site_date+"&end_site_date="+end_site_date+"&state="+state+"&extra="+extra+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
// 				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_site.php?client="+client+"&select="+sorts+"&site="+site+"&designer="+designer+"&curator="+curator+"&start_site_date="+start_site_date+"&end_site_date="+end_site_date+"&state="+state+"&extra="+extra+"&url_site="+url_site+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function updateRecord_site(mode,id,param,dir,sorts)
		{
			state = document.getElementById("txtstate").value;
			extra = document.getElementById("txtextra").value;
			
			extra = extra.replace(pattern,"<br>");

				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_site.php?uid="+id+"&select="+sorts+"&state="+state+"&extra="+extra+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}
		function saveRecordPr_site(mode,id,param,dir,sorts,pr)
		{
			// state = document.getElementById("txtstate").value;

				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_site.php?uid="+id+"&select="+sorts+"&prior="+pr+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function saveNewRecord_site(mode,param,dir,sorts)
		{
			//uid = document.getElementById("txtId").value;

			client = document.getElementById("txtclient").value;
			site = document.getElementById("txtsite").value;
			designer = document.getElementById("txtdesigner").value;
			curator = document.getElementById("txtcurator").value;
			start_site_date = document.getElementById("txtstart_site_date").value;
			end_site_date = document.getElementById("txtend_site_date").value;
			state = document.getElementById("txtstate").value;
			extra = document.getElementById("txtextra").value;
			url_site = document.getElementById("txturl_site").value;
			
			extra = extra.replace(pattern,"<br>");
			site = site.replace(pattern,"<br>");

				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_site.php?client="+client+"&select="+sorts+"&site="+site+"&designer="+designer+"&curator="+curator+"&start_site_date="+start_site_date+"&end_site_date="+end_site_date+"&state="+state+"&extra="+extra+"&url_site="+url_site+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}
		function saveNewRecord_site_url(mode,param,dir,sorts)
		{
			//uid = document.getElementById("txtId").value;

			url_site_title = document.getElementById("txturl_site_title").value;
			url_site = document.getElementById("txturl_site").value;

				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_site.php?url_site_title="+url_site_title+"&select="+sorts+"&url_site="+url_site+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function newRecord_site(mode,param,dir,sorts)
		{
				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_site.php?mode="+mode+"&select="+sorts+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}
		function newRecord_site_url(mode,param,dir,sorts)
		{
				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_site.php?mode="+mode+"&select="+sorts+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

		function manipulateRecord_site(mode,id,param,dir,sorts)
		{
		if (mode == "delete"){
		if ( confirm("Are you sure you want to "+mode+" record ?") != 1 )
		{
			return false;
		}
		}

				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
// 				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents.php?id="+id+"&select="+designerz+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_site.php?id="+id+"&select="+sorts+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}

// ***************************************************************************************************
		function handleHttpResponse() {
			if (xmlHttp.readyState == 4) {
			  document.getElementById("hiddenDIV").style.visibility="visible";
			  document.getElementById("hiddenDIV").innerHTML='';
			  document.getElementById("hiddenDIV").innerHTML=xmlHttp.responseText;
			  }
		}
function copyToClipboard(content) {
	if (window.clipboardData && window.clipboardData.setData) {
		window.clipboardData.setData("Text", content);
		return true;
	}
	else {
		try { 
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
		} 
		catch (e) { 
			return false;
		}
		
		var clipboard = Components.classes["@mozilla.org/widget/clipboard;1"].getService(); 
		if (clipboard) { 
			clipboard = clipboard.QueryInterface(Components.interfaces.nsIClipboard); 
		} 
		
		var transferable = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(); 
		if (transferable) { 
			transferable = transferable.QueryInterface(Components.interfaces.nsITransferable); 
		}
		
		if (clipboard && transferable) {
			var textObj = new Object(); 
			var textObj = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString); 
			if (textObj) { 
				textObj.data = content; 
				transferable.setTransferData("text/unicode", textObj, content.length*2); 
				var clipid=Components.interfaces.nsIClipboard; 
				clipboard.setData(transferable,null,clipid.kGlobalClipboard); 
				
				return true;
			} 
		}
		
		return false;
	}
}
		function cc(ccc) {
			ccc = ccc.replace("%20", " ");
			copyText();
			alert(ccc);
		}
// ***************************************************************************************************
function manipulateRecord_moroz(mode,id,param,dir,sorts)
		{
		if (mode == "delete"){
		if ( confirm("Are you sure you want to "+mode+" record ?") != 1 )
		{
			return false;
		}
		}

				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
// 				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents.php?id="+id+"&select="+designerz+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_moroz.php?id="+id+"&select="+sorts+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}
function saveRecord_moroz(mode,id,param,dir,sorts)
		{
			state = document.getElementById("txtstate").value;

				var myRandom=parseInt(Math.random()*99999999);  // cache buster
				xmlHttp=GetXmlHttpObject(handleHttpResponse);
				// xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_moroz.php?uid="+id+"&client="+client+"&select="+sorts+"&work="+work+"&designer="+designer+"&curator="+curator+"&start_work_date="+start_work_date+"&close_work_date="+close_work_date+"&state="+state+"&extra="+extra+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.open("GET","http://insight.dzherelo.org/include/getagents_moroz.php?uid="+id+"&select="+sorts+"&state="+state+"&mode="+mode+"&param=" + escape(param) + "&dir=" + dir + "&rand=" + myRandom, true);
				xmlHttp.send(null);
		}


