$(document).ready(function(){ 
				
		
				$("#calendarD li a").each(function(){
					var a = $(this).find("span.tooltip").html();
					
					if(a != null ){
					
					$(this).qtip({
					
						content: a,
						position: {
							target: 'mouse',
							adjust: { 
								screen: true, 
								mouse:true,
								x: 0,
								y: -10
							},
							corner: {
								target: 'topRight',
								tooltip: 'bottomLeft'
							}
						},
						style: { 
							width: 300,
							height: 'auto',
							padding: 2,
							background: '#333',
							color: '#fff',
							textAlign: 'left',
							border: {
								width: 2,
								radius: 5,
								color: '#333'
							},
							show: { 
								effect: { 
									type: 'fade' 
								}
							},
							tip: 'bottomLeft',
							name: 'dark' 
						}
					});
					}
				});
			}); 
			
			

function cmp(a, b){
	return a>b;
}
onl=(window.onload||new Function);
onload=function(){
	onl();
	for(var i=0, e, tds=document.getElementsByTagName('td'); td=tds[i]; i++){
		if(/\s?sort\s?/.test(td.className)){
			td.n=i;
			td.onclick=function(){sort(this.n,this);}
		}
	}
}
function sort(v,d){
	d.o=d.o>0?-1:1;
	var tbody=d.parentNode.parentNode.parentNode.getElementsByTagName('tbody')[0];
	for(var i=0, c=[], tr, trs=tbody.getElementsByTagName('tr'); tr=trs[i]; i++){c[i]=tr} // just make an array from trs
	c.sort(function(a,b){return cmp(a.getElementsByTagName('td')[v].firstChild.data,b.getElementsByTagName('td')[v].firstChild.data)>0?d.o:-d.o});
	for(var i=0; i<c.length; i++){
		tbody.appendChild(c[i]);
	}
}
