// SpryData.js - version 0.52 - Spry Pre-Release 1.6.1
//
// Copyright (c) 2006. Adobe Systems Incorporated.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of Adobe Systems Incorporated nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
(function() { // BeginSpryComponent
if (typeof Spry == "undefined") window.Spry = {}; if (!Spry.Utils) Spry.Utils = {};
//////////////////////////////////////////////////////////////////////
//
// Spry.Utils
//
//////////////////////////////////////////////////////////////////////
Spry.Utils.msProgIDs = ["MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.3.0"];
Spry.Utils.createXMLHttpRequest = function()
{
var req = null;
try
{
// Try to use the ActiveX version of XMLHttpRequest. This will
// allow developers to load file URLs in IE7 when running in the
// local zone.
if (window.ActiveXObject)
{
while (!req && Spry.Utils.msProgIDs.length)
{
try { req = new ActiveXObject(Spry.Utils.msProgIDs[0]); } catch (e) { req = null; }
if (!req)
Spry.Utils.msProgIDs.splice(0, 1);
}
}
// We're either running in a non-IE browser, or we failed to
// create the ActiveX version of the XMLHttpRequest object.
// Try to use the native version of XMLHttpRequest if it exists.
if (!req && window.XMLHttpRequest)
req = new XMLHttpRequest();
}
catch (e) { req = null; }
if (!req)
Spry.Debug.reportError("Failed to create an XMLHttpRequest object!" );
return req;
};
Spry.Utils.loadURL = function(method, url, async, callback, opts)
{
var req = new Spry.Utils.loadURL.Request();
req.method = method;
req.url = url;
req.async = async;
req.successCallback = callback;
Spry.Utils.setOptions(req, opts);
try
{
req.xhRequest = Spry.Utils.createXMLHttpRequest();
if (!req.xhRequest)
return null;
if (req.async)
req.xhRequest.onreadystatechange = function() { Spry.Utils.loadURL.callback(req); };
req.xhRequest.open(req.method, req.url, req.async, req.username, req.password);
if (req.headers)
{
for (var name in req.headers)
req.xhRequest.setRequestHeader(name, req.headers[name]);
}
req.xhRequest.send(req.postData);
if (!req.async)
Spry.Utils.loadURL.callback(req);
}
catch(e)
{
if (req.errorCallback)
req.errorCallback(req);
else
Spry.Debug.reportError("Exception caught while loading " + url + ": " + e);
req = null;
}
return req;
};
Spry.Utils.loadURL.callback = function(req)
{
if (!req || req.xhRequest.readyState != 4)
return;
if (req.successCallback && (req.xhRequest.status == 200 || req.xhRequest.status == 0))
req.successCallback(req);
else if (req.errorCallback)
req.errorCallback(req);
};
Spry.Utils.loadURL.Request = function()
{
var props = Spry.Utils.loadURL.Request.props;
var numProps = props.length;
for (var i = 0; i < numProps; i++)
this[props[i]] = null;
this.method = "GET";
this.async = true;
this.headers = {};
};
Spry.Utils.loadURL.Request.props = [ "method", "url", "async", "username", "password", "postData", "successCallback", "errorCallback", "headers", "userData", "xhRequest" ];
Spry.Utils.loadURL.Request.prototype.extractRequestOptions = function(opts, undefineRequestProps)
{
if (!opts)
return;
var props = Spry.Utils.loadURL.Request.props;
var numProps = props.length;
for (var i = 0; i < numProps; i++)
{
var prop = props[i];
if (opts[prop] != undefined)
{
this[prop] = opts[prop];
if (undefineRequestProps)
opts[prop] = undefined;
}
}
};
Spry.Utils.loadURL.Request.prototype.clone = function()
{
var props = Spry.Utils.loadURL.Request.props;
var numProps = props.length;
var req = new Spry.Utils.loadURL.Request;
for (var i = 0; i < numProps; i++)
req[props[i]] = this[props[i]];
if (this.headers)
{
req.headers = {};
Spry.Utils.setOptions(req.headers, this.headers);
}
return req;
};
Spry.Utils.setInnerHTML = function(ele, str, preventScripts)
{
if (!ele)
return;
ele = Spry.$(ele);
var scriptExpr = "";
ele.innerHTML = str.replace(new RegExp(scriptExpr, "img"), "");
if (preventScripts)
return;
var matches = str.match(new RegExp(scriptExpr, "img"));
if (matches)
{
var numMatches = matches.length;
for (var i = 0; i < numMatches; i++)
{
var s = matches[i].replace(/