



//------------------
function enlarge(imgurl)
{
    openWin(imgurl,'','');    
}

function openWin(theURL,winName,features) 
{
    window.open(theURL,winName,features);  
}

var box;
var container;
var currentpos;
var maxheight;

var movevar;
var speed = 5;
var howoften = 30;

function scroll(dir, holder, content){
	
    if(box == null) { box = document.getElementById(content); }
    if(container == null) { container = document.getElementById(holder); }    
    if(currentpos == null) { currentpos = 0; }

    var test1 = box.scrollHeight;
    var test2 = box.offsetHeight;

    if(maxheight == null) {
        if(test1 > test2){
            maxheight = container.offsetHeight - box.offsetHeight;       
        } else {
            maxheight = container.offsetHeight - box.scrollHeight;
        }                    
    }    

    if(dir == "down") {    
        if ((currentpos - speed) >= maxheight) {
            currentpos -= speed;
            box.style.top = currentpos + 'px';
        } else {
            currentpos = maxheight;
            box.style.top = maxheight + 'px';
        }
    } else if (dir == "up") {
        if ((currentpos + speed) <= 0) {
            currentpos += speed;
            box.style.top = currentpos + 'px';    
        } else {
            currentpos = 0;
            box.style.top = 0;
        }
    }

	movevar=setTimeout("scroll('"+dir+"', '"+holder+"', '"+content+"')", howoften);    
}



// --------------------------

var gMENUDELAY = 350;
var canhideCM = false;
var canhidePM = false;
var canhideNM = false;


function tmShowCompanyProfileMenu() {
/*	Element.show($('sbbSportdropdown'));*/
	// must be a bug in prototype.js. if an element already has display: none, you can't use the .show	
	Element.setStyle( $('subnav_companyprofile'), { display:'block'});	
	canhideCM = false;
	return false;
}

function tmShowPortfolioMenu() {
/*	Element.show($('sbbSportdropdown'));*/
	
	// must be a bug in prototype.js. if an element already has display: none, you can't use the .show	
	Element.setStyle( $('subnav_portfolio'), { display:'block'});	
	canhidePM = false;
	return false;
}

function tmShowNewsMenu() {
/*	Element.show($('sbbSportdropdown'));*/
	
	// must be a bug in prototype.js. if an element already has display: none, you can't use the .show	
	Element.setStyle( $('subnav_news'), { display:'block'});	
	canhideNM = false;
	return false;
}


function tmHideCompanyProfileMenu() {
	if(canhideCM) {
		Element.hide($('subnav_companyprofile'));
	}
	return false;
}

function tmHideCompanyProfileMenuWithDelay() {
	canhideCM = true;
	setTimeout('tmHideCompanyProfileMenu()', gMENUDELAY);
}

function tmHidePortfolioMenu() {
	if(canhidePM) {
		Element.hide($('subnav_portfolio'));
	}
	return false;
}

function tmHidePortfolioMenuWithDelay() {
	canhidePM = true;
	setTimeout('tmHidePortfolioMenu()', gMENUDELAY);
}

function tmHideNewsMenu() {
	if(canhideNM) {
		Element.hide($('subnav_news'));
	}
	return false;
}

function tmHideNewsMenuWithDelay() {
	canhideNM = true;
	setTimeout('tmHideNewsMenu()', gMENUDELAY);
}

function tmRegObservers() {
	Event.observe($('companyprofile'), 'mouseover', tmShowCompanyProfileMenu, false);
	Event.observe($('companyprofile'), 'mouseout', tmHideCompanyProfileMenuWithDelay, false);
	Event.observe($('subnav_companyprofile'), 'mouseover', tmShowCompanyProfileMenu, false);
	Event.observe($('subnav_companyprofile'), 'mouseout', tmHideCompanyProfileMenuWithDelay, false);

	Event.observe($('portfolio'), 'mouseover', tmShowPortfolioMenu, false);
	Event.observe($('portfolio'), 'mouseout', tmHidePortfolioMenuWithDelay, false);
	Event.observe($('subnav_portfolio'), 'mouseover', tmShowPortfolioMenu, false);
	Event.observe($('subnav_portfolio'), 'mouseout', tmHidePortfolioMenuWithDelay, false);
	
	
	Event.observe($('news'), 'mouseover', tmShowNewsMenu, false);
	Event.observe($('news'), 'mouseout', tmHideNewsMenuWithDelay, false);
	Event.observe($('subnav_news'), 'mouseover', tmShowNewsMenu, false);
	Event.observe($('subnav_news'), 'mouseout', tmHideNewsMenuWithDelay, false);	
}

function drawScrollers() {

	if($('scrollcontent') && $('scrollcontainer')) {
		if(Element.getHeight($('scrollcontent')) > Element.getHeight($('scrollcontainer'))) {

			var scrollers = '<a href=\"#\" onmouseover=\"javascript:scroll(\'up\', \'scrollcontainer\', \'scrollcontent\');\" onmouseout=\"javascript:clearTimeout(movevar);\" id=\"scrollup\"><img src=\"_common/images/blank.gif\" height=\"16\" width=\"31\" alt=\"\" border=\"0\" /></a><a href=\"#\" onmouseover=\"javascript:scroll(\'down\', \'scrollcontainer\', \'scrollcontent\');\" onmouseout=\"javascript:clearTimeout(movevar);\"id=\"scrolldown\"><img src=\"_common/images/blank.gif\" height=\"16\" width=\"31\" alt=\"\" border=\"0\" /></a>';
			
			new Insertion.Before('maincontent', scrollers);
		
		}
	}
}

function init() {
	tmRegObservers();
	if($('scrollcontainer')) {
		$('scrollcontainer').style.overflow = 'hidden';
		drawScrollers();
	}	
	return false;
}