
function TTdetail_msgShow(parentId,unit,country,express){
	var idNumParent=parentId;
	var idNumSpan=idNumParent+"_span";
	var msgbox=document.getElementById(idNumSpan);

	var tip1 = unit;
	if(tip1 != null && tip1 != 'undefined'){
		if(tip1.lastIndexOf(",") > 0){
			tip1 = tip1.substring(0,tip1.lastIndexOf(","));
        	//tip1 = replaceAll(tip1,"-",",");
		}
	}
	var tip2 = country;
	if(tip2 != null && tip2 != 'undefined'){
		if(tip2.lastIndexOf(",") > 0){
    		tip2 = country.substring(0,country.lastIndexOf(","));
        	//tip2 = replaceAll(tip2,"-",",");
		}

	}
	var tip3 = express;
	if(tip3 != null && tip3 != 'undefined'){
		if(tip3.lastIndexOf(",") > 0){
			tip3 = tip3.substring(0,tip3.lastIndexOf(","));
        	//tip3 = replaceAll(tip3,"-",",");
		}
	}
	//alert(tip1);alert(tip2);alert(tip3);
	//first fill object content to get object width and height
	var tipString = 
	"Sale Unit: "+ tip1 +"<br>"+
	"Available Country: " + tip2 +"<br>"+
	"Available Express: " + tip3 +"<br> Click price link for detail information";
	msgbox.innerHTML = tipString;
	
	msgbox.style.display="inline";
}

function TTdetail_msgHide(parentId){
	var idNumParent=parentId;
	var idNumSpan=idNumParent+"_span";
	var msgbox=document.getElementById(idNumSpan);
	msgbox.style.display="none";
}


function xstooltip_show(tooltipId, parentId, posX, posY,unit,country,express)
{
	it = document.getElementById(tooltipId);
    if ((it.style.top == '' || it.style.top == 0) && (it.style.left == '' || it.style.left == 0))
    {
    	var tip1 = unit;
    	if(tip1 != null && tip1 != 'undefined'){
    		if(tip1.lastIndexOf(",") > 0){
    			tip1 = tip1.substring(0,tip1.lastIndexOf(","));
            	//tip1 = replaceAll(tip1,"-",",");
    		}
    	}
    	var tip2 = country;
    	if(tip2 != null && tip2 != 'undefined'){
    		if(tip2.lastIndexOf(",") > 0){
        		tip2 = country.substring(0,country.lastIndexOf(","));
            	//tip2 = replaceAll(tip2,"-",",");
    		}

    	}
    	var tip3 = express;
    	if(tip3 != null && tip3 != 'undefined'){
    		if(tip3.lastIndexOf(",") > 0){
    			tip3 = tip3.substring(0,tip3.lastIndexOf(","));
            	//tip3 = replaceAll(tip3,"-",",");
    		}
    	}
    	//alert(tip1);alert(tip2);alert(tip3);
    	//first fill object content to get object width and height
    	var tipString = 
    	"Sale Unit: "+ tip1 +"<br>"+
		"Available Country: " + tip2 +"<br>"+
		"Available Express: " + tip3 +"<br> Click price link for detail information";
    	it.innerHTML = tipString;

        // need to fixate default size (MSIE problem)
        it.style.width = it.offsetWidth + 'px';
        it.style.height = it.offsetHeight + 'px';
        
        img = document.getElementById(parentId); 
        // if tooltip is too wide, shift left to be within parent 
        if (posX + it.offsetWidth > img.offsetWidth) posX = img.offsetWidth - it.offsetWidth;
        if (posX < 0 ) posX = 0; 
        
        x = xstooltip_findPosX(img) + posX;
        y = xstooltip_findPosY(img) + posY;
        it.style.top = y + 'px';
        it.style.left = x + 'px';
    }
    
    it.style.visibility = 'visible'; 
}

function xstooltip_hide(id)
{
    it = document.getElementById(id);
    it.style.top = '';
    it.style.left = '';
    it.innerHTML = '';
    it.style.visibility = 'hidden'; 
}

function xstooltip_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 xstooltip_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 replaceAll(strOrg,strFind,strReplace){
	 var index = 0;
	 while(strOrg.indexOf(strFind,index) != -1){
	  strOrg = strOrg.replace(strFind,strReplace);
	  index = strOrg.indexOf(strFind,index);
	 }
	 return strOrg
} 

