// JavaScript Document

var menuint;
var current_menu = '';
var popup_div;
var popup_div_x;
var popup_img;
var popup_caption;

var IE = document.all?true:false

var tempX = 0
var tempY = 0

function init_hoffman()
{
	var btns = document.getElementsByTagName('IMG');

	for( i=0;i<btns.length;i++ )
	{
		btn = btns[i];
		if( btn.className && btn.className == 'ad_button' )
		{
			btn.inactive_src = btn.src;
			btn.active_src = btn.src.replace('inactive','active');
			
			btn.onmouseover = function(){ this.src = this.active_src; }
			btn.onmouseout = function(){ this.src = this.inactive_src; }
		}
	}
	
	// init functions here
	domain = window.location.toString();
	domain = domain.split("/")[2];
	var a = document.getElementsByTagName('A');
	var aNum = a.length;
	for( i=0;i<aNum;i++ )
	{
		// add new window icon
		if(a[i].href.indexOf(domain)==-1 && !a[i].className )
		{
			a[i].className = "new";
			a[i].target = "_blank";
		}
		
		// add mail icon
		if(a[i].href.indexOf("mailto")>-1)
		{
			a[i].className = "mail";
		}
	}
	
	
	/*if(BrowserDetect.browser != 'Explorer')
	{
		document.addEventListener('mousemove',getMouseXY,true)	
	}
	else
	{
		document.attachEvent('onmousemove',getMouseXY)
	}*/
	
	popup_div = document.getElementById('output');
	//popup_img = document.getElementById('output_img');
	
	if(popup_div)
	{
		popup_div.style.display = 'none';
		if (!IE) document.captureEvents(Event.MOUSEMOVE)
		document.onmousemove = getMouseXY;
	}
}

function overMenu(rel)
{
	current_menu = rel;
	clearTimeout(menuint);
	showMenu(rel);
}

function outMenu()
{
	clearTimeout(menuint);
	menuint = setTimeout(hideMenu,250);
}

function showMenu()
{
	document.getElementById('menu_'+current_menu).style.display = 'block';
}

function hideMenu()
{
	document.getElementById('menu_'+current_menu).style.display = 'none'
}

function showTooltip(img,w,h,fullname)
{
	//if(popup_img) popup_div.removeChild(popup_img);
	
	var newsrc = img.src.replace('thumb','med');
	
	popup_img = document.createElement("img");
	popup_img.setAttribute('src', newsrc);
	popup_img.style.width = w+"px";
	popup_img.style.height = h+"px";
	
	popup_caption = document.createElement("p");
	popup_caption.innerHTML = fullname;
	
	if(popup_div)
	{
		popup_div.appendChild(popup_img);
		popup_div.appendChild(popup_caption);
	}
	
	if(popup_div) popup_div.style.display = 'block';
}

function hideTooltip()
{
	if(popup_div) popup_div.style.display = 'none';
	if(popup_div)
	{
		popup_div.removeChild(popup_img);
		popup_div.removeChild(popup_caption);
	}
}




function getMouseXY(e)
{
	if (IE)
	{
		// grab the x-y pos.s if browser is IE
		tempX = event.clientX + document.documentElement.scrollLeft
		// IE6 is stupid. help it out.
		if( BrowserDetect.version < 7 ) tempX -= ((document.documentElement.clientWidth-800)/2);
 		tempY = event.clientY + document.documentElement.scrollTop
	}
	else
	{
		// grab the x-y pos.s if browser is NS
		//alert("Not IE");
		tempX = e.pageX
		tempY = e.pageY
	}  
  	// catch possible negative values in NS4
 	if (tempX < 0){tempX = 0}
  	if (tempY < 0){tempY = 0}  
  	// show the position values in the form named Show
  	// in the text fields named MouseX and MouseY
	tempX -= ( document.documentElement.clientWidth-tempX<275 ) ? 200 : 0;
  	popup_div.style.left = (tempX+10)+"px";
	popup_div.style.top = (tempY-75)+"px";
  	return true
}

