// JavaScript Document

function hideError() {
	document.getElementById("errorMessage").style.visibility = "hidden";
}

function hideProjectFormElement($hide1) {
	
	if (document.forms.showFormType.projectType.value == "community"){
		document.getElementById($hide1).style.display='';
	}
	
	if (document.forms.showFormType.projectType.value == "blog"){
		document.getElementById($hide1).style.display='';
	}
	
	if (document.forms.showFormType.projectType.value == "forum"){
		document.getElementById($hide1).style.display='';
	}
	
	if (document.forms.showFormType.projectType.value == "website"){
		document.getElementById($hide1).style.display='';
	}
	
	if (document.forms.showFormType.projectType.value == "video"){
		document.getElementById($hide1).style.display='none';
		document.getElementById($hide1).style.display='none';
	}
	
	if (document.forms.showFormType.projectType.value == "image"){
		document.getElementById($hide1).style.display='none';
	}
	
	if (document.forms.showFormType.projectType.value == "sound"){
		document.getElementById($hide1).style.display='none';
		document.getElementById($hide1).style.display='none';
	}
	
	if (document.forms.showFormType.projectType.value == "other"){
		document.getElementById($hide1).style.display='none';
	}
	
	
}

function initialHideProjectFormElement() {
	document.getElementById("hideLayer").style.visibility = "visible";
}

function deleteUserConfirm(url){
	projectConfirm = confirm("Möchtest Du wirklich Dein Account und alle Projekte löschen?");
	if (projectConfirm) window.location.href=url;
}

function confirmSecurityQuestion(text, url){
	projectConfirm = confirm(text);
	if (projectConfirm) window.location.href=url;
}

function createUsername1($field_1){
	document.getElementById("userNickname").value = $field_1;
}


function createUsername2($field_2){
	$field_1 = document.getElementById("userForename").value;
	
	if($field_1 || $field_2){
		if($field_1 && $field_2){
			$userName = $field_1+" "+$field_2;
		}else if($field_1){
			$userName = $field_1;
		}else if($field_2){
			$userName = $field_2;
		}
		

	}else{
		$userName = '';
	}
	
		
	document.getElementById("userNickname").value = $userName;

}

function deactivateUserNickname(){
	if(document.getElementById("userNicknameIsForeSurename").checked){
		document.getElementById("userNickname").readOnly = true;
	}else{
		document.getElementById("userNickname").readOnly = false;
	}
}

function deactivateInternetService(){
	
	if(document.getElementById("projectInternetService").checked){
		document.getElementById("projectInternetServiceURL").value = "";
		document.getElementById("projectInternetServiceURL").disabled = true;
	}else{
		document.getElementById("projectInternetServiceURL").disabled = false;
	}
}



function showFormInformationBoxClick($boxName) {
// Shows information box when I click the question mark to open and close it


	if(document.getElementById($boxName).style.display =='none'){
		document.getElementById($boxName).style.display='';
	}else{
		document.getElementById($boxName).style.display='none';
	}
}

function checkCheckboxesInForm($elementID){
// I need this fucntion, becaus of the informationMessages. I cannot select the checkboxes with first
// click when the informatinMessage from the other field is closed (entire form jumps up)

	if(document.getElementById($elementID).checked == true){
		document.getElementById($elementID).checked = false;
	}else{
		document.getElementById($elementID).checked = true;
	}
}

function showFormInformationBox($boxName) {
	document.getElementById($boxName).style.display='';
}

function hideFormInformationBox($boxName) {
	document.getElementById($boxName).style.display='none';
}


function toggleSearchForm($currentSearch, $newSearch) {
	document.getElementById($currentSearch).style.display='none'
	document.getElementById($newSearch).style.display='';
	$cookie = "search="+$newSearch;
	document.cookie = $cookie;
	// cookie is read in php not in this javascript function (header.html.php)
}

function showContactText($shortText, $longText){
	document.getElementById($shortText).style.display='none';
	document.getElementById($longText).style.display='';

}
