var numMenus = 5;
var timer = null;
var t = null;

/* ------------------------- */

function init()
{
	if (document.getElementByTagName) return false;
	
	var links = document.getElementsByTagName("a");
	
	for (var i=0;i<links.length;i++)
	{
	  if (links[i].id == "txtSmall")
	  {
		  links[i].onclick = function() { document.body.className = "small"; return false; }
	  }
	  if (links[i].id == "txtMedium")
	  {
		  links[i].onclick = function() { document.body.className = "medium"; return false; }
	  }
	  if (links[i].id == "txtLarge")
	  {
		  links[i].onclick = function() { document.body.className = "large"; return false; }
	  }		
	}
}
/* ------------------------- */
function changeLogo()
{
	var fn = imLogo.src.substring(imLogo.src.lastIndexOf("/") + 1);

	switch(fn)
	{
		case "logo6.jpg":
			imLogo.src = "images/logo1.jpg";
			break;
			
		case "logo1.jpg":
			imLogo.src = "images/logo2.jpg";
			break;			
		
		default:
			imLogo.src = "images/logo6.jpg";
			break;			
		
	}
}
/* ------------------------- */
function openMenu(obj, child)
{
    clearTimeout(timer);  
    hideMenus();
	
	obj.className="lmenucellOn";

	var curleft = curtop = 0;
	
	if (obj.offsetParent)
	{
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent)
		{
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	child.style.top = curtop;
	child.style.left = curleft + 115;
	changeOpac(0,child.id,false);
	child.className = "tbDropDown";
	opacity(child.id,0,100,200);	
}
/* ------------------------- */
function closeMenus()
{
  var i;
  clearTimeout(timer);
  
  for (i=1;i<=numMenus;i++)
  {
	 closeMenu("tbMenu" + i);
  }
}
/* ------------------------- */
function hideMenus()
{
  var i;
  clearTimeout(timer);
  
  for (i=1;i<=numMenus;i++)
  {
	 hideMenu("tbMenu" + i);
  }	
}
/* ------------------------- */
function closeMenu(tb)
{
  	var obj = document.getElementById(tb);
	
	//alert(tb + "/" + obj.className);
	
	if (obj != null && obj.className == "tbDropDown")
	{
		opacity(tb,100,0,400);
	}
}
/* ------------------------- */
function hideMenu(tb)
{
  	var obj = document.getElementById(tb);
	
	//alert(tb + "/" + obj.className);
	
	if (obj != null && obj.className == "tbDropDown")
	{
		obj.className = "tbDropOff";
	}
}
/* ------------------------- */
function timeoutOn(obj)
{
  timer = setTimeout('closeMenu("' + obj.id + '")', 1500);
}
/* ------------------------- */
function timeoutOff()
{
	//if (obj.className == "tbDropDown" && timer != null) // If table is visible and timer set
	//{
	//if (t != null) clearTimeout(t);
	if (timer != null) clearTimeout(timer);	
	//}
}
/* ------------------------- */
function opacity(id, opacStart, opacEnd, millisec)
{ 
	//speed for each frame 
    var speed = Math.round(millisec / 100); 
    var time = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd)
	{ 
        for(i = opacStart; i >= opacEnd; i--)
		{ 
            timer = setTimeout("changeOpac(" + i + ",'" + id + "', true)",(time * speed)); 
            time++; 
        } 
    }
	else if(opacStart < opacEnd)
		 { 
        	for(i = opacStart; i <= opacEnd; i++) 
            { 
            	timer = setTimeout("changeOpac(" + i + ",'" + id + "', true)",(time * speed)); 
            	time++; 
        	} 
    	 } 
} 
/* ------------------------- */
//change the opacity for different browsers 
function changeOpac(opacity, id, hide)
{ 
	try
	{
      var object = document.getElementById(id).style; 
  	  //var td = document.getElementById(id);

	  object.opacity = (opacity / 100); 
      object.MozOpacity = (opacity / 100); 
      object.KhtmlOpacity = (opacity / 100); 
      object.filter = "alpha(opacity=" + opacity + ")"; 
	
	  //if ((opacity <= 0) && hide)
	  //{
		//document.getElementById(id).className = "tbDropOff";
		//timer = setTimeout("hide('" + id + "')", 3000);
		//changeOpac(100,id);
	  //}
	}
	catch (err)
	{
	}
}
/* ------------------------- */
function hide(id)
{
	document.getElementById(id).className = "tbDropOff";
	clearTimeout(timer);
}
/* ------------------------- */
function bgShowHide()
{
	var object1 = document.getElementById("_homePage");
	var object2 = document.getElementById('aBG');
	
	if (object1.className == "homePage")
	{
		object1.className = "homePageNoBG";
		object2.innerHTML = "Show Background";
	}
	else
	{
		object1.className = "homePage";
		object2.innerHTML = "Hide Background";		
	}
	object1 = null;
	object2 = null;
}
/* ------------------------- */
function changeImage(im, t)
{
	parent.document.getElementById("imMain").src = im;
	
	//if (t.Length) > 0
	//{
		parent.document.getElementById("spImageText").innerHTML = t;	
	//}
}
/* ------------------------- */
function positionIt(obj)
{
	try
	{
	  var x = (Math.random() * document.documentElement.clientWidth);
	  if (x > 200)
	  {
		x -= 200;  
	  }
	  document.getElementById(obj).style.left = x.toFixed(0) + "px";
	  
	  x = (Math.random() * document.documentElement.clientHeight);
	  if (x > 30)
	  {
		x -= 30;  
	  }

	  document.getElementById(obj).style.top = x.toFixed(0) + "px";
	  document.getElementById(obj).className='visible';
	  timer = setTimeout("hideIt('" + obj + "')", Math.random() * 2500); 
	}
	catch (err)
	{
	}
}
/* ------------------------- */
function hideIt(obj)
{
  document.getElementById(obj).className='invisible';	
}