var urlStringContentBase = "AjaxGenericHandler.aspx";
var stringContentClientCache = new Array();

/*
Seny - 04/07/2009 - Localization of JavaScript messages
Calls an aspx page in ASYNC mode to get the localized string content
This can be called instead of the javascript alert. 
Usage: Call this to ALERT the localized value of a string to be used in JavaScript, ASYNCRONOUSLY
*/
function AsyncAlert(stringName) {
    AsyncAlertFormat('', stringName, '');
}
/*
Seny - 04/07/2009 - Localization of JavaScript messages
Calls an aspx page in ASYNC mode to get the localized string content
This can be called instead of the javascript alert. 
Pass a messagePrefix and a messageSuffix if needed
Usage: Call this to ALERT the localized value of a string to be used in JavaScript, ASYNCRONOUSLY
*/
function AsyncAlertFormat(messagePrefix, stringName, messageSuffix) {

    // first check cache to see if entry exists
    var cacheKey = messagePrefix + stringName + messageSuffix;
    if (typeof (stringContentClientCache[cacheKey]) !== 'undefined') {
        // we've already made at least one async call for these options, 
        //   so let's just use the last result        
        return stringContentClientCache[cacheKey];
    }

    var paramDictionary = {
        string_name: stringName,
        w2p_ajaxRequestType: 'stringcontent'
    };
    var asyncRequest = new Ajax.Request(urlStringContentBase,
        {
            method: 'post',
            parameters: paramDictionary,
            onSuccess: function (transport) {
                // Success, update the images                    
                try {
                    var result = transport.responseText;
                    stringContentClientCache[cacheKey] = result; // add to cache for faster retrieval next time through

                    alert(messagePrefix + result + messageSuffix);
                }
                catch (e) {
                    //alert("Unable to get Product Attributes:" + e);
                }
            },
            onException: function (req, exception) {
                //alert("Exception Occurred for Product Attributes Display: r\nDetails:\r\n\r\n" + exception);
                return false;
            },
            onFailure: function (transport) {
                //alert("some failure for Product Attributes...");
            }
        });
}

/*
NOTE: THIS WILL DO SYNCHRONOUSLY, so the browser may get locked for the time
Seny - 04/07/2009 - Localization of JavaScript messages
Calls an aspx page in SYNC mode to get the localized string content
Usage: Call this to get the localized value of a string to be used in JavaScript, SYNCRONOUSLY
*/
function GetStringContent(stringName) {

    // first check cache to see if entry exists
    var cacheKey = stringName;
    if (typeof (stringContentClientCache[cacheKey]) !== 'undefined') {
        // we've already made at least one async call for these options, 
        //   so let's just use the last result        
        return stringContentClientCache[cacheKey];
    }

    var stringValue = '';
    var paramDictionary = {
        string_name: stringName,
        w2p_ajaxRequestType: 'stringcontent'
    };
    var asyncRequest = new Ajax.Request(urlStringContentBase,
        {
            method: 'post',
            asynchronous: false,
            parameters: paramDictionary,
            onSuccess: function (transport) {
                // Success, update the images                    
                try {
                    stringValue = transport.responseText;
                    stringContentClientCache[cacheKey] = stringValue; // add to cache for faster retrieval next time through
                } catch (e) {
                    //alert("Unable to get Product Attributes:" + e);
                }
            },
            onException: function (req, exception) {
                //alert("Exception Occurred for Product Attributes Display: r\nDetails:\r\n\r\n" + exception);
                return false;
            },
            onFailure: function (transport) {
                //alert("some failure for Product Attributes...");
            }
        });
    return stringValue;
}
