function pachete(destDiv,varname){
   var that=this;
   
   this.splitter="";
   
   this.destDiv=document.getElementById(destDiv);
   this.destDiv.style.width=372+"px";
   this.destDiv.style.height=438+"px";
   //this.destDiv.style.background="#FFFF00";
   
   this.maskDiv=document.createElement("div");
   this.maskDiv.style.position="absolute";
   this.maskDiv.style.width=372+"px";
   this.maskDiv.style.height=438+"px";
   this.maskDiv.style.zIndex=3;
   this.maskDiv.style.background="url(imgs/pads/pachete_mask.png)";
   this.destDiv.appendChild(this.maskDiv);
   
   this.underDiv=document.createElement("div");
   this.underDiv.style.position="absolute";
   this.underDiv.style.width=372+"px";
   this.underDiv.style.height=438+"px";
   this.underDiv.style.zIndex=2;
  // this.underDiv.style.background="#00FF00";
   this.destDiv.appendChild(this.underDiv);
   
   this.contentDiv=document.createElement("div");
   this.contentDiv.style.position="absolute";
   this.contentDiv.style.width=372+"px";
   this.contentDiv.style.height=438+"px";
   this.contentDiv.style.zIndex=4;
  // this.contentDiv.style.background="#0000FF";
   this.destDiv.appendChild(this.contentDiv);
 
   
  this.myajax=new ajaxObject("","includes/ajax_db_ops.php",varname+".returFunction");
  var opcode=0;
  
  this.picstoload=new Array();
  this.picsadr=new Array();
  this.picsloaded=new Array();
  
  this.lefts=Array(17,17-68,17-68*2);
  this.tops=Array(143,143+18+68,143+18+68+68+15);
  
  this.divtops=Array(160,250,330);
  this.divlefts=Array(94,94,94);
  
  
  var that=this;
 
  this.returFunction=function(what){
   switch(opcode){
      case 1:
        //alert(what);
           var broken=what.split(this.splitter);
            this.contentDiv.align="left";
             var headerhtml="";
             
             headerhtml+="<div align=\"left\" style=\"position:relative;top:65px;left:0px;width:325px;height:65px\"><font class=\"usual_font\" style=\"text-align:left;font-weight:normal;font-size:13px\">";
  headerhtml+="Ultimele sunt cele mai tentante. Ii lasi pe ceilalti sa le testeze, cumperi exact ce ti se potriveste si te bucuri de reduceri considerabile de pret.";
  headerhtml+="</font></div>";
             
           var pas=0;
           for(var i=0;i<broken.length;i+=4){
              var tmppic=document.createElement("img");
               
               tmppic.onload=function(){
                 //alert("incarcata");
                 this.style.position="relative";
                 this.style.width=68+"px";
                 this.style.height=68+"px";
                 
                 that.checkAllLoaded(this);
               } 
              
                if(broken[i+1]!=""){
                   this.picsadr.push("products/packs/"+broken[i+1]+"_th.jpg");
                }else{
                 this.picsadr.push("products/noimage.jpeg");
                }
                this.picstoload.push(tmppic);
                
                this.underDiv.appendChild(tmppic);
                tmppic.style.top=this.tops[pas]+"px";
                tmppic.style.left=this.lefts[pas]+"px";
                
                 headerhtml+="<div align=\"left\" style=\"position:absolute;top:"+this.divtops[pas]+"px;left:"+this.divlefts[pas]+"px;height;90px;cursor:pointer\" onclick=\"window.location='?cmd=detalii_pachete&id="+broken[i]+"';\"><font text-align=\"left\" style=\"font-family:Arial;font-size:14px;color:#03428e;font-weight:bold\">";
                headerhtml+=broken[i+2];
                headerhtml+="</font>";
                headerhtml+="<br><font text-align=\"left\" style=\"font-family:Arial;font-size:14px;color:#e33528;font-weight:bold\">"+formatNumber(broken[i+3])+"</font>";
                headerhtml+="</div>";
                
                  pas++;
           
           }
           
            headerhtml+="<div align=\"left\" style=\"position:relative;top:335px;left:25px;height;65px\"><font text-align=\"left\" style=\"font-family:Arial;font-size:14px;color:#b80a32;font-weight:bold;cursor:pointer\" onclick=\"window.location='?cmd=pachete'\">";
                headerhtml+="+ Vezi toate pachetele";
                headerhtml+="</font>";
                
                headerhtml+="</div>";
           
           
           this.contentDiv.align="center";
           this.contentDiv.innerHTML=headerhtml;
           
           this.startLoading();
      break;
      
      case 2:
      this.splitter=what;
        opcode=1;
        this.myajax.setDataToSend("op=get_packs");
        this.myajax.sendData();
      break;
      
   }
  }
  
   this.checkAllLoaded=function(who){ // nu prea mai e nevoie de functia asta....
    var care=-1;
    for(var i=0;i<this.picstoload.length;i++){
       if(this.picstoload[i]==who){
         care=i;
       }
    }
    if(care!=-1){
       
       this.picsloaded[care]=true;
    }
    this.ok=true;
    for(var i=0;i<this.picsloaded.length;i++){
      if(!this.picsloaded[i]){ this.ok=false;}
    }
    if(this.ok){
      //alert("gata");
     // this.destPad.redraw();
    }
  }
  
  this.startLoading=function(){
     for(var i=0;i<this.picstoload.length;i++){
        this.picsloaded[i]=false;
        
     }
     for(var i=0;i<this.picstoload.length;i++){
        this.picstoload[i].src=this.picsadr[i];
     }
  }
  
 
 
 /*
 this.startLoading=function(){
     for(var i=0;i<this.picstoload.length;i++){
        this.picsloaded[i]=false;
        
     }
     for(var i=0;i<this.picstoload.length;i++){
        this.picstoload[i].src=this.picsadr[i];
     }
  }
  
  
   this.destPad=destPad;
   var that=this;
  
  this.lefts=Array(17,17-68,17-68*2);
  this.tops=Array(143,143+18+68,143+18+68+68+15);
  
  this.divtops=Array(60,115,160);
  this.divlefts=Array(94,94,94);
  
  
  
 
  
 

  

  //---------------------methods------------------------
  
  
  this.checkAllLoaded=function(who){
    var care=-1;
    for(var i=0;i<this.picstoload.length;i++){
       if(this.picstoload[i]==who){
         care=i;
       }
    }
    if(care!=-1){
       
       this.picsloaded[care]=true;
    }
    this.ok=true;
    for(var i=0;i<this.picsloaded.length;i++){
      if(!this.picsloaded[i]){ this.ok=false;}
    }
    if(this.ok){
      //alert("gata");
      this.destPad.redraw();
    }
  }
  
  
  

 this.returFunction=function(what){
   switch(opcode){
      case 1:
           // alert(what);
           //destPad.underdiv.style.zIndex=10;
            var broken=what.split(";");
            this.destPad.contentDiv.align="left";
             var headerhtml="";
             headerhtml+="<div align=\"left\" style=\"position:relative;top:14px;left:15px\"><font class=\"usual_font\" text-align=\"left\">";
  headerhtml+="Ultimele sunt cele mai tentante. Îi latesteze, cumperi exact ce reduceri considerabile de pret.";
  headerhtml+="</font></div>";
             
           var pas=0;
           for(var i=0;i<broken.length;i+=4){
              var tmppic=document.createElement("img");
               
               tmppic.onload=function(){
                 //alert("incarcata");
                 this.style.position="relative";
                 this.style.width=68+"px";
                 this.style.height=68+"px";
                 that.destPad.redraw();
                 that.checkAllLoaded(this);
               } 
               
                if(broken[i+1]!=""){
                   this.picsadr.push("products/packs/"+broken[i+1]+"_th.jpg");
                }else{
                this.picsadr.push("products/noimage.jpeg");
                }
                this.picstoload.push(tmppic);
                this.destPad.underdiv.appendChild(tmppic);
                tmppic.style.top=this.tops[pas]+"px";
                tmppic.style.left=this.lefts[pas]+"px";
               
                
                
                 
             /*   headerhtml+="<div align=\"left\" style=\"position:relative;top:"+this.divtops[pas]+"px;left:"+this.divlefts[pas]+"px;height;68px;cursor:pointer\" onclick=\"window.location='?cmd=detalii_pachete&id="+broken[i]+"';\"><font text-align=\"left\" style=\"font-family:Arial;font-size:14px;color:#03428e;font-weight:bold\">";
                headerhtml+=broken[i+2];
                headerhtml+="</font>";
                headerhtml+="<br><font text-align=\"left\" style=\"font-family:Arial;font-size:14px;color:#e33528;font-weight:bold\">"+broken[i+3]+"</font>";
                headerhtml+="</div>";*/
                
           /*     
                pas++;
           
           }
           
            headerhtml+="<div align=\"left\" style=\"position:relative;top:200px;left:30px;height;68px\"><font text-align=\"left\" style=\"font-family:Arial;font-size:14px;color:#b80a32;font-weight:bold;cursor:pointer\" onclick=\"window.location='?cmd=pachete'\">";
                headerhtml+="+ Vezi toate pachetele";
                headerhtml+="</font>";
                
                headerhtml+="</div>";
           
           
           this.destPad.contentDiv.align="center";
           this.destPad.contentDiv.innerHTML=headerhtml;
           
           this.startLoading();
           
           /*
           this.mypic1=document.createElement("img");
          
           this.mypic1.onload=function(){
             this.style.width=68+"px";
             this.style.height=68+"px";
             this.style.left="17px";
             this.style.top="143px";
             this.style.position="relative";
             that.checkAllLoaded(this);
           }
           this.picstoload.push(this.mypic1);
           this.picsadr.push("products/trans/"+broken[0]+"_th.jpg");
          
           
           this.mypic2=document.createElement("img");
           this.mypic2.onload=function(){
             this.style.width=68+"px";
             this.style.height=68+"px";
             this.style.left=(17-68)+"px";
             this.style.top=(143+18+68)+"px";
             this.style.position="relative";
             that.checkAllLoaded(this);
           }
           this.picstoload.push(this.mypic2);
           this.picsadr.push("products/trans/"+broken[3]+"_th.jpg");
          
           
           this.mypic3=document.createElement("img");
           this.mypic3.onload=function(){
             this.style.width=68+"px";
             this.style.height=68+"px";
             this.style.left=(17-68*2)+"px";
             this.style.top=(143+18+68+68+15)+"px";
             this.style.position="relative";
             that.checkAllLoaded(this);
           }
           this.picstoload.push(this.mypic3);
           this.picsadr.push("products/trans/"+broken[6]+"_th.jpg");
          
           
           this.destPad.underdiv.appendChild(this.mypic1);
           this.destPad.underdiv.appendChild(this.mypic2);
           this.destPad.underdiv.appendChild(this.mypic3);
           
           
           
           
           var headerhtml="";
  headerhtml+="<div align=\"left\" style=\"position:relative;top:14px;left:15px\"><font text-align=\"left\">";
  headerhtml+="Ultimele sunt cele mai tentante. Îi latesteze, cumperi exact ce reduceri considerabile de pret.";
  headerhtml+="</font></div>";
  
  headerhtml+="<div align=\"left\" style=\"position:relative;top:50px;left:94px;height;68px\"><font text-align=\"left\" style=\"font-family:Arial;font-size:14px;color:#03428e;font-weight:bold\">";
  headerhtml+=broken[1];
  headerhtml+="</font>";
  headerhtml+="<br><font text-align=\"left\" style=\"font-family:Arial;font-size:14px;color:#e33528;font-weight:bold\">"+broken[2]+"</font>";
  headerhtml+="</div>";
  
  headerhtml+="<div align=\"left\" style=\"position:relative;top:100px;left:94px;height;68px\"><font text-align=\"left\" style=\"font-family:Arial;font-size:14px;color:#03428e;font-weight:bold\">";
  headerhtml+=broken[4];
  headerhtml+="</font>";
  headerhtml+="<br><font text-align=\"left\" style=\"font-family:Arial;font-size:14px;color:#e33528;font-weight:bold\">"+broken[2]+"</font>";
  headerhtml+="</div>";
  
  headerhtml+="<div align=\"left\" style=\"position:relative;top:140px;left:94px;height;68px\"><font text-align=\"left\" style=\"font-family:Arial;font-size:14px;color:#03428e;font-weight:bold\">";
  headerhtml+=broken[7];
  headerhtml+="</font>";
  headerhtml+="<br><font text-align=\"left\" style=\"font-family:Arial;font-size:14px;color:#e33528;font-weight:bold\">"+broken[2]+"</font>";
  headerhtml+="</div>";
  
  
  this.destPad.contentDiv.align="center";
   this.destPad.contentDiv.innerHTML=headerhtml;
  
  this.startLoading();
  //destPad.redraw();
       */   
     /*              
      break;
   }
 }
 
 
 
 //-------------------------------constructor---------------------------------
 
    
  
  
 */ 
  opcode=2;
  this.myajax.setDataToSend("op=getsplitter");
  this.myajax.sendData();
 
  
}

