function clearInput(idElement, defaultValue) {
	if (document.getElementById(idElement).value == defaultValue) {
		document.getElementById(idElement).value = "";
		$("#"+idElement).css("color", "black");
	}
}

function returnDefaultValue(idElement, defaultValue) {
	if (document.getElementById(idElement).value == "") {
		document.getElementById(idElement).value = defaultValue;
		$("#"+idElement).css("color", "#cccccc");
	}
}

function verifyDeleteAlbum(link) {
	var areYouSure = confirm("Jesteś pewien, że chcesz usunąć ten album, wraz ze wszystkimi jego podrzędnymi albumami i zdjęciami?");

	if (areYouSure == true) {
		window.location = link;
	} else {
		return false;
	}
}

function verifyDeleteArticle(link) {
	var areYouSure = confirm("Jesteś pewien, że chcesz usunąć ten artykuł?");

	if (areYouSure == true) {
		window.location = link;
	} else {
		return false;
	}
}

function verifyDeleteImage(link) {
	var areYouSure = confirm("Jesteś pewien, że chcesz usunąć to zdjęcie?");

	if (areYouSure == true) {
		window.location = link;
	} else {
		return false;
	}
}

function verifyDeleteForumEntry(link) {
	var areYouSure = confirm("Jesteś pewien, że chcesz usunąć ten wpis?");

	if (areYouSure == true) {
		window.location = link;
	} else {
		return false;
	}
}

function showBlock(idElement) {
	$("#"+idElement).css("display", "inline");
}

function showBlock2(idElement) {
	$("#"+idElement).css("display", "block");
}

function hideBlock(idElement) {
	$("#"+idElement).css("display", "none");
}

function showOrHide(idElement) {
	if (document.getElementById(idElement).style.display == 'none') {
		showBlock(idElement);
	} else {
		hideBlock(idElement);
	}
}

function showHide(value, idBlock) {
	if (value == 'dontKnow') {
		hideBlock(idBlock);
	} else {
		showBlock(idBlock);
	}
}

function setColorForBackground(color) {
	$("#colorBackground").css("background-color", color);
	document.getElementById("imgBackground").value = color;
	$("#background2preview").css("background-color", color);
}

function setColorForBorder(color) {
	$("#colorBorder").css("background-color", color);
	document.getElementById("borderColor").value = color;
	var width = document.getElementById("borderWidth2preview").value;
	$("#img2preview").css("border", width + "px solid " + color);
}

function setBorderWidth(width) {
	document.getElementById("borderWidth2preview").value = width;
	var color = document.getElementById("borderColor").value;
	$("#img2preview").css("border", width + "px solid " + color);
}

function changeView(link, param1, param2, param3) {
	window.location = link + param1 + "/" + param2 + "/" + param3 + "/";
}

function changeForumView(link, param1) {
	window.location = link + param1 + "/";
}

function showCriteriaLink() {
	showBlock2("hideCriteriaLink");
	hideBlock("showCriteriaLink");
	showBlock2("criteriaBox");
}

function hideCriteriaLink() {
	showBlock2("showCriteriaLink");
	hideBlock("hideCriteriaLink");
	hideBlock("criteriaBox");
}

function showHideCriteria(checkboxId, idElement) {
	if (document.getElementById(checkboxId).checked == true) {
		$("#"+idElement).css("display", "block");
	} else {
		hideBlock(idElement);
	}
}

function changeViewFullLink(link) {
	window.location = link;
}

function showStatsBlock(idElement) {
	hideBlock("bestDayHeader");
	hideBlock("bestDayContent");
	hideBlock("bestAllTimeHeader");
	hideBlock("bestAllTimeContent");
	hideBlock("mostCommentedHeader");
	hideBlock("mostCommentedContent");
	hideBlock("mostViewsHeader");
	hideBlock("mostViewsContent");
	hideBlock("bestAllDaysHeader");
	hideBlock("bestAllDaysContent");
	hideBlock("bestAuthorsHeader");
	hideBlock("bestAuthorsContent");

	$("#"+idElement+"Header").css("display", "block");
	$("#"+idElement+"Content").css("display", "block");
}

function showOrHideWithText(idElement, idTextElement, newText, oldText) {
	if (document.getElementById(idElement).style.display == 'none') {
		showBlock(idElement);
	} else {
		hideBlock(idElement);
	}
	$("#"+idTextElement).empty();
	$("#"+idTextElement).prepend(newText);
	document.getElementById(idTextElement).onclick = new Function("showOrHideWithText('"+idElement+"', '"+idTextElement+"', '"+oldText+"', '"+newText+"');return false;");
}

function editForum(idElement) {
	showOrHide("editForumEntry"+idElement);
}

function showOrHideEquipmentNew(value, name) {
	if (value == 'new') {
		showBlock(name);
	} else {
		hideBlock(name);
	}
}

function verifyDelete(link, text) {
	var areYouSure = confirm(text);

	if (areYouSure == true) {
		window.location = link;
	} else {
		return false;
	}
}

function showEquipmentBlock(idElement, textHeader) {
	hideBlock("bestPhotosBlock");
	hideBlock("descriptionBlock");
	hideBlock("paramsBlock");
	hideBlock("imgBlock");

	$("#"+idElement).css("display", "block");
	document.getElementById('header').innerHTML = textHeader;
}
