function popup(file,width,height)
{
	window.open(file,"site_path","height="+height+",width="+width+",status=no,location=no,toolbar=no,directories=no,resizable=yes,scrollbars=yes,menubar=no,top=10,left=10");
}

function makeSiteLink(name) {
	if (!window.js_base_url) {
		str = document.location.toString();
		js_base_url = str.replace("/javascript/editor/scripts/hyperlink.htm","");
		js_base_url = js_base_url.replace("/javascript/editor/scripts/moz/hyperlink.htm","");
	}
	popup(js_base_url+'/admin/index.php?mod=tree&action=mini_browser&returnname='+name,'600','400');
}

function retBack(obj, str) {
	window.close();
	obj.value = str;
}

function insertIntoWYSIWYG(str) {
	doc = "window.opener";
	for ( property in eval(doc) ) {
		fullPropertyName = "document."+property;

		if (fullPropertyName.indexOf("document.myStyle")!=-1) {
			objName = fullPropertyName.replace("document.myStyle", "");
			break;
		}
	}
	objName = eval(doc+".window."+objName);
	objName.insertCustomTag(str);
	self.window.close();
}

function check4compare(obj) {
	for(i=0; i<obj.elements.length; i++) if (obj.elements[i].type=="checkbox" && obj.elements[i].checked) return true;
	alert('Не выделено ни одного продукта для сравнения');
	return false;
}

function switch_loading_box (box_id) {
	if(document.getElementById(box_id).style.display!="none") {
		document.getElementById(box_id).style.display="none";
	}
	else {
		document.getElementById(box_id).style.display="";
		var ie=document.all;
		iebody=document.body;
		var scroll_top=(ie)? iebody.scrollTop : window.pageYOffset;
		var docwidth=(ie)? iebody.clientWidth : window.innerWidth;
		docheight=(ie)? iebody.clientHeight: window.innerHeight;
		var objwidth=document.getElementById(box_id).offsetWidth;
		objheight=document.getElementById(box_id).offsetHeight;
		var test=docwidth/2-objwidth/2+"px";
		document.getElementById(box_id).style.left=docwidth/2-objwidth/2+"px";
		document.getElementById(box_id).style.top=scroll_top+docheight/2-objheight/2+"px";
	}
	return false;
}
ff2=function(t){
		t.className=/\D/.test(t.value)?'err':'';
		if(/\D/.test(t.value)){t.value=t.defaultValue;
				if(self.ww)clearTimeout(ww);
				o=t;
				ww=setTimeout("o.className='';",999);
	}else t.defaultValue=t.value;
}

function openClub() {
	var width=screen.width;
	var height=screen.height;
	window.open('https://prcab.x5club.ru/cwa/','cabinet','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=yes,resizable=yes,height='+ height +'px,width='+ width +'px'); 
	return false;
}
function openClubKarusel() {
	var width=screen.width;
	var height=screen.height;
	window.open('https://prcab.x5club.ru/cwa/karusel/','Личный кабинет','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=yes,resizable=yes,height='+ height +'px,width='+ width +'px'); 
	return false;
}
function openClub_anketa() {
	window.open('http://perekrestok.x5club.ru/anketa/','Анкета','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=yes,resizable=yes,height=650,width=950'); 
	return false;
}

function flatOver(cl) {
	cl.className = 'act';
}
function flatOut(cl) {
	cl.className = '';
}
function poll_city(answer) {
    var req = new Subsys_JsHttpRequest_Js();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            if (req.responseJS) {
                document.getElementById('my_list_city').innerHTML = 
                    (req.responseJS.content||'');
            }
        }
    }
    req.caching = false;
    req.open('GET', 'http://'+document.location.host+'/modules/page/loader/city.php', true);
    req.send({answer:answer});
    return false;
}
function poll_recipe(answer,ball) {
	
    var req = new Subsys_JsHttpRequest_Js();
    req.onreadystatechange = function() 
    {
        if (req.readyState == 4) {
            if (req.responseJS) {
                document.getElementById('total_'+answer).innerHTML = 
                    (req.responseJS.basket_number||'');
				document.getElementById('res_'+answer).innerHTML = "<strong>Спасибо, ваш голос принят</strong>"; 
            }
        }
    }
    req.caching = false;
    req.open('GET', 'http://'+document.location.host+'/modules/articles/front/poll_vote.php', true);
    req.send({answer:answer,ball:ball});
    return false;
}
