/*

	YaTooltip - Version 1.2.4

	http://www.yatooltip.com

    This program is free software and distributed in the 
	hope that it will be useful, but WITHOUT ANY WARRANTY

*/


function yatt_on(tt_el,html,theme,tip_width,webtip_height) {


	// Change if you like: tooltip without a theme:
	var tt_fade_in = 'no';               // yes or no
	var tt_font_family = 'arial';
	var tt_font_color = '#FFFFFF';
	var tt_font_size = '8pt';
	var tt_font_line_height = '10pt';
	var tt_background_color = '#000000';
	var tt_shadow = 'no';                 // yes or no
	var tt_border_size = '10';             // only without shadow
	var tt_border_color = '#ff9900';      // only without shadow
	var tt_transparent = 1;               // 1...9 - only without shadow, 

	////////////////////////////////
	// Don't change the themes below
	if (theme) {
		var tt_font_family = 'Verdana, Arial, Helvetica, sans-serif';
		var tt_font_size = '9pt';
		var tt_font_line_height = '14pt';
	}
	if (theme == 'simple' || theme == 'image') {
		var tt_font_color = '#000';
		var tt_shadow = 'no';
		var tt_background_color = '#FFEC00';
		var tt_border_size = '2';
		var tt_border_color = '#ff9900';
		var tt_transparent = 0;
	}
	if (theme == 'image') {
		var tt_background_color = '#EEE';
		var tt_font_line_height = '20pt';
	}
	if (theme == 'shadow') {
		var tt_font_color = '#FFF';
		var tt_shadow = 'yes';
		var tt_background_color = '#626262';
	}
	if (theme == 'transparent') {
		var tt_font_color = '#FFF';
		var tt_shadow = 'no';
		var tt_background_color = '#001E2F';
		var tt_border_size = '1';
		var tt_border_color = '#000';
		var tt_transparent = 8;
	}
	if (theme == 'webtip') {
		var tt_font_color = '#FFF';
		var tt_shadow = 'no';
		var tt_background_color = '#FFF';
		var tt_border_size = '1';
		var tt_border_color = '#000';
		html = "<iframe src ='" + html +  "' width=" + tip_width + " height=" + webtip_height + " frameborder=0><p>Your browser does not support iframes.</p></iframe>"
	}


	// canvas width and height
	if (document.all) {
		canvas_x = document.body.clientWidth + document.body.scrollLeft;
		canvas_y = document.body.clientHeight + document.body.scrollTop;
	}
	else {
		canvas_x = window.innerWidth + window.pageXOffset;
		canvas_y = window.innerHeight + window.pageYOffset;
	}
		

	// find span position rel to body
	var tt_spanwidth = tt_el.offsetWidth;
	var tt_spanheight = tt_el.offsetHeight;

	var tt_span_left = tt_span_top = 0;

	if (tt_el.offsetParent) {
		do {
			tt_span_left += tt_el.offsetLeft;
			tt_span_top += tt_el.offsetTop;
		} 
		while (tt_el = tt_el.offsetParent);
	}
	
	span_x = tt_span_left + tt_spanwidth;
	span_y = tt_span_top + tt_spanheight;

			
	// create tooltip-div
	var tooldiv = document.createElement('div');
	tooldiv.setAttribute('id', 'tt_tooltip_id'); 
	tooldiv.style.position = "absolute"; 
	tooldiv.style.left = eval(span_x + 1) + 'px';
	tooldiv.style.top = eval(span_y + 1) + 'px';
	tooldiv.style.opacity = 1;
	tooldiv.style.filter = 'alpha(opacity=' + 100 + ')';

	if (tt_shadow == 'yes') {
		var tt_htm = "<TABLE border=0 style='width:" + tip_width + "px' cellspacing=0 cellpadding=0>";
		tt_htm += "<TR>";
		tt_htm += "<TD style='padding-top: 1px;background-color:" + tt_background_color + ";width:5px;height:5px' colspan=2></TD>";
		tt_htm += "<TD style='width:5px;height:5px'></TD>";
		tt_htm += "</TR>";
		tt_htm += "<TR>";
		tt_htm += "<TD style='background-color:" + tt_background_color + ";width:5px;'></TD>";
		tt_htm += "<TD style='background-color:" + tt_background_color + ";width:" + eval(tip_width - 10) + "px; padding: 0 2px 5px 5px; font-family: " + tt_font_family + "; font-size:" + tt_font_size + "; line-height:" + tt_font_line_height + ";color: " + tt_font_color + "'>" + html + "</TD>";
		tt_htm += "<TD style='background-color:#BCBCBC;width:5px;'></TD>";
		tt_htm += "</TR>";
		tt_htm += "<TR>";
		tt_htm += "<TD style='width:5px;height:5px'></TD>";
		tt_htm += "<TD style='background-color:#BCBCBC;width:5px;height:5px' colspan=2></TD>";
		tt_htm += "</TR>";
		tt_htm += "</TABLE>";
	}
	else {
		if (theme == 'webtip' && !document.all) { var tt_padding = '3px 15px 5px 6px' }
		else { var tt_padding = '3px 5px 5px 6px' }
		var tt_htm = "<div style='"
		if (tt_transparent > 0) {
			tt_htm += "opacity:0." + tt_transparent + ";filter:alpha(opacity=" + tt_transparent + "0);"
		}
		tt_htm += "border: " + tt_border_size + "px solid " + tt_border_color + "; background-color:" + tt_background_color + ";width:" + eval(tip_width - 10) + "px; padding: " + tt_padding + "; font-family: " + tt_font_family + "; font-size:" + tt_font_size + "; line-height:" + tt_font_line_height + "; color:" + tt_font_color + "'>";
		
		if (theme == 'webtip') { tt_htm += "<div onclick='yatt_out()' style='padding-bottom:3px;border-bottom: 1px solid #ccc;color:#000; font-weight:bold'>[close]</div>"}

		tt_htm += html + "</div>";
	}

	tooldiv.innerHTML = tt_htm;
	
	
	if (!document.getElementById("tt_tooltip_id")) {

		document.body.appendChild(tooldiv);
		var tt_div = document.getElementById("tt_tooltip_id");
		
		// replace tooltip
		var tt_tooltip_id_height = tt_div.offsetHeight
		var tt_tooltip_id_width = tt_div.offsetWidth

		// to the left
		if (canvas_x < span_x + tt_tooltip_id_width) {
			tt_div.style.left = eval(tt_span_left - tt_tooltip_id_width) + 'px';
		}
		// up
		if (canvas_y && canvas_y < span_y + tt_tooltip_id_height) {
			tt_div.style.top = eval(tt_span_top - tt_tooltip_id_height) + 'px';
		}
		if (tt_fade_in == 'yes') yatt_opac(tt_div,1)
	}
}


function yatt_out() {
	var tt_out = document.getElementById("tt_tooltip_id");
	if (tt_out) document.body.removeChild(tt_out);
}


function yatt_opac(obj,value) {
	if (obj) {
		obj.style.opacity = value/10;
		obj.style.filter = 'alpha(opacity=' + value*10 + ')';
		value++;
		if (value <= 10) setTimeout("yatt_opac(document.getElementById('tt_tooltip_id')," + value + ")", 40)
	}
}
