
//--------------------------------
//********************************
//******** Class button***********
//********************************
//--------------------------------


//********************************
//********* Constructors *********
//********************************
function pan_button()
{
  
}

function owk_pan_button_create(i_parent,i_region,i_visible,i_dragable)
{
   this.set_parent(i_parent);
   this.ancestor_create(i_region,i_visible,false, i_dragable);  
   i_parent.push_back_layer(this);
}


function owk_pan_button_load_patterns(i_url)
{
   this.m_top = new button();
   this.m_left = new button();
   this.m_right = new button();
   this.m_bottom = new button();
   
   this.m_top.set_parent(this);
   this.m_left.set_parent(this);
   this.m_right.set_parent(this);
   this.m_bottom.set_parent(this); 
   
   var xmlDoc = null;   

   if (window.ActiveXObject)
   {
      xmlDoc = new ActiveXObject("Microsoft.XMLDOM");          
   }
   else if (document.implementation.createDocument)
   {     
      xmlDoc = document.implementation.createDocument("","",null);      
   }

   xmlDoc.async=false;
  
   xmlDoc.load(i_url+ "top/info.xml"); 
   var x=xmlDoc.getElementsByTagName("image_size");

   var top_width = x[0].getElementsByTagName("width")[0].childNodes[0].nodeValue;
   var top_height = x[0].getElementsByTagName("height")[0].childNodes[0].nodeValue;

   xmlDoc.load(i_url+ "left/info.xml"); 
   x=xmlDoc.getElementsByTagName("image_size");
   var left_width = x[0].getElementsByTagName("width")[0].childNodes[0].nodeValue;
   var left_height = x[0].getElementsByTagName("height")[0].childNodes[0].nodeValue;

   xmlDoc.load(i_url+ "right/info.xml"); 
   x=xmlDoc.getElementsByTagName("image_size");
   var right_width = x[0].getElementsByTagName("width")[0].childNodes[0].nodeValue;
   var right_height = x[0].getElementsByTagName("height")[0].childNodes[0].nodeValue;

   xmlDoc.load(i_url+ "bottom/info.xml"); 
   x=xmlDoc.getElementsByTagName("image_size");
   var bottom_width = x[0].getElementsByTagName("width")[0].childNodes[0].nodeValue;
   var bottom_height = x[0].getElementsByTagName("height")[0].childNodes[0].nodeValue;

   //Create the 4 button
   this.m_top.create(this, new rectangle(0, 0, top_width*1, top_height*1), true, "");
   this.m_left.create(this, new rectangle(0, top_height*1, left_width*1, top_height*1+left_height*1), true, "");       
   this.m_right.create(this,new rectangle(left_width*1, top_height*1, left_width*1+right_width*1, top_height*1+right_height*1), true, "");         
   this.m_bottom.create(this, new rectangle(0, top_height*1+left_height*1, bottom_width*1, top_height*1+left_height*1+bottom_height*1), true, false, false);       
  
   //Resizer le layer
   //this.region().set_right(this.region().left()*1 + bottom_width*1);
   //this.region().set_bottom(this.region().left()*1 + top_height*1+left_height*1+bottom_height*1+5);
   //this.set_region(this.region());    
  
   this.m_top.load_patterns(i_url + "/top/", true, false, false);   
   this.m_left.load_patterns(i_url + "/left/", true, false, false);   
   this.m_right.load_patterns(i_url + "/right/", true, false, false);  
   this.m_bottom.load_patterns(i_url + "/bottom/", true, false, false);   
}

function owk_pan_button_button_top()
{
   return this.m_top;
}

function owk_pan_button_button_bottom()
{
   return this.m_bottom;
}

function owk_pan_button_button_left()
{
   return this.m_left;
}

function owk_pan_button_button_right()
{
   return this.m_right;
}


pan_button.prototype = new layer_group;
pan_button.prototype.load_patterns = owk_pan_button_load_patterns;
pan_button.prototype.create = owk_pan_button_create;
pan_button.prototype.ancestor_create = owk_layer_create;
pan_button.prototype.button_top = owk_pan_button_button_top;
pan_button.prototype.button_bottom = owk_pan_button_button_bottom;
pan_button.prototype.button_left = owk_pan_button_button_left;
pan_button.prototype.button_right = owk_pan_button_button_right;
