﻿function OpenFactSheet(fid,year,month,quaterly) {
    var openURL = "";  
    var handlerdata = 'id=' + fid + '&y=' + year + '&m=' + month + '&quaterly='+quaterly;
    $.ajax({
        type: 'GET',
        url: '/_Layouts/FactSheetHandler.ashx',
        async: false,
        data: handlerdata,
        success: function(result) {
            var result = eval('(' + result + ')');
            if (result.LinkValid) {
                openURL = result.url;
            }
            else {
                alert('No fact sheet exists for the current selection');
            }

        },
        error: FailedFunc
    });

    if (openURL != "") {
        pageTracker._trackPageview(openURL);
        window.open(openURL, "FactSheet");
  }
}

function FailedFunc(xhr, ajaxOptions, thrownError)
{
    alert('There was a problem downloading the fact sheet. Please retry the operation');
}

