

/* HTML 2 PlainText */


function fWriteHtml() {
	plain  = GetData();
	plain = plain.replace(/[\r]|[\n]|[\r\n]|[\t]/ig,"");
	plain = plain.replace(/<br \/>/ig,"\r\n");
	plain = plain.replace(/(<([^>]+)>)/ig,"");

	fId('sPlaintext').value = plain;

	return false;
}

function GetData()
{
	return oEditsHtml.getXHTML();
}


function fShowHidePlaintext() {
	if(fId('tr_plain').style.display == "none") {
		fId('tr_plain').style.display = '';
		fId('circle').src = "images/icons/"+ sIconpack +"/circle_up_16.png";
	}
	else {
		fId('tr_plain').style.display = "none";
		fId('circle').src = "images/icons/"+ sIconpack +"/circle_down_16.png";
	}
	return false;
}


function fHideTable(_sId) {

	if(fId(_sId).style.display == "none") {
		fId(_sId).style.display = '';
		fId("img_" + _sId).src = "images/icons/"+ sIconpack +"/circle_up_16.png";
	}
	else {
		fId(_sId).style.display = "none";
		fId("img_" + _sId).src = "images/icons/"+ sIconpack +"/circle_down_16.png";
	}
	fCheckOutIn(_sId.substring(0,_sId.length-2));
	return false;
}

function fHideAll(_sType) {
	for(i = 0; i < 3; i++) {
		if(fId(_sType + "_" + i)) {
			if(fId(_sType + "_" + i).style.display == "none") {
				fId(_sType + "_" + i).style.display = '';

				fId("img_" + _sType + "_" + i).src = "images/icons/"+ sIconpack +"/circle_up_16.png";
			}
			else {
				fId(_sType + "_" + i).style.display = 'none';
				fId("img_" + _sType + "_" + i).src = "images/icons/"+ sIconpack +"/circle_down_16.png";;
			}
		}
	}
	if(fId("img_" + _sType).alt == "up") {
		fId("img_" + _sType).src = "images/icons/"+ sIconpack +"/circle_down_16.png"
		fId("img_" + _sType).alt = "down";
	}
	else {
		fId("img_" + _sType).src = "images/icons/"+ sIconpack +"/circle_up_16.png"
		fId("img_" + _sType).alt = "up";
	}
	return false;
}


function fCheckOutIn(_sType) {
	nCountAll = 0;
	nCount = 0;
	for(i = 0; i < 3; i++) {
		if(fId(_sType + "_" + i)) {
			nCountAll++;
			if(fId(_sType + "_" + i).style.display == "none") {
				nCount++;
			}
		}
	}
	if(nCountAll == nCount) {
		fId("img_" + _sType).src = "images/icons/"+ sIconpack +"/circle_down_16.png";
	}
	else {
		fId("img_" + _sType).src = "images/icons/"+ sIconpack +"/circle_up_16.png";
	}

}
