﻿// This file contains javascript pertaining to openning popup windows

function void_GeneralPopup_OpenLinkInNewWindow(string_txtLink, int_height, int_width, bool_scrollbars)
{
    if (bool_scrollbars == null)
        bool_scrollbars = true;

    var string_features = string_GeneralPopup_GenerateWindowFeaturesString(int_height, int_width, 0, 0, bool_scrollbars, true, true);

    window.open(string_txtLink, '', string_features);
}

function string_GeneralPopup_GenerateWindowFeaturesString(int_height, int_width, int_xPosition, int_yPosition, bool_scrollbars, bool_resizeable, bool_statusBar)
{
    string_features = "";
    
    if (int_height > 0)
        string_features += "height = " + int_height + ",";
    if (int_width > 0)
        string_features += "width = " + int_width + ",";
    if (int_xPosition > 0)
        string_features += "screenX = " + int_xPosition + ",";
    if (int_yPosition > 0)
        string_features += "screenY = " + int_yPosition + ",";
    if (bool_scrollbars)
        string_features += "scrollbars = yes,";
    else
        string_features += "scrollbars = no,";
    if (bool_resizeable)
        string_features += "resizable = yes,";        
    else
        string_features += "resizable = no,";
    if (bool_statusBar)
        string_features += "status = yes,";        
    else
        string_features += "status = no,";
        
    if (string_features.length > 0)
        string_features = string_features.substring(0, string_features.length - 1);
        
    return string_features;
}

function void_GeneralPopup_OpenPopupByFilenameParametersAndAttributes(string_fileName, string_parameter_names, string_parameter_values, int_height, int_width, bool_scrollbars, bool_resizeable, bool_statusBar)
{
    var string_features = string_GeneralPopup_GenerateWindowFeaturesString(int_height, int_width, 0, 0, bool_scrollbars, bool_resizeable, bool_statusBar);
    
    var string_completeFilename = string_GeneralUtilities_SitePrefix() + string_fileName;

    if (string_parameter_names != '')
    {
        var stringArray_paramaterNames = string_parameter_names.split('|');
        var stringArray_paramaterValues = string_parameter_values.split('|');
        
        if (stringArray_paramaterNames.length == stringArray_paramaterValues.length)
        {
            string_completeFilename += "?";    
    
            for (i = 0; i < stringArray_paramaterNames.length; i++)
            {
                string_completeFilename += stringArray_paramaterNames[i] + "=" + stringArray_paramaterValues[i];
                
                if (i != stringArray_paramaterNames.length - 1)
                    string_completeFilename += "&";                
            }
        }
        else if (stringArray_paramaterNames.length == 1)
        {
            string_completeFilename += "?" + stringArray_paramaterNames[0] + "=" + string_parameter_values;    
        }
    }   
    
    myWindow = window.open(string_completeFilename, "", string_features);
}

function void_GeneralPopup_InformationDisplayPopup(int_informationDisplayID)
{   
    void_GeneralPopup_OpenPopupByFilenameParametersAndAttributes("cs_Popup.aspx", "ID", int_informationDisplayID.toString(), 475, 761, true, true, true);
}

function void_GeneralPopup_StructurePrintPopupByProductIDAndPONString(int_productID, string_productOptionNotationString)
{   
        void_GeneralPopup_OpenPopupByFilenameParametersAndAttributes("StructurePrintPopup.aspx", "ProductID|ProductOptionNotationString", int_productID + "|" + string_productOptionNotationString, 550, 710, true, true, true);
}

function void_GeneralPopup_RequestSpecificationPopupByProductIDAndPONString(int_productID, string_productOptionNotationString)
{   
    void_GeneralPopup_OpenPopupByFilenameParametersAndAttributes("SpecRequestPopup.aspx", "ProductID|ProductOptionNotationString", int_productID + "|" + string_productOptionNotationString, 630, 600, true, true, true);
}

function void_GeneralPopup_3DPopup(int_productID, string_productOptionNotationString)
{   
    void_GeneralPopup_OpenPopupByFilenameParametersAndAttributes("3DPopup.aspx", "ProductID|ProductOptionNotationString", int_productID + "|" + string_productOptionNotationString, 575, 600, true, true, true);
}
