//Եsettergetter
Element.Properties = new Hash;

/*
stylegettersetter
ʹelement.set('style', value)ֵ
*/
Element.Properties.style = {

 set: function(style){
  this.style.cssText = style;
 },

 get: function(){
  return this.style.cssText;
 },

 erase: function(){
  this.style.cssText = '';
 }

};

/*
ǩgetterעûsetterֻԣ磺
element.get('tag');
*/
Element.Properties.tag = {get: function(){
 return this.tagName.toLowerCase();
}};

/*
Ahrefgetter
Ȼûsetterֻ
ΪԣԿֱ element.set('href', value)
֮ԵдΪĬȡhrefֵص·͹ľԵַ
ͨҪԭֵ
*/
Element.Properties.href = {get: function(){
 return (!this.href) ? null : this.href.replace(new RegExp('^' + document.location.protocol + '\/\/' + document.location.host), '');
}};

//innerHTMLĿݷʽֿ֧ɱܱⳤַ
Element.Properties.html = {set: function(){
 return this.innerHTML = Array.flatten(arguments).join('');
}};

//ΪElementWindowDocumentչʵ
Native.implement([Element, Window, Document], {

 //¼
 addListener: function(type, fn){
  if (this.addEventListener) this.addEventListener(type, fn, false);
  else this.attachEvent('on' + type, fn);
  return this;
 },

 //Ƴ¼
 removeListener: function(type, fn){
  if (this.removeEventListener) this.removeEventListener(type, fn, false);
  else this.detachEvent('on' + type, fn);
  return this;
 },

 //ȡѱʱʵ󲻴ڣָdflt(ṩ˲)
 retrieve: function(property, dflt){
  var storage = Element.Storage.get(this.uid);
  var prop = storage[property];
  if ($defined(dflt) && !$defined(prop)) prop = storage[property] = dflt;
  return $pick(prop);
 },

 //ʱ
 store: function(property, value){
  var storage = Element.Storage.get(this.uid);
  storage[property] = value;
  return this;
 },

 //ɾʱ
 eliminate: function(property){
  var storage = Element.Storage.get(this.uid);
  delete storage[property];
  return this;
 }

});

//Elementļԣֻزĵ׼͵ִемӹԷ𴦵ĵ
Element.Attributes = new Hash({
 Props: {'html': 'innerHTML', 'class': 'className', 'for': 'htmlFor', 'text': (Browser.Engine.trident) ? 'innerText' : 'textContent'},
 Bools: ['compact', 'nowrap', 'ismap', 'declare', 'noshade', 'checked', 'disabled', 'readonly', 'multiple', 'selected', 'noresize', 'defer'],
 Camels: ['value', 'accessKey', 'cellPadding', 'cellSpacing', 'colSpan', 'frameBorder', 'maxLength', 'readOnly', 'rowSpan', 'tabIndex', 'useMap']
});

//Elementļӹ
(function(EA){

 var EAB = EA.Bools, EAC = EA.Camels;
 //BoolsתPropsĸʽ
 EA.Bools = EAB = EAB.associate(EAB);
 //CamelsתPropsĸʽϲProps
 Hash.extend(Hash.combine(EA.Props, EAB), EAC.associate(EAC.map(function(v){
  return v.toLowerCase();
 })));
 //ɾCamels
 EA.erase('Camels');

})(Element.Attributes);

