try {
document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

var dojo = {};

function sethref (what) {
    var o; var nh;
    var tli=document.getElementById('maincat_list');
    var lilist=tli.getElementsByTagName('A');
    for (var i=0;i<lilist.length;i++) {
	nh="";
        // alert("old[" + lilist[i].href + "]");
	var c=lilist[i].href.split("/");
	for (o=0;o<c.length;o++) {
	    if ( c[o] == "topics" ) {
		c[o + 2] = what;
	    }
	    nh += c[o];
	    if (o < c.length - 1) nh += "/";
	    // lilist[i].href += "/" + what;
	}
	if ( c[c.length - 1] != what )  nh += what;
        // alert("[" + nh + "]");
	lilist[i].href = nh;
    }
}

function closeTabspot() {
    x=document.getElementById("tabspot");
    if ( x )  dojo.addClass(x,"hidden");
    x=document.getElementById("tablist");
    if ( x )  dojo.removeClass(x,"hidden");
}

function switchtab(group,who,urlpart,showloading) {
    if ( urlpart ) sethref(urlpart);
    var i; var x; var y; var z;
    z=document.getElementById(group + "load");
    for ( i=0;i<=10;i++ ) {
	x=document.getElementById(group + "d" + i);
	y=document.getElementById(group + i);
	if ( y ) { dojo.removeClass(y,"tabbutton_active") };
	if ( x && !showloading ) { x.style.display="none"; }
    }
    if ( z && showloading ) { 
        // document.getElementById("loadani").src="/images/imloading.gif";
	// z.style.display="block"; 
    }
    x=document.getElementById(group + "d" + who);
    y=document.getElementById(group + who);
    if ( y ) dojo.addClass(y,"tabbutton_active");
    if ( x && !showloading ) x.style.display="block";
    x=document.getElementById("xxxtabspot");
    if ( x )  dojo.addClass(x,"hidden");
    x=document.getElementById("xxxtablist");
    if ( x )  dojo.removeClass(x,"hidden");
    return(false);
}

function show_blog_preview() {
    return;
    var bi=document.getElementById("blog_preview");
    var bl=document.getElementById("blog_tab");
    console.dir(bl);
    bi.style.top=bl.offsetTop + "px";
    bi.style.left=bl.offsetLeft + "px";
    bi.style.top= "123px";
    bi.style.left="370px";
}

dojo.trim = function(/*String*/ str){
        // summary: trims whitespaces from both sides of the string
        // description:
        //      This version of trim() was selected for inclusion into the base
        //      due to its compact size and relatively good performance (see Steven Levithan's blog:
        //      http://blog.stevenlevithan.com/archives/faster-trim-javascript).
        //      The fastest but longest version of this function is going to be placed in dojo.string.
        return str.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); // String
}

dojo.hasClass = function(/*HTMLElement*/node, /*String*/classStr){
        //      summary:
        //              Returns whether or not the specified classes are a portion of the
        //              class list currently applied to the node.
        return ((" "+node.className+" ").indexOf(" "+classStr+" ") >= 0);  // Boolean
};

dojo.addClass = function(/*HTMLElement*/node, /*String*/classStr){
        //      summary:
        //              Adds the specified classes to the end of the class list on the
        //              passed node.
        var cls = node.className;
        if((" "+cls+" ").indexOf(" "+classStr+" ") < 0){
                node.className = cls + (cls ? ' ' : '') + classStr;
        }
};

dojo.removeClass = function(/*HTMLElement*/node, /*String*/classStr){
        // summary: Removes classes from node.
        node.className = dojo.trim((" " + node.className + " ").replace(" " + classStr + " ", " "));
};

dojo.toggleClass = function(/*HTMLElement*/node, /*String*/classStr, /*Boolean?*/condition){
        //      summary:
        //              Adds a class to node if not present, or removes if present.
        //              Pass a boolean condition if you want to explicitly add or remove.
        //      condition:
        //              If passed, true means to add the class, false means to remove.
        if(typeof condition == "undefined"){ 
                condition = !dojo.hasClass(node, classStr);
        }
        dojo[condition ? "addClass" : "removeClass"](node, classStr);
};
