// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function go_to_company(sel) {    
  if (sel.selectedIndex == -1) return;    
    var opt = sel.options[sel.selectedIndex];    
    if (opt && opt.value)       
      location.href =  "/mytag/company/" + opt.value; 
} 



function moveHoverPane(eventid) {
  //if I ran the function using the command "checkval('hello')"
  //then passvar would take on the value 'hello'
  var whichElement = "'event_" + eventid + "\'";
  var xpos = $("'" + whichElement + "'").style.left;
  var ypos = $(eval(whichElement)).style.top;
  alert(xpos);
  $('hoverPane').style.top = ypos;
  $('hoverPane').style.left = xpos;
}

/* external_link
----------------------------------------------------------------------------------------*/
var external_link = Class.create({
	initialize: function(selector) {
		this.selector = selector;
		this.setup();
	},
	setup: function() {
		if(this.selector.getAttribute("href") && this.selector.getAttribute("rel") == "external")
			this.selector.observe('click', this.open_window.bind(this));
	},
	open_window: function(ev) {
		window.open(this.selector.href);
		ev.stop();
	}
});
var match_height = Class.create({
	initialize: function(col_a, col_b) {
		this.col_a = col_a;
		this.col_b = col_b;
		this.setup();
	},
	setup: function() {
		if(this.col_a.getHeight() < this.col_b.getHeight())
			this.col_a.style.height = this.col_b.getHeight() + "px";
		else
			this.col_b.style.height = this.col_a.getHeight() + "px";
	}
});

document.observe('dom:loaded', function() {
	if($('sidebar'))
		new match_height($('sidebar'), $('content_main'));
	$$('a').each(function(el) { new external_link(el); });
});