﻿// JScript File
     
  // JScript File
var PanelDividendo = null; // Panello 
var cell_numero_cedola;
var cell_data_cedola;
var cell_data_pagamento;
var cell_data_annuncio;
var cell_importo;
var cell_valuta;
var wnd_height, wnd_width;
var tooltip_height, tooltip_width;
var tooltip_shown=false;
var transparency = 100;
var timer_id = 1;


function SetDocumentChange(){
  if (document != null)
  {
    if (document.onmousemove == null) // Evita di richiamare la propertychange su se stessa
    {
      document.onmousemove = AdjustToolTipPosition;
    }
  }
}

function SortHandler(column, desc)
{
  return false;
}


function HideToolTip(){
  if (PanelDividendo != null){
    tooltip_shown = false;
    clearTimeout(timer_id);
    PanelDividendo.style.display="none";  
  }
}


function DisplayTooltip(numero_cedola,data_cedola,data_pagamento,
                        data_annuncio, importo, valuta)
{
  if (PanelDividendo != null){
	  cell_numero_cedola.innerText = "Cedola " + numero_cedola;
    cell_data_cedola.innerText = data_cedola;
    cell_data_pagamento.innerText = data_pagamento;
    cell_data_annuncio.innerText = data_annuncio;
    cell_importo.innerText = importo;
    cell_valuta.innerText = valuta;
	  tooltip_shown = true;
    // Get tooltip window height
	  tooltip_height=(PanelDividendo.style.pixelHeight)? PanelDividendo.style.pixelHeight : PanelDividendo.offsetHeight;
	  transparency=0;
	  ToolTipFading();
  }
}

function AdjustToolTipPosition(e)
{
	if(tooltip_shown)
	{
		offset_y = (event.clientY + tooltip_height - document.body.scrollTop + 30 >= wnd_height) ? - 15 - tooltip_height: 20;
		PanelDividendo.style.display = "inline";
		PanelDividendo.style.left = Math.min(wnd_width - tooltip_width - 10 , Math.max(3, event.clientX + 6)) + document.body.scrollLeft + 'px';
		PanelDividendo.style.top = event.clientY + offset_y + document.body.scrollTop + 'px';
	}
}

function LoadingDividendi()
{
	PanelDividendo = document.getElementById('ctl00_ContentPlaceHolder1_PanelDividendo');
	if (PanelDividendo != null)
	{
    
    window.onresize = UpdateWindowSize;              
    document.onmousemove = AdjustToolTipPosition;  // Per posizionare la scheda del dividendo
    document.onpropertychange = SetDocumentChange; // Per l'ajax mode della griglia   
    
    cell_numero_cedola=document.getElementById('numero_cedola');
    cell_data_cedola=document.getElementById('data_cedola');
    cell_data_pagamento=document.getElementById('data_pagamento'); 
    cell_data_annuncio=document.getElementById('data_annuncio');    
    cell_importo=document.getElementById('importo');    
    cell_valuta=document.getElementById('valuta');        
	  // Get tooltip  window width				
	  tooltip_width = (PanelDividendo.style.pixelWidth) ? PanelDividendo.style.pixelWidth : PanelDividendo.offsetWidth;	
	  // Get tooltip window height
	  tooltip_height=(PanelDividendo.style.pixelHeight)? PanelDividendo.style.pixelHeight : PanelDividendo.offsetHeight;	  
	  UpdateWindowSize();
	}
}

function ToolTipFading()
{
	if(transparency <= 100)
	{
		PanelDividendo.style.filter="alpha(opacity="+transparency+")";
		transparency += 5;
		timer_id = setTimeout('ToolTipFading()', 35);
	}
}

function UpdateWindowSize() 
{
	wnd_height=document.body.clientHeight;
	wnd_width=document.body.clientWidth;
}
