﻿function showPeriod(start,period,id,month,obj)
{
    /*for(i = 0; i< period; i++)
    {
        var v = document.getElementById(start+i);
	if(month == 1)
          v.style.backgroundColor = "#edfdd6";
	else if(month == 2) 
	  v.style.backgroundColor = "#f3dbdc";
	else if(month == 3) 
	  v.style.backgroundColor = "#ffffe0";
	else if(month == 4) 
	  v.style.backgroundColor = "#e9f2fa";
	else if(month == 5) 
	  v.style.backgroundColor = "#ffe6e6";
	else if(month == 6) 
	  v.style.backgroundColor = "#e3fdee";
	else if(month == 7) 
	  v.style.backgroundColor = "#fff1e4";
	else if(month == 8) 
	  v.style.backgroundColor = "#e4fffe";
	else if(month == 9) 
	  v.style.backgroundColor = "#f8e6f5";
	else if(month == 10) 
	  v.style.backgroundColor = "#efe6f5";
	else if(month == 11) 
	  v.style.backgroundColor = "#d1d6ef";
	else if(month == 12) 
	  v.style.backgroundColor = "#fff5d3";
    }	*/
    showTip(id,obj);
}

function hidePeriod(start,period,id)
{
    /*for(i = 0; i< period; i++)
    {
        var v = document.getElementById(start+i);
        v.style.backgroundColor = "";
    }*/
    hideTip(id);
}

function showTip(id,obj)
{
    var v = document.getElementById(id);
    v.style.display = "block";
    setLyr(obj,id);
}

function hideTip(id)
{
    var v = document.getElementById(id);
    v.style.display = "none";
}
function setLyr(obj,lyr)
{
    var newX = findPosX(obj);
    var newY = findPosY(obj);
    
    // added on 20070821      
    x_display = false;
    y_display = false;
    // shift tooltip by 10 to the left if x position is more than 500
    if(newX >= 600) {
    	    newX = newX - document.getElementById(lyr).offsetWidth - 10;
	    x_display = true;
    }
    
    // shift tooltip by 45 to the top if y position is more than 700
    //if(newY >= 580) {
    //	    newY = newY - document.getElementById(lyr).offsetHeight - 45;
    //	    y_display = true;
    //}
    
    if(x_display || y_display){
    	var x = new getObj(lyr);
	
	if(y_display)
		x.style.top = newY + 'px';
	
	if(x_display)
    		x.style.left = newX + 'px';
    }
}

function findPosX(obj)
{
    var curleft = 0;
    if (obj.offsetParent)
    {
            while (obj.offsetParent)
            {
                    curleft += obj.offsetLeft
                    obj = obj.offsetParent;
            }
    }
    else if (obj.x)
            curleft += obj.x;
    return curleft;
}

function findPosY(obj)
{
    var curtop = 0;
    if (obj.offsetParent)
    {
            while (obj.offsetParent)
            {
                    curtop += obj.offsetTop
                    obj = obj.offsetParent;
            }
    }
    else if (obj.y)
            curtop += obj.y;
    return curtop;
}

function getObj(name)
{
if (document.getElementById)
{
    this.obj = document.getElementById(name);
    this.style = document.getElementById(name).style;
}
else if (document.all)
{
    this.obj = document.all[name];
    this.style = document.all[name].style;
}
else if (document.layers)
{
    this.obj = document.layers[name];
    this.style = document.layers[name];
}
}


