
var ColRootMenu = new cPopupMenu( window.parent, null, 'Style/Menu.css' );
var ColSetMenu  = new cPopupMenu( window.parent, null, 'Style/Menu.css' );
var ColumnMenu  = new cPopupMenu( window.parent, null, 'Style/Menu.css' );

var Ajax, cPath, cName, cTitle, siteName;

function Page_load()	//用户登录 系统启动
    {
	siteName = Common.GetQueryString('sitename');
	if( !siteName ) return;
	
	if( !self.parent.OpenFrame ) return;
	    window.OpenFrame = self.parent.OpenFrame; // 在主框架打开页面
	
	ColRootMenu.AddItem( 'secHead', {value:'内容栏目根'});
	ColRootMenu.AddItem( 'link', {method:'function', value:'新建栏目(C)', funcRef: Operation, parames:['AddColumn'] });
//	ColRootMenu.AddItem( 'link', {method:'function', value:'新建栏目集(N)', funcRef: Operation, parames:['AddColSet'] });
//	ColRootMenu.AddItem( 'divider' );
//	ColRootMenu.AddItem( 'link', {method:'function', value:'属性(R)', funcRef: Operation, parames:[''] });
	
	ColSetMenu.AddItem( 'secHead', {value:'栏目集作'});
//	ColSetMenu.AddItem( 'link', {method:'function', value:'新建栏目(C)', funcRef: Operation, parames:['AddColumn'] });
//	ColSetMenu.AddItem( 'link', {method:'function', value:'新建子栏目集(N)', funcRef: Operation, parames:['AddColSet'] });
//	ColSetMenu.AddItem( 'divider' );
	ColSetMenu.AddItem( 'link', {method:'function', value:'删除(D)', funcRef: Operation, parames:['DelColSet'] });
//	ColSetMenu.AddItem( 'link', {method:'function', value:'重命名(M)', funcRef: Operation, parames:['RenColSet'] });
//	ColSetMenu.AddItem( 'divider' );
//	ColSetMenu.AddItem( 'link', {method:'function', value:'属性(R)', funcRef: Operation, parames:[''] });

	ColumnMenu.AddItem( 'secHead', {value:'栏目'});
	ColumnMenu.AddItem( 'link', {method:'function', value:'编辑栏目内容(C)..',isBold:true, funcRef: Operation, parames:['ContentList'] });
	ColumnMenu.AddItem( 'link', {method:'function', value:'更改栏目结构(E)..', funcRef: Operation, parames:['ColumnEdit'] });
	ColumnMenu.AddItem( 'divider' );
	ColumnMenu.AddItem( 'link', {method:'function', value:'删除(D)', funcRef: Operation, parames:['DelColumn'] });
	ColumnMenu.AddItem( 'link', {method:'function', value:'重命名(M)', funcRef: Operation, parames:['RenColumn'] });
//	ColumnMenu.AddItem( 'divider' );
//	ColumnMenu.AddItem( 'link', {method:'function', value:'属性(R)', funcRef: Operation, parames:[''] });
	
	Ajax = new AjaxRequest( 'ColumnOp.aspx', FreshTree, null );
	
	document.oncontextmenu = function(){ return false; };
	document.onselectstart = function(){ return false; };
    }    
function ShowMenu( menu )
    {
	cPath = event.srcElement.id;
	cName = event.srcElement.value;
	cTitle = event.srcElement.innerText;
	
	menu.Show( event.x+8, event.y+130 );
	return false;
    }
function dbClick()
    {
	cPath = event.srcElement.id;
	cName = event.srcElement.value;
	cTitle = event.srcElement.innerText;
	
        Operation( 'ContentList' );
    }
function Operation( op )
    {
	if( !op || !siteName || !cPath || !cName || !cTitle ) return;
	
//	var postText = 'optype='+ op.toLowerCase() +'&sitename='+ siteName;
	var post = new UrlText( ['optype', op], ['sitename', siteName] );
		
	switch( op ){
	// 栏目集操作 *************************************
	case 'AddColSet':	// 添加 // Common Dialog -- Ajax	    
	    var ret = Common.ShowDialog( 11, '../CommonUI/NewTitle.htm', {DialogMode:op} );
	    if( ret && ret.name && ret.title ){
//	        postText += '&path='+ cPath +'&newname='+ ret.name +'&newtitle='+ escape(ret.title);
	        post.Add( ['path', cPath], ['newname', ret.name], ['newtitle', ret.title] );
	        Ajax.Post( post.Text );
	    }
	    break;
	    
	case 'RenColSet':	// 重命名 // Common Dialog -- Ajax	    
	    var ret = Common.ShowDialog( 11, '../CommonUI/NewTitle.htm', {DialogMode:op, OldTitle:cTitle} );
	    if( ret && ret.title ){
//	        postText += '&path='+ cPath +'&newtitle='+ escape(ret.title);
	        post.Add( ['path', cPath], ['newtitle', ret.title] );
	        Ajax.Post( post.Text );
	    }
	    break;
	
	case 'DelColSet':	// 删除 // Confirm? -- Ajax
	    if( confirm('您确认要删除栏目集"'+ cTitle +'"吗?') ){
//	        postText += '&path='+ cPath;
	        post.Add( ['path', cPath] );
	        Ajax.Post( post.Text );
	    }
	    break;

	// 栏目操作 *************************************
	case 'AddColumn':	// 添加 // Common Dialog -- Ajax
	    var ret = Common.ShowDialog( 11, '../CommonUI/NewTitle.htm', {DialogMode: op} );
	    if( ret && ret.name && ret.title ){
//	        postText += '&path='+ cPath +'&newname='+ ret.name +'&newtitle='+ escape(ret.title);
	        post.Add( ['path', cPath], ['newname', ret.name], ['newtitle', ret.title] );
	        Ajax.Post( post.Text );
	    }
	    break;

	case 'RenColumn':	// 重命名 // Common Dialog -- Ajax
	    var ret = Common.ShowDialog( 11, '../CommonUI/NewTitle.htm', {DialogMode:op, OldTitle:cTitle} );
	    if( ret && ret.title ){
//	        postText += '&colname='+ cName +'&newtitle='+ escape(ret.title);
	        post.Add( ['colname', cName], ['newtitle', ret.title] );
	        Ajax.Post( post.Text );
	    }
	    break;
	    
	case 'DelColumn':	// 删除 // Confirm? -- Ajax
	    if( confirm('您确认要删除栏目"'+ cTitle +'"吗?') ){
//	        postText += '&colname='+ cName;
	        post.Add( ['colname', cName] );
	        Ajax.Post( post.Text );
	    }
	    break;
	    
	case 'ContentList':     // 内容编辑 // frame
	    var url = new UrlText( 'ColumnManage/ContentList.aspx', ['sitename', siteName], ['colname', cName], 'uni' );
//	    var url = 'ColumnManage/ContentList.aspx?sitename='+ siteName +'&colname='+ cName +'&uni='+ Common.UniqueValue();
	    OpenFrame( url.Text );
	    break;
	    
	case 'ColumnEdit':      // 栏目结构编辑 // frame
	    var url = new UrlText( 'ColumnManage/ColumnEdit.aspx', ['sitename', siteName], ['colname', cName], 'uni' );
//	    var url = 'ColumnManage/ColumnEdit.aspx?sitename='+ siteName +'&colname='+ cName + '&uni='+ Common.UniqueValue();
	    OpenFrame( url.Text );
	    break;
        }
    }
// 刷新树
function FreshTree()
    {
	window.location.reload( true );
    }
