//menu window opener
function openMenuWindow(menu, order, level, parent){
	var mywin = window.open("?path=control_popup&sec=menu_manager&act=new&menu="+menu+"&order="+order+"&level="+level+"&parent="+parent+"","mywindow","width=800, height=590, status=1, scrollbars=1");
}


//show size
var panelIDs = new Array();

function printSize(e) {
	var contentWidth;
	contentWidth = document.getElementById(e).offsetWidth;

	document.getElementById(e).innerHTML = '<span class="showSize">&lt;--- ' + contentWidth + 'px wide. ---&gt;</span>'
	return contentWidth;
}

function setPanelId(e) {
	panelIDs[panelIDs.length] = e;
}

function showPanelSizes() {
	var i=0;
	for (i=0;i<=(panelIDs.length-1);i++) {
		printSize(panelIDs[i]);
	}
}

//meta editor
function show_meta_editor(e) {
	if(document.getElementById(e).style.display == 'block') {
		document.getElementById(e).style.display = 'none';
	}else{
		document.getElementById(e).style.display = 'block';
	}
}

function addMetaKeyword(sWord){
	var keyBox = document.getElementById('page_keywords_tag');
	
	var keyArray = keyBox.value.split(',');
	var bExists = false;
	
	for(i=0;i<keyArray.length;i++){
		if(trim(keyArray[i]) == sWord){
			bExists = true;
		}
	}
	if(!bExists){
		if(keyBox.value.length != 0){
			keyBox.value = keyBox.value + ', ' + sWord;
		}else{
			keyBox.value = sWord;
		}
	}else{
		alert(sWord + ' is already in your keyword list');
	}
}


function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}