var DisplayedPost = "";

function EID(Id) {
	return document.getElementById(Id);
}

function ShowHide(Id) {
	if (EID(Id).style.display == "none") EID(Id).style.display = "block";
	else EID(Id).style.display = "none";
}

function DisplayPost(Id) {
	if(DisplayedPost != "") EID(DisplayedPost).style.display = "none";
	EID(Id).style.display = "block";	
	DisplayedPost = Id;
}

function AddBold() {
	if(EID("InputBold").value == 'B') {
		EID("Content").value += '[B]';
		EID("InputBold").value = 'B*';
		EID("Content").focus();
	}
	else {
		EID("Content").value += '[/B]';
		EID("InputBold").value = 'B';
		EID("Content").focus();
	}
}

function AddUnderline() {
	if(EID("InputUnderline").value == 'U') {
		EID("Content").value += '[U]';
		EID("InputUnderline").value = 'U*';
		EID("Content").focus();
	}
	else {
		EID("Content").value += '[/U]';
		EID("InputUnderline").value = 'U';
		EID("Content").focus();
	}
}

function AddItalic() {
	if(EID("InputItalic").value == 'I') {
		EID("Content").value += '[I]';
		EID("InputItalic").value = 'I*';
		EID("Content").focus();
	}
	else {
		EID("Content").value += '[/I]';
		EID("InputItalic").value = 'I';
		EID("Content").focus();
	}
}

function AddImage() {
	if(EID("InputImage").value == 'IMG') {
		EID("Content").value += '[IMG]';
		EID("InputImage").value = 'IMG*';
		EID("Content").focus();
	}
	else {
		EID("Content").value += '[/IMG]';
		EID("InputImage").value = 'IMG';
		EID("Content").focus();
	}	
}

function AddURL() {
	if(EID("InputURL").value == 'URL') {
		EID("Content").value += '[URL]';
		EID("InputURL").value = 'URL*';
		EID("Content").focus();
	}
	else {
		EID("Content").value += '[/URL]';
		EID("InputURL").value = 'URL';
		EID("Content").focus();
	}	
}

function AddPre() {
	if(EID("InputPre").value == 'PRE') {
		EID("Content").value += '[PRE]';
		EID("InputPre").value = 'PRE*';
		EID("Content").focus();
	}
	else {
		EID("Content").value += '[/PRE]';
		EID("InputPre").value = 'PRE';
		EID("Content").focus();
	}	
}

function AddHidden() {
	if(EID("InputHidden").value == 'HID') {
		EID("Content").value += '[HID]';
		EID("InputHidden").value = 'HID*';
		EID("Content").focus();
	}
	else {
		EID("Content").value += '[/HID]';
		EID("InputHidden").value = 'HID';
		EID("Content").focus();
	}
}

function AddEmoticon(code) {
	EID("Content").value += code;
	EID("Content").focus();
}

function AddImportant() {
	if(EID("InputImportant").value == 'IMP') {
		EID("Content").value += '[IMP]';
		EID("InputImportant").value = 'IMP*';
		EID("Content").focus();
	}
	else {
		EID("Content").value += '[/IMP]';
		EID("InputImportant").value = 'IMP';
		EID("Content").focus();
	}	
}

function AddHR() {
	EID("Content").value += '[HR]';
	EID("Content").focus();
}

function AddTab() {
	EID("Content").value += '[TAB]';
	EID("Content").focus();
}