function saveContentForm(strSaveOK) {//$j("#insertForm").submit();
    /*
    *	tinyMCE.triggerSave()
    *		Makes a cleanup and moves the contents from the editor to the form field.
    *		This method is automatically called by tinyMCE by adding a trigger on the forms submit method.
    *
    *		Must be called manually in AJAX forms!
   
    */

    tinyMCE.triggerSave();
	var contentForm = $j("#insertForm :input").serialize(); // serialize() drops off all unchecked checkboxes, radiobuttons etc..
	
	$j.ajax({
		url: "index.php?name=Content&method=save",
		type: "POST",
		data: contentForm,
  		success: function(msg){
  			if(msg == 'notitle'){
  				Common.showMessage('error',Common.getLocale(objLC.js_noTitleError,'js_noTitleError'));
  			}
  			else{
				if(window.location.href.match("method=insert")) {
					window.location.href = "index.php?name=Content&method=update&nodeIDX="+parseInt(msg);
				}
				else {
					Common.showMessage('success',strSaveOK);
				}
			}
		}
	}); 
}
var dlg_tellafriend = "";

function tellAFriend(data, header){
	if(document.getElementById('dlg_tellafriend'))
		var dlg_tellafriend = $j("#dlg_tellafriend");
	else
		var dlg_tellafriend = $j("<div id='dlg_tellafriend'></div>");
	dlg_tellafriend.appendTo("#body");
	dlg_tellafriend.load("index.php?name=Content&method=tellAFriend&blocks=ah&data="+data);

	dlg_tellafriend = $j("#dlg_tellafriend").modal({
		onClose: function(dialog){
			dialog.data.fadeOut('fast', function () {
				dialog.container.hide('fast', function () {
					$j.modal.close();
				});
			});
		},
		containerHeaderText: header
	});
}
function createPage(url) {
	window.open(url, '_blank', 'toolbar=no, location=0, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, address=no, width=850, height=600');
}

function closeInsertForm(){
	window.opener.location.reload();
	window.close();
}

function openPagePicker(field_name, win){
	tinyMCE.activeEditor.windowManager.open({
        file : "index.php?name=Content&method=getPagePicker&blocks=bn",
        title : 'Page picker',
        width : 350,  // Your dimensions may differ - toy around with them!
        height : 250,
        resizable : "yes",
        inline : "yes",  // This parameter only has an effect if you use the inlinepopups plugin!
        close_previous : "no"
    }, {
        window : win,
        input : field_name
    });
    
    return false;
}

function pagePickerOk(){
	var page = $j('input[name=pagePickerValue]').val();
	var win = tinyMCEPopup.getWindowArg("window");
	win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value = page;
	tinyMCEPopup.close();
}


