function showId(id) {
	$(id).style.display = '';
}

function hideId(id) {
	$(id).style.display = 'none';
}

function toggleBucket(bucketId) {
	state = $(bucketId).style.display;

	if(state == '') {
		Effect.BlindUp(bucketId, {duration: 1});
	} else if(state == 'none') {
		Effect.BlindDown(bucketId, {duration: 1});
	}
}

function toggleIdText(id,textOff,textOn,thisId) {
	state = $(id).style.display;

	if(state == '') {
		hideId(id);
		$(thisId).innerHTML = textOff;
	} else if(state == 'none') {
		showId(id);
		$(thisId).innerHTML = textOn;
	}
}

function closeBuckets() {
	$('bucket1_links').style.display = 'none';
	$('bucket2_links').style.display = 'none';
	$('bucket3_links').style.display = 'none';
	$('bucket4_links').style.display = 'none';
}

function toggleComment(commentId,linkId) {
	var content = 'userCommentContent_' + commentId;
	state = $(content).style.display;
	
	if (state == 'none') {
		$(content).style.display = '';
		$(linkId).innerHTML = '<img src=\"/images/publicAction/bttn_contract.gif\" class=\"toggleIMG\" title=\"Hide post\">';
	} else if(state =='') {
		$(content).style.display = 'none';
		$(linkId).innerHTML = '<img src=\"/images/publicAction/bttn_expand.gif\" class=\"toggleIMG\" title=\"Show post\">';
	}
}

//*********************************
// forum_list.htm
//********************************

function toggleDetails(commentId,linkId) {
	var content = 'details_' + commentId;
	state = $(content).style.display;
	
	if (state == 'none') {
		new Effect.BlindDown(content);
		$(linkId).innerHTML = '<img src=\"/images/publicAction/bttn_contract.gif\" class=\"toggleIMG\" title=\"Hide Most Recent Posts in this Conversation\">';
	} else if(state =='') {
		new Effect.BlindUp(content);
		$(linkId).innerHTML = '<img src=\"/images/publicAction/bttn_expand.gif\" class=\"toggleIMG\" title=\"Show Most Recent Posts in this Conversation\">';
	}
}

var id;
var idDisplay;
var idState = 1;
var idCurrent;

function toggleId(elem) {
	var id = 'details_' + elem;
	var idDisplay = document.getElementById(id).style.display;
	if(idDisplay == '') {
		new Effect.BlindUp(id);
		idState = 0;
	} else {
		if(idState == 1 && idCurrent != null) {
			new Effect.BlindUp(idCurrent);
			setTimeout('new Effect.BlindDown('+id+')', 1000);
		} else if(idState == 1 && idCurrent == null || idState == 0) {
			new Effect.BlindDown(id);		
		}

		idState = 1;
		idCurrent = id;
	}
}

//******************************
// basic scripts for star rating system
//
//*****************************

var o = "";
var starClass = "";

function removeStarClass(item) {
	starClass = item.className;
	item.className = '';
}

function restoreStarClass(item) {
	item.className = starClass;
}

function setStarClass(rating,item) {
	ul = item.parentNode.parentNode;
	starClass = 'urated' + rating;
	ul.className = starClass;
}


//***********************************************
// scripts for user_form.html
//************************************************
var tabLI;
var tabsA;

function toggleProfileTab(tab) {
	tabId = tab;
	thisTab = 'tab_' + tab;

	for(i=0;i<tabsA.length;i++) {
		if(tabsA[i] != tabId) {
			//build the li id
			tabLI = 'tab_' + tabsA[i];
			$(tabsA[i]).style.display = 'none';
			$(tabLI).className = '';	
		}
	}
	
	$(tabId).style.display = '';
	$(thisTab).className = 'active';
	return false;
}

var a;
var a_inner;
var ic;
var nc;

function addFavorite(type) {
	a = 'favorites_' + type;
	c = getElementsByClassName('inputText');
	
	ic = 0;

	for(i=0;i<c.length;i++) {
		b = c[i].id;
		if(b != '' && b.indexOf(a) != -1) {
			ic++;
		}
	}
	// next count and build the text field
	nc = ic + 1;
//	if(nc <= 9) {
//		nc = '0' + nc;
//	}
	
	tfid = a + '_' + nc;
	
	var inputNode=document.createElement("input");
	inputNode.type="text";
	inputNode.value=""
	inputNode.name = tfid;
	inputNode.id = tfid;
	inputNode.className = "inputText";
	
	$(a).appendChild(inputNode); 	

//	alert('adding ' + tfid);

}

function getElementsByClassName(clsName){ 
	var arr = new Array(); 
	var elems = document.getElementsByTagName("*");
	for(var cls,i=0;( elem = elems[i]);i++){
		if(elem.className == clsName){
			arr[arr.length] = elem;
		}
	}
	return arr;
}

// generic script for showing those lil info boxes

function showInfo(element) {
	var a = $(element);
	var state = a.childNodes[1];
	if (state.style.display == ''){
		state.style.display = 'none';
	} else if(state.style.display == 'none') {
		state.style.display = '';
	}
}


var updateId;
function cancelUpdate(postId) {
	updateId = 'newPost_' + postId;
	$(updateId).innerHTML = "";
}