﻿/*
 * JAM 02/27/2008 - Added GETDENSDOCS Function
 *
 * Function: GETDENSDOCS(iPackageID, oElement)
 * Parameters:
 *		iPackageID  = CES Package ID of Product Tab
 *		oElement	= HTML element that was clicked
 * Returns:
 *		void
 * Purpose:
 *		Gets Product Tab content and put the content in the productContent div
 */
 function getDensDocs(iPackageID, product, solution, roof)
{
    var oContext = new Object();
    oContext.Function = "getDensDocs";
    oContext.PackageID = iPackageID;
    try
    {
        Services.AJAX.getDensDocs(iPackageID, product, solution, roof, OnAJAXSucceeded, OnAJAXFailed, oContext);
    }
    catch (e)
    {
        alert(e);
    }
}

/**********************************************************************************************************************
    AJAX Return Functions
***********************************************************************************************************************/
/*
 * JAM 02/27/2008 - Added OnAJAXSucceeded Function
 *
 * Function: OnAJAXSucceeded(result, userContext, methodName)
 * Parameters:
 *		result      = Return value of ajax server call
 *		userContext	= Context object created during the calling function
 *      methodName  = Method name called
 * Returns:
 *		void
 * Purpose:
 *		Processes successful server calls for tree
 */
function OnAJAXSucceeded(result, userContext, methodName) 
{
    switch(userContext.Function.toUpperCase())
    {
        case "GETDENSDOCS":
            //HIDE CURRENT TAB and SHOW CLICKED TAB
            //var aClicked = document.getElementById(userContext.TabClickedID);
            //Replace the class on all of the tabs
            //var ulProductTabs = aClicked.parentNode.parentNode;
//            for(ili = 0; ili < ulProductTabs.childNodes.length; ili++)
//            {
//                var li = ulProductTabs.childNodes[ili];
//                if (li.nodeName.toLowerCase() == "li")
//                {
//                    li.className = "";
//                }
//            }
            //Change the class on the selected tab to selected
            //aClicked.parentNode.className = "selected";            
            //Replace the HTML in the Tab Div with returned content
            document.getElementById("dvWarranty").innerHTML = result;
            break;
        default:
            break;
    }
}

/*
 * JAM 02/27/2008 - Added OnAJAXFailed Function
 *
 * Function: OnAJAXFailed(error, userContext, methodName)
 * Parameters:
 *		error       = error message of ajax server call
 *		userContext	= Context o
 bject created during the calling function
 *      methodName  = Method name called
 * Returns:
 *		void
 * Purpose:
 *		Processes failed server calls for tree
 */
function OnAJAXFailed(error, userContext, methodName) 
{
    var sMessage = "";
    switch(userContext.Function.toUpperCase())
    {
        case "GETDENSDOCS":
            sMessage = "Error retrieving documents.";
            break;
        default:
            break;
    }
    
    alert("error: "+error+", userContext:"+userContext+", Message: "+sMessage+", Methodname:"+methodName);    
}
