function checkEmail(obj){
    var str=obj.value;
    if(str=='') return true;
    if (/^([\w-~_]+\.)*[\w-~_]+@([\w-_]+\.){1,3}\w{2,4}$/.test(str))	return true;

alert("Неправильный e-mail адрес");
obj.focus();
return false;
}


function zoom(name,format){
        var p=window.open('/zoom.plx?n='+name+'&amp;f='+format,'preview_window',"width=10,height=10,top=0,left=0,location=0,toolbar=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,fullscreen=0");
        if(p)p.focus();
	return false;
}

function zoomCT(file){
        var p=window.open('/zoomCT.plx?id='+file,'preview_window',"width=10,height=10,top=0,left=0,location=0,toolbar=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,fullscreen=0");
        if(p)p.focus();
	return false;
}

function ch_sz(tobj,num){
        var obj=document.getElementById("IS_"+num);
        var st=tobj.value;
        obj.innerHTML=st.split('_')[1];
	return true;
}


function mm(url){
    var img=new Image;
    img.src=url;
    return img;
}

var imgBkYes=mm('/i/note_yes.gif');
var imgBkNo=mm('/i/note_no.gif');



function SetCookie ( name, value, expires, path, domain, secure) {
	szCookie = name + "=" + escape (value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
	document.cookie = szCookie;
}

function doBk(iid,section,price) {
   var obj,obj1,img;
   if(document.all) { obj= document.all['my_note_i'];}
   else {obj=document.getElementById('my_note_i');}
    if(!isInBk(iid)) {
        addToBk(iid+'_1');
         var noteBK=document.getElementById("noteBK");
         var notePrice=document.getElementById("notePrice");
         var count=parseInt(cookieVal("noteCount"))+1;
         var nprice=parseInt(cookieVal("moneyCount"))+parseInt(price);
         
		 if(noteBK)
		 {
		  var ender='ов';
		  if(count<5) ender='a';
		  if(count==1) ender='';
		  noteBK.innerHTML=count;
		 
		 }
		 
		 if(notePrice)
		 {
		  notePrice.innerHTML=nprice;
		 
		 }
		 
		 
        var it=document.getElementById('it_'+iid);
        it.innerHTML="<nobr><img src='http://res.domikbt.ru/img/inbasket.jpg' width='49' height='9' border='0' /><img src='http://res.domikbt.ru/img/spacer.gif' height='9' width='7' border='0' /></nobr>";
        document.cookie ="noteCount="+count+"; domain=.domikbt.ru; path=/";
       document.cookie ="moneyCount="+nprice+"; domain=.domikbt.ru; path=/";
         img=imgBkYes;
    } else img=imgBkNo;
    if (img && img.complete) {
        obj.src=img.src;
        showBk(iid,section);
    }
return false;
}

function showBk(iid,section){
 var obj=document.getElementById("my_note");
 var obj1=document.getElementById("ti_"+iid+"_"+section);
 var ox,oy;
 for(ox=oy=0;obj1;obj1=obj1.offsetParent)ox+=obj1.offsetLeft, oy+=obj1.offsetTop;
 obj.style.top=oy-26; obj.style.left=ox;
 obj.style.display='block';
return false;
}

function dropBk(){
 var obj=document.getElementById("my_note");
 obj.style.display='none';
}

function cookieVal(cookieName) {
    thisCookie = document.cookie.split("; ")
        for (i = 0; i < thisCookie.length; i++) {
            if (cookieName == thisCookie[i].split("=")[0]) {
                return thisCookie[i].split("=")[1];
            }
        }
    return 0;
}


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; domain=.domikbt.ru; path=/';
   // document.writeln(p_cookie);
    document.cookie=p_cookie;

}

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


var ldr=null;

function add(sel,v,n){
var newOpt=sel.appendChild(document.createElement('option'));
newOpt.text=n;
newOpt.value=v;
}

var divname=null;
var div=null;

function chan(f,name,qw,parm)
{

 if(ldr&&ldr.readyState!=0) { ldr.abort() }
 ldr=selector();
 if(ldr)
 {
 	name.length = 0;
 	var now = new Date();
 		//window.location="/selector.plx?q="+parm+"&sel="+qw;
 	ldr.open("GET","/selector.plx?q="+parm+"&sel="+qw+"&t="+now.getSeconds(),true);
	ldr.onreadystatechange=function()
	{
	if(ldr.readyState==4 && ldr.responseText)
		{
			eval(ldr.responseText);
		}
	};
	ldr.send(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 HTMLchan(name,qw)
{
 divname=name;
 div=document.getElementById(name);
 document.getElementById(name).innerHTML="<div style='position:absolute; color:red; font-size:13px; font-weight:bold; padding-left: 70px; padding-top:1px;'>Идет загрузка...</div>"+document.getElementById(name).innerHTML;
 if(ldr&&ldr.readyState!=0) { ldr.abort() }
 ldr=selector();
 if(ldr)
 {
 	name.length = 0;
 	var now = new Date();
 	ldr.open("GET","/attr.plx?sel="+qw+"&t="+now.getSeconds(),true);

	ldr.onreadystatechange=function()
	{
	if(ldr.readyState==4 && ldr.responseText)
		{
			//alert(div.innerHTML);
			var txt1=ldr.responseText;
			div.innerHTML=txt1;
		}
	};
	ldr.send(null)
 }
 return false;
}
