  /*Вспомогательные функции*/   
   //MIME-тип картинки по названию файла
   function getImgType(src)
    {
	  if (src.indexOf(".") > 0)
	   {
	     tmp_type = src.split(".");
	     return tmp_type[tmp_type.length-1]; 
	   }   
	}
	
	//Определение браузера пользователя
	function detectBrowser()
	 {
	  ua = navigator.userAgent.toLowerCase();
	  if ((ua.indexOf('msie 5.5')>-1 || ua.indexOf('msie 6.')>-1) && ua.indexOf('opera')==-1)
	    return "IE";
	      else if (ua.indexOf('opera')>-1)
		    return "OPERA";
			  else if (ua.indexOf('firefox')>-1)
		        return "FIREFOX";
	 }
	 
	//Загрузка изображения
	function imageLoaded()
	 {
	   layer_obj = eval(this.layer_name);
	   layer_obj.setComplete();
	 } 
	 
	//Загрузка фильтра AlphaImageLoader
	function filterChanged()
	 { 
	   if (!this.loadstat)
	    {
		 this.loadstat = 1;
		 
		 sobj_id = this.id.replace("_tmploaded", "");
		 sobj = document.getElementById(sobj_id);
		 this.width = sobj.width;
		 this.height = sobj.height;		 
		 sobj.replaceNode(this);
		 
		 sobj = document.getElementById(sobj_id+"_tmploaded");
		 sobj.setAttribute("id", sobj_id);
		 
	     layer_obj = eval(this.layer_name);
	     layer_obj.setComplete();
		}
	 } 	 
  /*************************/
  
     
  /*Описание слоя загружаемых объектов*/
  function imgLayer(name, load_type)
   {
     this.name = name;          //название слоя
	 this.idarr = new Array();  //массив идентификаторов
	 this.loadtype = load_type; //способ загрузки: true - налету, false - после всего документа 
	 this.elcount = 0;          //количество загружаемых элементов
	 
	 	 
	 this.addImages = function(arr)
	  {
	    ua_type = detectBrowser();
		if (ua_type == "FIREFOX") this.loadtype = true;
	  
	    this.elcount = arr.length;
		this.idarr = arr;
		
		to_top = true;
		
	    for (i=0; i<arr.length; i++)
	     {
		   c_obj = document.getElementById(arr[i]);
		   if (c_obj != null && c_obj.tagName=="IMG")
		    {
		      c_obj.layer_name = this.name;
			  c_obj.style.visibility = "hidden";
			  
			  if (getImgType(c_obj.src) != "png" || ua_type != "IE")
			   {
			      if (this.loadtype)
				   {
					  if (!c_obj.complete)
					   {
					     c_obj.onload = imageLoaded;
					   }
					   else
					      this.setComplete();
				   }	  
			    }
				else
				 {  
				    if (this.loadtype)
					 {		
					    if (to_top)
						 {
						    document.getElementById("load_cont").scrollIntoView(true);
							to_top = false;
						 }
					 		   
						new_img = document.createElement("IMG");
						new_img.setAttribute("src", "images/1x1.gif");
                        new_img.setAttribute("id", c_obj.id+"_tmploaded");
						new_img.setAttribute("width", "1");
						new_img.setAttribute("height", "1");
						new_img.setAttribute("layer_name", this.name);
                        document.getElementById("load_cont").appendChild(new_img);
						
						new_img.onfilterchange = filterChanged;
						new_img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + c_obj.src + "',sizingMethod='scale')";
					  }		  									 
				 }
		    }
			else
			  this.elcount--;
		 }
		 
		if (!this.loadtype)
		 {
		  document.body.layer_name = this.name;
		  document.body.onload = function()
		   {
		    layer_obj = eval(document.body.layer_name);
	        layer_obj.setCompleteBody();
		   }
		 }   
	  }
	  
	 this.setComplete = function()
	  {
	   this.elcount--;
	   if (this.elcount == 0)
	     for (i=0; i<this.idarr.length; i++)
		  {
		   c_obj = document.getElementById(this.idarr[i]);
		   c_obj.style.visibility = "visible";
		  }
	  }
	  
	 this.setCompleteBody = function()
	  {
	    for (i=0; i<this.idarr.length; i++)
		  {
		   c_obj = document.getElementById(this.idarr[i]);
		   c_obj.style.visibility = "visible";
		  }
	  }   
   }	 
  /*************************/ 
     
