var CSBalloon = function() {
	this.base = 'http://www.chemspider.com';

	this.width = 250;
	this.height = 300;

	this.ballon = null;
}

CSBalloon.prototype.init = function() {
	var head = null;
	var heads = document.documentElement.getElementsByTagName('HEAD');
	if(heads.length == 0) {
		head = document.createElement('HEAD');
		document.documentElement.appendChild(head);
	}
	else {
		head = heads[0];
	}

	var script = document.createElement('SCRIPT');
	script.setAttribute('language', 'javascript');
	script.setAttribute('type', 'text/javascript');
	script.setAttribute('src', this.base + '/js/balloon.js');
	head.appendChild(script);

	script = document.createElement('SCRIPT');
	script.setAttribute('language', 'javascript');
	script.setAttribute('type', 'text/javascript');
	script.setAttribute('src', this.base + '/js/yahoo-dom-event.js');
	head.appendChild(script);

	var oThis = this;
	utils.addEvent(window, "load", function() { oThis.markup(); } );
}

CSBalloon.prototype.markup = function() {
	var oThis = this;

	oThis.balloon = new Balloon();
	oThis.balloon.images = oThis.base + '/images/balloons';
	oThis.balloon.minWidth = oThis.width;
	oThis.balloon.maxWidth = oThis.width;

	var oElements = $C("cs-balloon", "class", null, 'SPAN');
	for(var i=0; i<oElements.length; i++) {
		oElements[i].onmouseover = function(evt) { 
			oThis.balloon.showTooltip(utils.bIsIe?event:evt,'<iframe style=\'width:' + oThis.width + ';height:' + oThis.height + ';\' frameborder=\'0\' src=\'' + oThis.base + '/CSBalloon.ashx?d=' + this.innerHTML + '\'></iframe>', 1);	
		}
	}
}

var csBalloon = new CSBalloon();
csBalloon.init();

//	THIS FUNCTION IS USED TO CALL MARKUP FROM ANOTHER WINDOW IN MANUAL CURATION PLUGIN.
function CSBalloonMarkup()
{
	csBalloon.markup();
}
