var title_div = null;
function linkOver(the_link, way){
	var x = $(the_link).offset().left+($(the_link).width())/2+$(window).scrollLeft();
	var y = $(the_link).offset().top+$(window).scrollTop();
	if(title_div.css("display")=="block"){
		title_div.remove();
	}
	addTitleDiv();
	var link_title = $(the_link).attr('title').replace(/~/gi, "<br />");
	if(way==1){
		title_div.html("<div style='text-align:left;background-color:#000000;color:#FFFFFF;padding:3px; border:solid 1px #333333' class='ui-corner-all'>"+link_title+"</div><div style='background:url("+server_url_v2+"images/title_bullet.png) no-repeat center; height:5px; position:relative; top:-1px;'></div>");
	}else{
		title_div.html("<div style='background:url("+server_url_v2+"images/title_bullet2.png) no-repeat center; height:5px; position:relative; top:1px;'></div><div style='background-color:#000000;color:#FFFFFF;padding:3px; border:solid 1px #333333' class='ui-corner-all'>"+link_title+"</div>");
	}
	$(the_link).attr('title', '');
	if(way==1){
		y=y-title_div.height()-2;
	}else{
		y=y+title_div.height();
	}
	title_div.offset({left:x-title_div.width()/2,top:y});
	title_div.animate({opacity: 'show'}, 300);
}
function linkOut(){
	title_div.animate({opacity: 'hide'}, 300);
}
function resolveTitleLinks(){
	if (document.getElementsByTagName) {
		var links = document.getElementsByTagName("a");
		for (var i=0; i < links.length; i++) {
			if(links[i].className.match(/with_rollover/gi)){
				links[i].onmouseover = function(){
					this.link_title = $(this).attr('title');
					var way=1;
					if(this.className.match(/with_rollover2/gi)){
						way=2;
					}
					linkOver(this, way);
				}
				links[i].onmouseout = function(){
					linkOut();
					$(this).attr('title',this.link_title);
				}
			}
		}
	}
	addTitleDiv();
}
function addTitleDiv(){
	title_div = $("<div style='z-index:10000'></div>");
	title_div.css("position", "absolute");
	title_div.css("display", "none");
	$("body").prepend(title_div);
}
$(document).ready(function(){
	resolveTitleLinks();
});
