
// this function is what creates the popup window 
function OpenPopUp(strFile, thewidth, theheight) {
  window.open(strFile,'Add','width=' + thewidth + ',height=' + theheight + ',top=50,left=50,scrollbars=1,resizable=1,status=1');
}

//Registers mouse events for controlling styles.
function registerButtonEvents(buttons)
{
    var events = ['mouseover','mouseout','mousedown','mouseup'];
    for(var i =0;i < buttons.length;i++)
    {
        var element = $get(buttons[i]);
        if (element!=null)
        {
            for(var e = 0; e < events.length;e++)
            {
                $addHandler(element,events[e],setButtonClass);
            }
        }
    }
}

//Sets the class for elements based on an event type.
function setButtonClass(eventElement)
{
    var className = eventElement.target.className;
    switch(eventElement.type)
    {
        case 'mouseover':
            className = 'buttonMouseOver';
            break;
        case 'mouseout':
            className = 'button';
            break;
        case 'mousedown':
            className = 'buttonMouseDown';
            break;
        case 'mouseup':
            className = 'buttonMouseOver';
            break;
    }
    
    eventElement.target.className = className;            
}

//Show a panel
function showPanel(panelId)
{    
    hidePanels();
    var panel = $get(panelId);
    if (panel != null)
    {
        panel.style.display = "block";
    }
}

//Hide Panels
function hidePanels()
{
    //panels is a variable defined in the parent document.    
    if (panels != null)
    {
        
        for(var i = 0;i < panels.length; i++)
        {
            var panel = $get(panels[i]);            
            if (panel != null)
            {
                panel.style.display = "none";
            }
        }
    }
}
/* Get Query Srings
 * var args = getArgs( );  // Parse args from URL
 * var q = args.q || "";  // Use argument, if defined, or a default value
 * var n = args.n ? parseInt(args.n) : 10;
 */
function getArgs() {
    var args = new Object( );
    var query = location.search.substring(1);     // Get query string
    var pairs = query.split("&");                 // Break at ampersand
    for(var i = 0; i < pairs.length; i++) {
        var pos = pairs[i].indexOf('=');          // Look for "name=value"
        if (pos == -1) continue;                  // If not found, skip
        var argname = pairs[i].substring(0,pos);  // Extract the name
        var value = pairs[i].substring(pos+1);    // Extract the value
        value = decodeURIComponent(value);        // Decode it, if needed
        args[argname] = value;                    // Store as a property
    }
    return args;                                  // Return the object
}


//Open Legal pages in its own popup window.
function winOpenLegal(legURL) { 
newWin=window.open(legURL,"Legal","width=500,height=400,status=no,toolbar=no,menubar=no,location=no,resizable=no,titlebar=no,scrollbars=yes,fullscreen=no,top=20,left=20") 
}
if(typeof(Sys) !== "undefined") Sys.Application.notifyScriptLoaded();