/*
Sweet Titles (c) Creative Commons 2005
http://creativecommons.org/licenses/by-sa/2.5/
Author: Dustin Diaz | http://www.dustindiaz.com
Revision:ex-ftb 2006*/
var sweetTitles = { 
	xCord : 0,								
	yCord : 0,								
	tipElements : ['a','img','span','area'],			
	obj : Object,							
	x : Object,							
	init : function() {
		if ( !document.getElementById ||
			!document.createElement ||
			!document.getElementsByTagName ) {return;	}
		var i,j,Over;
		this.x = document.createElement('div');	
		this.x.id = 'toolTip';
		document.getElementsByTagName('body')[0].appendChild(this.x);
		this.x.style.top = '0';
		this.x.style.visibility = 'hidden';
		var tipLen = this.tipElements.length;
		for ( i=0; i<tipLen; i++ ) {
			var Elms = document.getElementsByTagName(this.tipElements[i]);
			var curLen = Elms.length;
			for ( j=0; j<curLen; j++ ) {
				var el= Elms[j];
				var tv = el.getAttribute('title')
				if ( tv != null && tv !="")
				 {addEvent(el,'mouseover',this.tipOver);
					addEvent(el,'mousemove',this.tipMouseMove);
					addEvent(el,'mouseout',this.tipOut);
					var sv = el.getAttribute('swttips');
					el.setAttribute('tiptitle', tv);
					el.setAttribute('tipswt', sv );
					el.removeAttribute('title'); 
					el.removeAttribute('swttips');}
				el.removeAttribute('alt');}
		}
	},

	updateXY : function(e) {
		if ( document.captureEvents ) {
			sweetTitles.xCord = e.pageX;
			sweetTitles.yCord = e.pageY;
		} else if ( window.event.clientX ) {
			sweetTitles.xCord = window.event.clientX+document.documentElement.scrollLeft;
			sweetTitles.yCord = window.event.clientY+document.documentElement.scrollTop;}
	},
	tipOut: function() {
		if ( window.tID ) {
			clearTimeout(tID);		}
		if ( window.opacityID ) {
			clearTimeout(opacityID);}
		sweetTitles.x.style.visibility = 'hidden';},
	checkNode : function() {
		var trueObj = this.obj;
		if ( this.tipElements.inArray(trueObj.nodeName.toLowerCase()) ) {
			return trueObj;
		} else {return trueObj.parentNode;}
	},
	tipOver : function(e) {sweetTitles.obj = this;
	tID = window.setTimeout("sweetTitles.tipShow()",100);
	 sweetTitles.updateXY(e);},
	
	tipMouseMove : function(e) {sweetTitles.updateXY(e); sweetTitles.tipMove();},
	
	tipShow : function() {			
		var anch = this.checkNode();
		this.x.innerHTML ="";
	 this.x.innerHTML = "<p class='title'> <span> "+anch.getAttribute('tiptitle')+"</span></p>";
		sv = anch.getAttribute('tipswt');
		if ( sv != null && sv !="")
		{this.x.innerHTML= this.x.innerHTML + "<p>" + anch.getAttribute('tipswt') + "</p>"; }
		sweetTitles.Move;
		var T = this.x.style;
		T.visibility = 'visible';
		T.opacity = '.1';
		this.tipFade(10);	},
	
	tipMove: function()
	{ var scrX = Number(this.xCord);
		var scrY = Number(this.yCord);
		var tp = parseInt(scrY+8);
		var lt = parseInt(scrX+8);
		var D = document.documentElement;
		var T = this.x.style;
		if ( parseInt(D.clientWidth+D.scrollLeft) < parseInt(this.x.offsetWidth+lt) ) {
			T.left = parseInt(lt-(this.x.offsetWidth+3))+'px';
		} else {
			T.left = lt+'px';		}
		if ( parseInt(D.clientHeight+D.scrollTop) < parseInt(this.x.offsetHeight+tp) ) {
			T.top = parseInt(tp-(this.x.offsetHeight+3))+'px';
		} else {T.top = tp+'px';		}
	},
	tipFade: function(opac) {
		var passed = parseInt(opac);
		var newOpac = parseInt(passed+10);
		 T = this.x.style;
		if ( newOpac < 92 ) {
			T.opacity = '.'+newOpac;
			T.filter = "alpha(opacity:"+newOpac+")";
			opacityID = window.setTimeout("sweetTitles.tipFade('"+newOpac+"')",20);}
		else { T.opacity = '.92';
			T.filter = "alpha(opacity:92)";		}
	}
};
function pageLoader() {	sweetTitles.init();}
addEvent(window,'load',pageLoader);
