isIE = ((/MSIE/i).test(navigator.appVersion));
function addEvent(el, event, fn) {if (isIE) el.attachEvent('on'+event,fn); else el.addEventListener(event,fn,false);}
addEvent (window, 'load', init);
swf_part = new Array (7,5,1,3);
var last_over=0;

function fixPNG(element) {
	if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent)) {
		var src;
		src = element.currentStyle.backgroundImage.match(/url\("(.+\.gif)"\)/i)
		if (src) {src = src[1]; element.runtimeStyle.backgroundImage="none";}
		if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='crop')";
	}
}

function activateFlash() {
	objects = document.getElementsByTagName("object");
	for (var i = 0; i < objects.length; i++) objects[i].outerHTML = objects[i].outerHTML;

	objects = document.getElementsByTagName("embed");
	for (var i = 0; i < objects.length; i++) objects[i].outerHTML = objects[i].outerHTML;
}

function getMovie() {
    var M$ =  navigator.appName.indexOf("Microsoft")!=-1
    return (M$ ? window : document)["BridgeMovie"]
}

function inpFocus(el,elval) {
	el.onblur  = function fun() {if (el.value == "") el.value = elval; el.className='text'};
	el.onfocus = function fun() {if (el.value == elval) el.value=""; el.className='text_focus'};
}

function fl_click() {
	//getMovie().SetVariable("movstate", swf_part[this.nn-1]);
	document.location.href=this.getElementsByTagName("A")[0].href;
}

function fl_over() {
	getMovie().SetVariable("movstate", swf_part[this.nn-1]);
	this.className='line'+this.nn+'_act';
	if(typeof(last_over)=='object'){
	  if(last_over!=this){
	    fl_out1(last_over);
	  }
	}
	if (isIE) {
		if (this.nn == 14) this.runtimeStyle.backgroundImage="url(images/line15_act.gif)";
		fixPNG(this);
	}
	last_over=this;
}

function fl_out1(obj) {
//	alert(swf_part[this.nn-1]+1);
	//getMovie().SetVariable("movstate", swf_part[this.nn-1]+1);
	obj.className = obj.className.replace("_act", "");
	if (isIE) {
		if (obj.nn == 14) obj.runtimeStyle.backgroundImage="url(images/line15.gif)";
		fixPNG(obj);
	}
}

function fl_out() {
//	alert(swf_part[this.nn-1]+1);
	getMovie().SetVariable("movstate", swf_part[this.nn-1]+1);
	this.className = this.className.replace("_act", "");
	if (isIE) {
		if (this.nn == 14) this.runtimeStyle.backgroundImage="url(images/line15.gif)";
		fixPNG(this);
	}
}
function popup_show() {
//	this.parentNode.parentNode.parentNode.style.display = 'block';
	//document.getElementById('rss').style.zIndex=1;
	pb = this.parentNode.nextSibling.nextSibling;
	$(pb).animate({height: "show", opacity: 100, width: "458px"}, 300);
	return false;
}

function popup_close() {
//	this.parentNode.parentNode.parentNode.style.display = 'none';
	//document.getElementById('rss').style.zIndex=99999;
	pb = this.parentNode.parentNode.parentNode;
	$(pb).animate({height: "hide", opacity: 0, width: "0"}, 300);
}

function init() {

	activateFlash();

		tm = document.getElementById("menu").getElementsByTagName("UL");
		err1=1;
		if (isIE) err1=0;
		for (var i=0, len=tm.length; i<len; i++) {
			tm[i].style.zIndex=1000-i;
			tm[i].style.zoom = 0;
//			alert(tm[i].childNodes.length);
//			tm[i].style.border='1px solid #ff0000';
			if (tm[i].childNodes[err1].className == 'li1_act') {
//				tm[i].style.zIndex='5000 !important';
				tm[i].style.zIndex=5000;
//				tm[i].childNodes[err1].style.border='1px solid #ff0000';
			}
		}

	if (isIE) {
		tm = document.getElementById("menu").getElementsByTagName("UL");
		for (var i=0, len=tm.length; i<len; i++) {
			if (tm[i].className == 'ul1') {
				tm[i].onmouseover=function() { this.className+=" jshover";}
				tm[i].onmouseout=function() { this.className=this.className.replace(" jshover", "");}
			}
		}

		tmp = document.getElementById("menu").getElementsByTagName("LI");
		for (var i=0, len=tmp.length; i<len; i++) {
			if (tmp[i].className == 'li1_sub') {
				tmp[i].onmouseover=function() { this.className+=" jshover";}
				tmp[i].onmouseout=function() { this.className=this.className.replace(" jshover", "");}
			}
		}

	}

	sf = document.getElementById('search').elements;
	for (i=0; i<sf.length; i++) {if (sf[i].type == 'text') inpFocus(sf[i], sf[i].value);}

	fl = document.getElementById('flashlist');
	if (fl != null) {
		fl = fl.getElementsByTagName('LI');
		fla = Array();
		for (i=1; i<15; i++) {
			fla[i] = new Image(); fla[i].src = 'images/line'+i+'_act.gif';
			fl[i-1].nn = i;
			fl[i-1].onmouseover = fl_over;
			fl[i-1].onmouseout = fl_out;
			fl[i-1].onclick = fl_click;
			if (isIE) fixPNG(fl[i-1]);
		}
		fla[4].src = 'images/line15_act.gif';
	}

	c3 = document.getElementById('col3');
	if (c3 == null) return;
	ss = c3.getElementsByTagName('SMALL');
	pp = c3.getElementsByTagName('BIG');
	for (i=0; i<ss.length; i++) {
		pc = pp[i].childNodes[0];
		ps = ss[i].childNodes[0];
		if (pc.className == 'popup_close') {
			pc.onclick = popup_close;
			ps.onclick = popup_show;
		}
	}
}

function ge(str){
return document.getElementById(str);
}

//---------------------------------------------------------------------||
// FUNCTION: getCookieVal ||
// PARAMETERS: offset ||
// RETURNS: URL unescaped Cookie Value ||
// PURPOSE: Get a specific value from a cookie ||
//---------------------------------------------------------------------||
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

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

function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg) return getCookieVal(j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}

function DeleteCookie(name, path, domain){
if (GetCookie(name)) {
document.cookie = name + "=" +
("; path=/") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 10-Feb-82 00:00:01 GMT"
}
}

//id='t2i43'
function setFavTitle(table,goodsid){
  obj=ge('t'+table+'i'+goodsid);
  if(obj){
    val=GetCookie('t'+table+'i'+goodsid);
    if(val==null){
      obj.className='fav1';
      obj.innerHTML='<em>Добавить в избранное</em>';
    }else{
      obj.className='fav0';
      obj.innerHTML='<em>Убрать из избранного</em>';
    }
  }
}

function changeFav(table,goodsid){
  val=GetCookie('t'+table+'i'+goodsid);
  if(val==null){
    cnt=GetCookie('gcount');
    if(cnt==null){
      cnt=0;
    }
    cnt++;
    SetCookie('gcount',cnt);
    SetCookie('t'+table+'i'+goodsid,cnt);
    SetCookie('tables['+cnt+']',table);
    SetCookie('goods['+cnt+']',goodsid);
  }else{
    cnt=GetCookie('gcount');
    DeleteCookie('tables['+val+']');
    DeleteCookie('goods['+val+']');
    DeleteCookie('t'+table+'i'+goodsid);
    if(val!=cnt){
    last_t=GetCookie('tables['+cnt+']');
    last_i=GetCookie('goods['+cnt+']');
    SetCookie('t'+last_t+'i'+last_i,val);
    SetCookie('tables['+val+']',last_t);
    SetCookie('goods['+val+']',last_i);
    DeleteCookie('goods['+cnt+']');
    DeleteCookie('tables['+cnt+']');
    }
    cnt--;
    if(cnt<0){ cnt=0;}
    SetCookie('gcount',cnt);
    //last_t=GetCookie('t'+table+'i'+goodsid);
  }
  setFavTitle(table,goodsid);
}

/*function BigImage(img,w,h)
{
  var obj_window =
window.open(img,"","toolbar=no,directories=no,status = no,resizable=yes,menubar=no,scrollbars=auto,width="+w+"pt, height="+h+"pt");
        obj_window.focus();
}*/
function BigImage(img,w,h)
{
  var obj_window =
window.open('/big_image.php?Image='+img,"","toolbar=no,directories=no,status = no,resizable=yes,menubar=no,scrollbars=auto,width="+w+"pt, height="+h+"pt");
	obj_window.focus();
}
var current = '';

function showEl(id)
{
      document.getElementById(id).style.visibility = 'visible';
	  document.getElementById(id).style.display = 'inline';
}
function hideEl(id)
{
   if( document.getElementById(id) )
   {
      document.getElementById(id).style.visibility = 'hidden';
	  document.getElementById(id).style.display = 'none';
}
}
function changeTree(id)
{
   if( document.getElementById(id).style.visibility == 'hidden' )
   {
      showEl(id);
	  if( current!='' && current!=id)
	      hideEl(current);
	  current = id;
   }
   else
   {
      hideEl(id);
   }
}
function ChangeMap(img)
{
  if (document.images && document.images['RegionsMap'] )
	document.images['RegionsMap'].src = img;
}

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 show_dropdown(id)
{
	var v = document.getElementById(id).style.display;
	if (v == "none")
	  document.getElementById(id).style.display = "block";
	else
	  document.getElementById(id).style.display = "none";
}

<!--
function nph_open_window(url, name, feature)
{
    window.open(url, name, feature);
}
// -->
