﻿/*Common.js contains common functions used throughout the application.*/

//Function to launch a new browser window.
function launchNewWindow(URL, setFocusToWindow, windowName, windowSpecs, replaceInHistory)
{
    //Check required field  URL
    if (URL == null)
    {
        alert("Error: Please specify URL when opening new browser window");
        return false;
    }

    //Set defaults for: setFocusToWindow, windowName, windowSpecs, replaceInHistory
    if(setFocusToWindow == null)
    {
        setFocusToWindow = true;
    }
    if(windowName == null)
    {
        windowName = "v-lab";
    }
    if(windowSpecs == null)
    {
        windowSpecs = "";
    }
    if(replaceInHistory == null)
    {
        replaceInHistory = false;
    }
    
    //Open the browser window
    var newWindow=window.open('','','width=200,height=100')
    if (setFocusToWindow == true)
    { 
        newWindow.focus(); 
    }
}

//Helper for attaching events to instance functions
function delegate(target, callback) {
  return function() { callback.apply(target, arguments); };
}