var fadingElement;
var selectedRowInLedger;
var selectedRowInExercise;

function openWindow(strURL, strWidth, strHeight, strTitle) {
	var win = $('GATE');
    if (win == null ) {
        win = new Window('GATE', {className: "dialog", title: strTitle, 
                            zIndex: 9999999999, width: strWidth, height: strHeight, resizable: false, 
                            minimizable: false, maximizable: false, 
                            showEffect:Effect.Appear, hideEffect:Element.hide, draggable:true, wiredDrag: false,
                            url: strURL });
        win.showCenter(true);
    } else {
        win = Windows.getWindow('GATE');
    }
    win.setDestroyOnClose(false);
    win.toFront();
}


function openWindow1(strURL, strWidth, strHeight, strTitle) {
	var win = $('GATE');
    if (win == null ) {
        win = new Window('GATE', {className: "dialog", title: strTitle, 
                            zIndex: 9999999999, width: strWidth, height: strHeight, resizable: false, 
                            minimizable: false, maximizable: false, 
                            showEffect:Effect.Appear, hideEffect:Element.hide, draggable:true, wiredDrag: false,
                            url: strURL});
        win.showCenter(true);
		
    } else {
        win = Windows.getWindow('GATE');
    }
    win.setDestroyOnClose(false);
    win.toFront();
	
	var teste = win.getLocation();
//	alert(teste.left);
	win.setLocation(2,124);
}

// Wrapper util class for window.js functionality
var WindowUtil = new Object();

// Retrieves an existing window instance
WindowUtil.getWindow = function(strId) {
    var windowInstance = undefined;
    if (Windows && strId) {
        windowInstance = Windows.getWindow(strId);
    }
    return windowInstance;
}

// Closes an existing window instance
WindowUtil.closeWindow = function(strId) {
    var closeDiv = parent.document.getElementById(strId + "_close");
    closeDiv.onclick();
}

// Open a new window
WindowUtil.openWindow = function(strId, strUrl, strWidth, strHeight, strTitle) {
    var windowInstance = $(strId);
    if ( !windowInstance ) {
        windowInstance = new Window(strId, {className: "dialog", title: strTitle, 
                            zIndex: 9999999999, width: strWidth, height: strHeight, resizable: false, 
                            minimizable: false, maximizable: false, closable: true,
                            showEffect:Effect.Appear, hideEffect:Element.hide, draggable:true, wiredDrag: false,
                            url: strUrl});
        windowInstance.showCenter(true);
    }
    windowInstance.setDestroyOnClose(true);
    windowInstance.toFront();
}


// Open a new window in the top position of the screen
WindowUtil.openWindowTop = function(strId, strUrl, strWidth, strHeight, strTitle) {
    var windowInstance = $(strId);
    if ( !windowInstance ) {
        windowInstance = new Window(strId, {className: "dialog", title: strTitle, 
                            zIndex: 9999999999, width: strWidth, height: strHeight, resizable: false, 
                            minimizable: false, maximizable: false, closable: true,
                            showEffect:Effect.Appear, hideEffect:Element.hide, draggable:true, wiredDrag: false,
                            url: strUrl});
        
        windowInstance.showCenter(true, -5, 0);
    }
    windowInstance.setDestroyOnClose(true);
    windowInstance.toFront();
}

// Navigates the parent window
WindowUtil.navigateParent = function(strUrl) {
    if (strUrl) {
        parent.location.href=strUrl;
    }
}

function showTable(id) {
	if (document.getElementById(id).style.display == 'block') {
		document.getElementById(id).style.display = 'none';
	}
	  else {
		document.getElementById(id).style.display = 'block';	      
	}
	

  
}
