function ShowNews(theURL,winName)
{ //v1.0
	var now = new Date();
	window.open(theURL,winName+now.getTime(),'scrollbars=1,width=800,height=600,');
}
function ShowImage(URL,width,height)
{ //v1.0
	var now = new Date();
	winName="Изображение";
	window.open(URL,winName+now.getTime(),'scrollbars=0,width='+(parseInt(width)+30).toString()+',height='+(parseInt(height)+30).toString()+',');
}
function DetectBrowser()
{
    var browserName=navigator.appName; 
    
    var Class='';
    if (browserName=="Netscape")
    { 
     Class+='NS ';
    }
    if (browserName=="Microsoft Internet Explorer")
    {
      Class+='IE ';
      if(navigator.appVersion.indexOf('MSIE 7')!=-1) Class+='IE7 ';
      if(navigator.appVersion.indexOf('MSIE 6')!=-1) Class+='IE6 ';
      if(navigator.appVersion.indexOf('MSIE 5')!=-1) Class+='IE5 ';
    }
    else
       Class+='NIE ';
    if (browserName=="Opera")
     {
      Class+='OP ';
     } 
     //alert(Class);
     document.body.className=Class;
}
$(document).ready(DetectBrowser);

function fixPNG(element)
{
	if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent))
	{
		var src;
		
		if (element.tagName=='IMG')
		{
			if (/\.png$/.test(element.src))
			{
				src = element.src;
				element.src = "/images/1.gif";
			}
		}
		else
		{
			src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i)
			if (src)
			{
				src = src[1];
				element.runtimeStyle.backgroundImage="none";
			}
		}
		
		if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
	}
}

//Всплывающая подсказка для изображений
function ToolTipShowMove(e)
    {
        var tt=document.getElementById("tool_tip");
        
        var IsIE=0;
        if (navigator.appName=="Microsoft Internet Explorer") IsIE=1;
        
        var x,y;
        x=0;
        y=0;
        if (IsIE==0)
        {
            x=e.pageX+13;
            y=e.pageY+18;
        }
        else
        {
            x=window.event.x+document.documentElement.scrollLeft+13;
            y=window.event.y+document.documentElement.scrollTop+18;
        }
        if (tt.oldx!=x) tt.style.left=x+'px';
        if(tt.oldy!=y) tt.style.top=y+'px';
        tt.oldx=x;
        tt.oldy=y;
        if(tt.style.display!='block')tt.style.display='block';
        
    }
    function ToolTipShow(Img,Text)
    {
        
        var tt=document.getElementById("tool_tip");
        if (!tt) 
        {
            tt=document.createElement("DIV");
            tt.style.display='none';
            tt.style.position='absolute';
            tt.id="tool_tip";
            document.body.appendChild(tt);            
        }
        tt.innerHTML=Text;
        tt.oldx=0;
        tt.oldy=0;
        tt.style.display='block';
        
        Img.onmousemove=ToolTipShowMove;        
        
        Img.old_onmouseover=Img.onmouseover;
        Img.onmouseover=new Function();        
        
        Img.old_onmouseout=Img.onmouseout;
        
        Img.onmouseout=ToolTipHide;
        
    }
    function ToolTipHide()
    {
        document.getElementById("tool_tip").style.display='none';    
        this.onmouseout=this.old_onmouseout;
        try{this.onmouseout();} catch(e){}
        
        this.onmouseover=this.old_onmouseover;            
    }
    function ToolTipImageShow(ImgUrl,HtmlElt)
    {
        var i=document.getElementById("tooltip_image");
        if(i==undefined)
        {
            i=document.createElement('DIV');
            i.id="tooltip_image";
			i.style.positon='absolute';
			i.style.top='0px';
			i.style.left='0px';
            i.style.display='none';
            document.body.appendChild(i);
            var data=document.createElement('IMG');
            i.appendChild(data);
            i.data=data;
        }
        //alert(i.src);
        i.data.src=ImgUrl;
        var Pos=GetElementOffsetPosition(HtmlElt);
        //alert(Pos.offsetTop);
        i.style.top=(Pos.offsetTop-50).toString()+'px';
        i.style.left=(Pos.offsetLeft-200).toString()+'px';
        
        i.style.display='block';
    }
    function GetElementOffsetPosition(Elt)
    {
        var CurX,CurY;
        CurX=0;
        CurY=0;
        var Parent=Elt.parentNode;
        
        //alert(Elt.offsetLeft);
        while(Parent!=undefined)
        {
            //alert(Parent.tagName+"_"+Parent.offsetLeft+" "+Parent.offsetTop);
            //alert(CurY);
            if(Parent.offsetLeft!= undefined) CurX+=Parent.offsetLeft;
            if(Parent.offsetTop!= undefined) CurY+=Parent.offsetTop;
            Parent=Parent.parentNode;
        }
        
        //alert("exit"+CurY);
        var ret=new Object();
        ret.offsetLeft=CurX;
        ret.offsetTop=CurY;
        //alert(CurX+" "+CurY);
        return ret;
    }
    function ToolTipImageHide()
    {
        var i=document.getElementById("tooltip_image");
        if(i) i.style.display='none';
    }
    
    function HideMyCursor()
    {
        var d=document.getElementById("find_cursor");
        if(d != undefined)
        {
            d.style.display='none';
        }
    }
    function ShowMyCursor(Elt)
    {
        var d=document.getElementById("find_cursor");
        if(d == undefined)
        {
            d=document.createElement("DIV");
            d.id="find_cursor";
            d.className="find_cursor";
            d.style.display='none';
            document.body.appendChild(d);
        }      
        d.style.display='block';
        Elt.onmousemove=MyCursorPos;
        Elt.focus();
    }
    function MyCursorPos(e)
    {
        if (!e) var e = window.event;
        var d=document.getElementById("find_cursor");
        d.style.left=(e.clientX+2).toString()+"px";
        
        d.style.top=(e.clientY+2+document.documentElement.scrollTop).toString()+"px";
    }
    
    var OldCatalogId='';
    function ShowCatalog(Id,A)
    {
        if(OldCatalogId==Id) return;
        if(OldCatalogId!='') $(document.getElementById(OldCatalogId)).hide('normal');
        OldCatalogId=Id;
        //document.getElementById(Id).style.display='block';
        $(document.getElementById(Id)).show('normal');
        $('.fast_access .by_assortiment .item').removeClass('active');
        $(A).addClass('active');
    }
    function ByAssortymentMonitor(e)
    {
        if(OldCatalogId=='') return;
        
        var elt=$('.by_assortiment');
        var pos=elt.position();
        //alert(elt.outerWidth()+' '+elt.outerHeight());
        if(e.pageX>=pos.left && e.pageX<=pos.left+elt.outerWidth())
        if(e.pageY>=pos.top && e.pageY<=pos.top+elt.outerHeight())
            return;
        
        
        OldCatalogId='';
        $('.fast_access .by_assortiment .item').removeClass('active');
        $('.fast_access .by_assortiment .hidden_list').hide('normal');
        
    }
    function navigate_to_catigory(Sel)
    {
        if(Sel.selectedIndex!=-1)
        if(Sel.options[Sel.selectedIndex].value!=0)
            location.href='/show_cat/?cat_id='+Sel.options[Sel.selectedIndex].value;    
    }
    $(document).ready(function(){$(document).mousemove(ByAssortymentMonitor);});