var currentContent = "more News...";
function callExternalInterface() {
    thisMovie("sidebar").clearHighlight();
}
function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}
String.prototype.find=function(what){
return(this.indexOf(what)>=0 ? true : false);
}
function strip(s) {
	var sa = s.split(' ');
	while (sa[0].length == 0)
		sa.shift();
	while (sa[sa.length-1].length == 0)
		sa.pop();
	return sa.join(' ');
}
function showContent(kind, info, src) {
	if (kind == 'URL') {
		window.location.href = info;
		return;
	}
	var current = document.getElementById(currentContent);
	current.className = 'content-hidden';
	var newContent = info;
	if (newContent == currentContent)
		newContent = "more News...";
	current = document.getElementById(newContent);
	current.className = 'content-shown';
	currentContent = newContent;
	scroll(0,0);
    if (src == 'page')
        callExternalInterface();
}
function toggleSection(node) {
    var content = document.getElementById(node.id+'_section');
	var closed = node.className.find('section-close');
    content.className = (closed) ? 'section-content-hidden' : 'section-content-shown';
	node.className = (closed) ? node.className.split('close').join('open') :
								node.className.split('open').join('close');
    fixWidths("td.section-open");
	fixWidths("td.section-open-wide");
    fixWidths("td.section-close");
	fixWidths("td.section-close-wide");
}
function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (true) {
            curleft += obj.offsetLeft;
            if (!obj.offsetParent)
                break;
            obj = obj.offsetParent;
        }
    } else if (obj.x)
        curleft += obj.x;
    return curleft;
}
function fixWidths(selector) {
    var elems = getElementsBySelector(selector);
    for (var i=0; i<elems.length; i++) {
        var elem = elems[i];
        var x = findPosX(elem);
		var tx = findPosX(document.getElementById('menupanel'));
		if ((x-tx) < 250) {
			if (elem.className.indexOf('wide') == -1)
				elem.className += '-wide';
		} else if (elem.className.indexOf('wide') > 0)
			elem.className = elem.className.substr(0, elem.className.length-5);
	}
}