function setVisibility(item) {
	var blocks = new Array('myMessages', 'myTribes',
	'mySMS', 'myProfile', 'myAccount', 'mySearch', 'myFriends');
	for (i=0, c=blocks.length ; i<c ; i++) {
		//document.getElementById(blocks[i]).style.display = 'none';
	}
	current = document.getElementById(item).style.display;
	if (current == 'none')
	document.getElementById(item).style.display = '';
	else
	document.getElementById(item).style.display = 'none';
}

function setClass(item) {
	var blocks = new Array('linkToAll', 'linkToPicture', 'linkToVideo', 'linkToText','linkToEvents','linkToMembers','linkToConfirms','linkToMp3','linkToChat','linkToDoc');
	for (i=0, c=blocks.length ; i<c ; i++) {
		if(document.getElementById(blocks[i]))
		document.getElementById(blocks[i]).className = '';
	}
	document.getElementById(item).className = 'selected';
}

function setImage(item, source) {
	image		= document.getElementById(item);
	image.src	= source;
}

function gHost(item) {
	current = document.getElementById(item).style.display;
	if (current == 'none')
	document.getElementById(item).style.display = 'block';
	else
	document.getElementById(item).style.display = 'none';
}

function closeAgenda(which) {
	document.getElementById(which).style.display = 'none';
	document.getElementById('dontmove').value = 0;
}

function ag3nda(dt, d) {
	document.getElementById('imgd').src = '/images/days/' + d + '.gif';
	document.getElementById('d4t3').value = dt;
	document.getElementById('add2Calendar').style.display = 'block';
	document.getElementById('dontmove').value = 1;
}

function editAgenda(oid, otext) {
	document.getElementById('oid').value = oid;
	document.getElementById('message').value = otext;
	document.getElementById('editCalendar').style.display = '';
}

function modifyLocation(vl) {
	if (vl == 90) {
		document.getElementById('citylist').style.display='block';
		document.getElementById('citycustom').style.display='none';
	} else {
		document.getElementById('citylist').style.display='none';
		document.getElementById('citycustom').style.display='block';
	}
}

function highlight_stars(id, note, do_highlight)
{
	for (var i = 1 ; i <= note ; i++)
	{
		if(do_highlight)
		Element.addClassName($('vote_'+id+'_'+i), 'ratehover');
		else
		Element.removeClassName($('vote_'+id+'_'+i), 'ratehover');
	}
}

function highlight_VotedStars(id, note, do_highlight)
{
	for (var i = 1 ; i <= note ; i++)
	{
		if(do_highlight)
		{
			if(!Element.hasClassName(document.getElementById('voted_'+id+'_'+i), 'ratehover'))
			Element.addClassName(document.getElementById('voted_'+id+'_'+i), 'ratehover');
		}
		else
		{
			if(Element.hasClassName(document.getElementById('voted_'+id+'_'+i), 'ratehover'))
			Element.removeClassName(document.getElementById('voted_'+id+'_'+i), 'ratehover');
		}
	}
}

function selectAllCheckBoxes(FormName, FieldName, CheckValue)
{
	if(!document.forms[FormName])
	{
		return;
	}

	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
	{
		return;
	}
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
	objCheckBoxes.checked = CheckValue;
	else
	// set the check value for all check boxes
	for(var i = 0; i < countCheckBoxes; i++)
	objCheckBoxes[i].checked = CheckValue;
}

function selectAllDiffCheckBoxes(FormName, FieldName, CheckValue,checkboxCount)
{
	if(!document.forms[FormName])
	return;
	else
	// set the check value for all check boxes
	for(var i = 1; i <= checkboxCount; i++)
	{
		objCheckBox=document.forms[FormName].elements[FieldName+i];
		if(objCheckBox)
		objCheckBox.checked = CheckValue;
	}
}

function selectAllDiffCheckBoxesById(checkboxId, CheckValue,checkboxCount)
{
	for(var i = 1; i <= checkboxCount; i++)
	{
		objCheckBox=document.getElementById(""+checkboxId+i);
		if(objCheckBox)
		objCheckBox.checked = CheckValue;
	}
}

function selectboxAll(selectBoxObject,selectStatus)
{
	if(selectBoxObject)
	{
		var len=selectBoxObject.length;
		for(var i=0;i<len;i++)
		{
			selectBoxObject.options[i].selected=selectStatus;
		}
	}
}

function mouseX(e) {
	var posx = 0;
	if (!e) var e = window.event;
	if (e.pageX) 	{
		posx = e.pageX;
	}
	else if (e.clientX) 	{
		posx = e.clientX + document.body.scrollLeft
		+ document.documentElement.scrollLeft;
	}

	return posx;
}

function mouseY(e) {
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageY) 	{
		posy = e.pageY;
	}
	else if (e.clientY) 	{
		posy = e.clientY + document.body.scrollLeft
		+ document.documentElement.scrollLeft;
	}

	return posy;
}

function showTooltip(id,event,topShift,leftShift)
{
	var eleman=$(id);
	var xpos=parseInt(mouseX(event));
	var ypos=parseInt(mouseY(event));

	if(xpos>((parseInt(screen.width)-parseInt(eleman.style.width)-100)))
	xpos=parseInt(screen.width)-parseInt(eleman.style.width)-100;

	ypos=ypos+parseInt(topShift);
	xpos=xpos+parseInt(leftShift);
	//alert("xpos="+xpos+",screen="+screen.width+",width="+eleman.style.width);

	eleman.style.left=xpos+'px';
	eleman.style.top=ypos+'px';
}

function switchBanner(idPrefix,num)
{
	for(var i=1;i<=4;i++)
	{
		var elem=document.getElementById(idPrefix+i);
		if(elem)
		{
			if(i==parseInt(num))
			{
				elem.style.display='block';
			}
			else
			{
				elem.style.display='none';
			}
		}

	}
}

function selectBanner(idPrefix,num,classChecked,classUnchecked)
{
	for(var i=1;i<=4;i++)
	{
		var elem=document.getElementById(idPrefix+i);
		if(elem)
		{
			if(i==parseInt(num))
			{
				if(classChecked)
				elem.className=classChecked;
			}
			else
			{
				if(classUnchecked)
				elem.className=classUnchecked;
			}
		}

	}
}

/* ----------- tooltip ------------------------------------*/
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

function prepareInputsForHints() {
	var inputs = document.getElementsByTagName("input");
	for (var i=0; i<inputs.length; i++){
		// test to see if the hint span exists first
		if (inputs[i].parentNode.getElementsByTagName("span")[0]) {
			// the span exists!  on focus, show the hint
			inputs[i].onfocus = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
			}
			// when the cursor moves away from the field, hide the hint
			inputs[i].onblur = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "none";
			}
		}
	}
	// repeat the same tests as above for selects
	var selects = document.getElementsByTagName("select");
	for (var k=0; k<selects.length; k++){
		if (selects[k].parentNode.getElementsByTagName("span")[0]) {
			selects[k].onfocus = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
			}
			selects[k].onblur = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "none";
			}
		}
	}
}
addLoadEvent(prepareInputsForHints);