function ChangeSPO()
{

   // var mifrom=document.getElementById('mifrom').value;
   var mifrom = 0;
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById('lastspotabl').innerHTML = req.responseJS.newstext;
        }
    }
    req.open(null, 'includem/loadspolist.php', true);
    req.send( {'mifrom':mifrom} );
}
function RedrawTable1P()
{
	var Hotel4Sel = new Array();
	var ls_cod = document.getElementById('s_cod').value;

	var hotsubstr = document.getElementById('hotsubstr').value;

	//  список  отелей
	lfo = document.forms['poiskt'];
	var lstr='';
	var kolhot = 0;
	var kolchk = 0;

	var lfltbdate = document.getElementById('fltbdate').value;
	var lfltedate = document.getElementById('fltedate').value;

	if (!TestDate2(lfltbdate)) {
        // focus if validation fails
		document.getElementById('fltbdate').focus();
        document.getElementById('fltbdate').select();
		return;
    }
	if (!TestDate2(lfltedate)) {
        // focus if validation fails
		document.getElementById('fltedate').focus();
        document.getElementById('fltedate').select();
		return;
    }

	var lnightfrom 	= document.getElementById('nightfrom').value;
	var lnightto 	= document.getElementById('nightto').value;

	var ladults = document.getElementById('adults').value;
	var lchildren = document.getElementById('children').value;

	var larrivalfrom = document.getElementById('arrivalfrom').value;
	var loading = document.getElementById("searching");
	loading.style.display = "block";

    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
			loading.style.display = "none";
			//document.getElementById('brontour2').innerHTML = '';
            document.getElementById('Table1P').innerHTML = req.responseJS.newstext;
        }
    }


    req.open(null, 'includem/testfind1p.php', true);
    req.send( { 's_cod':ls_cod,
		'hotsubstr':hotsubstr,
		'fltbdate':lfltbdate,'fltedate': lfltedate,
		'nightfrom':lnightfrom, 'nightto':lnightto,
		'adults':ladults,
		'children':lchildren,
		'arrivalfrom':larrivalfrom
		} );
}


function loadcpbyvid(idc,idw,mifrom,prazdnik,idord,idvip) 
{
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById('wrk_bod'+idc+'_'+idw+'_'+idord).innerHTML = req.responseJS.newstext;
        }
    }
    req.open('POST', 'includem/loadcoubyvid.php', true);
    req.send( { "idc":idc, "idw":idw,"mifrom":mifrom,"prazdnik":prazdnik,"idord":idord,"idvip":idvip} );
}
function Hidecpbyvid(idc,idw,idord,idvip) {
     document.getElementById('wrk_bod'+idc+'_'+idw+'_'+idord).innerHTML =""
}

function RedrawCPCOST(isNY)
{

//alert(isNY);
	var s_cod=document.getElementById('s_codCSCP').value;

	//alert(s_cod);

	var worktype=document.getElementById('worktype').value;
	var arrivalfrom=document.getElementById('arrivalfrom').value;
	var flnewyear=document.getElementById('flnewyear').value;
	flnewyear = isNY;
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById('resultFL').innerHTML = req.responseJS.newstext;
        }
    }
//alert(arrivalfrom);	
	if (s_cod=='000') { req.open(null, 'includem/aj_cpcost.php', true);}
	else  {req.open(null, 'includem/aj_cpcostgrp.php', true);}
    req.send( {'s_cod':s_cod,'worktype':worktype,'arrivalfrom':arrivalfrom,'flnewyear':flnewyear} );
//alert(1);
}



function onLoadH(){
	tOut = window.setTimeout(onLoadHandler,200);
	//tOut = window.setTimeout(onLoadHandler,2000);
}

function onLoadHandler(){
Tooltip.init();
Typecast.Init();
var Ctrl;
if (Ctrl=document.getElementById("lastspotabl")) {ChangeSPO();}


/*if (document.getElementById('s_codCSCP')||0)
{
	alert("Yes");
	RedrawCPCOST();
}
else
{
	//alert("No");
}
*/
//RedrawCPCOST();
//var Ctrl;
if (Ctrl=document.getElementById("CostCenyPage")) {RedrawCPCOST(0);}
if (Ctrl=document.getElementById("CostNYPage")) {RedrawCPCOST(1);}
if (Ctrl=document.getElementById("Cost8MPage")) {RedrawCPCOST(2);}
if (Ctrl=document.getElementById("Cost1MPage")) {RedrawCPCOST(3);}

if (Ctrl=document.getElementById("CostSKIPage")) {RedrawCPCOST(4);}
if (Ctrl=document.getElementById("CostWTOSPage")) {RedrawCPCOST(5);}
if (Ctrl=document.getElementById("CostNYREPage")) {RedrawCPCOST(6);}
if (Ctrl=document.getElementById("CostVALPage")) {RedrawCPCOST(7);}

if (Ctrl=document.getElementById("CostCruPage")) {RedrawCPCOST(9);}
if (Ctrl=document.getElementById("CostEduPage")) {RedrawCPCOST(16);} 
if (Ctrl=document.getElementById("Table4Costs2"))
{
	RedrawMisto2();
//	tOut = window.setTimeout(onLoadHandler,300);
	RedrawHotel2(0);
//	tOut = window.setTimeout(onLoadHandler,500);
//	RedrawTable2();
}
if (Ctrl=document.getElementById("Table4Costs"))
{
	// Страница: Поиск тура
	RedrawMisto(0);
//	RedrawHotel2(0);
}



  /*Ctrl.style.display="none";*/

}
function setGlobalOnLoad(f) {
   var root = window.addEventListener || window.attachEvent ? window : document.addEventListener ? document : null
   if (root){
      if(root.addEventListener) root.addEventListener("load", f, false)
      else if(root.attachEvent) root.attachEvent("onload", f)
   } else {
      if(typeof window.onload == 'function') {
         var existing = window.onload
         window.onload = function() {
            existing()
            f()
         }
      } else {
         window.onload = f
      }
   }
}

function doKillCP() {
    JsHttpRequest.query(
		'includem/aj_killcp.php',
        {
			'zcp_id': document.getElementById('zcp_id').value
        },
        function(result, errors) {
            if (result) {
                document.getElementById("resultFL").innerHTML = result["newstext"];
            }
        },
        false
    );
	document.getElementById("resultFL").innerHTML = '';
}

function doLoadF() {
    JsHttpRequest.query(
		'includem/upl_backend.php',
        {
			'zcp_id': document.getElementById('zcp_id').value,
            'newname': document.getElementById("newname").value,
            'path2save': document.getElementById("path2save").value,
            'upl': document.getElementById("myupl")
        },
        function(result, errors) {
            if (result) {
                document.getElementById("resultFL").innerHTML = result["newstext"];
            }
        },
        false
    );
}

function doRename() {
    JsHttpRequest.query(
		'includem/aj_cprename.php',
        {
			'zcp_id': document.getElementById('zcp_id').value,
            'newname': document.getElementById("newname").value
        },
        function(result, errors) {
            if (result) {
                document.getElementById("resultFL").innerHTML = result["newstext"];
            }
        },
        false
    );
}
function doLoadP() {
    JsHttpRequest.query(
		'includem/upl_pbackend.php',
        {
			'name2catal': document.getElementById('name2catal').value,
            's_cod': document.getElementById("s_cod").value,
            'worktype': document.getElementById("worktype").value,
            'datlist': document.getElementById("datlist").value,
            'path2save': document.getElementById("path2save").value,
            'prazdnik': document.getElementById("prazdnik").value,
            'mistofrom': document.getElementById("mistofrom").value,
            'upl': document.getElementById("myupl")
        },
        function(result, errors) {
            if (result) {
                document.getElementById("resultPRAZD").innerHTML = result["newstext"];
            }
        },
        false
    );
}

function doLoadCnc() {
    JsHttpRequest.query(
		'includem/upl_cbackend.php',
        {
            's_cod': document.getElementById("s_cod").value,
            'hotelconcept': document.getElementById("hotelconcept").value,
            'path2doc': document.getElementById("path2doc").value,
            'path2save': document.getElementById("path2save").value,
            'upl': document.getElementById("myupl")
        },
        function(result, errors) {
            if (result) {
                document.getElementById("resultConcept").innerHTML = result["newstext"];
            }
        },
        false
    );
}

function RedrawMisto(zcp_id)
{
	var s_cod;
	if (s_cod=document.getElementById('s_cod').value) {a=1;}
	else {s_cod='000';}
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
			if (zcp_id==0) {document.getElementById('mistalist').innerHTML = req.responseJS.newstext;}
			else {document.getElementById('mistalist2').innerHTML = req.responseJS.newstext;}
		RedrawHotel(0,zcp_id);
        }
    }
    req.open(null, 'includem/loadmista.php', true);
    req.send( {'s_cod':s_cod,'zcp_id':zcp_id} );
	document.getElementById('hotellist').innerHTML = '';
}


function RedrawHotel(isOneHotel,zcp_id) 
{
	var Mista4Sel = new Array();
	ls_cod = document.getElementById('s_cod').value;
	lhotsubstr = document.getElementById('hotsubstr').value;
	lfo = document.forms['poiskt'];

	var lstr='';

	for (var i = 0; i <lfo.length; i++) {
          formitem = lfo[i];
		  switch(formitem.type) {
		  case 'checkbox' :

			if (isOneHotel == 0)
			{
				lname=formitem.id;
				if (lname.substr(0,5) == "misto" && lname.substr(0,9) !== "mistoplus")
				{
					if (formitem.checked) {
						nn = Mista4Sel.push(lname.substr(5));
						lstr = lstr + Mista4Sel[nn-1] + '('+lname.substr(0,5)+')';
					}
				}
				
			}
			else
			{
				if (formitem.checked) {
					lname=formitem.id;

					if (lname.substr(0,5) == "misto" && lname.substr(0,9) !== "mistoplus") {
						// nn = Mista4Sel.push(formitem.id);
						nn = Mista4Sel.push(lname.substr(5));
						lstr = lstr + Mista4Sel[nn-1] + '('+lname.substr(0,5)+')';
					}
				}
			}
			break;
		  }

    }
	
	
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById('hotellist').innerHTML = req.responseJS.newstext;
        }
    }
    req.open(null, 'includem/loadhotels.php', true);
    req.send( { 's_cod':ls_cod, 'hotsubstr':lhotsubstr,'zcp_id':0,'Mista4Sel': Mista4Sel } );
//	document.getElementById('hotellist2').innerHTML = '1111';
	

}

function RedrawMisto2()
{
	//var s_cod=document.getElementById('s_cod').value;
	var ls_cod = document.getElementById('s_cod').value;
	var zcp_id = document.getElementById('zcp_id').value;
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
			document.getElementById('mistalist2').innerHTML = req.responseJS.newstext;
			document.getElementById('hotellist2').innerHTML = '';
			//document.getElementById('hotelplus2').checked = checked;
			RedrawHotel2(0);
	}
    }
	if (document.getElementById('mistoplus2').checked) {lmistoplus2 = 1;} else {lmistoplus2 =0;}
    req.open(null, 'includem/loadmista.php', true);
    // req.send( {'s_cod':'000','mistoplus':lmistoplus2,'zcp_id':zcp_id} );
	req.send( {'s_cod':ls_cod,'mistoplus':lmistoplus2,'zcp_id':zcp_id} );
}
function RedrawHotel2(isOneHotel)
{
	var Mista4Sel = new Array();
	var zcp_id = document.getElementById('zcp_id').value;
	var s_cod = document.getElementById('s_cod').value;

	if (document.getElementById('mistoplus2').checked) {lmistoplus2 = 1;} else {lmistoplus2 =0;}
	if (document.getElementById('hotelplus2').checked) {lhotelplus2 = 1;} else {lhotelplus2 =0;}
	var lhotsubstr = document.getElementById('hotsubstr').value;

	lfo = document.forms['poiskt2'];
	//lfo = document.getElementById('poiskt');
	var lstr='';
	for (var i = 0; i <lfo.length; i++) {
          formitem = lfo[i];

		  switch(formitem.type) {
		  case 'checkbox' :

			if (isOneHotel == 0 && lmistoplus2 == 1)
			{
				lname=formitem.id;
//alert(lname);


				if (lname.substr(0,5) == "misto" && lname.substr(0,10) !== "mistoplus2")
				{
				//alert(lname.substr(5));
					nn = Mista4Sel.push(lname.substr(5));
					lstr = lstr + Mista4Sel[nn-1] + '('+lname.substr(0,5)+')';
				}
			}
			else if (isOneHotel == 0 && lmistoplus2 == 0)
			{
				lstr='';
			}
			else
			{
				if (formitem.checked) {
					lname=formitem.id;

					if (lname.substr(0,5) == "misto" && lname.substr(0,10) !== "mistoplus2") {
						// nn = Mista4Sel.push(formitem.id);

						nn = Mista4Sel.push(lname.substr(5));
						lstr = lstr + Mista4Sel[nn-1] + '('+lname.substr(0,5)+')';
					}
				}
			}
			break;
		  }

    }
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById('hotellist2').innerHTML = req.responseJS.newstext;
        }
    }
	//var s_cod='000';
    req.open(null, 'includem/loadhotels.php', true);
    req.send( { 's_cod':s_cod, 'hotelplus':lhotelplus2,'mistoplus':lmistoplus2,'hotsubstr':lhotsubstr,'zcp_id':zcp_id,'Mista4Sel':Mista4Sel} );
}

function RedrawTableOneCP()
{
	document.getElementById('roffset').value=1;
	RedrawTable2();
}
function OtherPageCP(inum)
{
	document.getElementById('roffset').value=inum;
	RedrawTable2();
}

function RedrawTable2()
{
	var Hotel4Sel = new Array();
	//var ls_cod = '000';
	//alert(1111);
	var ls_cod = document.getElementById('s_cod').value;

	var hotsubstr = document.getElementById('hotsubstr').value;
	var zcp_id = document.getElementById('zcp_id').value;
	if (document.getElementById('mistoplus2').checked) {lmistoplus2 = 1;} else {lmistoplus2 =0;}
	if (document.getElementById('hotelplus2').checked) {lhotelplus2 = 1;} else {lhotelplus2 =0;}

	//alert(zcp_id);

	//  список  отелей
	lfo = document.forms['poiskt2'];
	var lstr='';
	var kolhot = 0;
	var kolchk = 0;
	for (var i = 0; i <lfo.length; i++) {
          formitem = lfo[i];
		  switch(formitem.type) {
		  case 'checkbox' :
			{
				lname=formitem.id;
				if (lname.substr(0,5) == "hotel" && lname.substr(0,10) !== "hotelplus2") {
					kolhot = kolhot+1;
				}
				if (formitem.checked) {
					lname=formitem.id;
					if (lname.substr(0,5) == "hotel" && lname.substr(0,10) !== "hotelplus2") {
						kolchk = kolchk+1;
						nn = Hotel4Sel.push(formitem.id);
						//lstr = lstr + Hotel4Sel[nn-1] + '('+lname.substr(0,5)+')';
					}
				}
				break;
			}
		  }
    }





	 if  (kolchk==0) {
	// alert('Не задан ни один отель для поиска');
		return;
	 }

	lfltbdate = document.getElementById('fltbdate').value;
	lfltedate = document.getElementById('fltedate').value;

	if (!TestDate2(lfltbdate)) {
        // focus if validation fails
		document.getElementById('fltbdate').focus();
        document.getElementById('fltbdate').select();
		return;
    }
	if (!TestDate2(lfltedate)) {
        // focus if validation fails
		document.getElementById('fltedate').focus();
        document.getElementById('fltedate').select();
		return;
    }

	lnightfrom 	= document.getElementById('nightfrom').value;
	lnightto 	= document.getElementById('nightto').value;


	if (document.getElementById('pitplus').checked) {lpitplus = 1;} else {lpitplus =0;}
	if (document.getElementById('katplus').checked) {lkatplus = 1;} else {lkatplus =0;}
	lpit_code = document.getElementById('pit_code').value;
	lkat = document.getElementById('kat').value;

	ladults = document.getElementById('adults').value;
	lchildren = document.getElementById('children').value;

	ltcena1 = document.getElementById('tcena1').value;
	ltcena2 = document.getElementById('tcena2').value;

	var larrivalfrom = 0;
	var loading = document.getElementById("searching");
	loading.style.display = "block";

    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
			loading.style.display = "none";
            document.getElementById('Table4Costs2').innerHTML = req.responseJS.newstext;
        }
    }



	var roffset = document.getElementById('roffset').value;

    req.open(null, 'includem/testfindform.php', true);
    req.send( { 's_cod':ls_cod,
		'Hotel4Sel':Hotel4Sel,
		'fltbdate':lfltbdate,'fltedate': lfltedate,
		'nightfrom':lnightfrom, 'nightto':lnightto,
		'pitplus':lpitplus,
		'katplus':lkatplus,
		'pit_code':lpit_code,
		'kat':lkat,
		'adults':ladults,
		'children':lchildren,
		'tcena1':ltcena1,
		'tcena2':ltcena2,
		'arrivalfrom':larrivalfrom,'zcp_id':zcp_id,'roffset':roffset
		} );
	document.getElementById('Table4Costs2').innerHTML = '';


}

function otherzvkpage(inum)
{
	document.getElementById('zoffset').value=inum;
	doLoadFindZvk0();
}

function doLoadFindZvk0(inum,fdv,lrg,lbatch)
{
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
			document.getElementById('resultZVK').innerHTML = req.responseJS.newstext;
        }
    }

    req.open(null, 'includem/loadzvkfind1.php', true);
    req.send( {'findvar':fdv,'idzvk':0,'zbatch': lbatch,'zoffset': inum,'rg':lrg} );
	document.getElementById('resultZVK').innerHTML = '';
	
}

function doLoadFindZvk1()
{
	/* find by number */
	var currentforma = 'zvkfin1';
	lfo = document.forms[currentforma];
	for (var i = 0; i <lfo.length; i++) {
        formitem = lfo[i];
		lname=formitem.id;
		if (lname.substr(0,2) == "rg") { rg=formitem.value;}
		if (lname.substr(0,5) == "idzvk") { idzvk=formitem.value;}
		if (lname.substr(0,6) == "zbatch") { zbatch=formitem.value;}
		
    }
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
			document.getElementById('resultZVK').innerHTML = req.responseJS.newstext;
        }
    }

    req.open(null, 'includem/loadzvkfind1.php', true);
    req.send( {'findvar':1,'idzvk':idzvk,'zbatch': 10,'zoffset': 1,'rg': rg} );
	document.getElementById('resultZVK').innerHTML = '';
	
}

function OtherFindZvk3(loffset,lbatch)
{
	var currentforma = 'zvkfin3';
	lfo = document.forms[currentforma];
	for (var i = 0; i <lfo.length; i++) {
        formitem = lfo[i];
		lname=formitem.id;
		if (lname.substr(0,7) == "zoffset") { formitem.value=loffset;}
		if (lname.substr(0,6) == "zbatch") { formitem.value=lbatch;}
	}
	doLoadFindZvk3();
}

function doLoadFindZvk3()
{
	/* find by date tura */
	var currentforma = 'zvkfin3';
	lfo = document.forms[currentforma];
	for (var i = 0; i <lfo.length; i++) {
        formitem = lfo[i];
		lname=formitem.id;
		if (lname.substr(0,2) == "rg") { rg=formitem.value;}
		if (lname.substr(0,7) == "zoffset") { zoffset=formitem.value;}
		if (lname.substr(0,6) == "zbatch") { zbatch=formitem.value;}
		if (lname.substr(0,9) == "date_tura") { date_tura=formitem.value;}
	}

	if (!TestDate2(date_tura)) {
        // focus if validation fails
		document.getElementById('date_tura').focus();
        document.getElementById('date_tura').select();
		return;
    }

    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
			document.getElementById('resultZVK').innerHTML = req.responseJS.newstext;
        }
    }

    req.open(null, 'includem/loadzvkfind1.php', true);
    req.send( {'findvar':3,'idzvk':0,'zbatch': zbatch,'zoffset':zoffset,'rg': rg,'date_tura':date_tura} );
	document.getElementById('resultZVK').innerHTML = '';
	
}

function OtherFindZvk2(loffset,lbatch)
{
	var currentforma = 'zvkfin2';
	lfo = document.forms[currentforma];
	for (var i = 0; i <lfo.length; i++) {
        formitem = lfo[i];
		lname=formitem.id;
		if (lname.substr(0,7) == "zoffset") { formitem.value=loffset;}
		if (lname.substr(0,6) == "zbatch") { formitem.value=lbatch;}
	}
	doLoadFindZvk2();
}

function doLoadFindZvk2()
{
	/* find by date period */
	var currentforma = 'zvkfin2';
	lfo = document.forms[currentforma];
	for (var i = 0; i <lfo.length; i++) {
        formitem = lfo[i];
		lname=formitem.id;
		if (lname.substr(0,2) == "rg") { rg=formitem.value;}
		if (lname.substr(0,7) == "zoffset") { zoffset=formitem.value;}
		if (lname.substr(0,6) == "zbatch") { zbatch=formitem.value;}
		if (lname.substr(0,6) == "date_s") { date_s=formitem.value;}
		if (lname.substr(0,7) == "date_po") { date_po=formitem.value;}
	}
	
	if (!TestDate2(date_po)) {
		document.getElementById('date_po').focus();
        document.getElementById('date_po').select();
		return;
    }
	if (!TestDate2(date_s)) {
		document.getElementById('date_s').focus();
        document.getElementById('date_s').select();
		return;
    }

    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
			document.getElementById('resultZVK').innerHTML = req.responseJS.newstext;
        }
    }

    req.open(null, 'includem/loadzvkfind1.php', true);
    req.send( {'findvar':2,'idzvk':0,'date_s':date_s,'date_po': date_po,'zbatch': zbatch,'zoffset':zoffset,'rg': rg} );
	document.getElementById('resultZVK').innerHTML = '';
}

function Statist()
{
	var currentforma = 'zvkstat1';
	var godd=2009;
	lfo = document.forms[currentforma];
	for (var i = 0; i <lfo.length; i++) {
        formitem = lfo[i];
		lname=formitem.id;
		if (lname.substr(0,8) == "god4stat") { godd = formitem.value }
	}
	
	doLoadStat(godd);
}

function doLoadStat(god)
{
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
			document.getElementById('resultStat').innerHTML = req.responseJS.newstext;
        }
    }
//alert(god);	
    req.open(null, 'includem/loadstat.php', true);
    req.send( {'god':god} );
	document.getElementById('resultStat').innerHTML = '';
}


function OtherFindZvk4(loffset,lbatch)
{
	var currentforma = 'zvkfin4';
	lfo = document.forms[currentforma];
	for (var i = 0; i <lfo.length; i++) {
        formitem = lfo[i];
		lname=formitem.id;
		if (lname.substr(0,7) == "zoffset") { formitem.value=loffset;}
		if (lname.substr(0,6) == "zbatch") { formitem.value=lbatch;}
	}
	doLoadFindZvk4();
}

function doLoadFindZvk4()
{
	/* find by date period */
	var currentforma = 'zvkfin4';
	lfo = document.forms[currentforma];
	for (var i = 0; i <lfo.length; i++) {
        formitem = lfo[i];
		lname=formitem.id;
		if (lname.substr(0,2) == "rg") { rg=formitem.value;}
		if (lname.substr(0,7) == "zoffset") { zoffset=formitem.value;}
		if (lname.substr(0,6) == "zbatch") { zbatch=formitem.value;}
		if (lname.substr(0,9) == "firma4zvk") { firma4zvk=formitem.value;}
	}
	
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
			document.getElementById('resultZVK').innerHTML = req.responseJS.newstext;
        }
    }

    req.open(null, 'includem/loadzvkfind1.php', true);
    req.send( {'findvar':4,'firma4zvk':firma4zvk,'zbatch': zbatch,'zoffset':zoffset,'rg': rg} );
	document.getElementById('resultZVK').innerHTML = '';
}


function ZminaCommenta()
{
	var formafio = 'zvkprim';
	var divfio = 'divzvkprim';

	var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById(divfio).innerHTML = req.responseJS.newstext;
        }
    }

	var idzvk=document.getElementById('idzvk').value;
	var agcomment=document.getElementById('agcomment').value;

    req.open(null, 'includem/ZminaCommentaZvk.php', true);
    req.send( { 'idzvk':idzvk,'agcomment':agcomment } );
}

function Annuliren()
{
	var formafio = 'zvktitle';
	var divfio = 'divzvktitle';

	var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById(divfio).innerHTML = req.responseJS.newstext;
        }
    }

	var idzvk=document.getElementById('idzvk').value;

    req.open(null, 'includem/AnnulirenZvk.php', true);
    req.send( { 'idzvk':idzvk } );
	//document.getElementById(divfio).innerHTML = '';

	}

function ZamenaFio(NomerFormy)
{

	var formafio = 'fio';
	var divfio = 'divfio';

	var idzvk=document.getElementById('idzvk').value;


	lfo = document.forms[formafio];
	for (var i = 0; i <lfo.length; i++) {
        formitem = lfo[i];
		lname=formitem.id;
		//alert(lname);
		if (lname.substr(0,5) == "famr"+NomerFormy) { famr=formitem.value;}
		if (lname.substr(0,5) == "imar"+NomerFormy) { imar=formitem.value;}
		if (lname.substr(0,5) == "otch"+NomerFormy) { otch=formitem.value;}
		if (lname.substr(0,5) == "faml"+NomerFormy) { faml=formitem.value;}
		if (lname.substr(0,5) == "imal"+NomerFormy) { imal=formitem.value;}
		if (lname.substr(0,6) == "pas_s"+NomerFormy) { pas_s=formitem.value;}
		if (lname.substr(0,6) == "pas_n"+NomerFormy) { pas_n=formitem.value;}
		if (lname.substr(0,7) == "date_r"+NomerFormy) { date_r=formitem.value;}
		if (lname.substr(0,8) == "date_to"+NomerFormy) { date_to=formitem.value;}
    }

	if (!TestDate2(date_r)) {
		return;
    }
	if (!TestDate2(date_to)) {
		return;
    }
    var idmen=document.getElementById('idmen'+NomerFormy).value;
	var idzvk=document.getElementById('idzvk').value;

	var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById(divfio).innerHTML = req.responseJS.newstext;
        }
    }

    req.open(null, 'includem/changefio.php', true);
    req.send( { 'idzvk':idzvk,
    'idmen':idmen,
    'famr':famr,
    'imar':imar,
    'otch':otch,
    'faml':faml,
    'imal':imal,
    'pas_s':pas_s,
    'pas_n':pas_n,
    'date_r':date_r,
    'date_to':date_to
     } );
	document.getElementById(divfio).innerHTML = '';


}




function Redraw3ByCou()
{
	ls_cod=document.getElementById('s_cod').value;
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById('cpsamlist').innerHTML = req.responseJS.newstext;
        }
    }
    req.open(null, 'includem/cplist2bycou.php', true);
    req.send( {'s_cod':ls_cod} );
}

function RedrawAirList(isNY)
{
	var formafio = 'AirPage';
	var divfio = 'divfio';
	var s_cod=document.getElementById('tis_cod').value;
	var zr_cod=document.getElementById('tireisy').value;
	
	lfo = document.forms[formafio];
	for (var i = 0; i <lfo.length; i++) {
        formitem = lfo[i];
		lname=formitem.id;
		if (lname.substr(0,8) == "tir_date") { r_date=formitem.value;}
    }
	if (!TestDate2(r_date)) {
		return;
    }
	
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById('ListAirPage').innerHTML = req.responseJS.newstext;
        }
    }
    req.open(null, 'includem/aj_airlist.php', true);
    req.send( {'s_cod':s_cod,'zr_cod':zr_cod,'r_date':r_date} );
//alert(1);
}