
function anzeigen(das)
{
	
	
	if (document.getElementById(das).style.display == 'none')
 	{
		document.getElementById(das).style.display='block';
	}
 	else
	{
		document.getElementById(das).style.display='none';
	}
	
}

function anzeigen2(das)
{
	
	
	if (document.getElementById(das).style.display == 'none')
 	{
		document.getElementById(das).style.display='inline-block';
	}
 	else
	{
		document.getElementById(das).style.display='none';
	}
	
}



search_types = new Array("lection", "user", "word", "group", "global");


function change_search_type_language(type, language)
{
	var type_destination_language;
	
	if (language == 'german')
	{
		
		if(type == search_types[0])
		{
			type_destination_language = 'Lektion';
		}
		else if (type == search_types[1])
		{
			type_destination_language = 'Benutzer';
		}
		
		else if (type == search_types[2])
		{
			type_destination_language = 'Wort';
		}
		
		else if (type == search_types[3])
		{
			type_destination_language = 'Gruppe';
		}
		
		else if (type == search_types[4])
		{
			type_destination_language = 'Global';
		}
	}
	else 
	{
		type_destination_language = type;
	}
	
	
	return type_destination_language;
}



var edit_search_type;
function change_search_type (type, query)
{

	/*
	var read_query = document.getElementById('search_input').value;
	var read_query_equal_search_type = 0;
	
	for(a=0; a < search_types.length; a++)
	{
		if(read_query == search_types[a]) {
			read_query_equal_search_type = 1;
		}
	}
	
	if(read_query_equal_search_type == 1)
	{
		change_search_type (type, read_query)
	}
	*/
	
	if (query != '')
	{
		document.getElementById('search_input').value = query;
		edit_search_type = 0;
	}
	else
	{
		document.getElementById('search_input').style.color='#CCCCCC';
		edit_search_type = 1;
		document.getElementById('search_input').style.fontStyle='italic';
		document.getElementById('search_input').value = change_search_type_language(type, 'german');
	}
	
	document.getElementById('search_type').value=type;
	document.getElementById('search_type_img').src='/vocable/static/images/search_'+type+'.png';
	document.getElementById('form_search').action = '/vocable/search/'+type;
	
	
}



function clear_search()
{
	var search_input = document.getElementById('search_input').value;
	if (edit_search_type == 1 || search_input == 'Suche')
	{
		document.getElementById('search_input').value='';
		document.getElementById('search_input').style.color='#000000';
		document.getElementById('search_input').style.fontStyle='normal';
		
		edit_search_type = 0;
	}
	else
	{
		set_focus_on_search()
	}
	
	
}

function set_focus_on_search()
{
	document.getElementById('search_input').focus();
	document.getElementById('search_input').select();
}



function practiceinputfocus() 
{
  document.getElementById('practice_mode_standard_input_field').focus();
}





function search_type_by_url() {
	
		var pathname = window.location.pathname;
		var pathparts = pathname.split("/");
		var search_type;
		var query;

		var queryname = window.location.search;
		
			if(queryname != undefined)
			{
				var queryparts = queryname.split("&");
				queryparts[0] = queryparts[0].substr(1, queryparts[0].length);
						
				for (i=0; i < queryparts.length; i++)
				{
					if(queryparts[i].match('query'))
					{
						query = queryparts[i].split("=");
						query = query[1];
					}
					
				}
			}
		
		
		for (i=0; i < pathparts.length; i++)
		{
			
			if(pathparts[i] == 'search')
			{
				search_type = pathparts[i+1];
				
			}
					
		}
		
		if (search_type)
		{
			change_search_type(search_type, query);
			
		}
		else
		{
			change_search_type('word', '');
		}
		
}





function divmouseout(div_name) {
	
	setTimeout(anzeigen(div_name), 1500);
		
}




function SetAllCheckBoxes(FormName, AreaID, CheckValue)
{
	if(!document.forms[FormName])
	return;
		var objCheckBoxes = document.getElementById(AreaID).getElementsByTagName('input');
		
	if(!objCheckBoxes)
	return;
		var countCheckBoxes = objCheckBoxes.length;
		
	if(!countCheckBoxes)
	objCheckBoxes.checked = CheckValue;
	else
	for(var i = 0; i < countCheckBoxes; i++)
	objCheckBoxes[i].checked = CheckValue;
}
