function ContentLoaderClass(URL,HTTP_GPC,target_place,http_method,callback_function,callback_object,progress_dialog,callback_start_loading,callback_stop_loading)
{                       
         this.URL = URL;
         this.target_place = target_place;
         this.target_object =  document.getElementById(this.target_place);
         this.callback_function = callback_function;
         this.callback_object = callback_object;
         this.progress_dialog = progress_dialog;
         this.callback_start_loading = callback_start_loading;
         this.callback_stop_loading = callback_stop_loading;

         if(!this.target_object &&  !this.callback_object && !this.callback_function)
                             return null;
         this.HTTP_GPC = HTTP_GPC;  
         this.HTTP_METHOD = arguments[3]?arguments[3]:"GET";
         
            this.xmlReq = null;
            if(window.XMLHttpRequest)
            this.xmlReq = new XMLHttpRequest();
            else 
            if(window.ActiveXObject)
             this.xmlReq = new ActiveXObject("Microsoft.XMLHTTP");

            if(this.xmlReq==null)
             return;

//             window["xmlReq"+creationtime] = this.xmlReq;

this.stop = function()
{
/*
if(this.xmlReq.readyState > 1) 
{
}
*/
this.xmlReq.abort();
}

this.handleResponse =   function()
    {
        switch(this.readyState)
        {
        case 0: // Uninitialized  
            if(typeof(this.progress_dialog) == "object")        
this.progress_dialog.show({type:"modeless",start_width:300,start_height:200,result_width:300,result_height:200}); 

  //this.target_object.innerHTML='<center><img src="http://www.iural.ru/pict/ajaxloader.gif"></center>';

            break;
        case 1: // Loading
            break;
        case 2: // Loaded
            break;
        case 3: // Interactive
            break;
        case 4: // Done!
        {
        // if(this.status == 200)
        // {
         if(this.parent)
         {
         if(typeof(this.parent.callback_stop_loading)=="function")
         {
         this.parent.callback_stop_loading(this.status);
         }        
            if(this.parent.callback_function)
            {
            this.parent.callback_function(this,this.parent.target_object);
            }else
            if (this.parent.callback_object)
            this.parent.callback_object.handleResponse(this,this.parent.target_object,this.parent.callback_object);
            else
            if (this.parent.target_object)
            this.parent.target_object.innerHTML = this.responseText;
         }// if parent
         //} // f status 200  
         
        }
            break;
        default:
            break;
        }// switch readyState
    } //end of handleResponse  
    
this.handleResponse_ms =   function()
    {
        switch(self.xmlReq.readyState)
        {
        case 0: // Uninitialized          
            break;
        case 1: // Loading
            break;
        case 2: // Loaded
            break;
        case 3: // Interactive
            break;
        case 4: // Done!
        if(typeof(self.callback_stop_loading)=="function")
         {
         self.callback_stop_loading(self.xmlReq.status);
         }        
            if (self.callback_function)
            {
            self.callback_function(self.xmlReq,self.target_object);
            }else
            if (self.callback_object)
            {
            self.callback_object.handleResponse(self.xmlReq,self.target_object,self.callback_object);
            }
            else
            if (self.target_object)
            {
            self.target_object.innerHTML = self.xmlReq.responseText;
            }
            break;
        default:
            break;
        }
    }  // end of handleResponse_ms
            
            try{
            this.xmlReq.parent = this;
            this.xmlReq.onreadystatechange =  this.handleResponse;
            }catch(err)
            {
            this.xmlReq.onreadystatechange =  this.handleResponse_ms;
            var self = this;
            }
      //if(this.target_object)
      //this.target_object.innerHTML='<center><img src="http://www.iural.ru/pict/ajaxloader.gif"></center>';
    // Make the request
    
    
    if(this.HTTP_METHOD == "GET")
      {
        this.xmlReq.open ("GET", this.URL+"?"+this.HTTP_GPC, true);
        this.xmlReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        this.xmlReq.setRequestHeader("Content-length", this.HTTP_GPC.length);
        this.xmlReq.setRequestHeader("Connection", "close");
        this.xmlReq.send(null);
       }  
    if(this.HTTP_METHOD == "POST")
      {
        this.xmlReq.open ("POST", this.URL, true);
        this.xmlReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        this.xmlReq.setRequestHeader("Content-length", this.HTTP_GPC.length);
        this.xmlReq.setRequestHeader("Connection", "close");
        this.xmlReq.send(this.HTTP_GPC);
       }  
    if(typeof(this.callback_start_loading)=="function")
    {
      this.callback_start_loading();
    }
       
}   // end of contentloaderclass


function ContentScrollerClass(URL,HTTP_GPC,target_place,splitter,delay)
{
         this.URL = URL;
         this.target_place = target_place;
         this.format = 1; 
         this.HTTP_GPC = HTTP_GPC;  
         this.splitter = splitter;
         this.step_count = 60;
         this.delay = delay/this.step_count;
         this.current = 0;
         this.step = 0;
         this.content_array = Array();
         this.content = null;
         this.target_object = document.getElementById(this.target_place);
         if(!this.target_object)return null;
         this.current_interface = 1;     // closed status
        // Create the XML request 
           this.xmlReq = null;
            if(window.XMLHttpRequest) this.xmlReq = new XMLHttpRequest();
            else if(window.ActiveXObject) this.xmlReq = new ActiveXObject("Microsoft.XMLHTTP");
            if(this.xmlReq==null)
            {
            alert("error:"+this.URL);
             return; // Failed to create the request
            }
      
      var self = this;
    this.handleResponse = function()
    {
        switch(self.xmlReq.readyState)
        {
        case 0: // Uninitialized
            break;
        case 1: // Loading
            break;
        case 2: // Loaded
            break;
        case 3: // Interactive
            break;
        case 4: // Done!
        // Retrieve the data between the <quote> tags
        self.content = self.xmlReq.responseText;
         self.prepare_content();
            break;
        default:
            break;
        }
    }
 this.onmouseover = function(event)
 {
 if(self.timerid)
 {
    clearInterval(self.timerid);
 }
 var a = new InfoBubble("bebebe",event.x,event.y);
 }
 
 this.onmouseout = function()
 {
   var current = self.current>0? self.current-1:0;
   self.target_object.innerHTML = self.content_array[self.current];
   self.timerid = setInterval(self.timerCallback,self.delay);
 }
 
 this.onclick = function()
 {
 if(self.current_interface ==1)
 {
 self.current_interface = 2;// opened status
 if(self.timerid)
 {
    clearInterval(self.timerid);
 }
 self.target_object.style.overflow = "visible";
 self.target_object.style.height = "auto";
 self.target_object.innerHTML = "<h2>Для закрытия списка нажмите мышь.</h2>"+self.content;
 var anchor = self.content_array[self.current].match("<a name=\"([^\"]*)\".*");
 if(anchor)
 {
 //document.getElementById(anchor[1]).focus();
  window.open("#"+anchor[1],"_self");
   }          
   
   
 }// if closed status
else 
 if(self.current_interface ==2)
 {
 self.current_interface = 1;// closed status
 self.target_object.style.overflow = "hidden";
self.target_object.style.height = "60px";
   self.target_object.innerHTML = self.content_array[self.current];
   self.timerid = setInterval(self.timerCallback,self.delay);
 }// if opened status
 
 }// on click end
 
 this.prepare_content = function()
   {
    self.content_array = self.content.split(self.splitter);
    self.current = Math.round(Math.random()*(self.content_array.length-1));
    //self.target_object.onmouseover = self.onmouseover;
    //self.target_object.onmouseout = self.onmouseout;
    ///self.target_object.onclick = self.onclick;
    self.timerid = setInterval(self.timerCallback,self.delay);
   }
 
   this.timerCallback = function()
   {
        if(self.step == 0)
        {                
                self.target_object.innerHTML = self.content_array[self.current];
                if(self.content_array.length <= ++self.current)self.current = 0;
                self.step++;
        }
        else
        {
        self.step++;
           if(self.step >= self.step_count)
            {
               self.step = 0;
            }
           
           if(self.step > self.step_count/2) 
           self.target_object.innerHTML = "<br style='line-height:2px;'>"+self.target_object.innerHTML;
           
        }       
   }

   
        self.xmlReq.onreadystatechange =  self.handleResponse;
        
    // Make the request
   self.xmlReq.open ('GET', this.URL+"?"+this.HTTP_GPC, true);
  self.xmlReq.send(this.HTTP_GPC);
   
}                                            

function loadContentForSection(section_id)
{
var catalog_section = null; 
if(catalog_section = document.getElementById("catalog_section_"+section_id))
{      
if (LAST_OPEN_MENU)
LAST_OPEN_MENU.style.display ="none";

    if(!catalog_section.innerHTML.length)
    {             
       var section_result = new ContentLoaderClass("http://www.iural.ru/js/catalog_section.php","sec="+section_id,"catalog_section_"+section_id);
    }     
         if(!catalog_section.onmouseout)  
           catalog_section.onmouseout = function()
             {
               catalog_section.style.display ="none";
             }
             
      if(!document.getElementById("section_container_"+section_id).onmouseout)
      document.getElementById("section_container_"+section_id).onmouseout = function()
      {
         catalog_section.style.display = "none";
      } 
    catalog_section.style.display ="block";
    LAST_OPEN_MENU = catalog_section;
}
}
function loadMenuForFirm(firm_info)
{
var firm_menu = null; 
if(firm_menu = document.getElementById("firm_menu_"+firm_info))
{      

if (LAST_OPEN_MENU)
LAST_OPEN_MENU.style.display ="none";

if(!firm_menu.innerHTML.length)
    {             
   var section_result = new ContentLoaderClass("http://www.iural.ru/js/firm_menu.php","firm="+firm_info,"firm_menu_"+firm_info);
    }     
         if(!firm_menu.onmouseout)  
           firm_menu.onmouseout = function()
             {
               if(this.mo)firm_menu.style.display ="none";
             }

         if(!firm_menu.onmouseover)  
           firm_menu.onmouseover = function()
             {
              this.mo = 1;
         firm_menu.style.display = "block";
             }

         if(!firm_menu.onclick)  
           firm_menu.onclick = function()
             {
                firm_menu.style.display ="none";
             }
       
      if(!document.getElementById("firm_container_"+firm_info).onmouseout)
      document.getElementById("firm_container_"+firm_info).onmouseout = function()
      {
         firm_menu.style.display = "none";
     };       
     firm_menu.mo = 0;
     firm_menu.style.display ="block";
//     var tmp = document.getElementById("extended_search_result");
//     if(typeof(tmp) == "object")
//     {
     var tmp2 = document.getElementById("firm_container_"+firm_info);
if(!window.ActiveXObject)
{      
     firm_menu.style.top = tmp2.offsetTop+"px";
     firm_menu.style.left = tmp2.offsetLeft+"px";
}    
else
{
 firm_menu.style.left = tmp2.offsetLeft+"px";
} 
//     }
      LAST_OPEN_MENU = firm_menu;
}
}

var LAST_OPEN_MENU = 0;
