jQuery(document).ready(function() {
	


	
if (screen.width > 1000 && screen.height > 700)	
{ document.getElementsByTagName('BODY').item(0).style.overflowX = "hidden";	}
							
								
								
								
								
    //Tooltips
    jQuery(".tip_trigger").hover(function(event){
										  
		  
		tip = jQuery(this).find('.tip');
				  
		tip.show(); //Show tooltip									 
									 
		 var retu = $(this).attr('id');							 
		id8 =	parseInt(retu.replace("t_",""));
		
	
		if(!id8){id8 =	parseInt(retu.replace("ts_",""));
		
		
		jQuery.ajax({
		'type':'POST',
		'data':{'id':id8},
		'url':'http://'+location.host+'/'+baseUrl+'site/producta',
		'cache':false,
		'success':function(html){jQuery("#tots_"+id8).html(html);
		}});

		}
	
	
	
	
	else {
		jQuery.ajax({
		'type':'POST',
		'data':{'id':id8},
		
		'url':'http://'+location.host+'/'+baseUrl+'site/producta',
		'cache':false,
		'success':function(html){
		
		
		jQuery("#tot_"+id8).html(html);		

		}});
	}

		
    }, function() {
        tip.hide(); //Hide tooltip
		
		

		
		
		
    }).mousemove(function(e) {
		

if (e.pageX || e.pageY) {
        posx = e.pageX;
        posy = e.pageY;
}
else if (e.clientX || e.clientY) {
        posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
        posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
}

		
		var mousex = posx + 20; //Get X coodrinates
        var mousey = posy + 20; //Get Y coordinates

        var tipWidth = tip.width(); //Find width of tooltip
        var tipHeight = tip.height(); //Find height of tooltip

        //Distance of element from the right edge of viewport
        var tipVisX = jQuery(window).width() - (mousex + tipWidth);
        //Distance of element from the bottom of viewport
        var tipVisY = jQuery(window).height() - (mousey + tipHeight);
	
	
	

	
	
        if ( tipVisX < 20 ) { //If tooltip exceeds the X coordinate of viewport
            mousex = posx - tipWidth - 40;
        } if ( tipVisY < 20 ) { //If tooltip exceeds the Y coordinate of viewport
            mousey = posy - tipHeight - 20;
        }

	  apacioje =  document.documentElement.clientHeight - e.clientY - 22;
	  virsuje =  e.clientY;
	
	
	  if(apacioje > tipHeight){mousey = posy;}else{
	  if(virsuje > tipHeight){mousey = posy - tipHeight;}else{
		
		mousey = document.body.scrollTop + document.documentElement.scrollTop + document.documentElement.clientHeight - tipHeight - 22;
		
	  }}
	//jQuery("#tot_"+id8).html(jQuery("#tot_"+id8).html()+document.documentElement.scrollTop);
		
        //Absolute position the tooltip according to mouse position
        tip.css({  top: mousey , left: mousex });
		tip.css({  top: mousey , left: mousex });
	//	alert(tipHeight+" ant");	
			
    })
	
	

})





