
var DomHighlight = Class.create({
	initialize: function() {
		this._highlightColor = null;
		this._domRef = null;
	},
	getHighlightColor: function()
	{
		return this._highlightColor;
	},
	setHighlightColor: function(val)
	{
		this._highlightColor = val;
	},
	getDomRef: function()
	{
		return this._domRef;
	},
	setDomRef: function(val)
	{
		this._domRef = val;
	},
	highlight: function()
	{
		this._domRef.setStyle({color:this._highlightColor});
	}
});
var DomDrag = Class.create({
	initialize: function(){
		this._domRef = null;
		this._target = null;
		this._x = null;
		this._y = null;
		this._diffX = null;
		this._diffY = null;
	},
	getDomRef: function(){
		return this._domRef;
	},
	setDomRef: function(val){
		this._domRef = val;
	},
	getTarget: function(){
		return this._target;
	},
	setTarget: function(val){
		this._target = val;
	},
	getX: function(){
		return this._x;
	},
	getY: function(){
		return this._y;
	},
	initListeners: function(){
	  var parObj = this;
	  this._domRef.observe('mousedown', function(event){
		//document.fire('calendarData:onCalendarHeadMouseDown', {name:parObj._name});
		var mouseX = Event.pointerX(event);
		var mouseY = Event.pointerY(event);
		var t = Element.cumulativeOffset(parObj._target.getDomRef());
		var divX = t[0];
		var divY = t[1];
		parObj._diffX = mouseX - divX;
		parObj._diffY = mouseY - divY + 2;
		parObj.startDrag();
	  });
	  window.document.observe('mouseup', function(event){
		parObj.stopDrag();
		//document.fire('calendarData:onCalendarHeadMouseUp', {name:parObj._name});
	  });
	},
	startDrag: function(){
	  var parObj = this;
	  window.document.body.style.MozUserSelect = "none";
	  window.document.observe('selectstart', function(event){
	  	return false;
	  });
	  window.document.observe('mousedown', function(event){
	  	return false;
	  });
	  window.document.observe('mousemove', function(event){
	  	var mousex = Event.pointerX(event);
	  	var mousey = Event.pointerY(event);
		parObj._target.setX((mousex - parObj._diffX));
		parObj._target.setY((mousey - parObj._diffY));
		//document.fire('DomDrag:onDrag', {target:parObj._domRef, x:parObj._x, y:parObj._y});
	  });
	},
	stopDrag: function(){
	  window.document.body.style.MozUserSelect = "text";
	  window.document.stopObserving('mousemove');
	  window.document.stopObserving('mousedown');
	}
});
var DomDiv = Class.create({
	initialize: function() {
	  this._domRef = null;
	  this._id = null;
	  this._x = 0;
	  this._y = 0;
	  this._width = 0;
	  this._height = 0;
	  this._alpha = 100;
	  this._backgroundColor = null;
	  this._border = null;
	  this._parent = null;
	  this._position = null;
	  this._content = null;
	  this._zIndex = null;
	},
	getDomRef: function(){
		return this._domRef;
	},
	getParent: function(){
		return this._parent;
	},
	getX: function(){
		return this._x;
	},
	setX: function(val){
		this._x = val;
		this._domRef.style.left = this._x+'px';
	},
	getContent: function(){
		return this._content;
	},
	setContent: function(val){
		this._content = val;
		this._domRef.update(val);
	},
	getY: function(){
		return this._y;
	},
	setY: function(val){
		this._y = val;
		this._domRef.style.top = this._y+'px';
	},
	getWidth: function(){
		return this._width;
	},
	setWidth: function(val){
		this._width = val;
		this._domRef.style.width = this._width+'px';
	},
	getHeight: function(){
		return this._height;
	},
	setHeight: function(val){
		this._height = val;
		this._domRef.style.height = this._height+'px';
	},
	getAlpha: function(){
		return this._alpha;
	},
	setAlpha: function(val){
		this._alpha = val;
		this._domRef.setOpacity(this.alpha);
	},
	getBackgroundColor: function(){
		return this._backgroundColor;
	},
	setBackgroundColor: function(val){
		this._backgroundColor = val;
		this._domRef.style.backgroundColor = this._backgroundColor;
	},
	getBorder: function(){
		return this._border;
	},
	setBorder: function(val){
		this._border = val;
		this._domRef.style.border = this._border;
	},
	getZIndex: function(){
		return this._zIndex;
	},
	setZIndex: function(val){
		this._zIndex = val;
		this._domRef.style.zIndex = val;
	},
	hide: function(){
		this._domRef.hide();
	},
	show: function(){
		this._domRef.show();
	},
	visible: function(){
		return this._domRef.visible();
	},
	create: function(parent, position) {
	  //var browserInfo = new BrowserCheck();
	  //browserInfo.init();

	  q = document.createElement('div');
	  q.id = 'div_' + Util.randomNumber(1, 10000);
	  //q.style.zIndex = '15000';
	  if(position != null){
		  q.style.position = 'absolute';
		  q.style.left = '0px'
		  q.style.top = '0px';
	  } else {
	  	  if(browserInfo.getBrowserName().toLowerCase() == 'internet explorer'){
		    q.style.styleFloat = 'left';
	  	  } else {
		  	q.style.cssFloat = 'left';
	  	  }
	  }
	  q.style.width = '1px';
	  q.style.height = '1px';
	  //q.style.display = 'inline';
	  q.style.border = '1px solid #000000';
	  this._parent = parent;
	  this._position = position;
	  this._domRef = parent.appendChild(q);
	  Element.extend(this._domRef);
	}
});
var DomDivExtended = Class.create(DomDiv, {
	initialize: function($super) {
	  $super();
	  this._margin = null;
	  this._padding = null;
	  this._float = null;
	  this._textAlign = null;
	  this._background = null;
	  this._cursor = 'auto';
	  this._borderLeft = null;
	  this._borderRight = null;
	  this._borderTop = null;
	  this._borderBottom = null;
	  this._bold = null;
	  this._clip = null;
	  this._overflow = null;
	},
	getBold: function(){
		return this._bold;
	},
	setBold: function(val){
	  	this._bold = val;
	  	(this._bold) ? this._domRef.style.fontWeight = 'bold' : this._domRef.style.fontWeight = 'normal';
	},
	getFloat: function(){
		return this._float;
	},
	setFloat: function(val){
	  this._float = val;
	  //var browserInfo = new BrowserCheck();
	  //browserInfo.init();
  	  if(browserInfo.getBrowserName().toLowerCase() == 'internet explorer'){
	    this._domRef.style.styleFloat = val;
  	  } else {
	  	this._domRef.style.cssFloat = val;
  	  }
	},
	getBackground: function(){
		return this._background;
	},
	setBackground: function(val){
		this._background = val;
		this._domRef.style.background = val;
	},
	getMargin: function(){
		return this._margin;
	},
	setMargin: function(val){
		this._margin = val;
		this._domRef.style.margin = val;
	},
	getPadding: function(){
		return this._padding;
	},
	setPadding: function(val){
		this._padding = val;
		this._domRef.style.padding = val;
	},
	getTextAlign: function(){
		return this._textAlign;
	},
	setTextAlign: function(val){
		this._textAlign= val;
		this._domRef.style.textAlign = val;
	},
	getCursor: function(){
		return this._cursor;
	},
	setCursor: function(val){
		this._cursor = val;
		this._domRef.style.cursor = val;
	},
	getBorderLeft: function(){
		return this._borderLeft;
	},
	setBorderLeft: function(val){
		this._borderLeft = val;
		this._domRef.style.borderLeft = val;
	},
	getBorderRight: function(){
		return this._borderRight;
	},
	setBorderRight: function(val){
		this._borderRight = val;
		this._domRef.style.borderRight = val;
	},
	getBorderTop: function(){
		return this._borderTop;
	},
	setBorderTop: function(val){
		this._borderTop = val;
		this._domRef.style.borderTop = val;
	},
	getBorderBottom: function(){
		return this._borderBottom;
	},
	setBorderBottom: function(val){
		this._borderBottom = val;
		this._domRef.style.borderBottom = val;
	},
	getClip: function(){
		return this._clip;
	},
	setClip: function(val){
		this._clip = val;
		this._domRef.style.clip = val;
	},
	getOverflow: function(){
		return this._overflow;
	},
	setOverflow: function(val){
		this._overflow = val;
		this._domRef.style.overflow = val;
	}
});
