// Модуль, исправляющий ошибку, связаную с некорректным отображением PNG файлов в IE 6 и ниже
// и содержащий в себе все дополнения к конкретному сайту
function fixPNG()
{
    for(var i = 0; i < document.images.length; i++)
    {
        var img = document.images[i];
        imgSrc = img.src;
        if (imgSrc.substr(imgSrc.length-3).toLowerCase() == "png")
        {
            var w, h;
            w = img.width, h = img.height;
            img.src = "resource/px.gif";
            img.width = w, img.height = h;
            img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'" + imgSrc + "\', SizingMethod='scale');";
        }
    }
}
function fixPNGBackground(id, src)
{
	var obj = document.getElementById(id);
	if(obj)
	{
		obj.style.background = "url(resource/px.gif) repeat left top";
		obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'" + src + "\', SizingMethod='scale');";
		obj.parentNode.style.background = "url(resource/px.gif) repeat left top";
	}
}
function isIE()
{
    return ((navigator.userAgent.indexOf("IE") != -1)&&(navigator.userAgent.indexOf("Opera") == -1));
}
if( isIE() )
{
    window.attachEvent("onload", fixPNG);
}
function isIE6()
{
    return isIE()&&(navigator.userAgent.indexOf("IE 6") != -1);
}
function isFirefox()
{
    return (navigator.userAgent.indexOf("Firefox") != -1);
}
function hide_all_picts()
{
	if( !_opened)
	{
		var obj = document.getElementById("PList");
		if(obj)
		{
			var a = obj.getElementsByTagName("img");
			for(var i=0;i<a.length;i++)
				if(a[i].className == "BigPopImage")
					a[i].style.display = "none";
			_opened = true;
		}
	}
	else{
	_opened = false; }
}
_opened = false;

//прелоудер
var $preloader = 
{
    panel:null,
    progress:null,
    images:null,
    text:null,
    Init:function()
    {
        //Картинки
        //this.images = document.images;
        
        //Панель
        this.panel = document.createElement("div");
        this.panel.className = "Preloader";
        document.body.appendChild(this.panel);
        
        //inner
        var inner = document.createElement("div");
        inner.className = "Inner";
        this.panel.appendChild(inner);
        
        //mask
        var mask = document.createElement("img");
        mask.className = "Mask";
        mask.src = "resource/preloader.gif";
        mask.alt = "Загрузка";
        inner.appendChild(mask);
        
        //progress
        this.progress = document.createElement("div");
        this.progress.className = "Progress";
        inner.appendChild(this.progress);
        
        //text
        this.text = document.createElement("div");
        this.text.className = "Text";
        this.text.innerHTML = "0%";
        inner.appendChild(this.text);
        //this.Cycle();
    },
    ReportProgress:function(proc)
    {
        this.progress.style.width = Number(proc*2)+"px";
        this.text.innerHTML = ""+ proc + "%";
    },
    Start:function()
    {
        this.images = document.images;
        this.Cycle();
    },
    Cycle:function()
    {
        var a = $preloader.Progress();
        $preloader.ReportProgress(a);
        if(Number(a) < 100)
            setTimeout("$preloader.Cycle()", 100); 
        else
            $preloader.Finish(); 
    },
    Progress:function()
    {
        var p = 0;
        for(var i=0; i< $preloader.images.length; i++)
            if($preloader.images[i].complete)
                p++;
        return Math.floor(Number((p/$preloader.images.length)*100));
    },
    Finish:function()
    {
        if(this.panel)
            this.panel.style.display = "none";
    }
}
function body_OnMouseUpHandler(e)
{
    if(!e) e = window.event;
    var target = e.target ? e.target : e.srcElement;
    if(target.tagName.toLocaleLowerCase() != "a")
    {
        var obj = document.getElementById("TopMenu_Pointer");
        if(obj)
            CloseOpenedMenus(obj);
    }
    if(target.tagName.toLocaleLowerCase() != "img")
        CloseOpenedImages();
} 
function CloseOpenedImages()
{
    var images = document.getElementsByTagName("img");
    for(var i=0;i<images.length;i++)
        if(images[i].className != null)
            if(images[i].className == "BigPopImage2")
                images[i].style.display = "none";
}
function body_OnResizeHandler()
{
    var obj = GetOpenedMenuObject();
    if(obj)
        $global.ShowUnderObject(obj, obj.parentNode);
}
function pager(lnk)
{
    var _cont = document.getElementById('NavigationLinks');
    if(_cont)
    {
	    var _arr = $global.GetElementsByTagName(_cont, 'a');
	    for(var i=0;i<_arr.length;i++)
	    {
		    _arr[i].className = 'pager_main_text';
		    document.getElementById('txt_' + _arr[i].id).style.display = 'none';
		}
    }
    lnk.className  = "pager_main_text_a";
    document.getElementById('txt_' + lnk.id).style.display = 'block';
}