
var name_wid1 ='1';
var name_wid2 ='2';
var name_wid3 ='3';
var sadd=" ";
var d = document;

function GEByID1(id) { return d.all ? d.all[id] : d.getElementById(id); }

function GEByID(id) {
if (document.getElementById(id)) {
	return document.getElementById(id);
	} else if (document.all[id]) {
		return document.all[id];
		} else if (document.layers && document.layers[id]) {
			return (document.layers[id]);
			} else {
				return false;
			}
}

function load_form(name_div,name_form,surl) 
{
	elementdiv= GEByID(name_div);
	//elementdiv.innerHTML =_cmsload;
    
	var squery = surl;
	if (squery.substr(0, 1)=='?') squery='index.php'+squery;

	//alert (name_div+' '+name_form+' '+squery);

         JsHttpRequest.caching = false;
           JsHttpRequest.query(
            squery, // backend
            {
                // pass a text value
		'___':'____',

                '_____form' : GEByID(name_form)
            },
            // Function is called when an answer arrives.
            function(result, errors) {
                // Write errors to the debug div.
               // GEByID("debug").innerHTML = errors;
                // Write the answer.
                if (result) {
                    GEByID(name_div).innerHTML =result["md5"];
                }
            },
            false  // do not disable caching
        );
 }

//<!-- /* Sample Script to execute when user click over the photo link */ -->

	function updatepicture(	code, name, lastname ){
		alert ("SAMPLE SCRIPT\n\nHere must go a process to update the picture or something else for:\n\nRecord ID:"+code+
				"\nName: "+ name +
				"\nLast name: "+ lastname );
	}



function obj_visibility(id, flag)  {

if (GEByID(id)) {
	GEByID(id).style.visibility = (flag) ? 'visible' : 'hidden';
	}
}

function obj_visibiltrig(id)  {
obj=GEByID(id);
if (obj) {
 if(obj.style.display=='none')
   {
   obj.style.display='block';
   //image.src='img/minus.gif'
   }
   else
   {
   obj.style.display='none';

   //image.src='img/plus.gif'
   }

	}
}

function obj_visidiv(id,id2,id3)  {
// показать скрыть объект id
// при показе показать в центральном регионе объект id2
// при скрытии показать в центральном регионе объект id3
// tckb id3=0 очистить центрральный регион

obj=GEByID(id);
if (obj) {
 if(obj.style.display=='none')
   {
   obj.style.display='block';
   //image.src='img/minus.gif'
    load_inf0('?oper=lock_2&kod='+id2+'&fp=1');
window.location.hash="center_region";

   }
   else
   {
   obj.style.display='none';
if (id3==0){
  load_inf0('?oper=lockzero');
}else{
   load_inf0('?oper=lock_2&kod='+id3+'&fp=1');
}
   //image.src='img/plus.gif'
   }

	}
}

function obj_search()
{
	form = GEByID("search");
	
	//alert ('searchwww:'+form.str_search.value);
	
	load_div('center_region','index.php?oper=search&kod=1&_d=1&fp=3&str_search='+form.str_search.value);
	
}
function obj_search_jear()
{
	form = GEByID("search");
	
	//alert ('searchwww:'+form.str_search.value);
	
	load_div('center_region','index.php?oper=search_jear&kod=1&_d=1&fp=3&fromjear='+form.fromjear.value+'&tojear='+form.tojear.value);
	
}

function load_infn(descrind,region,kod)
{
//нельзя форма в форме
	//alert    ("load_inf"+ descrind+kod) ;
	load_div(region,descrind);

}


function list_gros(kod_onj)
{
	// "показать подробное описание" 
//alert(kod_onj);
	url_text="index.php?oper=list_gros&fp=2&kod="+kod_onj+'&_d=0&fp=2';
	var myWin=window.open(url_text, 'dispgros'+kod_onj,'location=0,width=700,height=800,toolbar=0,resizable=1,directories=0,status=0,menubar=0,scrollbars=1');

} 

function listgrosslast(kod_onj,work)
{
// показать подробности пред брата
s='index.php?oper=listgrosslast&kod='+kod_onj+'&_d=1&fp=3&work='+work;
//alert (s);
load_div('center_region',s);
}

function listgrossnext(kod_onj,work)
{
// показать подробности след брата
s='index.php?oper=listgrossnext&kod='+kod_onj+'&_d=1&fp=3&work='+work;
//alert (s);
load_div('center_region',s);
}
// Загрузка данных
function load_list_obj(razdel,num_page,num_page1,region)
{
	
	// alert('load_list_obj('+razdel+' '+num_page+')');
	load_div( region, 'index.php?oper=load_list_obj&_d=1&fp=3&kod='+razdel+'&num_page='+num_page+'&num_page1='+num_page1+'&region='+region);
	
}
function load_towl(razdel,num_page,num_page1,region)
{
	//alert('load_towl('+razdel+' '+num_page+')');
	load_div(region,'index.php?oper=load_towl&_d=1&fp=3&kod='+razdel+'&num_page='+num_page+'&num_page1='+num_page1+'&region='+region);
	
}

function lockinwin0(displayWindow,url_text,width,height)
{
	//alert ('lockinwin0'+url_text);
	
	var myWin=window.open(url_text+'&_d=0&fp=2',displayWindow,'location=0,width='+width+',height='+height+',toolbar=0,resizable=1,directories=0,status=0,menubar=0,scrollbars=1');
}




function load_tow(razdel,num_page,num_page1)
{
	//   alert('load_tow('+razdel+', '+num_page+', '+num_page1+')');
	
	load_div('center_region','index.php?oper=load_towl&_d=1&fp=3&kod='+razdel+'&num_page='+num_page+'&num_page1='+num_page1);
}


function detal_towar(razdel)
{
	//   alert('detal_towar('+razdel+')');
	
	//   lockinwin('Подробное описание','index.php?oper=detal_towar&kod='+razdel,'Wind'+razdel,sadd);
	
}
//====


function load_fwr(name_file,p_wait)
{
	//alert( 'load_f(name_file) {'+name_file);
	load_div('center_region','index.php?oper=list_html_write&_d=1&kod='+name_file);
}



function load_f0(name_file,region,p_wait)
{
	
	
	load_div(region,'index.php?oper=list_html&_d=1&kod='+name_file);
}


function load_inf(descrind,p_wind)
{
	//alert    ("load_inf"+ descrind) ;
	load_div('center_region','index.php?oper='+descrind+'&_d=1&fp=3');
}



function doload_sity(ntree)
{
	
	// Получаем текст запроса из <input>-поля.
	//alert ('doload_sity(ntree)');
	
	var query = '' +  'index.php?idRecord=' + ntree+'&_d=1';
	load_div('select_sity',query);
	
}

function lockinwin1(titlwindow,url_text,type)
{
	//alert (url_text);
	//type=1 короткий 0 полный путь
	var myWin=window.open(url_text,'displayWindow','width=600,height=400,toolbar=0,resizable=1,directories=0,status=0,menubar=0,scrollbars=1');
}

function load_inf0w(url_text,type,titlwindow,namedisplayWindow)
{
	//alert ("load_inf0w!! "+url_text+namedisplayWindow);
	var myWin=window.open('index.php'+url_text+'&_d=0&fp=2' , namedisplayWindow,'width=600,height=400,toolbar=0,resizable=1,directories=0,status=0,menubar=0,scrollbars=1, location=0');
	//  lockinwin(titlwindow,'index.php'+url_text ,namedisplayWindow,'');
	
}  

function load_infwr(titlwindow,name_file,namedisplayWindow)
{
	lockinwin(titlwindow, 'index.php?oper=list_html&kod='+name_file+'&_d=1', namedisplayWindow,'');
}
function ftest()
{
	
	//load_inf0w("?oper=lock_1&kod=907",0,0,'titlwindow','namedisplayWindow');
	load_inf0w("?oper=sum_cart",0,0,'titlwindow','namedisplayWindow');
	
}
function load_url(url,name_file,p_wait)
{
	//alert( 'load_url(name_file) '+url+name_file);
	
	load_div('center_region','index.php?oper=list_url&_d=1&fp=3&url='+url+'&kod='+name_file);
}
function load_f(name_file,p_wait)
{
	//alert( 'load_f(name_file) {'+name_file);
	load_div('center_region','index.php?oper=list_html&_d=1&fp=3&kod='+name_file);
}

function load_inf0(descrind)
{
	  //alert    ("load_inf0:  "+'index.php'+ descrind+'&_d=1&fp=1') ;  
	load_div('center_region','index.php' + descrind)+'&_d=1&fp=1';
}

function   load0fw(url_text,titlwindow,namedisplayWindow)
{
	//alert ("load0fw:"+url_text);
	var myWin=window.open(url_text, namedisplayWindow,'width=600,height=400,toolbar=0,resizable=1,directories=0,status=0,menubar=0,scrollbars=1');
	return; 
	myWin.document.open();
	
	// генерировать новый документ 
	myWin.document.write("<html><head>");
	myWin.document.write("<title>",titlwindow,"</title></head><body>");
	myWin.document.write("<script language=\"JavaScript\"  src=\""+phpscr+"js.js\"> </script>");  
	
	myWin.document.write("</body></html>");
	
	// закрыть документ - (но не окно!)
	myWin.document.close();  
	
}


function load_urlw(url_text,kod,titlwindow,namedisplayWindow)
{
	lockinwin(titlwindow,"index.php?oper=list_url&url="+url_text+"&kod="+kod,namedisplayWindow,'');
}

function   load_fw(url_text,type,titlload,titlwindow,namedisplayWindow)
{
	//alert ("load_fw:url_text="+url_text+":namedisplayWindow="+namedisplayWindow);
	lockinwin(titlwindow,"index.php?oper=list_html&kod="+url_text,namedisplayWindow,'');
	
}       


function show_imig(path_imig,type,titl,namewindow,_width,_height)
{
	
	 //alert ("show_imig "+path_imig);

if (_width>0){

	myWin= open("", namewindow, 
	"width="+_width+",height="+_height+",status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes");
}else{
	myWin= open("", namewindow, "status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes");

}

	// открыть объект document для последующей печати 
	// namewindow,
	//_width ширина окна
	//_height высота окна
	//titl,path_imig
	myWin.document.open();
	
	// генерировать новый документ 
	myWin.document.write("<html><head>");
	myWin.document.write("<title>",titl,"</title></head><body>");
myWin.document.write("<p>",titl,"</p>");



if (_width>0){
	myWin.document.write("<img src='",path_imig,"'",' width="',_width,'" height="',_height,'"/>');
}else{
	//myWin.document.write("<img src='",path_imig,"'",' width="100%" height="100%"/>');
	myWin.document.write("<img src='",path_imig,"'/>");
}
	
	myWin.document.write("</body></html>");
	
	// закрыть документ - (но не окно!)
	myWin.document.close();  
}


function show_imig_inwind(path_htmlbeg,path_imig,type,titlload,titl,namewindow,_width,_height)
{
	

	myWin= open("", namewindow, 
	"width="+_width+",height="+_height+",status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes");
	// открыть объект document для последующей печати 
	// namewindow,
	//_width ширина окна
	//_height высота окна
	//titl,path_imig
	myWin.document.open();	
	// генерировать новый документ 
	myWin.document.write("<iframe src="+path_htmlbeg+ " frameborder=0 vspace=0 hspace=0 width=800 height=150  marginwidth=0  marginheight=0 scrolling=no></iframe>"); 
	
	myWin.document.write("<img src='",path_imig,"'",'/>');
	
	myWin.document.write("</body></html>");
	
	// закрыть документ - (но не окно!)
	myWin.document.close();  
}

function show_html_wr(path_html,titl,namewindow,_width,_height)
{
	//alert ("show_html_wr");
	_width=850;
	_height=600;
	myWin= open("", namewindow, 
	"width="+_width+",height="+_height+",status=no,toolbar=yes,menubar=no,scrollbars=yes,resizable=yes");
	// открыть объект document для последующей печати 
	// namewindow,
	//_width ширина окна
	//_height высота окна
	//titl
	myWin.document.open();
	
	// генерировать новый документ 
	myWin.document.write("<html><head>");
	myWin.document.write("<META http-equiv=Content-Type content='text/html; charset=windows-1251'>");
	myWin.document.write("<title>",titl,"</title></head><body>");
	
	myWin.document.write("<iframe src="+path_html+ " frameborder=0 vspace=0 hspace=0 width=800 height=600  marginwidth=0  marginheight=0 scrolling=no></iframe>"); 
	myWin.document.write("</body></html>");
	
	// закрыть документ - (но не окно!)
	myWin.document.close();  
}
function lockinwin(titlwindow,url,namedisplayWindow,sadd)
{
	//alert ("lockinwin(titlwindow,url,namedisplayWindow,sadd");
	var myWin=window.open("",namedisplayWindow,'width=600,height=400,toolbar=0,resizable=1,directories=0,status=0,menubar=0,scrollbars=1');
	
	// открыть объект document для последующей печати 
	myWin.document.open();
	
	// генерировать новый документ 
	myWin.document.write("<html><head><title>"+titlwindow+"</title>");
	myWin.document.write(sadd);
	
	myWin.document.write("</head><body>");
	
	myWin.document.write("<div id='wind'> Загрузка данных....  </div>");
	
	
	myWin.document.write("</body></html>");
	
	// закрыть документ - (но не окно!)
	myWin.document.close();   
	name_div= 'wind';
	
	
	var query = '' +  url;
	// Создаем новый объект JSHttpRequest.
	var req = new JsHttpRequest();
	// Код, АВТОМАТИЧЕСКИ вызываемый при окончании загрузки.
	req.onreadystatechange = function()
	{
		if (req.readyState == 4) 
		{
			// Записываем в <div> результат работы. 
			if ( req.responseJS)
			{       myWin.document.getElementById(name_div).innerHTML = req.responseJS.md5 ;
			}else{
				alert (req.responseText);
			}
			
			// Отладочная информация.
			//  document.getElementById('debug').innerHTML = 
			//  req.responseText;
		}
	}
	// Разрешаем кэширование (чтобы при одинаковых запросах
	// не обращаться к серверу несколько раз).
	req.caching = false;
	// Подготваливаем объект.
	req.open('GET', query, true);
	// Посылаем данные запроса (задаются в виде хэша).
	req.send({ q: query });
	
	myWin.document.getElementById(name_div).value = new Date().getTime();
	
	myWin.focus();
}  


function expand_div(item,url)
{
	load_div('expand_div' + item,url);
	window.location.hash="label_"+item;
	
}

function expandIt_doclst(item,namediv)
{
	if (document.getElementById(namediv).innerHTML.length==0)
	{load_div(namediv,'index.php?oper=list_obj1&kod=' + item);
	document.getElementById(namediv).style.display='block' ;
	}else{
		document.getElementById(namediv).innerHTML="";
		document.getElementById(namediv).style.display='none'
	}
	
	window.location.hash="label_"+item;
}


function expandIt_doc(item,namediv)
{
obj=GEByID(namediv)

	if(obj.style.display=='none')
	{load_div(namediv,'index.php?oper=list_obj1&kod=' + item);
	   obj.style.display='block';
	}else{
	obj.style.display='none';
	}
	
	window.location.hash="label_"+item;
}



function expandIt_menu(url_text,namediv)
{
	load_div(namediv,'index.php'+url_text);
	
}


function expandIt_new(item,namediv)
{
	load_div(namediv,'index.php?oper=list_page&kod=' + item);
	window.location.hash="label_"+item;
	
}





function load_div(name_div,url) 
{

// Получаем текст запроса из url и отображаем в div c id=name_div.
	elementdiv= GEByID(name_div);
	elementdiv.innerHTML =_cmsload;
	var query = url;
	if (query.substr(0, 1)=='?') query='index.php'+query;
	//alert (query+':'+name_div);

	// Создаем новый объект JSHttpRequest.
	var req = new JsHttpRequest();
	// Код, АВТОМАТИЧЕСКИ вызываемый при окончании загрузки.
	req.onreadystatechange = function() 
	{
		if (req.readyState == 4) 
		{
			// Записываем в <div> результат работы. 
			
			//        elementdiv.innerHTML =      req.responseJS.md5 ;
			if ( req.responseJS)
			{       elementdiv.innerHTML = 
				req.responseJS.md5 ;
			}else{
				alert (req.responseText);
			}
			
			
			// Отладочная информация.
			document.getElementById('debug').innerHTML =  req.responseText;
			
		}
	}
	// Разрешаем кэширование (чтобы при одинаковых запросах
	// не обращаться к серверу несколько раз).
	req.caching = p_cache;
	// Подготавливаем объект.
	req.open('GET', query, true);
	// Посылаем данные запроса (задаются в виде хэша).
	req.send({ q: query });
	//    document.getElementById(name_div).value = new Date().getTime();
	elementdiv.value = new Date().getTime();
 window.location.hash=name_div;	

}



function doLoad_form_todiv(name_div,name_form,url) {
	elementdiv= GEByID(name_div);
	elementdiv.innerHTML =_cmsload;
	var query = url;
	if (query.substr(0, 1)=='?') query='index.php'+query;


    // Create new JsHttpRequest object.
    var req = new JsHttpRequest();
    // Code automatically called on load finishing.
req.loader = 'FORM';

    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            // Write result to page element (_RESULT become responseJS). 
			if ( req.responseJS)
			{       elementdiv.innerHTML = 
				req.responseJS.md5 ;
			}else{
				alert (req.responseText);
			}
            // Write debug information too (output become responseText).
            //document.getElementById('debug').innerHTML = req.responseText;

        }
    }
    // Prepare request object (automatically choose GET or POST).
    req.open(null, query, true);
    // Send data to backend.
    req.send( { q: query } );
   
 window.location.hash=name_div;	

}

//загрузка на сервер файлов
function doLoad(value,upl_backend_php) {
    // Create new JsHttpRequest object.
    var req = new JsHttpRequest();
    // Code automatically called on load finishing.
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            // Write result to page element (_RESULT becomes responseJS). 
            document.getElementById('result').innerHTML = 
                '<b>MD5("'+req.responseJS.q+'")</b> = ' +
                '"' + req.responseJS.md5 + '"<br> ';
            // Write debug information too (output becomes responseText).
            document.getElementById('debug').innerHTML = req.responseText;
        }
    }
    // Prepare request object (automatically choose GET or POST).
    req.open(null, upl_backend_php, true);
    // Send data to backend.
    req.send( { q: value } );
}

function Load_div_form2(name_div,url,idform) {
    // Create new JsHttpRequest object.
//    value=GEByID(nameform);
    var query = url;
	if (query.substr(0, 1)=='?') query='index.php'+query;
	
    value=GEByID(nameform)
    value=idform;
    elementdiv= GEByID(name_div);
    var req = new JsHttpRequest();
    // Code automatically called on load finishing.
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            // Write result to page element (_RESULT become responseJS). 
            elementdiv.innerHTML = 
                'MD5('+req.responseJS.q+') = ' +
                '"' + req.responseJS.md5 + '"<br> ';
            // Write debug information too (output become responseText).
           // document.getElementById('debug').innerHTML = req.responseText;
        }
    }
    // Prepare request object (automatically choose GET or POST).
    //req.open(null, query, true);
    // Send data to backend.
    //req.send( { q: value } );
    req.open('POST', query, true);
    req.send( { q: value } );
    
}
//Load_div_form('center_region','?oper=user_add&fp=1&_d=1','user_add_site');
function Load_div_form( name_div, url, name_form) {
    var value= GEByID(name_form);

    var query=url;
    if (query.substr(0, 1)=='?') query='index.php'+query; 
    
    var req = new JsHttpRequest();

    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById(name_div).innerHTML = req.responseText; 
         // Сообщение о подгружаемых данных
         } else {
        if (req.readyState == 3 || req.readyState == 1) {
         //document.getElementById(name_div).innerHTML = '<div id="loading"  style="display: block; text-align: center; font-family: Verdana; text-decoration: overline underline; font-size: large; border: 1px solid #BBBBBB; background: #D3D3D3; width: 150;  margin-left: 20%; margin-top: 10%"><font color="red">...LOADING...</font><br /></div>';
              document.getElementById(name_div).innerHTML = ' ...';
        }
        // Конец сообщения о подгружаемых данных
        }
    }
     req.open(null, query, true);
  //req.open('POST', query, true);
    req.send( { q: value } );
}

function setDateField(obj) 
{
	var d = obj.value + "";
	var original = d;

	if (d == '01.01.2050') 
	{
		d = '';
	}
	d = showModalDialog(phpscr+"calendar.htm",d,"status:no;center:yes;help:no;minimize:no;maximize:no;border:thin;statusbar:no;scroll:no;dialogWidth:170px;dialogHeight:220px;");
	if (d && d != '')
	{
		if (d == 'null')
		d = '';
		if (d == 'eternity')
		d = '01.01.2050';
		obj.value = d;
	}
	if (original != obj.value && obj['onchange'])
	{
		obj.onchange();
	}
	return original != obj.value;
}


function isNumberString_m (InString) {
//alert('isNumberString '+InString);
if(InString.length==0) return (false);
var RefString="1234567890";
for (Count=0; Count < InString.length; Count++) {
        TempChar= InString.substring (Count, Count+1);
        if (RefString.indexOf (TempChar, 0)==-1)
        return (false);
}
return (true);
}


function decode_utf8(utftext) {
             var plaintext = ""; var i=0; var c=c1=c2=0;
             // while-Schleife, weil einige Zeichen uebersprungen werden
             while(i<utftext.length)
                 {
                 c = utftext.charCodeAt(i);
                 if (c<128) {
                     plaintext += String.fromCharCode(c);
                     i++;}
                 else if((c>191) && (c<224)) {
                     c2 = utftext.charCodeAt(i+1);
                     plaintext += String.fromCharCode(((c&31)<<6) | (c2&63));
                     i+=2;}
                 else {
                     c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2);
                    plaintext += String.fromCharCode(((c&15)<<12) | ((c2&63)<<6) | (c3&63));
                     i+=3;}
                 }
             return plaintext;
         }


/**
*
*  UTF-8 data encode / decode
*  http://www.webtoolkit.info/
*
**/

var Utf8 = {

    // public method for url encoding
    encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // public method for url decoding
    decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }

}

//=================
function setCookie(name, value, expires, path, domain, secure)
{
        var newCookie = name+"="+escape(value)+
        ((expires)      ? ";expires="   + expires.toGMTString() :"") +
        ((path)         ? ";path="+ path:"") +
        ((domain)       ? ";domain=" + domain:"") +
        ((secure)       ? ";secure"                                                             :"");
        document.cookie=newCookie;
}

function getCookie(name)
{
        var prefix = name+"=";
        var start  = document.cookie.indexOf(prefix);
        if (-1==start)
                return '';
        var end = document.cookie.indexOf(";", start+prefix.length);
        if (-1==end)
                end = document.cookie.length;
        var value = document.cookie.substring(start+prefix.length, end);
        return unescape(value);
}

function delCookie(name, path, domain)
 {
  if (getCookie(name))
  {
  document.cookie = name + "=" + 
  ((path) ? "; path=" + path : "") +
  ((domain) ? "; domain=" + domain : "") +
  "; expires=Thu, 01-Jan-70 00:00:01 GMT"
  }
 }

//Передача данных из основного во всплывающее-popup окно через POST
//  http://www.codelab.ru/task/data2popup/#realizations

	function Form2Popup(params, actionUrl, name, popupConfig, get) { 
	        // free in choice: post or get
	        var method = (get == undefined || !get) ? 'POST' : 'GET'; 
	 
	        // it's important to assign non-null name!
	        if (name == undefined || name == '') { 
	                name = 'tmpPopup'; 
	        } 
	        var form = document.createElement('<form action="' + actionUrl + '" method="' + method + '" target="' + name + '" style="display:none;"></form>'); 
	        var element = null; 
	        for (var propName in params) { 
                element = document.createElement('<input type="text" name="' + propName + '" value="' + params[propName] + '">'); 
	                form.appendChild(element); 
	        } 
	        document.body.appendChild(form);
	 
	        // First, open empty window: why make redundant request to server?
	        var win = window.open('about:blank', name, popupConfig); 
	 
	        // in order to restore this window
	        // if it's already been opened before
	        win.focus(); 
	        form.submit();
	        form.removeNode(true); 
	        return win; 
	}
	 
/*
	// Example:
	var _name = document.getElementById("nameDiv");
	var _text = forms['myform'].messageTextarea.value;
	var params = {name:_name,title:"user preview",txt:_text};
	 
	var previewPopup = Form2Popup(params, 'save.jsp?preview=1', 'preview', 'top=100,left=100,scrollbars=1');

*/

// http://www.webproger.ru
function toPost(getString) 
{
 var parms = getString.split('?'); 
 var newF = document.createElement("form"); 
 newF.action = parms[0]; 
 newF.method = 'POST'; 
 newF.enctype="multipart/form-data" ; //ww
 
var parms = parms[1].split('&'); 
 for (var i=0; i<parms.length; i++) 
 {
  var pos = parms[i].indexOf('='); 
  if (pos > 0) 
  {
   var key = parms[i].substring(0,pos); 
   var val = parms[i].substring(pos+1); 
   /*@cc_on @if (@_jscript)  
   var newH = document.createElement("<input name='"+key+"'>");  
   @else */  
   var newH = document.createElement("input"); 
   newH.name = key; /* @end @*/ 
   newH.type = 'hidden'; 
   newH.value = val; 
   newF.appendChild(newH);
  }
 } 
 document.getElementsByTagName('body')[0].appendChild(newF); 
 newF.submit();
}

//Еще бывают такие задачи когда нам нужно из поля input взять значение и передать по ссылке в другую форму, 
//для такого случая мы немного модифицировали функцию:

function toPostform(getString) 
{
 var parms = getString.split('?'); 
 var newF = document.createElement("form"); 
 newF.enctype="multipart/form-data" ; //ww
 newF.action = parms[0]; 
 newF.method = 'POST'; 
 var newH = document.createElement("input"); 
 newH.name = 'fullname';
 newH.type = 'hidden'; 
 newH.value = 'Харис Пупкин'; //можем расширить возможности и брать значение с поля input, например document.getElementById('id').value 
 newF.appendChild(newH);
 document.getElementsByTagName('body')[0].appendChild(newF); 
 newF.submit();
}
