function openWindow(filename, w, h, winname)
{
    var nWidth;
    var nHeigth;
    if (h) nHeigth = h; else nHeigth = 500;
    if (w) nWidth = w; else nWidth = 700;
    if (!winname) winname = "_blank";
    var desktop = window.open(filename, winname,
    "width="+nWidth+",height="+nHeigth+",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
};

function mousePageXY(e)
{
    if (!e) e = window.event;
    if (e.pageX || e.pageY)
    {
      mouse_x = e.pageX;
      mouse_y = e.pageY;
    }
    else if (e.clientX || e.clientY)
    {
      mouse_x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
      mouse_y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
    }

}
document.onmousemove = function(e){var mCur =mousePageXY(e);}

function go_search(page)
{
		 words=document.getElementById('search_words').value;
		 otrasl=document.getElementById('search_otrasl').value;
		 country=document.getElementById('search_country').value;
		 spros=document.getElementById('search_spros').checked;
		 predl=document.getElementById('search_predl').checked;
		 if(!spros && !predl)
		 {
		   alert('Необходимо выбрать объекты поиска (спрос или предложения)');
		   return
		 }
 		 if(spros==false) spros='';
 		 if(predl==false) predl=''; 		 	
		 loadDoc('/go_search.php?predl='+predl+'&spros='+spros+'&words='+words+'&otrasl='+otrasl+'&country='+country+'&page='+page, 'main_text');
		 
}

function go_search_next(page)
{
	if(typeof(region)=='undefined') region='';
	if(typeof(subotr)=='undefined') subotr='';
	if(typeof(predl)=='undefined') predl='';
	if(typeof(spros)=='undefined') spros='';
	if(typeof(words)=='undefined') words='';
	if(typeof(otrasl)=='undefined') otrasl='';
	if(typeof(subotr)=='undefined') subotr='';
	if(typeof(country)=='undefined') country='';
	if(typeof(city)=='undefined') city='';
	//alert('/go_search.php?region='+region+'&city='+city+'&predl='+predl+'&spros='+spros+'&words='+words+'&otrasl='+otrasl+'&country='+country+'&subotr='+subotr);
	loadDoc('/go_search.php?region='+region+'&city='+city+'&predl='+predl+'&spros='+spros+'&words='+words+'&otrasl='+otrasl+'&country='+country+'&subotr='+subotr+'&page='+page, 'main_text');
}

function go_extend()
{
		 words=document.getElementById('esearch_words').value;
		 otrasl=document.getElementById('esearch_otrasl').value;
		 country=document.getElementById('esearch_country').value;
		 spros=document.getElementById('esearch_spros').checked;
		 predl=document.getElementById('esearch_predl').checked;
		 if(document.getElementById('region')) region=document.getElementById('region').value;
     if(document.getElementById('subotr')) subotr=document.getElementById('subotr').value;		 
		 city=document.getElementById('esearch_city').value;
		 
		 if(!spros && !predl)
		 {
		   alert('Необходимо выбрать объекты поиска (спрос или предложения)');
		   return
		 }		 
 		 if(spros==false) spros='';
 		 if(predl==false) predl='';
 		 if(typeof(region)=='undefined') region='';
 		 if(typeof(subotr)=='undefined') subotr='';
		 //alert ('/go_search.php?region='+region+'&city='+city+'&predl='+predl+'&spros='+spros+'&words='+words+'&otrasl='+otrasl+'&country='+country+'&subotr='+subotr);
		 loadDoc('/go_search.php?region='+region+'&city='+city+'&predl='+predl+'&spros='+spros+'&words='+words+'&otrasl='+otrasl+'&country='+country+'&subotr='+subotr, 'main_text');
}

function check_any_on()
{
	  if( !(document.getElementById('search_spros').checked || document.getElementById('search_predl').checked || document.getElementById('search_archive').checked) )  	
  		document.getElementById('search_spros').checked=true;
  	
}