function show_icq(width,height,s_url){
	var imgnwin=window.open(s_url,"icqwin","resizable=no,scrollbars=yes,toolbar=no,location=no,directoties=no,status=no,menubar=no,width="+width+",height="+height);
}

function show_bask(width,height,s_url){
	var basknwin=window.open(s_url,"baskswin","resizable=yes,scrollbars=yes,toolbar=no,location=no,directoties=no,status=no,menubar=no,width="+width+",height="+height);
}

function show_img(title,width,height,s_url){
	var imgnwin=window.open("","imgswin","resizable=yes,scrollbars=yes,toolbar=no,location=no,directoties=no,status=no,menubar=no,width="+width+",height="+height);
	imgnwin.document.write("<html><title>"+title+"</title><body topmargin=0 leftmargin=0 marginheight=0 marginwidth=0><center><img src='"+s_url+"' border=0></center></body></html>")
}

function show_win(width,height,s_url){
	var p_top=(window.screen.height-height)/2, p_left=(window.screen.width-width)/2;
	var imgnwin=window.open(s_url,"imgswin","resizable=yes,scrollbars=yes,toolbar=no,location=no,directoties=no,status=no,menubar=no,width="+width+",height="+height+",top="+p_top+",left="+p_left);
	imgnwin.focus();
}


function active_win(surl){
	window.opener.document.location=surl;
}

function show_div(id_cur){
	var div_set=null;
	div_set=document.getElementById(id_cur);
	if (div_set!=null) {
		if (div_set.style.display=="block") div_set.style.display="none";
		else div_set.style.display="block";
	}
}




function show_parent_div(div_par){
    var IDParentElement="", NextParentElement="";
		var obj=null; 
		var obj1=null;
    if (document.getElementById(div_par)!=null)
    {
			obj1=document.getElementById(div_par);
			for(var i=0; i<10; i++) {
				obj=obj1;
				if (obj!=null) {
					if (obj.id!="" && obj.style.display!="block") {
						obj.style.display="block";
					}
				}
				else break;
				obj1=eval("obj.parentElement");
			}
		}
}


var div_count=10;
var timeout_hide=null;

function show_menu(name_obj){
	var obj=null;
	obj=document.getElementById(name_obj);
	if (obj!=null) {	hide_all();	show_set(); obj.style.visibility="visible"; }
}
function hide_div(obj) { if ( !obj.contains(window.event.toElement) ) obj.style.visibility="hidden"; }
function hide_set() {	timeout_hide=setTimeout("hide_all()",1000); }
function show_set() {	if (timeout_hide!=null) { clearTimeout(timeout_hide); timeout_hide=null; } }
function hide_all() { 
	for (var i=0; i<div_count; i++) 
		if (document.getElementById("m"+i)!=null) {
			document.all["m"+i].style.visibility="hidden"; 
		}
}      

function price_alt(in_price,in_usd,in_rur){
	if (in_price=='' || (in_usd=='' && in_rur=='')) return;
	var normal_price=parseFloat("0"+in_price);
	if (in_usd!='') { document.write( normalize(normal_price*CurCurse)+" руб." ); return; } // если цена товара в USD, то пересчитаем в рублях и отобразим альтернативную цену
	if (in_rur!='') { document.write( normalize(normal_price/CurCurse)+" $" ); return; } // если цена товара в USD, то пересчитаем в рублях и отобразим альтернативную цену
}

function price_alt2(in_price){
	var normal_price=parseFloat("0"+in_price);
	if (CurValuteFlag=='1') { document.write( normalize(normal_price*CurCurse)+" руб." ); return; } // если цена товара в USD, то пересчитаем в рублях и отобразим альтернативную цену
	if (CurValuteFlag=='2') { document.write( normalize(normal_price/CurCurse)+" $" ); return; } // если цена товара в USD, то пересчитаем в рублях и отобразим альтернативную цену
}


function logoff(){
	RemoveCookie("login");
	RemoveCookie("pass");
	RemoveCookie("userid");
	CreateCookie("mode","2","10");
	location.reload();
}


var RND=parseInt(Math.random()*100000);

function add_bask_img(idcat,idgoods){
	document.write("<a href='javascript:show_win(400,200,\"/basket_add.html?idc="+idcat+"&idg="+idgoods+"&c=addbask&ctype=showbask&r="+RND+"\")'><img src='/i/korz.gif' width=16 height=14 border=0 hspace=4 style='margin-top: 1px;' alt='в корзину' ></a>");
}

function add_bask_text(idcat,idgoods){
	document.write("<a href='javascript:show_win(400,200,\"/basket_add.html?idc="+idcat+"&idg="+idgoods+"&c=addbask&ctype=showbask&r="+RND+"\")'>В корзину</a>");
}





CurCurse='1.0';
CurValuteFlag='0'; // 0 - не установлен, 1-доллары, 2-рубли.
function normalize(price)
{	var pr, str;
	pr=parseInt(Math.round(price*100));
	str = new String(pr);
	pr="";
	if (str.length>2)
		pr += str.substring(0, str.length-2);
	else
		pr += "0";
	pr += ".";
	if (str.length>2)
		pr += str.substring(str.length-2, str.length);
	else
	{	if (str.length==1)
			pr += "0";
		pr += str;
	}
	return pr;
}

function set_selected(p,v){
	for (i=0; i < p.options.length; i++) {
		if (p.options[i].value==v) { p.options[i].selected=true; break; }
	}
}

function set_radio(p,v){
	for (i=0; i < p.length; i++) {
		if (p[i].value==v) { p[i].checked=true; break; }
	}
}
function set_checked(p,v){
	if (p.value==v) p.checked=true; 
}