/*
 * Handles events from the ddl that picks plot type
 */
function PlotTypeManager(ptDDL,dim_browserID){
    var PTypeDDL;
    var DBrowser;
    var lastCursor;
    
    this.PTypeDDL = ptDDL;
    this.DBrowser = dim_browserID;
    this.TogglePlotType = TogglePlotType;
    this.SetPlotType = SetPlotType;
    
    function TogglePlotType(){
        var ptypeDDL = document.getElementById(this.PTypeDDL);
        var val = ptypeDDL[ptypeDDL.selectedIndex].value;
        document.getElementById('ptype').value = val;        
        frames['mframe'].location = 'load_members.aspx?loadptype=true&type='+val+'&atab='+document.getElementById('atab').value;
        this.lastCursor = document.body.style.cursor;
        document.body.style.cursor = 'wait';
    }
    function SetPlotType(){
        var dbrow = document.getElementById(this.DBrowser);
        dbrow.innerHTML = '';
        document.getElementById('dim_browser_title').innerHTML = '';
        var newplottype = frames['mframe'].document.getElementsByTagName('div')[0];
        newplottype  = document.importNode(newplottype,true);
        var header = newplottype.getElementsByTagName('h5')[0];       
        var body = newplottype.getElementsByTagName('div')[0];        
        while(dbrow.childNodes.length > 0)
            dbrow.removeChild(dbrow.childNodes[0]);
        document.getElementById('dim_browser_title').appendChild(header);   
        newplottype.style.height = document.getElementById('ltd').offsetHeight - document.getElementById('dim_browser_title').offsetHeight;
        dbrow.style.height = parseInt(newplottype.style.height)-4;
        dbrow.appendChild(body);       
        
        dbrow.style.height = parseInt(newplottype.style.height)-4;
        body.style.height = dbrow.style.height;
        
        document.body.style.cursor = this.lastCursor;
        sm.SetSelected('p1r');
        window.pb.TogglePButton(true);
    }
}