

function ShowSearch(target_file, target_id)
  {
    LoadFromURLin('/'+target_file+'.php', target_id);
  }


function  reload_region(id) 
  {	
    LoadFromURL('/select_region.php?mode=add&country_id='+id,'regions');
  }



function restore_password(mail){
	//alert(mail);
	document.getElementById('alert').innerHTML='Логин и пароль высланы вам на email';
	LoadFromURL('/restore_password.php?mail='+mail,'alert');
}

function  reload_region_simple(id) 
  {	
    LoadFromURL('/select_region.php?mode=add&simle=1&country_id='+id,'regions');
  }


function  reload_region2(id,width,part,category_id) 
  {	
  	if (id=='0' || id=='all')  document.getElementById('regions').innerHTML=''; 
  	else
      {
      
      	if (width!='') { LoadFromURL('/select_region.php?country_id='+id+'&width='+width+'&part='+part+'&category_id='+category_id,'regions');  }
      	else {  LoadFromURL('/select_region.php?country_id='+id,'regions');  }
      }	
}

function trim(string)
{
return string.replace(/(^\s+)|(\s+$)/g, "");
}

function  reload_region3(id,selected,width,part,category_id) 
  {	
  	if (id=='0')  document.getElementById('regions').innerHTML=''; 
  	else
  	{
       if (width!='') { LoadFromURL('/select_region.php?country_id='+id+'&selected='+selected+'&width='+width+'&part='+part+'&category_id='+category_id,'regions');  }
      else { LoadFromURL('/select_region.php?country_id='+id+'&selected='+selected,'regions'); }
    }
}

function  reload_catalog(id) 
  {	
  	if (id=='all' || id=='info' || id=='forum' || id=='marketplace') { 
  	  document.getElementById('category_id').innerHTML=''; 
  	  document.getElementById('country_id').style.display='none'; 
  	  document.getElementById('country_id').selectedIndex=0; 
  	  document.getElementById('regions').innerHTML=''; 
  	  document.getElementById('otrasl').style.display='none'; 
  	  document.getElementById('region').style.display='none'; 
  	   
 }
  	else {
  	  LoadFromURL('/select_catalog.php?razdel='+id,'category_id');
  	  document.getElementById('country_id').style.display=''; 
  	   document.getElementById('otrasl').style.display='';
  	   document.getElementById('region').style.display=''; 
  	  }
}

function  reload_catalog2(id,selected) 
  {	
  
  		if (id=='all' || id=='info' || id=='forum' ) { 
  	  document.getElementById('category_id').innerHTML=''; 
  	  document.getElementById('country_id').style.display='none'; 
  	  document.getElementById('regions').innerHTML=''; 
 }
  	else {
  	  LoadFromURL('/select_catalog.php?razdel='+id+'&catalog_id='+selected,'category_id');
  	  document.getElementById('country_id').style.display=''; 
  	  }
}


function  dlclick(dl,reg) {
 	//alert(dl);	
 	document.getElementById(dl).style.display='none';
    document.getElementById(reg).style.display='';
    return false;
}


function catalog_region(patch){
	
    
    //alert(patch);
    //alert(region_id);
    
   if (document.getElementById('region_2')) {
   	 var region_id=document.getElementById("region_2").options[document.getElementById("region_2").selectedIndex].getAttribute('region_id');	
	
   	 if (document.getElementById('region_2').value=='' || document.getElementById('region_2').value=='0') 
   	    location = '/catalog/'+patch;
   	 else
   	   {
   	   	 if (!region_id)
   	   	  region_id=document.getElementById("region_1").options[document.getElementById("region_1").selectedIndex].getAttribute('region_id');	
	
   	   	 location = '/catalog/'+patch+region_id+'/';
   	   }
        
        //'/region_'+document.getElementById('region_2').value;
    
        return;
    }
     
   if (document.getElementById('region_1')){
   	var region_id=document.getElementById("region_1").options[document.getElementById("region_1").selectedIndex].getAttribute('region_id');	
	
   	 if (document.getElementById('region_1').value=='' || document.getElementById('region_1').value=='0') 
   	    location = '/catalog/'+patch;
   	 else   
       location = '/catalog/'+patch+region_id+'/'; 
   	 //location = '/catalog/'+patch+'/region_'+document.getElementById('region_1').value;    
   	 
 } 
}



function tovar_region(patch){
	
		   if (document.getElementById('region_2')) {
   	 var region_id=document.getElementById("region_2").options[document.getElementById("region_2").selectedIndex].getAttribute('region_id');	
	
   	 if (document.getElementById('region_2').value=='' || document.getElementById('region_2').value=='0') 
   	    location = '/tovar/'+patch;
   	 else
   	   {
   	   	 if (!region_id)
   	   	  region_id=document.getElementById("region_1").options[document.getElementById("region_1").selectedIndex].getAttribute('region_id');	
	
   	   	 location = '/tovar/'+patch+region_id+'/';
   	   }
        return;
    }
     
   if (document.getElementById('region_1')){
   	var region_id=document.getElementById("region_1").options[document.getElementById("region_1").selectedIndex].getAttribute('region_id');	
	
   	 if (document.getElementById('region_1').value=='' || document.getElementById('region_1').value=='0') 
   	    location = '/tovar/'+patch;
   	 else   
       location = '/tovar/'+patch+region_id+'/'; 
   }
       

}


function load_image_m(url,id,dir,m_id){
	   var all = document.all ? document.all :
   document.getElementsByTagName('img');
   var elements = new Array();
   for (var e = 0; e < all.length; e++){
    if (all[e].className == "img-selected"){
      if (navigator.appName=="Microsoft Internet Explorer")  all[e].className="img-non-selected"; 
      else    all[e].setAttribute("class", "img-non-selected"); 
      }  
    }
    
    if (navigator.appName=="Microsoft Internet Explorer")  document.getElementById('img'+id).className="img-selected"; 
      else     document.getElementById('img'+id).setAttribute("class", "img-selected"); 
        
     document.getElementById('tovar_image'+m_id).style.width = '325px';
     document.getElementById('tovar_image'+m_id).style.height = '235px';
     document.getElementById('tovar_image'+m_id).src = 'http://glavagro.ru/'+dir+'/'+url;
     return false;
}

function load_image_e(url,id,dir,orig_image_url){
	
   
   var all = document.all ? document.all :
   document.getElementsByTagName('img');
   var elements = new Array();
   for (var e = 0; e < all.length; e++){
    if (all[e].className == "img-selected"){
      if (navigator.appName=="Microsoft Internet Explorer")  all[e].className="img-non-selected"; 
      else    all[e].setAttribute("class", "img-non-selected"); 
      }  
    }
    
    if (navigator.appName=="Microsoft Internet Explorer")  document.getElementById('img'+id).className="img-selected"; 
      else     document.getElementById('img'+id).setAttribute("class", "img-selected"); 
        
     document.getElementById('tovar_image').style.width = '325px';
     document.getElementById('tovar_image').style.height = '235px';
     document.getElementById('tovar_image').src = 'http://glavagro.ru/'+dir+'/'+url;
     if (document.getElementById('img'+id).alt)     
      	document.getElementById('img_alt').style.padding="0 0 5px 0";
     else 
      document.getElementById('img_alt').style.padding="0px";
     document.getElementById('img_alt').innerHTML = document.getElementById('img'+id).alt; 
     
    // alert(orig_image_url);
      if (document.getElementById('orig_href') )
      {
      	
      	if (orig_image_url!='' && orig_image_url!='undefined')
      	  {
      	  	//alert(orig_image_url);
      	  	document.getElementById('orig_href').href='http://glavagro.ru/'+dir+'/'+orig_image_url;
      	  }
      	else  document.getElementById('orig_href').href='http://glavagro.ru/'+dir+'/'+url;
      }
      
     return false;
}


function load_prices (id)
	{
		document.getElementById('prices_link_'+id).style.display='none'; 
		document.getElementById('prices_indicator_'+id).style.display=''; 
		LoadFromURL('/prices.php?id='+id,'prices_'+id);
	}

function close_prices (today_table_id,title)
	{
		document.getElementById('prices_'+today_table_id).innerHTML="<h5 id='prices_indicator_"+today_table_id+"' style='display:none;'>Загрузка</h5><a style='border-bottom:1px  dashed blue;cursor:pointer;' id='prices_link_"+today_table_id+"' onclick='load_prices("+today_table_id+");return false;' >"+title+"</a> "; 
		//alert(today_table_id+' '+title);	
		//close_prices
		//	
			 	
	}

function  show_block(id) {
 	//alert(dl);	
 	document.getElementById('subcatalog'+id).style.display='';
    document.getElementById('subcatalog_link'+id).style.display='none';
    return false;
}

function show_intro(){
	document.getElementById('full-intro-link').style.display='none';
    if (navigator.appName=="Microsoft Internet Explorer")
     {document.getElementById('full-intro').className = "full-intro-open";}
    else 
      document.getElementById('full-intro').setAttribute("class", "full-intro-open");
}

// обьявления
function select_nav()
{
	var location_url = document.getElementById('category_select').value;
	
	 if (document.getElementById('region_2')) {
   	 if (document.getElementById('region_2').value=='' || document.getElementById('region_2').value=='0') 
   	    location = location_url;
   	 else
        location = location_url+'region_'+document.getElementById('region_2').value;
    
        return;
    }
     
   if (document.getElementById('region_1')){
   	 if (document.getElementById('region_1').value=='' || document.getElementById('region_1').value=='0') 
   	    location = location_url
   	 else   
        location = location_url+'region_'+document.getElementById('region_1').value;    } 
 
}




function checkform2(contactform)
{




  if( (contactform.c_city.value == null) || (contactform.c_city.value.length < 1) ) 
  {  
    alert('Заполните поле: Город');
    contactform.c_city.focus();
    return false; 
  }
 
    if( (contactform.c_fio.value == null) || (contactform.c_fio.value.length < 1) ) 
  {  
    alert('Заполните поле: Фио');
    contactform.c_fio.focus();
    return false; 
  }    
 /*
   if( (contactform.c_company.value == null) || (contactform.c_company.value.length < 1) ) 
  {  
    alert('Заполните поле: Компания');
    contactform.c_company.focus();
    return false; 
  } 

  if( (contactform.c_post.value == null) || (contactform.c_post.value.length < 1) ) 
  {  
    alert('Заполните поле: Должность');
    contactform.c_post.focus();
    return false; 
  } 
*/

  if( (contactform.c_phones.value == null) || (contactform.c_phones.value.length < 1) ) 
  {  
    alert('Заполните поле: Контактные телефоны');
    contactform.c_phones.focus();
    return false; 
  } 
  


  if( (contactform.c_email.value == null) || (contactform.c_email.value.length < 1) ) 
  {  
    alert('Заполните поле: E-mail');
    contactform.c_email.focus();
    return false; 
  }  
  if( (contactform.c_body.value == null) || (contactform.c_body.value.length < 1) ) 
  {  
    alert('Заполните поле: Сообщение');
    contactform.c_body.focus();
    return false; 
  }  
 
  if( (contactform.captch_a.value == null) || (contactform.captch_a.value.length < 1) ) 
  {  
    alert('Введите текст с картинки');
    contactform.captch_a.focus();
    return false; 
  }    
    	
  document.forms['contact'].submit();     
  return true;
} 




function UnHide( eThis ){
        if( eThis.innerHTML=='+' ){  //.charCodeAt(0) == 9658
            eThis.innerHTML = '--'  //&#9660;
            eThis.parentNode.parentNode.parentNode.className = '';
        }else{
            eThis.innerHTML = '+'
            eThis.parentNode.parentNode.parentNode.className = 'cl';
        }
        return false;
    }
    
    /*
function load_child(id) {
 if (document.getElementById('menu_'+id).className == "razdel-opened"){
 	  
 	if (navigator.appName=="Microsoft Internet Explorer"){
		document.getElementById('menu_'+id).className = "razdel-closed";}
	 else { document.getElementById('menu_'+id).setAttribute("class", "razdel-closed"); }
	 document.getElementById('submenu_'+id).innerHTML='';
 	}
 	else {

	 LoadFromURL('/select_catalog_child.php?id='+id,'submenu_'+id);
	
	 if (navigator.appName=="Microsoft Internet Explorer"){
		document.getElementById('menu_'+id).className = "razdel-opened";}
	 else { document.getElementById('menu_'+id).setAttribute("class", "razdel-opened"); }
     }
     
	return false;
}    
    */
function load_child(id,marketplace) {
 if (document.getElementById('menu_'+id).className == "razdel-opened"){
 	  
 	if (navigator.appName=="Microsoft Internet Explorer"){
		document.getElementById('menu_'+id).className = "razdel-closed";}
	 else { document.getElementById('menu_'+id).setAttribute("class", "razdel-closed"); }
	 document.getElementById('submenu_'+id).innerHTML='';
 	}
 	else {

if (marketplace=='yes')
	 LoadFromURL('/select_catalog_child.php?id='+id+'&marketplace=1','submenu_'+id);
else
 	LoadFromURL('/select_catalog_child.php?id='+id,'submenu_'+id);	 
	
	 if (navigator.appName=="Microsoft Internet Explorer"){
		document.getElementById('menu_'+id).className = "razdel-opened";}
	 else { document.getElementById('menu_'+id).setAttribute("class", "razdel-opened"); }
     }
     
	return false;
}   

    
function add_photo(eThis,photo_div){
	eThis.style.display='none';
	document.getElementById(photo_div).style.display='';
	return false;
}    
    

function load_advertisement(id,user_id) {
 	
   if (navigator.appName=="Microsoft Internet Explorer")
      {		
		document.getElementById('info'+id).className = "";
		document.getElementById('adv'+id).className = "enterpruce-ul-active";
		document.getElementById('tovar'+id).className = "";	
		document.getElementById('news'+id).className = "";			
	  }
   else 
      { 
      	document.getElementById('info'+id).setAttribute("class", ""); 
      	document.getElementById('adv'+id).setAttribute("class", "enterpruce-ul-active");
      	document.getElementById('tovar'+id).setAttribute("class", "");  
      	document.getElementById('news'+id).setAttribute("class", "");
      }
   document.getElementById('info_'+id).innerHTML='<h5 class="load">Загрузка</h5>';
   LoadFromURL('/load_enterprise_info.php?type=advertisement&id='+id+'&user_id='+user_id,'info_'+id);
}

function load_tovar(id,user_id){
	
	if (navigator.appName=="Microsoft Internet Explorer")
      {
		document.getElementById('info'+id).className = "";
		document.getElementById('adv'+id).className = "";
		document.getElementById('tovar'+id).className = "enterpruce-ul-active";		
		document.getElementById('news'+id).className = "";	
	  }
   else 
      { 
      	document.getElementById('info'+id).setAttribute("class", ""); 
      	document.getElementById('adv'+id).setAttribute("class", "");
      	document.getElementById('tovar'+id).setAttribute("class", "enterpruce-ul-active");  
      	document.getElementById('news'+id).setAttribute("class", "");
      }
	 document.getElementById('info_'+id).innerHTML='<h5 class="load">Загрузка</h5>';
	 LoadFromURL('/load_enterprise_info.php?type=tovar&id='+id+'&user_id='+user_id,'info_'+id);
}




function load_info(id,user_id){
	if (navigator.appName=="Microsoft Internet Explorer")
      {
		document.getElementById('info'+id).className = "enterpruce-ul-active";
		document.getElementById('adv'+id).className = "";
		document.getElementById('tovar'+id).className = "";	
		document.getElementById('news'+id).className = "";	
	  }
   else 
      { 
      	document.getElementById('info'+id).setAttribute("class", "enterpruce-ul-active"); 
      	document.getElementById('adv'+id).setAttribute("class", "");
      	document.getElementById('tovar'+id).setAttribute("class", ""); 
      	document.getElementById('news'+id).setAttribute("class", ""); 
      }
	 document.getElementById('info_'+id).innerHTML='<h5 class="load">Загрузка</h5>';
	 
	 LoadFromURL('/load_enterprise_info.php?type=info&id='+id+'&user_id='+user_id,'info_'+id);
	 //
}


function load_news(id,user_id){
	if (navigator.appName=="Microsoft Internet Explorer")
      {
		document.getElementById('info'+id).className = "";
		document.getElementById('adv'+id).className = "";
		document.getElementById('tovar'+id).className = "";	
		document.getElementById('news'+id).className = "enterpruce-ul-active";	
	  }
   else 
      { 
      	document.getElementById('info'+id).setAttribute("class", ""); 
      	document.getElementById('adv'+id).setAttribute("class", "");
      	document.getElementById('tovar'+id).setAttribute("class", ""); 
      	document.getElementById('news'+id).setAttribute("class", "enterpruce-ul-active"); 
      }
	 document.getElementById('info_'+id).innerHTML='<h5 class="load">Загрузка</h5>';
	 
	 LoadFromURL('/load_enterprise_info.php?type=news&id='+id+'&user_id='+user_id,'info_'+id);
	 //
}


function check_category(id){
	var check = document.getElementById('category_'+id); 
	
	if (check.checked==false)
	  { //check.setAttribute("checked",0); 
	    document.getElementById('category_link_'+id).style.background='#52b717';   
	    document.getElementById('category_link_'+id).style.color='white'; 
	   //alert('');
    }
	else { //check.setAttribute("checked",1); 
	       //check.setAttribute("checked",1);
	       document.getElementById('category_link_'+id).style.background='white';  
	      // document.getElementById('category_'+id).
	      document.getElementById('category_link_'+id).style.color='#333333'; 
       }
}

function select_category(id){
	var check = document.getElementById('category_'+id); 
	
	if (check.checked==false)
	  { //check.setAttribute("checked",0); 
	    document.getElementById('category_link_'+id).style.backgroundColor='#ff6500';   
	    document.getElementById('category_link_'+id).style.color='white'; 
	    document.getElementById('category_link_'+id).style.borderColor='white';
	   //alert('');
    }
	else { //check.setAttribute("checked",1); 
	       //check.setAttribute("checked",1);
	       document.getElementById('category_link_'+id).style.background='white';  
	      // document.getElementById('category_'+id).
	      document.getElementById('category_link_'+id).style.color='#333333'; 
	      document.getElementById('category_link_'+id).style.borderColor='#333333';
       }
       return false;
}


function select_category_r(id){
	
	 var c = new Array();
	 c = document.getElementsByTagName('label');
	 //alert(c.length);
	 for (var i = 0; i < c.length; i++)
	 {// if (c[i].type == 'radio')
	  // {
	   	//alert();
        c[i].style.background='white'; 
        c[i].style.color='#333333'; 
        c[i].style.borderColor='#333333'; 
     //  }
     }
	   //field[i].checked = true ;
	
	var check = document.getElementById('category_'+id); 
	//if (check.checked==false)
	//  { //check.setAttribute("checked",0); 
	    document.getElementById('category_link_'+id).style.backgroundColor='#ff6500';   
	    document.getElementById('category_link_'+id).style.color='white'; 
	    document.getElementById('category_link_'+id).style.borderColor='white';
	   //alert('');
   // }
	/*
    else { //check.setAttribute("checked",1); 
	       //check.setAttribute("checked",1);
	       document.getElementById('category_link_'+id).style.background='white';  
	      // document.getElementById('category_'+id).
	      document.getElementById('category_link_'+id).style.color='#666666'; 
	      document.getElementById('category_link_'+id).style.borderColor='#666666';
       } */
       return false;
}


var ua = navigator.userAgent.toLowerCase();
var isOpera = (ua.indexOf('opera')  > -1);
var isIE = (!isOpera && ua.indexOf('msie') > -1);
 
function getDocumentHeight() {
  return Math.max(document.compatMode != 'CSS1Compat' ? document.body.scrollHeight : document.documentElement.scrollHeight, getViewportHeight());
}
 
function getViewportHeight() {
  return ((document.compatMode || isIE) && !isOpera) ? (document.compatMode == 'CSS1Compat') ? document.documentElement.clientHeight : document.body.clientHeight : (document.parentWindow || document.defaultView).innerHeight;
}


function show_login_form(type){
	if (type=='leftmenu') {
		document.getElementById('light').style.left='50%';
	}
	else {
		document.getElementById('light').style.left='80%';
	}	//login description.focus();

	document.getElementById('light').style.display='block';
	document.getElementById('fade').style.height=getDocumentHeight()+'px';
	document.getElementById('fade').style.display='block';
	document.getElementById('login').focus();
}

function show_message_form3(id){
	if (id!=0) {	
		document.getElementById('today_type_id').value=id;
	}
	document.getElementById('email_form22').style.left='50%';
	document.getElementById('email_form22').style.display='block';
	
	if (document.documentElement.clientHeight<parseInt(document.getElementById('email_form22').offsetHeight+70))
		{
			document.getElementById('email_form22').style.position='absolute';
			document.getElementById('contact_fio').focus();
		}
	document.getElementById('fade').style.height=getDocumentHeight()+'px';
	document.getElementById('fade').style.display='block';
	//document.getElementById('email_form').style.top  =50+'px';
}

function show_message_form(id){
	if (id!=0) {	
		document.getElementById('ent_id').value=id;
	}
	document.getElementById('email_form').style.left='50%';
	document.getElementById('email_form').style.display='block';
	
	if (document.documentElement.clientHeight<parseInt(document.getElementById('email_form').offsetHeight+70))
	
		{
			document.getElementById('email_form').style.position='absolute';
			document.getElementById('contact_company').focus();
		}
		
	document.getElementById('fade').style.height=getDocumentHeight()+'px';
	document.getElementById('fade').style.display='block';
	//document.getElementById('email_form').style.top  =50+'px';
}

function show_message_form2(id,today_type_id){
	if (id!=0) {	
		document.getElementById('today_id').value=id;
		document.getElementById('today_type_id').value=today_type_id;
	}
	
	document.getElementById('email_form2').style.left='50%';
	document.getElementById('email_form2').style.display='block';
	if (document.documentElement.clientHeight<parseInt(document.getElementById('email_form2').offsetHeight+70))
		{
			document.getElementById('email_form2').style.position='absolute';
			document.getElementById('contact_org').focus();
		}
	document.getElementById('fade').style.height=getDocumentHeight()+'px';
	document.getElementById('fade').style.display='block';
	//document.getElementById('email_form').style.top  =50+'px';
}

function logout_user(){
	document.forms['logout'].submit();
}

 function GetFucknIeCoords(_obj) {
     var _top=0;
     var _left=0;
     var _parent=_obj;
         _top+=_parent.offsetTop;
         _top+=_parent.clientTop;
         _left+=_parent.offsetLeft;
         _left+=_parent.clientLeft;
     do {
         _parent=_parent.offsetParent;
         _top+=_parent.offsetTop;
         _top+=_parent.clientTop;
         _left+=_parent.offsetLeft;
         _left+=_parent.clientLeft;
     } while (_parent!==document.body);
     return [_top-document.body.scrollTop, _left-document.body.scrollLeft];
  }
  
  
// тултип при добавлении
function show_add_tip(obj) {
	
	document.getElementById('add_tool_tip').style.left=obj.offsetLeft-14+'px';
	document.getElementById('add_tool_tip').style.top= obj.offsetTop-100+'px';
	document.getElementById('add_tool_tip').style.display='';
    
	 // ie >:[
    if (navigator.appName=="Microsoft Internet Explorer") 
    	{
    		var IECoords  = GetFucknIeCoords(obj);
    		var IETop  = IECoords[0];
    		var IELeft = IECoords[1];
    		document.getElementById('add_tool_tip').style.left = IELeft-14+'px';
    		document.getElementById('add_tool_tip').style.top  = IETop-100+'px';
	  }
	  return false;
}

// тултип при добавлении
function show_currency_tip(obj) {
/*	alert(obj.offsetLeft);
	document.getElementById('currency_tool_tip').style.left=obj.offsetLeft+'px'; //14
	document.getElementById('currency_tool_tip').style.top= obj.offsetTop+'px'; //100
	document.getElementById('currency_tool_tip').style.display='';
    
	 // ie >:[
    if (navigator.appName=="Microsoft Internet Explorer") 
    	{*/
    		var IECoords  = GetFucknIeCoords(obj);
    		var IETop  = IECoords[0];
    		var IELeft = IECoords[1];
    		document.getElementById('currency_tool_tip').style.left = IELeft-140+'px';
    		document.getElementById('currency_tool_tip').style.top  = IETop-120+'px';
	//  }
	document.getElementById('currency_tool_tip').style.display='';
	  return false;
}

function close_add_tip(Elementid) {
	document.getElementById(Elementid).style.display='none';
}



function submit_delete(type,id) {
	var type_str;
	if (type=='enterpise') type_str='предприятие';
	if (type=='marketplace') type_str='товар';
	if (type=='tovar') type_str='товар';
	
if (confirm ('Вы действительно хотите удалить '+type_str+'?')) {
	document.getElementById('delete_type').value=type;
	document.getElementById('delete_id').value=id;
	document.forms['delete_frm'].submit();
   }
   //{document.getElementById("delete_id").value=GlobID; document.getElementById("ActDelete").submit();} else {}
}
//alert(document.body.scrollHeight);

function show_new_cat_frm()
	{
	document.getElementById('new_catalog_category').style.left='50%';
	document.getElementById('new_catalog_category').style.display='block';
	document.getElementById('fade').style.height=getDocumentHeight()+'px';
	document.getElementById('fade').style.display='block';
	}

function insert_new_cat()
	{	
		var new_cat_title = trim(document.getElementById('title_new_cat_name').value);
		var new_cat_desc  = trim(document.getElementById('new_cat_desc2').value);
		new_cat_title=new_cat_title.replace('"', " ");
		new_cat_title=new_cat_title.replace("'", ' ');

		new_cat_desc=new_cat_desc.replace('"', " ");
		new_cat_desc=new_cat_desc.replace("'", ' ');
		
		if (new_cat_desc!='' && new_cat_title!='')
			{
				
				document.getElementById('new_cat_name').value=new_cat_title;
				document.getElementById('new_cat_desc').value=new_cat_desc;
				document.getElementById('new_title').innerHTML=new_cat_title;
				document.getElementById('new_desc').innerHTML=new_cat_desc.replace('\n', "<br/> ");;
				document.getElementById('new_catalog_category').style.display='none';
				document.getElementById('fade').style.display='none';
				document.getElementById('new_category_tip').style.display='none'; 
				document.getElementById('new_cat_div').style.display=''; 
			}
		

	}
function check_frm_today(){

	if(document.getElementById('today_contact_email').value=='' || document.getElementById('today_contact_email').value==null) 
	{  
	 
     document.getElementById('submit_today').disabled=true;
     document.getElementById('submit_today').style.color='#666465';
     
    } 
    else {
     document.getElementById('submit_today').disabled=false;
     document.getElementById('submit_today').style.color='#333333';
 }

}	

function setCookie(isName,isValue,daysExpire){
		expDate = new Date();
	if(daysExpire){		expDate.setTime(expDate.getTime()+(86400000*daysExpire)); }
	else{expDate.setTime(expDate.getTime()+24*60*60*1000*365);}
	        document.cookie = isName+"="+escape(isValue)+";expires="+expDate.toGMTString()+"; path=/";
	}
	
function popup_region_redirect (patch,region_id,type){
	
	//alert(type);	
	setCookie
	//alert(patchregion_id+' '+type);
	
 var url=patch;
 
 if (region_id>0) 
 		setCookie('region',region_id,1);	
 else 
    	setCookie('region','all',1);

  //  alert(region_id);
 if (region_id!=0) 
 	url+=region_id;
 if (type=='1') url+='?spros';
 location=url;
// alert(url);
//popup_region_redirect(document.getElementById('popup_catalog_patch').value,document.getElementById('popup_region_id').value,document.getElementById('popup_catalog_type').value)	
}


 
function select_popup_region(obj,text){
	//alert(id+'='+text);
	//alert(document.getElementById('catalog_id').value);
	//if (id==1 || id==2)
	//reload_region_popup(catalog_id,region_id,id,return_div)
	var region_id=obj.options[document.getElementById("popup_region_id").selectedIndex].getAttribute('region_id');
	
	//alert('region_id');
	if ((region_id==1 || region_id==2) && text!='Любой регион')
	  {
	  	
	  	document.getElementById('popup_country_title').innerHTML=text;
		var catalog_id=document.getElementById('popup_catalog_id').value;
		reload_region_popup(catalog_id,region_id,0,'load_select_div');
		document.getElementById('popup_change_country_link').style.display='';
		
	  }	
	
}

function reload_region_popup(catalog_id,region_id,id,return_div){
	
	
//alert(catalog_id);  
	 LoadFromURL('/load_region.php?catalog_id='+catalog_id+'&region_id='+region_id,return_div);	
	
	 /* 
	var element = document.getElementById('popup_region_id');
	alert(element);
	var options = element.onclick instanceof Function ? element.onclick() : {};
	element.onclick = null;
	element.removeAttribute('onclick');
	
	alert(options['title_0']);
	element.onclick = function () {
    //showPopup(options);
    //alert('bbbbb');
	};
	*/
}

function show_select_region_form(catalog_id,patch,type){
	
	//if (type=='1')
	
	
	document.getElementById('fade').style.height=getDocumentHeight()+'px';
	document.getElementById('fade').style.display='block';
	
	
	 document.getElementById('popup_catalog_patch').value=patch;
	 document.getElementById('popup_catalog_type').value=type;
	
	//if (id!=0) {	
	//	document.getElementById('today_type_id').value=id;
	//}
	document.getElementById('region_form').style.left='50%';
	document.getElementById('region_form').style.display='block';

	if (document.documentElement.clientHeight<700)
		{
			document.getElementById('region_form').style.position='absolute';
			//document.getElementById('contact_fio').focus();
		}
	//*/	
	
	
	
	document.getElementById('popup_country_title').innerHTML='';
	document.getElementById('popup_catalog_id').value=catalog_id;
	//document.getElementById('email_form').style.top  =50+'px';
	document.getElementById('popup_change_country_link').style.display='none';
	reload_region_popup(catalog_id,0,0,'load_select_div');
}

function enable_price(obj) {
	if (obj.value=='5')
		{
			document.getElementById('price').disabled=true;
			document.getElementById('price').style.display='none';		
			document.getElementById('cnt_title').style.display='none';		
		}
	 
	else
		{
	 		document.getElementById('price').disabled=false;
	 		document.getElementById('price').style.display='';	
	 		document.getElementById('cnt_title').style.display='';
	 	}	 
}	

function strpos (haystack, needle, offset) {
    var i = (haystack+'').indexOf(needle, (offset ? offset : 0));
    return i === -1 ? false : i;
}
/* проверка на налиие в описаниии товара запятых, если есть то показываем алерт*/
function checkMarketplaceInput(text)	{
	
	//&& strpos (trim(text), ',', 0)>text.length
	if (strpos (text, ',', 0) )
		{
			var trimmed_text=trim(text);
			var text_length=trimmed_text.length-1;
			//alert(parseInt(strpos(trimmed_text, ',', 0))+' '+parseInt(text_length));
			if ( strpos(trimmed_text, ',', 0)< parseInt(text_length) )
			document.getElementById("red-alert").style.cssText="margin-top:-"+document.getElementById("red-alert").offsetHeight+"px;";
		}
	else
	   {
	   	document.getElementById("red-alert").style.cssText="visibility:hidden;";
	   }	
	//
}

/* Проверка еть такой логин или нет 
*/
function check_login_exts(obj)	{
	 LoadFromURL('/check_login.php?login='+obj.value,'',1);
}