PayScaleExtension.showLogoOnPage=false;
PayScaleExtension.affiliateId='none';
PayScaleExtension.init();

// init Close Timer
var payscale_timer = '';

Event.addBehavior({  
  'a.payscale:click':function(e) {
    return false;
  },
      
  'a.payscale:mouseover':function(e) {
    // initializing Payscale variables
    title = this.down('.title').innerHTML;
    loc   = this.down('.location').innerHTML;

    // Displaying Payscale Box
    PayScaleExtension.displayChart(title, '', loc); 

    // Setting position of Payscale Box
    PayScaleExtension.container.style['top']=(mouseY+'px'); 
    PayScaleExtension.container.style['left']=(mouseX+'px');

    // Adding Behaviors to Payscale Box
    Event.addBehavior({
      // Remove close timer when hovering on box
      '#wizzyMeat:mouseover':function(e) {
        if(payscale_timer) {
          window.clearTimeout(payscale_timer);
          payscale_timer = null;
        }
      },

      // Restore close timer when going away from box
      '#wizzyMeat:mouseout':function(e) {
        payscale_timer = window.setTimeout(PayScaleExtension.cleanup, 1200);
      }      
    });
  },
  
  'a.payscale:mouseout':function(e) {
    payscale_timer = window.setTimeout(PayScaleExtension.cleanup, 4000);
  }
});



// Keep track of mouse --- made smarter with getXY()

//function getcords(e){
//	mouseX = Event.pointerX(e);
//	mouseY = Event.pointerY(e);  //-370 (the approx. height of the popup)
//}




function getXY(e) {
	
	//find the scroll height
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }


//find the window height
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }


//find the mouse x and y coordinates
	mouseX = Event.pointerX(e);
	mouseY = Event.pointerY(e);  


//magicNumber is the height of the popup div.   todo: how can i pull this in to js without declaring a number? 
//var magicNumber = document.getElementById("").offsetHeight;
var magicNumber = 370;
var added = scrOfY + myHeight;
var difY = added - mouseY;

//window.status = "Mouse: Y="+mouseY + "   Scroll Height:" +scrOfY + "   Window Height:" +myHeight + "   Scroll + Window = " + added;


		if (difY < magicNumber) {
			mouseY = added - magicNumber;
		}
		
		if (myHeight < magicNumber){
			mouseY = scrOfY;
		}

//correct so mouse is over opened window
		mouseX = mouseX - 30;
}

Event.observe(document, 'mousemove', getXY); 



