
function show_item(obj_id)
{
  var x = document.getElementById(obj_id);    	
  x.style.visibility = 'visible';
  return(is_on_right_side(obj_id));
}

function hide_item(obj_id)
{
	var x = document.getElementById(obj_id);
	x.style.visibility = 'hidden';
}

function is_FireFox()
{
  return navigator.userAgent.indexOf("Firefox")!=-1;
}

function is_IE6()
{
  return navigator.userAgent.indexOf("MSIE 6")!=-1;
}

function is_on_right_side(obj_id)
{
  var obj = document.getElementById(obj_id);
	var coors = findPos(obj);
  var center = 500;
  if(typeof no_list_boxes != "undefined")
    center = 475;
  return (coors[0] > center);
}


function show_bubble(obj_id,offset)
{
  var final_offset = offset || 0;
	var x = 0;
  var balloon_name = obj_id + "_balloon"
	x = document.getElementById(balloon_name); 
	x.style.position = 'absolute';
	setLyr(obj_id, balloon_name,final_offset );
	x.style.visibility = 'visible';
	x.style.display = 'block';
	if(is_IE6())
	{
	  x.style.display = 'inline-block';
	}
}


function waitjustagoshdarnminute()
{
  var awhile = 99999;
  
  while(awhile--)
  {
    awhile = (awhile * 1) / 1;
  }
}

function show_columnar_bubble(obj_id,x_offset,y_offset)
{
  var final_x_offset = x_offset || 0;
  var final_y_offset = y_offset || 0;
	var x = 0;
  var balloon_name = obj_id + "_balloon";
  
  
  if (typeof kill_balloons!="undefined")
  {
    if(kill_balloons)
     return;
  }
    
	if(is_on_right_side(obj_id))
	{
	  final_x_offset -= 370; 
	  if(is_IE6())
	    final_x_offset -= 20;
	}
	
	x = document.getElementById(balloon_name); 
	
  if((typeof no_list_boxes != "undefined") && (no_list_boxes == 1))
  {
    myOffset = ((getWindowWidth() - 1025)/2) + 390;
	  if(x.className == "comment_style")
    {      
  	  x.style.visibility = 'visible';
  	  if(typeof layout1 != "undefined")
  	  {
  	    x.style.left = myOffset + 115 + 'px';
  	    x.style.top = '45px';
  	  }
  	  else
  	  {
  	    x.style.left = myOffset + 30 + 'px';
  	    x.style.top = '125px';
  	  }
    }  
    else
  	{
  	  x.style.position = 'absolute';
  	  setLyr(obj_id, balloon_name,final_x_offset + myOffset - 360,final_y_offset + 130 );
  	  x.style.visibility = 'visible';
  	  x.style.display = 'block';
    }
  }
	else 
	{
	  if((typeof use_new_comments == "undefined") || (x.className != "comment_style"))
  	{
  	  x.style.position = 'absolute';
  	  setLyr(obj_id, balloon_name,final_x_offset,final_y_offset );
  	  x.style.visibility = 'visible';
  	  x.style.display = 'block';
    }
    else
    {
  	  x.style.visibility = 'visible';
    }
  }
}

function hide_bubble()
{
	var x = document.getElementById('bubble');
	x.style.visibility = 'hidden';
	x = document.getElementById('bubble_left');
	if(x)
	  x.style.visibility = 'hidden';
}


function hide_specific_bubble(obj_id)
{
  var bubble_name = obj_id + "_balloon";
	var x = document.getElementById(bubble_name);
	
	if(typeof keep_comments_up!="undefined")
	{
	  if(keep_comments_up)
	    return;
	}
	
	if(x)
	{
    x.style.visibility = 'hidden';
    if((typeof use_new_comments== "undefined") || (x.className != "comment_style"))
  	{
      x.style.display = 'none';
      x.style.left = 0;
      x.style.top = 0;
    }
  }
}

function setLyr(obj_id,lyr,x_offset, y_offset)
{
  var obj = document.getElementById(obj_id);
	var coors = findPos(obj);
	var x = document.getElementById(lyr);
  x.style.top = (coors[1] - 70 + y_offset) + 'px';
	if(navigator.appName.indexOf('Explorer') != -1)
	{
	  if(coors[0] > 250)
	  { 
	    x_offset -= 60;
	  }
	  x.style.left = (coors[0] + 45 + x_offset) + 'px';
  }
  else if(navigator.userAgent.indexOf("Firefox")!=-1)
	{
    x.style.left = (coors[0] + 45 + x_offset) + 'px';
  }
	else
	{
    x.style.left = (coors[0] + 45 + x_offset) + 'px';
  }
}

function getWindowWidth() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
  return myWidth;
}

function findPos(obj)
{
  var windowWidth = getWindowWidth();
  var greenWidth = (windowWidth - 1020)/2;
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft - greenWidth;
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}


