// MON: 14/01/2009 - BAU00321
var lastOpenedBox = '';
var lastImgSwap = new Array();

function showHidePanel(theID,isAutoClose) {
	if ($(theID).style.display != 'block') {
		$(theID).style.display = 'block';
		if (lastOpenedBox && (lastOpenedBox != theID) && isAutoClose) {
			$(lastOpenedBox).style.display = 'none';
		}
		
		if (lastImgSwap[0] && (lastOpenedBox != theID) && isAutoClose) {
			swapImage(lastImgSwap[0],lastImgSwap[1],lastImgSwap[2],true);
		}
		
		lastOpenedBox = theID;
	}else{
		$(theID).style.display = 'none';
	}
}

function swapImage(theID,Img1,Img2,isAuto) {
	var theDisplayedURL = getCleanURL($(theID).src);
	var theImg1 = getCleanURL(Img1);
	var theImg2 = getCleanURL(Img2);
	
	if (isAuto && theDisplayedURL == theImg1) {
		return;
	}
	
	if (theDisplayedURL == theImg1) {
		$(theID).src = theImg2;
	}else{
		$(theID).src = theImg1;
	}
	
	lastImgSwap[0] = theID;
	lastImgSwap[1] = theImg1;
	lastImgSwap[2] = theImg2;
}

function getCleanURL(theURL) {
	if (theURL.indexOf('http://') > -1 || theURL.indexOf('http://') > -1) {
		var findPos=0;
		var count;
		//find the 3rd occurance of / so we can make the url relative in stellent
		for (var i=0; i < 3; i++) {
			findPos = theURL.indexOf('/', findPos+1);
		}
		return theURL.substring(findPos,theURL.length);
	}else{
		return theURL;
	}
}



//make life easier...
function $(theID) {
	return document.getElementById(theID)	
}

function $$(theID){
	return document.getElementsByTagName(theID);
}