document.observe("dom:loaded", function() {    
  categoryDescription();                
  
     
});            

function toggleBio(item) {
  $('category-description').toggle();          
  if($('category-description').visible()) {
    item.update("Hide biography &gt;");
  } else {
    item.update("Designer biography &gt;");
  }                               
  
}    

function elementToList(e) {
  
  la = $("list" + e.id)
  html = ""
  for(var i = 0; i < e.options.length; i++) {
    if(e.options[i].value != "") {
      html += "<a href=\"#\" class=\"attr_link\" onclick=\"chooseElement(this,'" + e.id + "','" + e.options[i].value + "'); return false;\">" + e.options[i].innerHTML + "</a>"
    }
  }
  la.update(html)
}

function chooseElement(link,element,value) {
  e = $(element)
  la = $("list" + element)
  alinks = la.descendants();
  for(var j = 0; j < alinks.length; j++) {
    alinks[j].removeClassName("on");
  }

  link.addClassName("on");
  
  for(var i = 0; i < e.options.length; i++) {
    if(e.options[i].value == value) {
      $(element).selectedIndex = i;
      e.simulate('change');
    }
  }
  
}
     

function categoryDescription() {
  var i = 0   
  var category_ps = $$('div.category-description > p');
  var left_col = '<div class="left">';
  var right_col = '<div class="right">';        
   
  if(category_ps.size() > 0) {
    category_ps.each(function(e) { 
     if(i < (category_ps.size() / 2)) {      
       left_col += "<p>" + e.innerHTML + "</p>";    
     } else {            
       right_col += "<p>" + e.innerHTML + "</p>";
     } 
     i += 1;                                     
    }); 
  
    left_col += "</div>"
    right_col += "</div>"                                  
    $("category-description").update(left_col + " " + right_col);     
  }    
}                  

function setImage(i,src,big) {
  $$(".image_link").each(function(e) { $(e).hide(); });
  $("image_link_" + i).show();
  // $('image').writeAttribute('src',src);  
	$("image").replace('<img id="image" src="' + src + '" />');
  $('image_link').writeAttribute('href',big);


	

  // $('handle').style.left = "0px";
  return false;
}            

function addQty(id) {                          
  new_qty = parseInt($F("cart_" + id + "_qty"));
  new_qty = new_qty + 1;   
  updateQty(id,new_qty);

}  

function lessQty(id) {                          
  new_qty = parseInt($F("cart_" + id + "_qty"));
  new_qty = new_qty - 1;        
  if(new_qty < 1) new_qty = 0;    
  updateQty(id,new_qty);

}

function updateQty(id,new_qty) {
  $("cart_" + id + "_qty").value = new_qty;
  $("cart_" + id + "_qty_box").update(new_qty);
  $("cart_" + id + "_price").update('<a href="#" onclick="return basketForm.submit();">Update</a>')  
  $("total-footer").addClassName("fade");     
  $("prompt-update").show()
}