var win = '';
var dir = 'http://www.bios.unc.edu/~lin/hapstat/';


var caption = new Array(4);

caption[0] = new Array();

caption[0][0] = "Importing a case-control data file.";
caption[0][1] = "Selecting variables for the single-gene analysis.";
caption[0][2] = "Defining multiple genes.";
caption[0][3] = "Importing external data collected on family trios.";

caption[1] = new Array();

caption[1][0] = "Estimating haplotype frequencies under Hardy-Weinberg " +
                "equilibrium.";
caption[1][1] = "Estimating haplotype frequencies with external data.";

caption[2] = new Array();

caption[2][0] = "Estimating additive haplotype effects in the default setting.";
caption[2][1] = "The <em>Select effects</em> dialog.";
caption[2][2] = "Removing effects 10011, 10011&times;Age and " +
                "10011&times;Gender.";
caption[2][3] = "Adding interaction 01011&times;Age&times;Gender.";
caption[2][4] = "Estimating additive haplotype effects after selection of " +
                "effects.";
caption[2][5] = "Estimating additive haplotype effects of multiple genes.";
caption[2][6] = "Estimating the effects of multiple SNPs.";
caption[2][7] = "Estimating the effects of a single SNP.";

caption[3] = new Array();

caption[3][0]  = "Estimating haplotype frequencies under " +
                 "Hardy-Weinberg disequilibrium.";
caption[3][1]  = "Estimating dominant haplotype effects under " +
                 "Hardy-Weinberg disequilibrium.";
caption[3][2]  = "Estimating additive haplotype effects under " +
                 "Hardy-Weinberg equilibrium.";
caption[3][3]  = "Estimating additive haplotype effects under " +
                 "Hardy-Weinberg equilibrium.";
caption[3][4]  = "Adding the &ldquo;Time&rdquo; covariate to the random " +
                 "effects selection.";
caption[3][5]  = "Estimating additive haplotype effects under Hardy-Weinberg " +
                 "equilibrium.";
caption[3][6]  = "Selecting variables for untyped SNP analysis.";
caption[3][7]  = "Selecting effects for untyped SNP analysis.";
caption[3][8]  = "Untyped SNP analysis using external data collected on " +
                 "family trios.";
caption[3][9]  = "Typed SNP analysis.";
caption[3][10] = "Untyped SNP analysis using external data collected on " +
                 "unrelated individuals.";


function img( file, cap )
{
    var features  = "titlebar=no,menubar=no,resizable=yes,scrollbars=yes,";
        features += "directories=no,location=no,status=yes,toolbar=no,";
        features += "top=0,left=0";

    var cmd  = dir + "images/figure.phtml?fig=" + dir + file;
        cmd += "&caption=" + cap;

    if( win.location && !win.closed )
    {
        win.location.href = cmd;
        win.focus();
    }
    else
    {
        win = window.open( cmd, 'iwin', features );
        win.focus();
    }

    return false;
}


function figure( section, index )
{
    var features  = "titlebar=no,menubar=no,resizable=yes,scrollbars=yes,";
        features += "directories=no,location=no,status=no,toolbar=no,";
        features += "top=0,left=0";

    var ifile = "images/figure-" + section + "." + index + ".png";
    var icaption  = "Figure " + + section + "." + index + ": ";
        icaption += caption[section-1][index-1];

    var cmd  = dir + "images/figure.phtml?fig=" + dir + ifile;
        cmd += "&caption=" + icaption;

    if( win.location && !win.closed )
    {
        win.location.href = cmd;
        win.focus();
    }
    else
    {
        win = window.open( cmd, 'iwin', features );
        win.focus();
    }

    return false;
}


function set_size( width, height )
{
    window.resizeBy( width-window.document.body.clientWidth,
                     height-window.document.body.clientHeight );
/*
    alert( "w: " + width + " h: " + height + "\n ww: " + 
           window.document.body.clientWidth +
           " wh: " + window.document.body.clientHeight );
*/
    return false;
}


function pfv()
{
    var features  = "titlebar=yes,menubar=yes,resizable=yes,scrollbars=yes,";
        features += "directories=no,location=no,status=yes,toolbar=yes,";
        features += "width=700,top=0,left=0";

    var w = window.open( dir + 'documentation/documentation.phtml',
                         'pwin', 
                         features );

    w.focus();
    if( window.print )
    {
        w.print();
    }

    return false;
}


function redirect() 
{
    if( parent.location.href == window.location.href )
    { 
        var dir = location.pathname.substring(
            0, location.pathname.lastIndexOf('/') );

        var file = location.pathname.substring(
            location.pathname.lastIndexOf('/')+1 );

        window.location.replace( dir );
    }

    return false;
}


/*
function img( file )
{
    var features  = "titlebar=no,menubar=no,resizable=no,scrollbars=no,";
        features += "directories=no,location=no,status=no,toolbar=no,";
        features += "width=944,height=666,top=0,left=0";

    if( win.location && !win.closed ) 
    {
        win.location.href = dir+file; 
    }
    else
    {
        win = window.open( dir+file, 'iwin', features );
    }

    if( win )
    {
        win.document.write( "<html>\n" );
        win.document.write( "<head>\n" );
        win.document.write( "<title></title>\n" );
        win.document.write( "</head>\n\n" );
        win.document.write( "<body " );
        win.document.write( "style = \"" );
        win.document.write( "background-image:url(" + dir + file + "); " );
        win.document.write( "background-attachment:fixed; " );
        win.document.write( "background-repeat:no-repeat;\">\n\n" );
        win.document.write( "</body>\n" );
        win.document.write( "</html>\n" );
        win.document.write( "" );
        win.resizeBy( file.width-win.document.body.clientWidth,
                      file.height-win.document.body.clientHeight );

        win.document.close();
        win.focus();
    }
    
    return false;
}
*/
