function hoverClass(theID,n)
{
if(n==1)
{
document.getElementById(theID).className = "active";
}
else
{
document.getElementById(theID).className = "";
}
}
<div id="block1" onMouseOver="hoverClass('block2',1);" onMouseOut="hoverClass('block2',2);">текст1</div>
<div id="block2">текст2</div>