/**
Vertigo Tip by www.vertigo-project.com
Requires jQuery
*/

var vtipcount=0;
var removecount={};
this.vtip = function() {    
    this.xOffset = -10; // x distance from mouse
    this.yOffset = 10; // y distance from mouse       
    
    $("table a.vtip").add("span.vtip").unbind().hover(    
        function(e) {
        	//-------------------------------------
        	vtipcount++;
        	
            this.t = this.parent;
            var res;
            var body;
            
            if(!$(this).attr("col")){
	            res=this.innerHTML.replace(/&gt;/,"");
	            if(res<1002){}else{return;}
   	            body = "<table>"+$("table#kiji_"+res).html()+"</table>";
   	            
			}else{
				
				body="";
            	var rescount = $(this).attr("col").split(",");
            	for (var i=0; i < rescount.length; i++) {
					body += "<table>"+$("table#kiji_"+rescount[i]).html()+"</table>";
				}
   	            
            }
            this.title = ''; 
            this.top = (e.pageY + yOffset); this.left = (e.pageX + xOffset);
            $('body').append( '<div class="vtip'+vtipcount+' vtip0"><img id="vtipArrow" />' + body + '</div>' );
                        
            $('div.vtip'+vtipcount+' #vtipArrow').attr("src", '/images/vtip_arrow.png');
            $('div.vtip'+vtipcount).css("top", this.top+"px").css("left", this.left+"px").fadeIn("slow");
            $('div.vtip'+vtipcount).hover(function(e){},function(){$("div.vtip"+vtipcount).fadeOut("slow").remove();vtipcount--;});
            
        	//-------------------------------------
            $('div.vtip'+vtipcount+' a.vtip').hover(
       	        function(e) {
       	        	//-------------------------------------
       	        	var oldvipcount=vtipcount;
		        	vtipcount++;
		            this.t = this.parent;
		            var res;
		            var body;
		            
		            res=this.innerHTML.replace(/&gt;/,"");
		            
		            this.title = ''; 
		            this.top = (e.pageY + yOffset - $(".vtip"+oldvipcount).eq(0).offset().top );
		            this.left = (e.pageX + xOffset - $(".vtip"+oldvipcount).eq(0).offset().left);
		            body = "<table>"+$("table#kiji_"+res).html()+"<table>";

		            $('div.vtip'+oldvipcount).append( '<div class="vtip'+vtipcount+' vtip0"><img id="vtipArrow" />' + body + '</div>' );
		                        
		            $('div.vtip'+vtipcount+' #vtipArrow').attr("src", '/images/vtip_arrow.png');
		            $('div.vtip'+vtipcount).css("top", this.top+"px").css("left", this.left+"px").fadeIn("slow");
		            $('div.vtip'+vtipcount).hover(function(e){},function(){$("div.vtip"+vtipcount).fadeOut("slow").remove();vtipcount--;});
       	        	//-------------------------------------

		        	//-------------------------------------
		            $('div.vtip'+vtipcount+' a.vtip').hover(
		       	        function(e) {
		       	        	//-------------------------------------
		       	        	var oldvipcount=vtipcount;
				        	vtipcount++;
				            this.t = this.parent;
				            var res;
				            var body;
				            
				            res=this.innerHTML.replace(/&gt;/,"");
				            
				            this.title = ''; 
				            this.top = (e.pageY + yOffset - $(".vtip"+oldvipcount).eq(0).offset().top );
				            this.left = (e.pageX + xOffset - $(".vtip"+oldvipcount).eq(0).offset().left);
				            body = "<table>"+$("table#kiji_"+res).html()+"</body>";

				            $('div.vtip'+oldvipcount).append( '<div class="vtip'+vtipcount+' vtip0"><img id="vtipArrow" />' + body + '</div>' );
				                        
				            $('div.vtip'+vtipcount+' #vtipArrow').attr("src", '/images/vtip_arrow.png');
				            $('div.vtip'+vtipcount).css("top", this.top+"px").css("left", this.left+"px").fadeIn("slow");
				            $('div.vtip'+vtipcount).hover(function(e){},function(){$("div.vtip"+vtipcount).fadeOut("slow").remove();vtipcount--;});
		       	        	//-------------------------------------
		       	        	
		       	        	
		       	        	
				        	//-------------------------------------
				            $('div.vtip'+vtipcount+' a.vtip').hover(
				       	        function(e) {
				       	        	//-------------------------------------
				       	        	var oldvipcount=vtipcount;
						        	vtipcount++;
						            this.t = this.parent;
						            var res;
						            var body;
						            
						            res=this.innerHTML.replace(/&gt;/,"");
						            
						            this.title = ''; 
						            this.top = (e.pageY + yOffset - $(".vtip"+oldvipcount).eq(0).offset().top );
						            this.left = (e.pageX + xOffset - $(".vtip"+oldvipcount).eq(0).offset().left);
						            body = "<table>"+$("table#kiji_"+res).html()+"</body>";

						            $('div.vtip'+oldvipcount).append( '<div class="vtip'+vtipcount+' vtip0"><img id="vtipArrow" />' + body + '</div>' );
						                        
						            $('div.vtip'+vtipcount+' #vtipArrow').attr("src", '/images/vtip_arrow.png');
						            $('div.vtip'+vtipcount).css("top", this.top+"px").css("left", this.left+"px").fadeIn("slow");
						            $('div.vtip'+vtipcount).hover(function(e){},function(){$("div.vtip"+vtipcount).fadeOut("slow").remove();vtipcount--;});
				       	        	//-------------------------------------
				       	        	
				       	        	
				       	        	
				       	        	
				       	        	
				       	        	
						        }
				            	,
				       	        function() {
						        }
							);
		       	        	
		       	        	
				        }
		            	,
		       	        function() {
				        }
					);



		        }
            	,
       	        function() {
		        }



			);
            
            
        },
        function() {
        }
    ).mousemove(
        function(e) {
            this.top = (e.pageY + yOffset);
            this.left = (e.pageX + xOffset);
                         
            //$("div#vtip"+vtipcount).css("top", this.top+"px").css("left", this.left+"px");
        }
    );            
    
};

jQuery(document).ready(function($){vtip();}) 
