/*-----------------------------------------------------------
    Toggles element's display value
    Input: any number of element id's
    Output: none 
    ---------------------------------------------------------*/
function toggleDisp() {
    for (var i=0;i<arguments.length;i++){
        var d = $(arguments[i]);
        if (d.style.display == 'none')
            d.style.display = 'block';
        else
            d.style.display = 'none';
    }
}
/*-----------------------------------------------------------
    Toggles tabs - Closes any open tabs, and then opens current tab
    Input:     1.The number of the current tab
                    2.The number of tabs
                    3.(optional)The number of the tab to leave open
                    4.(optional)Pass in true or false whether or not to animate the open/close of the tabs
    Output: none 
    ---------------------------------------------------------*/
function toggleTab(num,numelems,opennum,animate) {
    if ($('tabContent'+num).style.display == 'none'){
        for (var i=1;i<=numelems;i++){
            if ((opennum == null) || (opennum != i)){
                var temph = 'tabHeader'+i;
                var h = $(temph);
                if (!h){
                    var h = $('tabHeaderActive');
                    h.id = temph;
                }
				$(h).removeClassName('currenttab');
                var tempc = 'tabContent'+i;
                var c = $(tempc);
                if(c.style.display != 'none'){
                    if (animate || typeof animate == 'undefined')
                        Effect.toggle(tempc,'appear',{duration:0.5, queue:{scope:'menus', limit: 3}});
                    else
                        toggleDisp(tempc);
                }
            }
        }
        var h = $('tabHeader'+num);
        if (h)
            h.id = 'tabHeaderActive';
        h.blur();
        var c = $('tabContent'+num);
        c.style.marginTop = '0px';
        if (animate || typeof animate == 'undefined'){
            Effect.toggle('tabContent'+num,'appear',{duration:0.5, queue:{scope:'menus', position:'end', limit: 3}});
        }else{
            toggleDisp('tabContent'+num);
        }
    }
    
    ffthumbsdiv = document.getElementsByClassName('ffthumbs')[0];
    
    /*
    thumbsli = $A($($(ffthumbsdiv).down('UL')).immediateDescendants());
    thumbsli.each(function(e) {
    	$(e).innerHTML = replacestring($(e).innerHTML, '_off.jpg', '.jpg');
    	$(e).innerHTML = replacestring($(e).innerHTML, '.jpg', '_off.jpg');
    });
    
    activeliid = 'tabHeaderActive';
    $(activeliid).innerHTML = replacestring($(activeliid).innerHTML, '_off.jpg', '.jpg');
    */
}
/** Function: replacestring
*
*	Replace string
*/
function replacestring(inputString, badString, goodString, caseSensitive) {
	fixedReplace = "";
	UI = inputString;
	UB = badString;
	if ((caseSensitive != 1) && (caseSensitive != true)) {
		UI = inputString.toUpperCase();
		UB = badString.toUpperCase();
	}
	badEnd = -1;
	badLoc = UI.indexOf(UB);
	if (badLoc != -1) {
		for (x=1; (badLoc != -1); x++) {
			fixedReplace = fixedReplace +
			inputString.substring((badEnd +
			1), badLoc) + goodString
			badEnd = badLoc + UB.length - 1;
			badLoc = UI.indexOf(UB, (badLoc + 1)); }
			fixedReplace = fixedReplace +
			inputString.substring((badEnd + 1),
			inputString.length); }
			else { fixedReplace = inputString;    }
			return fixedReplace;
}

function activateImg(el) {
 $(el).src = replacestring($(el).src, 'index.html', '.jpg');
}

function deactivateImg(el) {
 if($($(el).up('LI')).id != 'tabHeaderActive') {
  $(el).src = replacestring($(el).src, 'index.html', '.jpg');
  $(el).src = replacestring($(el).src, '.jpg', 'index.html');
 }
}