var wysiwygWin	= null;
var wysiwyg		= null;
var isPageDataChanged = false;

function pageDataChangeRegister() {
	isPageDataChanged=true;
	sbNavigationObject.addHidden('page', prevPage)
	//sbNavigationObject.setViewParam('page', prevPage);
}

function FCKeditor_OnComplete(editorInstance) {
	try{
		wysiwygWin = document.getElementById('wysiwyg___Frame').contentWindow;				
		wysiwyg = editorInstance;
	}catch(e){};
}

function wysiwygGo(nodeId) {
	FCKeditorAPI= null; 
	__FCKeditorNS = null; 
	
	var wIframe = document.getElementById('wysiwyg___Frame');
	wIframe.parentNode.removeChild(wIframe);

	var editorFileFullPath = '/wysiwyg/editor/fckeditor.wizard.php?page=' + nodeId;
	Init_wysiwyg(editorFileFullPath);
}			

function onNodeSelect(nodeId, nodeType) {
	if (!validateForm()) {
		return false;
	}
	if (nodeType=='Simple') {					
		if (wysiwygWin) {
			sbNavigationObject.setViewParam('page', nodeId);
			sbNavigationObject.addHidden('prevPage', prevPage);
			sbNavigationObject.go(action);
			return true;	
		} else {
			sbNavigationObject.setViewParam('page', nodeId);
			sbNavigationObject.addHidden('prevPage', prevPage);
			sbNavigationObject.go(action);
		}	
	} else {
		sbNavigationObject.setViewParam('page', nodeId);
		sbNavigationObject.addHidden('prevPage', prevPage);
		sbNavigationObject.go(action + '/Modules/' + nodeType);
	}	
	return false;
}

var pages = new Array();

function SBPage(title, keywords, description) {
	this.title = title;
	this.keywords = keywords;
	this.description = description;
}

function registerSBPage(id, title, keywords, description) {
	//keywords = keywords.replace(/\n/, ' ');
	//description = description.replace(/\n/, ' ');
	var page = new SBPage(title, keywords, description);
	pages[id] = page;
}

function toggleSBPageData(id) {
	if (pages[id]) {
		document.getElementById('pageTitle').value = pages[id].title;
		document.getElementById('pageKeywords').value = pages[id].keywords;
		document.getElementById('pageDescription').value = pages[id].description;
	}
}