function button_down(dem,img_over)
{
	if (dem != document.getElementById('search_handler').value)
	{
		document.getElementById(dem).src = img_over;
	}
}

function change_button(dem , img_down)
{
	var handler = document.getElementById('search_handler').value;

	document.getElementById(handler).src = 'images/search_' + handler + '.jpg';
	document.getElementById(dem).src = img_down;
	document.getElementById('search_handler').value = dem;
}

function open_desc(id)
{
	if (document.getElementById('desc_' + id).style.display != 'none')
	{
		document.getElementById('desc_' + id).style.display = 'none';
	}
	else
	{
		document.getElementById('desc_' + id).style.display = 'block';
	}
}

function changeView(view_id , handler_id)
{
	if (document.getElementById(handler_id).value != view_id && document.getElementById(handler_id).value != '')
	{
		document.getElementById(document.getElementById(handler_id).value).style.display = 'none';
		document.getElementById(view_id).style.display = 'block';

		document.getElementById(handler_id).value = view_id;
	}
	else
	{
		document.getElementById(view_id).style.display = 'block';
		document.getElementById(handler_id).value = view_id;
	}

}


function browse_profile(prof_id)
{
	if (document.getElementById('prof_handler').value != prof_id)
	{
		document.getElementById(document.getElementById('prof_handler').value).style.display = 'none';
		document.getElementById(prof_id).style.display = 'block';
		

		document.getElementById(document.getElementById('prof_handler').value + '_btn').className = 'profile_btn_txt';
		document.getElementById(prof_id + '_btn').className = 'profile_btn_txt_down';

		document.getElementById('prof_handler').value = prof_id;
	}
}

function browse_library(prof_id)
{
	if (document.getElementById('prof_handler').value != prof_id)
	{
		document.getElementById(document.getElementById('prof_handler').value).style.display = 'none';
		document.getElementById(prof_id).style.display = 'block';
		

		document.getElementById(document.getElementById('prof_handler').value + '_btn').className = 'library_btn_txt';
		document.getElementById(prof_id + '_btn').className = 'library_btn_txt_down';

		document.getElementById('prof_handler').value = prof_id;
	}
}

function changeproj(proj_id , handler_id)
{
	if (document.getElementById(handler_id).value != proj_id)
	{
		document.getElementById(document.getElementById(handler_id).value).style.display = 'none';
		document.getElementById(proj_id).style.display = 'block';
		
		document.getElementById(document.getElementById(handler_id).value + '_btn').className = 'proj_list';
		document.getElementById(proj_id +'_btn').className = 'proj_list_down'

		document.getElementById(handler_id).value = proj_id;

	}
}


function changelist(proj_id , handler_id)
{
	if (document.getElementById(handler_id).value != proj_id)
	{
		document.getElementById(document.getElementById(handler_id).value).style.display = 'none';
		document.getElementById(proj_id).style.display = 'block';
		
		document.getElementById(document.getElementById(handler_id).value + '_btn').className = 'blue_list';
		document.getElementById(proj_id +'_btn').className = 'blue_list_down';

		document.getElementById(handler_id).value = proj_id;

	}
}


	

function clearMenus() 
{
	$j("#submenu-friends, .catdropm").hide();
	$j("#friends-alink").removeClass("current");
	document.getElementById('my_websites').src = 'images/my_websites_btn.gif';
	document.getElementById('my_websites').setAttribute('srcover' , 'images/my_websites_btn_over.gif');

	document.getElementById('my_projects').src = 'images/my_projects_btn.gif';
	document.getElementById('my_projects').setAttribute('srcover' , 'images/my_projects_btn_over.gif');

	document.getElementById('my_groups').src = 'images/my_groups_btn.gif';
	document.getElementById('my_groups').setAttribute('srcover' , 'images/my_groups_btn_over.gif');

	document.getElementById('my_feeds').src = 'images/my_feeds_btn.gif';
	document.getElementById('my_feeds').setAttribute('srcover' , 'images/my_feeds_btn_over.gif');

}

function handleHover() 
{
	$j("body").bind("click", 
		function (event) 
		{
			if (!$j(event.target).is(".catdrop, #friends-activity") && (!$j(event.target).attr("id") || $j(event.target).attr("id").substring(0, 10) != "tooltoggle"))
			{
				clearMenus();
			}
		}
	);

	$j(".catdrop").click(
		function () {
			document.getElementById('my_websites').src = 'images/my_websites_btn.gif';
			document.getElementById('my_websites').setAttribute('srcover' , 'images/my_websites_btn_over.gif');

			document.getElementById('my_projects').src = 'images/my_projects_btn.gif';
			document.getElementById('my_projects').setAttribute('srcover' , 'images/my_projects_btn_over.gif');

			document.getElementById('my_groups').src = 'images/my_groups_btn.gif';
			document.getElementById('my_groups').setAttribute('srcover' , 'images/my_groups_btn_over.gif');

			document.getElementById('my_feeds').src = 'images/my_feeds_btn.gif';
			document.getElementById('my_feeds').setAttribute('srcover' , 'images/my_feeds_btn_over.gif');

			var m = $j(this).parents("li.h-drop").children(".catdropm");
			m.toggle();
			$j(".catdropm:visible, #submenu-friends").not(m).hide();
			$j("#friends-alink").removeClass("current");
			
			var image_parent_top = document.getElementById(this.id.replace('_hnd' , ''));
			var image_to_be_changed = image_parent_top.getAttribute("srcover");
			image_parent_top.setAttribute("srcover" , image_parent_top.src);
			image_parent_top.src = image_to_be_changed;
			

			return false;

		}
	);
}


function open_pop(id)
{
	if (document.getElementById('pop_' + id).style.display != 'none')
	{
		document.getElementById('pop_' + id).style.display = 'none';
	}
	else
	{
		document.getElementById('pop_' + id).style.display = 'block';
	}
}

function close_popup(id)
{
	document.getElementById(id).style.display = 'none';
}

function open_tab(id)
{
	if (document.getElementById('tab_' + id).style.display != 'none')
	{
		document.getElementById('tab_' + id).style.display = 'none';
		document.getElementById('tab'+id).className = 'group_tab';
	}
	else
	{
		document.getElementById('tab_' + id).style.display = 'block';
		document.getElementById('tab'+id).className = 'group_tab_over';
	}
}

function open_hidden(id)
{
	if (document.getElementById('hidden_' + id).style.display != 'none')
	{
		document.getElementById('hidden_' + id).style.display = 'none';
		document.getElementById('hidden'+id).className = 'blue';
	}
	else
	{
		document.getElementById('hidden_' + id).style.display = 'block';
		document.getElementById('hidden'+id).className = 'white';
	}
}

function open_section(id)
{
	if (document.getElementById('section_' + id).style.display != 'none')
	{
		document.getElementById('section_' + id).style.display = 'none';
		document.getElementById('section'+id).className = 'bold_grey';
	}
	else
	{
		document.getElementById('section_' + id).style.display = 'block';
		document.getElementById('section'+id).className = 'bold_grey';
	}
}

function switchProfileBasic(id)
{
	if (id != document.getElementById('my_profile_basic_content_box_handler').value)
	{
		document.getElementById(id + '_content').style.display = 'block';
		if (document.getElementById('my_profile_basic_content_box_handler').value != '')
		{
			document.getElementById(document.getElementById('my_profile_basic_content_box_handler').value + '_content').style.display = 'none';
		}
		document.getElementById('my_profile_basic_content_box_handler').value = id;
	}
}