if(typeof(myorel)=="undefined"){
  myorel=function(){};
}
////////////////////////////////////////////////////////
// ������� ����div
///////////////////////////////////////////////////////

myorel.bilddiv=function(div){
   this.idDiv=div;
   this.div_obj= new Object;
   this.check=false;

   this.create=function(){
    if (this.check){
	return true;
	}

	 var obj=document.getElementById(this.idDiv);
     if (!obj){
	  alert('id not found '+ this.idDiv);
	  return false;
	 }
	 this.div_obj=obj;
	 this.check=true;
   }

   // ��� ���
   this.insertcode=function(txt){
  	 if (!this.check){
   	 	 this.create();
		 return false;
  	 }
   this.div_obj.innerHTML=txt //myorel.buffer;
   }

   this.view = function (){
    return this.div_obj.innerHTML;
   }
}

doLoad=function(ar, obj){
	var req = new JsHttpRequest();
     // Code automatically called on load finishing.
      req.onreadystatechange = function(o) {
        if (req.readyState == 4) {
          if (req.responseJS.code==0) {

		  }

  		  if (obj!=null)  obj.insertcode(req.responseJS.code);
		  if (req.responseText==''){
		    document.getElementById('debug').innerHTML = req.responseText;

		  }

        }
    }
    // Prepare request object (automatically choose GET or POST).
    req.open(null, '/loader.php', true);
    // Send data to backend.
	req.send (ar);
 }



if(typeof(avto)=="undefined"){
  avto=function(){};
}

avto.form= function(){}


avto.form.list_model=function(brand_id){
  var s_model =new myorel.bilddiv('model');
  s_model.create();
  var ar = {'cmd':'listmodel', 'id':brand_id};
  doLoad(ar, s_model);
}

if(typeof(avto.news)=="undefined"){
  avto.news=function(){};
}

avto.news.holder=Array();

avto.news.view = function(nid){
  var block =new myorel.bilddiv('n'+nid);
    block.create();
    avto.news.holder['n'+nid]=block.view();
    var ar = {'cmd':'viewnews', 'id':nid};
    doLoad(ar, block);
}

avto.news.close = function(nid){
  var block =new myorel.bilddiv('n'+nid);
  block.create();
  // alert( avto.news.holder['n'+nid]);
  block.insertcode(avto.news.holder['n'+nid]);


}


