var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var path = '/imgs/design/';

dom = (document.getElementById) ? true : false;
nn4 = (document.layers) ? true : false;
ie = (document.all) ? true : false;
ie4 = ie && !dom;
Mac = (navigator.appVersion.indexOf("Mac") != -1);
ie4mac = ie4 && Mac;
opera = (navigator.userAgent.indexOf("Opera")!=-1);
Konqueror = (navigator.userAgent.indexOf("Konqueror")!=-1);

function getRef(id) {
    if (isDOM) return document.getElementById(id);
    if (isIE4) return document.all[id];
    if (isNS4) return document.layers[id];
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var enterTimer = 0;
//var strLogout = '<table cellpadding="0" cellspacing="0" border="0" bgcolor="#76889E" width="100%"><tr><td class="bg-basket" valign="top"><a href="/shop/cart.htm"><img src="/imgs/design/d_left_cart.gif" alt="÷ðúð÷" width="14" height="14" border="0" hspace="8" vspace="4"></a><br><img src=/imgs/design/sp.gif width="1" height="2" alt="" border="0"></td><td class="bg-basket" align="right" width="100%"><a href="/shop/cart.htm"><img src="/imgs/design/t_l_order.gif" alt="÷ðúð÷" width="54" height="8" border="0" hspace="11"></a></td></tr><tr><td colspan="2" valign="top"><div class="text-basket">ªþòð¨þò <span class="text-basket" id=trash_count_content> 0 </span> <br>ýð ¸ºüüº <span class="text-basket" id=trash_sum_content>0.00</span> <b>¨ºñ.</b></div></td></tr><tr><td colspan="2" bgcolor="#5B6F87"><img class="sp" src="/imgs/design/sp.gif" width="1" height="5" border="0" alt=""></td></tr><tr><td colspan="2" bgcolor="#5B6F87"><a href="/shop/cart.htm"><img src="/imgs/design/b_left_tocart.gif" width="101" height="12" hspace="7" border="0" alt="þ¯þ¨üøª¹ ÷ðúð÷"></a></td></tr><tr><td colspan="2" bgcolor="#5B6F87"><img class="sp" src="/imgs/design/sp.gif" width="1" height="2" border="0" alt=""></td></tr><tr><td colspan="2" bgcolor="#5B6F87"><a href="/" onClick="Logout(); return true;"><img src="/imgs/design/b_left_exit.gif" width="50" height="12" hspace="7" border="0" alt="òv¿þô"></a></td></tr><tr><td colspan="2" bgcolor="#5B6F87"><img class="sp" src="/imgs/design/sp.gif" width="1" height="5" border="0" alt=""></td></tr></table>';
var strLogout = '<div style="display:none"><span class="text-basket" id=trash_count_content></span><span class="text-basket" id=trash_sum_content></span></div>';
// var strLogout = '<table cellpadding="0" cellspacing="0" border="0" bgcolor="#76889E" width="100%"><tr><td class="bg-basket" valign="top"><a href="/shop/cart.htm"><img src="/imgs/design/d_left_cart.gif" alt="÷ðúð÷" width="14" height="14" border="0" hspace="8" vspace="4"></a><br><img src=/imgs/design/sp.gif width="1" height="2" alt="" border="0"></td><td class="bg-basket" align="right" width="100%"><a href="/shop/cart.htm"><img src="/imgs/design/t_l_order.gif" alt="÷ðúð÷" width="54" height="8" border="0" hspace="11"></a></td></tr><tr><td colspan="2" valign="top"><div class="text-basket">ªþòð¨þò <span class="text-basket" id=trash_count_content> 0 </span> <br>ýð ¸ºüüº <span class="text-basket" id=trash_sum_content>0.00</span> <b>¨ºñ.</b></div></td></tr><tr><td colspan="2"><table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td bgcolor="#5B6F87"><a href="/"><img src="/imgs/design/d_down_arr2.gif" alt="þ¯þ¨üøª¹ ÷ðúð÷" width="9" height="9" border="0" hspace="8" vspace="5"></a></td><td bgcolor="#5B6F87" valign="top" width="100%"><img src=/imgs/design/sp.gif width="1" height="4" alt="" border="0"><br><a href="/shop/cart.htm" class="text-basket"">þ¯þ¨üøª¹ ÷ðúð÷</a></td><td bgcolor="#5B6F87" align="center"><img src="/imgs/design/rasp/9da9b7.gif" width="1" height="11" vspace="6" border="0" alt=""></td><td bgcolor="#5B6F87" valign="bottom"><a href="/" onclick="Logout(); document.reload(); return false;"><img src="/imgs/design/b_exit.gif" width="22" height="15" hspace="9" vspace="4" border="0" alt="òv¿þô"></a></td></tr></table></td></tr></table>';
var strLogin ='<div id="enterform" name="enterform">'+
		'<table cellspacing="0" cellpadding="0" border="0" width="167" class="bg-left3">'+
		'<tr>'+
			'<td><img class="sp" src="/imgs/design/sp.gif" width="11" height="17" border="0" alt=""></td>'+
			'<td valign="bottom"><img src="/imgs/design/d_forward_arr.gif" width="11" height="11" border="0" alt=""></td>'+
			'<td width="100%" align="right" valign="bottom"><img src="/imgs/design/t_l_promoenter.gif" width="43" height="8" vspace="2" border="0" alt="ÿ¨þüþ ò¿þô"></td>'+
			'<td><img class="sp" src="/imgs/design/sp.gif" width="11" height="17" border="0" alt=""></td>'+
		'</tr>'+
		'<tr>'+
			'<td colspan="4"><img class="sp" src="/imgs/design/sp.gif" width="11" height="15" border="0" alt=""></td>'+
		'</tr></table>'+
		'<table cellspacing="0" cellpadding="0" border="0" width="167" bgcolor="#406592">'+
		'<form action="/cgi-bin/users/client.pl"  name=formLogin id=formLogin method=post>'+
		'<input type=hidden name=action value="autorize">'+
		'<tr>'+
			'<td><img class="sp" src="/imgs/design/sp.gif" width="11" height="1" border="0" alt=""></td>'+
			'<td width="100%"><input type="text" name="login" value="" size="13" style="width: 145px;"></td>'+
			'<td><img class="sp" src="/imgs/design/sp.gif" width="11" height="1" border="0" alt=""></td>'+
		'</tr>'+
		'<tr>'+
			'<td colspan="3"><img class="sp" src="/imgs/design/sp.gif" width="1" height="4" border="0" alt=""></td>'+
		'</tr>'+
		'<tr>'+
			'<td></td><td width="100%"><input type="password" name="pass" value="" size="13" style="width: 145px;"></td>'+
			'<td></td></tr><tr><td colspan="3"><img class="sp" src="/imgs/design/sp.gif" width="1" height="5" border="0" alt=""></td>'+
		'</tr></table>'+
		'<table cellspacing="0" cellpadding="0" border="0" width="167" bgcolor="#406592">'+
		'<tr>'+
			'<td><img class="sp" src="/imgs/design/sp.gif" width="11" height="1" border="0" alt=""></td>'+
			'<td width="100%"><input type="image" src="/imgs/design/b_l_promoenter_enter.gif" width="17" id="imgSubmit" name="imgSubmit"  height="17" border="0" title="òþùªø">'+
			'<img src="/imgs/design/rasp/6e8aac.gif" width="1" height="17" hspace="6" border="0" alt=""></td>'+
			'<td align="right" valign="top"><a href="/shop/forgot.htm"><img src="/imgs/design/b_l_promoenter_lost.gif" width="115" height="6" border="0" vspace="5" alt="÷ðñvªvù ÿð¨þû¹"></a></td>'+
			'<td><img class="sp" src="/imgs/design/sp.gif" width="11" height="1" border="0" alt=""></td>'+
		'</tr></table>'+
		'<table cellspacing="0" cellpadding="0" border="0" width="167" bgcolor="#406592">'+
		'<tr>'+
			'<td colspan="3"><img class="sp" src="/imgs/design/sp.gif" width="1" height="8" border="0" alt=""></td>'+
		'</tr></form></table></div>';



// var strLogout = 'test';

var strLogout2 = '<nobr>Tð° ÷ðúð÷: - <b><span id=trash_count_content>0</span></b> ªþòð¨þò </nobr><br><nobr>ýð ¸ºüüº <span id=trash_sum_content>0.00</span> ¨ºñ. </nobr>';

//var strLogin = '<table cellpadding="0" cellspacing="0" border="0" bgcolor="#406592" width="100%" id=enterform name=enterform><tr><td class="bg-leftcolum"><img src="/imgs/design/next-right.gif" alt="" width="12" height="11" border="0" hspace="10" vspace="6"><br><img class="sp" src="/imgs/design/sp.gif" width="1" height="1" alt="" border="0"></td><td align="right" class="bg-leftcolum" colspan="2"><img src="/imgs/design/promo-enter.gif" alt="ÿ¨þüþ ò¿þô" width="104" height="8" border="0" vspace="7" hspace="11"></td></tr><form action=/cgi-bin/trash/client.pl onsubmit="enterTimer=setTimeout(\'onLogin()\', 2000); if (this.login.value && this.pass.value) return submitToLayer(this, this.action, this.login, this.pass); else return false;" target=senddata name=formLogin id=formLogin method=post><input type=hidden name=action value="logining"><tr><td valign="top" colspan="3"><div class="login"><input type="Text" name="login" tabindex="1" value=" Tþóøý " onFocus="if (this.value==\' Tþóøý \') this.value=\'\';" size="13" style="width: 145px;"></div></td></tr><tr><td valign="top" colspan="3"><div  class="password"><input tabindex="2" type="password" name="pass" value="" alt=" ¦ð¨þû¹ " size="13" style="width: 145px;"></div></td></tr><tr><td valign="top"><div  class="push-next"><input type="image" tabindex="3" title="T¿þô" src="/imgs/design/push-next.gif" alt="òþùªø" border="0"></div></td><td valign="top"><img src="/imgs/design/line.gif" alt="" width="1" height="17" border="0"></td><td valign="top" align="right"><a href="/shop/forgot.htm"><img src="/imgs/design/forgot.gif" alt="÷ðñvûø ÿð¨þû¹" width="115" height="6" border="0" vspace="6"></a><img class="sp" src="/imgs/design/sp.gif" width="11" height="1" alt="" border="0"></td></tr></form></table>';

function submitToLayer(obj) {
	if (document.all) return true;
	var url = obj.action+"?";
	for (var i=1; i<arguments.length; i++) {
		if (i != 1) url+="&";
		url += (arguments[i]).name+"="+(arguments[i]).value;
	}
	var l = document.layers[obj.target];
	if (l) l.load(url,1);
	return false;
}

function clearsubmitLayer(obj) {
}

function Logout () {
	//alert('Âàñèñóàëèé');
	deleteCookie ('sessionID');
	deleteCookie ('isLogining'); 
	deleteCookie ('msgLogining'); 
	deleteCookie ('nameLogin'); 
	deleteCookie ('surnameLogin'); 
	deleteCookie ('otchLogin'); 
	deleteCookie ('countProducts'); 
}

function printEnter () {
	var login = getCookie ('isLogining');
	var str;
	//if (login != '1') {
		str = strLogin;
		document.write(str);
//	} else {
//		str = strLogout;
	//}
}

function printEnter2 () {
	if (getCookie ('isLogining') == '1') {
		var login = getCookie ('isLogining');
		var countProducts = getCookie ('countProducts');
		var sumProducts = getCookie ('sumProducts');
		if (!(countProducts && login)) {
			countProducts = 0;
		}
		if (!(sumProducts && login)) {
			sumProducts = 0;
		}
		document.write('<nobr>Tð° ÷ðúð÷: - <b><span id=trash_count_content>'+countProducts+'</span></b> ªþòð¨þò </nobr><br><nobr>ýð ¸ºüüº <span id=trash_sum_content>'+sumProducts+'</span> ¨ºñ. </nobr>');
	}
}

function setCountProducts () {
	/*
	var login = getCookie ('isLogining');
	var countProducts = getCookie ('countProducts');
	var sumProducts = getCookie ('sumProducts');
	if (countProducts && login) {
		o = getRef('trash_count_content');
		o.innerHTML = countProducts;
	}
	if (sumProducts && login) {
		o = getRef('trash_sum_content');
		o.innerHTML = sumProducts;
	}
	*/
	//parent.loadSource('/cgi-bin/basket/client.pl?action=count_basket');
}

function onTrashAdd () {
	if (enterTimer) {
		clearTimeout(enterTimer); enterTimer = 0;
	}
	setCountProducts ();
}


function onLoad () {
/*	var o = getRef('hi_content');
	var surnameLogin = getCookie ('surnameLogin');
	var nameLogin = getCookie ('nameLogin');
	if (surnameLogin == null) surnameLogin = '';
	if (nameLogin == null) nameLogin = '';
	if (surnameLogin || nameLogin) {
		o.innerHTML = '¦¨øòõª, <b>'+surnameLogin+' '+nameLogin+'!</b>';
	} else {
		o.innerHTML = '-þñ¨þ ÿþöðûþòðª¹ ýð <b>SHOP.UPLIFTO.RU</b>!';
	}
*/

	//setCountProducts ();

//	Logout();
}

function onUnLoad () {
}

function onLogin () {
	var login = getCookie ('isLogining');
	if (login == '1') {
		if (enterTimer) {
			clearTimeout(enterTimer); enterTimer = 0;
			window.location.href="/shop/authorization.htm";
		}
		var o = getRef('enterform'); 
		if (ie) o.outerHTML = strLogout; else o.innerHTML= strLogout;
		
		onLoad ();
		if (getCookie ('isFromCart') == '1') {
			window.location.href = '/shop/cart.htm?action=trash_change';
		}
	}
}

/*
function Buy (id) {
	if (!id) return false;
	var w=300;
	var h=140;
	var t=(document.body.clientHeight-h)/2;
	var l=(document.body.clientWidth-w)/2;
	var newwin = window.open ('/cgi-bin/basket/client.pl?action=add_in_basket&id='+id,'shoping','top='+t+',left='+l+'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0,width='+w+',height='+h);
	newwin.focus();
	enterTimer = setTimeout('onTrashAdd()', 2000);
	return true;
}
*/

//========================================================
CompareUrl='/cgi-bin/users/admin_select.pl';

function ChangeOnSelect(name)
{
	var sel = eval("name.region_id")
	var region_id = sel.options[sel.selectedIndex].value;	//Ïîëó÷àåì çíàå÷åíèå âûáðàííîé ãðóïïû
	if(region_id > 0){
		loadSource(CompareUrl + "?region_id=" + region_id);
	}
}
//========================================================


function details(det_url) { 
	window.open(det_url,'details','toolbar=0,location=0, directories=0, status=0, menubar=0, scrollbars=yes, resizable=1, width=300, height=400'); 
	return false; 
}

function info(det_url,base) { window.open("/cgi-bin/search/result_"+base+".pl?action=see_item&id="+det_url,'details','toolbar=0,location=0,directories=0, status=0,menubar=0,scrollbars=yes,resizable=1,width=300,height=400'); return false; }

function spam() {
	var w=300;
	var h=130;
	var t=(document.body.clientHeight-h)/2;
	var l=(document.body.clientWidth-w)/2;
	var newwin = window.open ('','ordering','width='+w+',height='+h+',top='+t+',left='+l+',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0');
	return true;
}


//********* Ôóíêöèÿ äîáàâëåíèÿ â êîðçèíó **********
function Buy (id, module) {
	if (!id) return false;
	var w=300;
	var h=130;
	var t=(document.body.clientHeight-h)/2;
	var l=(document.body.clientWidth-w)/2;
	var newwin = window.open ('/cgi-bin/basket/client.pl?action=add_in_demand&id='+id+'&module='+module,'shoping','top='+t+',left='+l+'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0,width='+w+',height='+h);
	newwin.focus();

	//enterTimer = setTimeout('onTrashAdd()', 2000);
	return true;
}
//********* Ôóíêöèÿ äîáàâëåíèÿ â êîðçèíó **********

//**********************************************
function Change(id, text) {
    document.all[id].innerHTML = text;
}


function loadSource(url) {
id = "content";
	if (document.layers) {
		var lyr = document.layers[id];
		lyr.load(url,lyr.clip.width);
	}
	else if (document.getElementById) {
		document.getElementById('HiddenFrame').src = url;
  	}
	else if (document.all) {
		parent.HiddenFrame.document.location = url;
	}
}
//**********************************************


function LookFoto (id, w, h) {
	if (!id) return;
	if(!w) w=480;
	if(!h) h=640;
	var t=(document.body.clientHeight-h)/2;
	var l=(document.body.clientWidth-w)/2;
	var newwin = window.open ('/includes/photo.htm?a'+id+'.jpg','foto','top='+t+',left='+l+',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0,width='+w+',height='+h);
	newwin.focus();
}

function Order () {
	var w=300;
	var h=130;
	var t=(document.body.clientHeight-h)/2;
	var l=(document.body.clientWidth-w)/2;
	var newwin = window.open ('','ordering','width='+w+',height='+h+',top='+t+',left='+l+',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0');
	return true;
}

function DoAddMail(){
	if (document.forma.mail.value) {
		var newwin;
		var w=300;
		var h=130;
		newwin = window.open('/cgi-bin/sendmail/subscribe.cgi?mail='+document.forma.mail.value, 'newwin', 'width='+w+',height='+h+',toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0');
	newwin.window.focus();
	}
}

function maxpic(picname,x,y,titl) {
 var win = window.open('','_photo1',"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width="+x+",height="+y);
 win.document.open("text/html");
 with (win.document) {
  write("<html><head><title>"+titl+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</title><script language='JavaScript'>self.focus();</script></head><body bgcolor='#FFFFFF' bottommargin='0' topmargin='0' leftmargin='0' rightmargin='0' marginheight='0' marginwidth='0'><table width=100% height=100% cellpadding=0 cellspacing=0 border=0><tr><td align=center valign=middle title='Close' style='cursor: hand;' onClick='window.close()'><a href='#' onclick='window.close()'><img src='/imgs/"+picname+"' alt='Close' border='0' width="+x+" height="+y+"></a></td></tr></table></body></html>");
  close();
 }
} 
