try{
	var imgBkYes=mm('/i/note_yes.gif');
	var imgBkNo=mm('/i/note_no.gif');
}catch(e){}

var chan_count = 0;

function TimeOut(){
	if(Timer!=null) {clearTimeout(Timer);Timer=null}
	var obj=document.getElementById("l_wait");
	obj.innerHTML=_oldform;
	hide_modal();
	return false;
}

function hideVirusSpam() {

	if (document.all){
		div = document.all['virus_message'];
	}else{
		div = document.getElementById('virus_message');
	}
	div.innerHTML = '<IMG SRC="/i/preloader_160.gif" WIDTH="126" HEIGHT="12" BORDER="0"/>';
	chan(0,'dontshow_virus');
	chan_count = 0;
	Timer = setTimeout("isHideVirusSpam()",4000);
}
function isHidedVirusSpam(){

	if (Timer != null)clearTimeout(Timer);
	chan_count += 1;
	if (chan_count>20){
		if (document.all){
			div = document.all['delfromlist_'+iid];
		}else{
			div = document.getElementById('delfromlist_'+iid);
		}
		div.innerHTML = 'запомнить скрытие не удалось';
	}else{
		chan(0,'dontshow_virus');
		Timer = setTimeout("isHidedVirusSpam()",4000);
	}
	return false;
}

function isInBk(posNum){
    var p_cookie=document.cookie;
    var cookie;
    cookie=unescape(p_cookie.substr(p_cookie.indexOf('book=')+5,p_cookie.indexOf('-NSB')-p_cookie.indexOf('book=')-4));
    return cookie.indexOf('-'+posNum+'_')==-1?false:true;
}

function addToBk(code){
    var p_cookie=document.cookie;
    var cookie;
    cookie=unescape(p_cookie.substr(p_cookie.indexOf('book=')+5,p_cookie.indexOf('-NSB')-p_cookie.indexOf('book=')-5));
    p_cookie='book='+escape(cookie+'-'+code)+'-NSB; path=/';
    document.cookie=p_cookie;
}

function comp(path){window.location='&amp;'+path; return false;}


var ldr=null;

function selector(){
	var A=null;
	try{A=new ActiveXObject("Msxml2.XMLHTTP")}
	catch(e){try{A=new ActiveXObject("Microsoft.XMLHTTP")}
	catch(oc){A=null}}
	if(!A&&typeof XMLHttpRequest!="undefined") {A=new XMLHttpRequest()}
	return A
}

function showBLK(){
	SetCookie ( 'BLK', '1', "", "/", "", "");
	document.getElementById('delivery_types').style.display = 'block';
	document.getElementById('menuicon3').style.display = 'none';
	document.getElementById('menuicon2').style.display = 'block';
	return false;
}

function hideBLK(){
	SetCookie ( 'BLK', '0', "", "/", "", "");
	document.getElementById('delivery_types').style.display = 'none';
	document.getElementById('menuicon3').style.display = 'block';
	document.getElementById('menuicon2').style.display = 'none';
	return false;
}

function setHP(obj) {
	if (document.all) {
	obj.style.behavior='url(#default#homepage)';
	obj.setHomePage('http://www.utkonos.ru');
	return false;
	}else
		if(!document.layers) {
			netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesWrite");
			navigator.preference("browser.startup.homepage", "http://www.utkonos.ru");
			return false;
		}
	return true;
}

function exchangeTDColors(id1,id2){
	var color1 = '#A8C604';
	var color2 = 'lightgrey';

	var td1;
	var td2;
	var IE =0;
	if (document.all){
		td1 = document.all[id1];
		td2 = document.all[id2];
		IE = 1;
	}else{
		td1 = document.getElementById(id1);
		td2 = document.getElementById(id2);
	}
	if (td1 != null){
			td1.removeAttribute("bgcolor",0);
			td1.setAttribute("BGCOLOR",color1,0);
	}

	if (td2 != null){
		td2.removeAttribute("bgcolor",0);
		td2.setAttribute("BGCOLOR",color2,0);
	}
	return false;
}

function switch_positions(link,id){
  var positions=getElement('positions_'+id);
  var positions_show=getElement('positions_switch_'+id+'_show');
  var positions_hide=getElement('positions_switch_'+id+'_hide');
  if(positions){
    if(positions.style.display!='block'){
    	positions.style.display='block';
    	positions_show.style.display='none';
    	positions_hide.style.display='inline';
    }else{
    	positions.style.display='none';
    	positions_show.style.display='inline';
    	positions_hide.style.display='none';
    }
  }
  return false;
}

/*ADDRESS SELECT*/

function unchecking (td){
	if (td){
		inps = td.getElementsByTagName('input');
		if (inps && inps.length > 0){
			for (i = 0;  i< inps.length; i++){
				inps[i].checked=false;
			}
		}
	}
}

///  Login scripts

function Login_Timer(){
	if(Timer!=null) clearTimeout(Timer);
	Count=Count+1;
	if(Count>60){
		var modal=document.getElementById("modal");
		modal.style.display='none';
		var obj=document.getElementById("l_wait");
		obj.innerHTML=document.getElementById('TIMEOUT').innerHTML+'<a href="" onclick="return LoginTimeOut();">Повторить</a>';
	}else{
		ajax('auth',getElement('session_id').value,LoginTimeOut);
	}
	return false;
}

function LoginTimeOut(){
	var welcome=document.getElementById("welcome");
	welcome.style.display='none';
	hide_modal();
	return false;
}

var Timer=null;
var Count=0;
var hotlog_stopper = 1;

var _oldform='';

function login_waiter_init(){
  try{
   	var session_id=getElement('session_id');
   	if(session_id&&session_id.value!=0){
			login_request(session_id.value);
   	}
  }catch(e){
    alert('Error in login_waiter_init:'+e.message);
  }
}

addEvent(window,'load',login_waiter_init);


/// Всплывающие окна

function disable_spam_wind(){
	var obj=document.getElementById("spam_banner_mess");
	obj.style.display='none';
}
function block_4first_spam_message(){chan('','block_4first_spam_message');}

function disable_wind(){
	var obj=document.getElementById("basket_mess");
	obj.style.display='none';
}
function erase_basket(){ajax_xml('','clear_basket','basket_updated');disable_wind();}

/// Прошлые заказы

var Timer=null;
var Count=0;

function OrdersViewWait(){
	var modal=document.getElementById("modal");
	modal.style.display='block';

	if(Timer!=null) clearTimeout(Timer);
	Count=Count+1;
	if(Count>60)
	{
		var modal=document.getElementById("modal");
		modal.style.display='none';
		var obj=document.getElementById("l_wait");
		obj.innerHTML=document.getElementById('TIMEOUT').innerHTML+'<a href="/orders_view/all/">Повторить</a>';
	}
	else
	{
		chan('','selectReestr');
	}
	Timer=setTimeout("OrdersViewWait()",4000);
	return false;
}


function save_order_in_arch(ord){
	var ord2arch = document.getElementById('ord2arch');
	if (ord2arch && ord>0) {
		chan(ord,'ord2arch');
	}
	return false;
}

function action_500_init(){
  try{
    if(getElement('action_500_goods')){
      var realHeight	=	document.body.offsetHeight;
      var owher				=	parent.document.getElementById('frame_500');
      if(owher){
        owher.style.height=realHeight+20+'px';
      }
    }
  }catch(e){
    alert('Error in action_500_init'+e.message);
  }
}

function basket_cleaned(){
  try{
    alert(basket_count+':'+basket_sum+':'+item_id+':'+item_count);
  }catch(e){
    alert('Error in basket_cleaned'+e.message);
  }
}

addEvent(window,'load',action_500_init);

