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 destroy_div(td)
{ 
 var DIVtoRemove = document.getElementById(td);
 DIVtoRemove.parentNode.removeChild(DIVtoRemove);
}
/************************************************/
function destroy_all_divs()
{
 var e=document.getElementsByTagName("div");
 var n = new Array();

 for(i=0;i<e.length;i++)
  {    
    n[i]=e[i].id;
  }

 for(i=0;i<e.length;i++)
  {    
    if(n[i].indexOf("__") != -1)
     destroy_div(n[i]);
  }
}
/************************************************/
function create_div_dynamic(td,mess)
{
 var element=document.getElementById(td);
 var X=findPosX(element);
 var Y=findPosY(element);

 dv = document.createElement('div');     // create dynamically div tag
 dv.setAttribute('id',"div__"+td);       //give id to it
 dv.className="divs";                    // set the style classname  
 dv.style.left=X+10;
 dv.style.top=Y+10;

 //set the html content inside the div tag
 var str='<table height=100% width=100% border=0>';
 str+='<tr><td class=text>'+mess+'<td></tr>';
 str+='<tr><td align=right valign=bottom><br><a href="#thecal" onclick="destroy_div(\'div__'+td+'\')">close[x]</a><td></tr>';  
 str+='</table>';

 dv.innerHTML=str;
// attach event onmouseclick to the created div tag 
//dv.attachEvent("onmouseclick",function(){element_event_onmouseclick();}); 
//finally add the div id to ur form 
 document.forms[0].appendChild(dv);
}
/*
function element_event_onmouseclick() //its called for onmouseclick 
{ 
     	alert("Inside function onmouseclick"); 
}
*/