var index=0;
var buffer=0;
var win3 = '';

function onCloseWin(){
  document.location.reload();
}

function onOpenChildWindow(){
  
}
/****************************************
**
** When in Edit mode, this opens the 
** corresponding admin window
**
****************************************/
Ajax.PosItem = Class.create();
Ajax.PosItem.defaultHighlightColor = "#FFFF99";
Ajax.PosItem.prototype = {
  initialize: function(element, url, options) {
    this.url = url;
    this.element = $(element);
    
    this.options = Object.extend({
    highlightcolor: Ajax.PosItem.defaultHighlightColor,
    highlightendcolor: "#FFFFFF"}
    , options || {});
    this.oldColor = this.element.getStyle('background-color');
    
    this.onclickListener = this.enterEditMode.bindAsEventListener(this);
    this.mouseoverListener = this.enterHover.bindAsEventListener(this);
    this.mouseoutListener = this.leaveHover.bindAsEventListener(this);
    

    Event.observe(this.element, 'click', this.onclickListener);
    Event.observe(this.element, 'mouseover', this.mouseoverListener);
    Event.observe(this.element, 'mouseout', this.mouseoutListener);
  },
  onCloseWin: function(){
    alert('onClose');    
  },
	enterEditMode: function() {
		var pars = 'empID=';
		    win3 = new Window('dialog'+index, {title: 'Stream', 
    								  width:760, height:400, 
    								  url: this.url+'&winID=dialog'+index,
    								  zIndex:10000, 
    								  className: "theme1",
    								  showEffectOptions:{duration:0},
    								  								  
    								  resizable: true,
    	                 maximizable:false,
    	                 minimizable: false,
		                  refreshParentOnUnload: true});
    index++;    
    win3.show(true);
    win3.setZIndex(10000+modZIndex);
    win3.setDestroyOnClose();
  },

  enterHover: function() {
    document.body.style.cursor = 'pointer';
    this.element.style.backgroundColor = '#efefef';
  },
  leaveHover: function() {
    document.body.style.cursor = 'auto';
    this.element.style.backgroundColor = this.oldColor;
  }
};
/*********************************
**
** Provides proper onhover etc events for links
**
*********************************/
//declaring the class
var LinkWatcher = Class.create();

//defining the rest of the class implmentation
LinkWatcher.prototype = {

   initialize: function(item, url, normalbg, hoverbg) {
		this.link = $(item);
		this.url = url;
		this.normalbg = normalbg;
		this.hoverbg = hoverbg;
		//assigning our method to the event
		this.link.onmouseover = this.mouseOver.bindAsEventListener(this);
		this.link.onmouseout = this.mouseOut.bindAsEventListener(this);
		this.link.onclick = this.click.bindAsEventListener(this);
		this.link.style.backgroundColor = this.normalbg;
   },
   click: function(ext){
     document.location.href = this.url;
   },
   mouseOut: function(evt) {
	  this.link.style.backgroundColor = this.normalbg;
	  this.link.style.cursor = 'normal';
   },
   mouseOver: function(evt) {
	  this.link.style.backgroundColor = this.hoverbg;
	  this.link.style.cursor = 'pointer';
   }
};
