/**
 * dCMS version 4
 *
 * Copyright (c) 2007-2008 Westernacher Products & Services AG. All rights reserved.
 * 
 * This software is made available under the terms of the license
 * which can be obtained from WPS: support-dcms@westernacher.com
 */
// Automatically generated file. Don't edit! 

/**
 * $Id: xmlhttp.js 247 2008-05-09 08:31:55Z hen $
 *
 * dCMS version 3
 *
 * Copyright (c) 2007 Westernacher Product and Services AG. All rights reserved.
 */
// Automatically generated file. Don't edit! 

/*
HTMLHttpRequest v1.0 beta2
(c) 2001-2005 Angus Turnbull, TwinHelix Designs http://www.twinhelix.com
Licensed under the CC-GNU LGPL, version 2.1 or later:
http://creativecommons.org/licenses/LGPL/2.1/
This is distributed WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
var aeOL = [];
function addEvent(o, n, f, l) {
var a = 'addEventListener', h = 'on' + n, b = '', s = '';
if (o[a] && !l) return o[a](n, f, false);
o._c |= 0;
if (o[h]) {
b = '_f' + o._c++;
o[b] = o[h];
}
s = '_f' + o._c++;
o[s] = f;
o[h] = function(e) {
e = e || window.event;
var r = true;
if (b) r = o[b](e) != false && r;
r = o[s](e) != false && r;
return r;
};
aeOL[aeOL.length] = { o: o, h: h };
};
addEvent(window, 'unload', function() {
for (var i = 0; i < aeOL.length; i++) {
with (aeOL[i]) {
o[h] = null;
for (var c = 0; o['_f' + c]; c++) o['_f' + c] = null;
}
}
});
function cancelEvent(e, c) {
e.returnValue = false;
if (e.preventDefault) e.preventDefault();
if (c) {
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
}
};
function HTMLHttpRequest(myName, callback) {
this.myName = myName;
this.callback = callback;
this.xmlhttp = null;
this.iframe = null;
window._ifr_buf_count |= 0;
this.iframeID = 'iframebuffer' + window._ifr_buf_count++;
this.loadingURI = '';
if (window.XMLHttpRequest) {
this.xmlhttp = new XMLHttpRequest();
} else if (window.ActiveXObject) {
try {
this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP")
} catch(e) {
var success = false;
var MSXML_XMLHTTP_PROGIDS = new Array(
'Microsoft.XMLHTTP',
'MSXML2.XMLHTTP',
'MSXML2.XMLHTTP.5.0',
'MSXML2.XMLHTTP.4.0',
'MSXML2.XMLHTTP.3.0'
);
for (var i = 0;i < MSXML_XMLHTTP_PROGIDS.length && !success; i++) {
try {
this.xmlhttp = new ActiveXObject(MSXML_XMLHTTP_PROGIDS[i]);
success = true;
} catch (e) {
this.xmlhttp = null;
}
}
}
}
with (this) {
if (xmlhttp && (typeof xmlhttp.overrideMimeType == "function")) {
xmlhttp.overrideMimeType('text/xml');
}
if (!xmlhttp) {
if (document.createElement && document.documentElement &&
(window.opera || navigator.userAgent.indexOf('MSIE 5.0') == -1)) {
var ifr = document.createElement('iframe');
ifr.setAttribute('id', iframeID);
ifr.setAttribute('name', iframeID);
ifr.style.visibility = 'hidden';
ifr.style.position = 'absolute';
ifr.style.width = ifr.style.height = ifr.borderWidth = '0px';
iframe = document.getElementsByTagName('body')[0].appendChild(ifr);
} else if (document.body && document.body.insertAdjacentHTML) {
document.body.insertAdjacentHTML('beforeEnd', '<iframe name="' + iframeID +
'" id="' + iframeID + '" style="display: none"></iframe>');
}
if (window.frames && window.frames[iframeID]) {
iframe = window.frames[iframeID];
}
iframe.name = iframeID;
}
}
return this;
};
HTMLHttpRequest.prototype.parseForm = function(form) {
with (this) {
var str = '', gE = 'getElementsByTagName', inputs = [
(form[gE] ? form[gE]('input') : form.all ? form.all.tags('input') : []),
(form[gE] ? form[gE]('select') : form.all ? form.all.tags('select') : []),
(form[gE] ? form[gE]('textarea') : form.all ? form.all.tags('textarea') : [])
];
for (var i = 0; i < inputs.length; i++) {
for (j = 0; j < inputs[i].length; j++) {
if (inputs[i][j]) {
var plus = '++'.substring(0,1);
str += escape(inputs[i][j].getAttribute('name')).replace(plus, '%2B') +
'=' + escape(inputs[i][j].value).replace(plus, '%2B') + '&';
}
}
}
return str.substring(0, str.length - 1);
}
};
HTMLHttpRequest.prototype.xmlhttpSend = function(uri, formStr) {
with (this) {
xmlhttp.open(formStr ? 'POST' : 'GET', uri, true);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
//var doc = (xmlhttp.responseXML.documentElement ? xmlhttp.responseXML : xmlhttp.responseText);
var doc = xmlhttp.responseText;
var isValidData = true;
if (window.beforeLoadByXmlHttp) {
isValidData = window.beforeLoadByXmlHttp(doc, loadingURI);
}
if (isValidData) {
if (callback) callback(doc, loadingURI);
if (window.onLoadByXmlHttp) {
window.onLoadByXmlHttp(doc, loadingURI);
}
}
loadingURI = '';
} else if (xmlhttp.readyState == 3) {
if (window.onProgressInXmlHttp && !document.all) {
var contentLength = 0;
try {
contentLength = xmlhttp.getResponseHeader("Content-Length");
} catch (e) {
contentLength = -1;
}
window.onProgressInXmlHttp(xmlhttp.responseText.length, contentLength);
}
/*
} else if (xmlhttp.readyState == 4) {
if (window.onFailXmlHttp) {
window.onFailXmlHttp(xmlhttp.status, xmlhttp.statusText);
} else {
alert("Data Request failed with an HTTP status=" + xmlhttp.status + " and error description=" + xmlhttp.statusText);
}
*/
}
};
if (formStr && (typeof xmlhttp.setRequestHeader == "function")) {
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
}
xmlhttp.send(formStr);
loadingURI = uri;
return true;
}
}
HTMLHttpRequest.prototype.iframeSend = function(uri, formRef) {
with (this) {
if (!document.readyState) return false;
if (document.getElementById) var o = document.getElementById(iframeID).offsetWidth;
if (formRef) {
formRef.setAttribute('target', iframeID);
} else {
var ifrDoc = iframe.contentDocument || iframe.document;
if (!window.opera && ifrDoc.location && ifrDoc.location.href != location.href) {
ifrDoc.location.replace(uri);
} else {
iframe.src = uri;
}
}
loadingURI = uri;
setTimeout(myName + '.iframeCheck()', (window.opera ? 250 : 100));
return true;
}
}
HTMLHttpRequest.prototype.iframeCheck = function() {
with (this) {
doc = iframe.contentDocument || iframe.document;
var il = iframe.location, dr = doc.readyState;
if ((il && il.href ? il.href.match(loadingURI) : 1) &&
(dr == 'complete' || (!document.getElementById && dr == 'interactive'))) {
if (callback) callback((doc.documentElement || doc), loadingURI);
loadingURI = '';
} else {
setTimeout(myName + '.iframeCheck()', 50);
}
}
}
HTMLHttpRequest.prototype.load = function(uri) {
with (this) {
if (!uri || (!xmlhttp && !iframe)) return false;
if (xmlhttp) {
return xmlhttpSend(uri, '');
} else if (iframe) {
return iframeSend(uri, null);
} else {
return false;
}
}
};
HTMLHttpRequest.prototype.submit = function(formRef, evt) {
with (this) {
evt = evt || window.event;
if (!formRef || (!xmlhttp && !iframe)) return false;
var method = formRef.getAttribute('method'), uri = formRef.getAttribute('action');
if (method && method.toLowerCase() == 'post') {
if (xmlhttp) {
if (evt) cancelEvent(evt);
return xmlhttpSend(uri, parseForm(formRef));
} else if (iframe) {
return iframeSend(uri, formRef);
} else {
return false;
}
} else {
if (evt) cancelEvent(evt);
return load(uri + (uri.indexOf('?') == -1 ? '?' : '&') + parseForm(formRef));
}
}
}
function RemoteFileLoader(myName) {
this.myName = myName;
this.threads = [];
this.loadingIDs = {};
this.onload = null;
};
RemoteFileLoader.prototype.getThread = function(destId) {
with (this) {
var thr = -1;
for (var id in loadingIDs) {
if (id == destId) {
thr = loadingIDs[id];
break;
}
}
if (thr == -1) for (var t = 0; t < threads.length; t++) {
if (!threads[t].loadingURI) {
thr = t;
break;
}
}
if (thr == -1) {
thr = threads.length;
threads[thr] = new HTMLHttpRequest(myName + '.threads[' + thr + ']', null);
loadingIDs[destId] = thr;
}
threads[thr].callback = new Function('doc', 'uri', 'with (' + myName + ') { ' +
'copyContent(doc, "' + destId + '"); if (onload) onload(doc, uri, "' + destId + '") }');
return threads[thr];
}
}
RemoteFileLoader.prototype.loadInto = function(uri, destId) {
return this.getThread(destId).load(uri);
}
RemoteFileLoader.prototype.submitInto = function(formRef, destId, event) {
return this.getThread(destId).submit(formRef, event);
}
RemoteFileLoader.prototype.copyContent = function(domDoc, destId) {
if (typeof domDoc == "string") {
var srcText = domDoc;
var dest = (typeof document.getElementById != "unknown")
? document.getElementById(destId) : (document.all ? document.all[destId] : null);
if (!srcText || !dest) {
return;
}
dest.innerHTML = srcText;
} else {
var src = (typeof domDoc.getElementsByTagName != "unknown")
? domDoc.getElementsByTagName("body")[0] : (domDoc.body ? domDoc.body : null);
if (!src && domDoc.documentElement) {
src = domDoc.documentElement;
}
var dest = (typeof document.getElementById != "unknown")
? document.getElementById(destId) : (document.all ? document.all[destId] : null);
if (!src || !dest) {
return;
}
if (src.innerHTML) {
dest.innerHTML = src.innerHTML;
} else if (document.importNode) {
while (dest.firstChild) { dest.removeChild(dest.firstChild); }
for (var i = 0; i < src.childNodes.length; i++) {
dest.appendChild(document.importNode(src.childNodes.item(i), true));
}
}
}
}
// end // end 
