﻿

function OnWebServiceComplete(arg) 
{
    alert("Generic OnWebServiceComplete");
}

function OnWebServiceTimeOut(arg) 
{
    alert("TimeOut encountered : " + arg);
}

function OnWebServiceError(arg) 
{
    alert("Error encountered : " + arg );
}



function showMoreInfo(productID)
{
    //alert('i would now call a web service to get the additional info for product ID= '+productID);
    ret = Shopping.showMoreInfo(productID,showMoreInfoComplete,OnWebServiceTimeOut, OnWebServiceError);
}

//function showRelatedProds(productID)
//{
////alert('i would now call a web service to get the additional info for product ID= '+productID);
//    ret = Shopping.showRelatedProds(productID,showMoreInfoComplete,OnWebServiceTimeOut, OnWebServiceError);
//}

function showMoreInfoComplete(args)
{

    // args  would be the value, want the ID and the text, so send the ID back as part of xxxxyyyy string.
    
    // eg return will be "true0057<table><tr><td>bob</td></tr></table>";
    
    var returnCode = args;
    var returnCodeStatus = returnCode.substring(0,4);
    if(returnCodeStatus=="true")
    {
        var thisID = returnCode.substring(4,8);
        var thisIntID = parseInt(thisID,10);
        
        var moreInfoHolder = document.getElementById("moreInfoDiv"+thisIntID);
        moreInfoHolder.innerHTML = returnCode.substring(8);
        document.getElementById("moreDetailsBtn" + thisIntID).style.backgroundPosition = '-0px -23px';
        
       
    }
}

function toggleshow(id)
{
    var moreInfoHolder = document.getElementById("moreInfoDiv"+id).innerHTML;
    
    if (moreInfoHolder.length==0)
    {
        // okay, there is no content, so we will want to add the info and set text to "hide";
       document.getElementById("prdDesc" + id).style.display = "none"; 
        showMoreInfo(id);
        
    }
    else 
    {
    // okay, it's already showing the content, so hide it
        document.getElementById("moreInfoDiv" + id).innerHTML = "";
        document.getElementById("moreDetailsBtn" + id).style.backgroundPosition = '-0px -0px';
        document.getElementById("prdDesc" + id).style.display = ""; 
       

    }
//    var viewRelatedProds = document.getElementById("relatedProds"+id).innerHTML;
//    
//    if(viewRelatedProds.length == 0)
//    {
//    showRelatedProds(id);
//    }
//    
//    else{
//     document.getElementById("relatedProds"+id).style.display = "";
//    }
}

