var mwst = 1.08;
var calcmwst = false;
var reseller_id = '1';
// simplify document.write
function p( txt ) { document.write( txt + '\n' ); }
var waitMsg = '
Bitte warten, die Seite wird initialisiert ...
';
p( ''+ waitMsg +'' );
// wddx JavaScript libraries ///////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
//
// Filename: wddx.js
//
// Authors: Simeon Simeonov (simeons@allaire.com)
// Nate Weiss (nweiss@icesinc.com)
//
// Last Modified: October 19, 1999
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
//
// WddxSerializer
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// serializeValue() serializes any value that can be serialized
// returns true/false
function wddxSerializer_serializeValue(obj)
{
var bSuccess = true;
var val;
if (obj == null)
{
// Null value
this.write("");
}
else if (typeof(val = obj.valueOf()) == "string")
{
// String value
this.serializeString(val);
}
else if (typeof(val = obj.valueOf()) == "number")
{
// Distinguish between numbers and date-time values
if (
typeof(obj.getTimezoneOffset) == "function" &&
typeof(obj.toGMTString) == "function")
{
// Possible Date
// Note: getYear() fix is from David Flanagan's
// "JS: The Definitive Guide". This code is Y2K safe.
this.write("" +
(obj.getYear() < 1000 ? 1900+obj.getYear() : obj.getYear()) + "-" + (obj.getMonth() + 1) + "-" + obj.getDate() +
"T" + obj.getHours() + ":" + obj.getMinutes() + ":" + obj.getSeconds());
if (this.useTimezoneInfo)
{
this.write(this.timezoneString);
}
this.write("");
}
else
{
// Number value
this.write("" + val + "");
}
}
else if (typeof(val = obj.valueOf()) == "boolean")
{
// Boolean value
this.write("");
}
else if (typeof(obj) == "object")
{
if (typeof(obj.wddxSerialize) == "function")
{
// Object knows how to serialize itself
bSuccess = obj.wddxSerialize(this);
}
else if (
typeof(obj.join) == "function" &&
typeof(obj.reverse) == "function" &&
typeof(obj.sort) == "function" &&
typeof(obj.length) == "number")
{
// Possible Array
this.write("");
for (var i = 0; bSuccess && i < obj.length; ++i)
{
bSuccess = this.serializeValue(obj[i]);
}
this.write("");
}
else
{
// Some generic object; treat it as a structure
// Use the wddxSerializationType property as a guide as to its type
if (typeof(obj.wddxSerializationType) == 'string')
{
this.write('')
}
else
{
this.write("");
}
for (var prop in obj)
{
if (prop != 'wddxSerializationType')
{
bSuccess = this.serializeVariable(prop, obj[prop]);
if (! bSuccess)
{
break;
}
}
}
this.write("");
}
}
else
{
// Error: undefined values or functions
bSuccess = false;
}
// Successful serialization
return bSuccess;
}
///////////////////////////////////////////////////////////////////////////
// serializeAttr() serializes an attribute (such as a var tag) using JavaScript
// functionality available in NS 3.0 and above
function wddxSerializer_serializeAttr(s)
{
for (var i = 0; i < s.length; ++i)
{
this.write(this.at[s.charAt(i)]);
}
}
///////////////////////////////////////////////////////////////////////////
// serializeAttrOld() serializes a string using JavaScript functionality
// available in IE 3.0. We don't support special characters for IE3, so
// just throw the unencoded text and hope for the best
function wddxSerializer_serializeAttrOld(s)
{
this.write(s);
}
///////////////////////////////////////////////////////////////////////////
// serializeString() serializes a string using JavaScript functionality
// available in NS 3.0 and above
function wddxSerializer_serializeString(s)
{
this.write("");
for (var i = 0; i < s.length; ++i)
{
this.write(this.et[s.charAt(i)]);
}
this.write("");
}
///////////////////////////////////////////////////////////////////////////
// serializeStringOld() serializes a string using JavaScript functionality
// available in IE 3.0
function wddxSerializer_serializeStringOld(s)
{
this.write("");
if (pos != -1)
{
startPos = 0;
while (pos != -1)
{
this.write(s.substring(startPos, pos) + "]]>]]>", startPos);
}
else
{
// Work around bug in indexOf()
// "" will be returned instead of -1 if startPos > length
pos = -1;
}
}
this.write(s.substring(startPos, s.length));
}
else
{
this.write(s);
}
this.write("]]>");
}
///////////////////////////////////////////////////////////////////////////
// serializeVariable() serializes a property of a structure
// returns true/false
function wddxSerializer_serializeVariable(name, obj)
{
var bSuccess = true;
if (typeof(obj) != "function")
{
this.write("");
bSuccess = this.serializeValue(obj);
this.write("");
}
return bSuccess;
}
///////////////////////////////////////////////////////////////////////////
// write() appends text to the wddxPacket buffer
function wddxSerializer_write(str)
{
this.wddxPacket += str;
}
///////////////////////////////////////////////////////////////////////////
// serialize() creates a WDDX packet for a given object
// returns the packet on success or null on failure
function wddxSerializer_serialize(rootObj)
{
this.wddxPacket = "";
this.write("");
var bSuccess = this.serializeValue(rootObj);
this.write("");
if (bSuccess)
{
return this.wddxPacket;
}
else
{
return null;
}
}
///////////////////////////////////////////////////////////////////////////
// WddxSerializer() binds the function properties of the object
function WddxSerializer()
{
// Compatibility section
if (navigator.appVersion != "" && navigator.appVersion.indexOf("MSIE 3.") == -1)
{
// Character encoding table
// Encoding table for strings (CDATA)
var et = new Array();
// Numbers to characters table and
// characters to numbers table
var n2c = new Array();
var c2n = new Array();
// Encoding table for attributes (i.e. var=str)
var at = new Array();
for (var i = 0; i < 256; ++i)
{
// Build a character from octal code
var d1 = Math.floor(i/64);
var d2 = Math.floor((i%64)/8);
var d3 = i%8;
var c = eval("\"\\" + d1.toString(10) + d2.toString(10) + d3.toString(10) + "\"");
// Modify character-code conversion tables
n2c[i] = c;
c2n[c] = i;
// Modify encoding table
if (i < 32 && i != 9 && i != 10 && i != 13)
{
// Control characters that are not tabs, newlines, and carriage returns
// Create a two-character hex code representation
var hex = i.toString(16);
if (hex.length == 1)
{
hex = "0" + hex;
}
et[n2c[i]] = "";
// strip control chars from inside attrs
at[n2c[i]] = "";
}
else if (i < 128)
{
// Low characters that are not special control characters
et[n2c[i]] = n2c[i];
// attr table
at[n2c[i]] = n2c[i];
}
else
{
// High characters
et[n2c[i]] = "" + i.toString(16) + ";";
at[n2c[i]] = "" + i.toString(16) + ";";
}
}
// Special escapes for CDATA encoding
et["<"] = "<";
et[">"] = ">";
et["&"] = "&";
// Special escapes for attr encoding
at["<"] = "<";
at[">"] = ">";
at["&"] = "&";
at["'"] = "'";
at["\""] = """;
// Store tables
this.n2c = n2c;
this.c2n = c2n;
this.et = et;
this.at = at;
// The browser is not MSIE 3.x
this.serializeString = wddxSerializer_serializeString;
this.serializeAttr = wddxSerializer_serializeAttr;
}
else
{
// The browser is most likely MSIE 3.x, it is NS 2.0 compatible
this.serializeString = wddxSerializer_serializeStringOld;
this.serializeAttr = wddxSerializer_serializeAttrOld;
}
// Setup timezone information
var tzOffset = (new Date()).getTimezoneOffset();
// Invert timezone offset to convert local time to UTC time
if (tzOffset >= 0)
{
this.timezoneString = '-';
}
else
{
this.timezoneString = '+';
}
this.timezoneString += Math.floor(Math.abs(tzOffset) / 60) + ":" + (Math.abs(tzOffset) % 60);
// Common properties
this.preserveVarCase = false;
this.useTimezoneInfo = true;
// Common functions
this.serialize = wddxSerializer_serialize;
this.serializeValue = wddxSerializer_serializeValue;
this.serializeVariable = wddxSerializer_serializeVariable;
this.write = wddxSerializer_write;
}
///////////////////////////////////////////////////////////////////////////
//
// WddxRecordset
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// isColumn(name) returns true/false based on whether this is a column name
function wddxRecordset_isColumn(name)
{
// Columns must be objects
// WddxRecordset extensions might use properties prefixed with
// _private_ and these will not be treated as columns
return (typeof(this[name]) == "object" &&
name.indexOf("_private_") == -1);
}
///////////////////////////////////////////////////////////////////////////
// getRowCount() returns the number of rows in the recordset
function wddxRecordset_getRowCount()
{
var nRowCount = 0;
for (var col in this)
{
if (this.isColumn(col))
{
nRowCount = this[col].length;
break;
}
}
return nRowCount;
}
///////////////////////////////////////////////////////////////////////////
// addColumn(name) adds a column with that name and length == getRowCount()
function wddxRecordset_addColumn(name)
{
var nLen = this.getRowCount();
var colValue = new Array(nLen);
for (var i = 0; i < nLen; ++i)
{
colValue[i] = null;
}
this[this.preserveFieldCase ? name : name.toLowerCase()] = colValue;
}
///////////////////////////////////////////////////////////////////////////
// addRows() adds n rows to all columns of the recordset
function wddxRecordset_addRows(n)
{
for (var col in this)
{
if (this.isColumn(col))
{
var nLen = this[col].length;
for (var i = nLen; i < nLen + n; ++i)
{
this[col][i] = null;
}
}
}
}
///////////////////////////////////////////////////////////////////////////
// getField() returns the element in a given (row, col) position
function wddxRecordset_getField(row, col)
{
return this[this.preserveFieldCase ? col : col.toLowerCase()][row];
}
///////////////////////////////////////////////////////////////////////////
// setField() sets the element in a given (row, col) position to value
function wddxRecordset_setField(row, col, value)
{
this[this.preserveFieldCase ? col : col.toLowerCase()][row] = value;
}
///////////////////////////////////////////////////////////////////////////
// wddxSerialize() serializes a recordset
// returns true/false
function wddxRecordset_wddxSerialize(serializer)
{
// Create an array and a list of column names
var colNamesList = "";
var colNames = new Array();
var i = 0;
for (var col in this)
{
if (this.isColumn(col))
{
colNames[i++] = col;
if (colNamesList.length > 0)
{
colNamesList += ",";
}
colNamesList += col;
}
}
var nRows = this.getRowCount();
serializer.write("");
var bSuccess = true;
for (i = 0; bSuccess && i < colNames.length; i++)
{
var name = colNames[i];
serializer.write("");
for (var row = 0; bSuccess && row < nRows; row++)
{
bSuccess = serializer.serializeValue(this[name][row]);
}
serializer.write("");
}
serializer.write("");
return bSuccess;
}
///////////////////////////////////////////////////////////////////////////
// dump(escapeStrings) returns an HTML table with the recordset data
// It is a convenient routine for debugging and testing recordsets
// The boolean parameter escapeStrings determines whether the <>&
// characters in string values are escaped as <>&
function wddxRecordset_dump(escapeStrings)
{
// Get row count
var nRows = this.getRowCount();
// Determine column names
var colNames = new Array();
var i = 0;
for (var col in this)
{
if (typeof(this[col]) == "object")
{
colNames[i++] = col;
}
}
// Build table headers
var o = "
RowNumber
";
for (i = 0; i < colNames.length; ++i)
{
o += "
" + colNames[i] + "
";
}
o += "
";
// Build data cells
for (var row = 0; row < nRows; ++row)
{
o += "
" + row + "
";
for (i = 0; i < colNames.length; ++i)
{
var elem = this.getField(row, colNames[i]);
if (escapeStrings && typeof(elem) == "string")
{
var str = "";
for (var j = 0; j < elem.length; ++j)
{
var ch = elem.charAt(j);
if (ch == '<')
{
str += "<";
}
else if (ch == '>')
{
str += ">";
}
else if (ch == '&')
{
str += "&";
}
else
{
str += ch;
}
}
o += ("
" + str + "
");
}
else
{
o += ("
" + elem + "
");
}
}
o += "
";
}
// Close table
o += "
";
// Return HTML recordset dump
return o;
}
///////////////////////////////////////////////////////////////////////////
// WddxRecordset([flagPreserveFieldCase]) creates an empty recordset.
// WddxRecordset(columns [, flagPreserveFieldCase]) creates a recordset
// with a given set of columns provided as an array of strings.
// WddxRecordset(columns, rows [, flagPreserveFieldCase]) creates a
// recordset with these columns and some number of rows.
// In all cases, flagPreserveFieldCase determines whether the exact case
// of field names is preserved. If omitted, the default value is false
// which means that all field names will be lowercased.
function WddxRecordset()
{
// Add default properties
this.preserveFieldCase = false;
// Add extensions
if (typeof(wddxRecordsetExtensions) == "object")
{
for (var prop in wddxRecordsetExtensions)
{
// Hook-up method to WddxRecordset object
this[prop] = wddxRecordsetExtensions[prop]
}
}
// Add built-in methods
this.getRowCount = wddxRecordset_getRowCount;
this.addColumn = wddxRecordset_addColumn;
this.addRows = wddxRecordset_addRows;
this.isColumn = wddxRecordset_isColumn;
this.getField = wddxRecordset_getField;
this.setField = wddxRecordset_setField;
this.wddxSerialize = wddxRecordset_wddxSerialize;
this.dump = wddxRecordset_dump;
// Perfom any needed initialization
if (WddxRecordset.arguments.length > 0)
{
if (typeof(val = WddxRecordset.arguments[0].valueOf()) == "boolean")
{
// Case preservation flag is provided as 1st argument
this.preserveFieldCase = WddxRecordset.arguments[0];
}
else
{
// First argument is the array of column names
var cols = WddxRecordset.arguments[0];
// Second argument could be the length or the preserve case flag
var nLen = 0;
if (WddxRecordset.arguments.length > 1)
{
if (typeof(val = WddxRecordset.arguments[1].valueOf()) == "boolean")
{
// Case preservation flag is provided as 2nd argument
this.preserveFieldCase = WddxRecordset.arguments[1];
}
else
{
// Explicitly specified recordset length
nLen = WddxRecordset.arguments[1];
if (WddxRecordset.arguments.length > 2)
{
// Case preservation flag is provided as 3rd argument
this.preserveFieldCase = WddxRecordset.arguments[2];
}
}
}
for (var i = 0; i < cols.length; ++i)
{
var colValue = new Array(nLen);
for (var j = 0; j < nLen; ++j)
{
colValue[j] = null;
}
this[this.preserveFieldCase ? cols[i] : cols[i].toLowerCase()] = colValue;
}
}
}
}
///////////////////////////////////////////////////////////////////////////
//
// WddxRecordset extensions
//
// The WddxRecordset class has been designed with extensibility in mind.
//
// Developers can add new properties to the object and as long as their
// names are prefixed with _private_ the WDDX serialization function of
// WddxRecordset will not treat them as recordset columns.
//
// Developers can create new methods for the class outside this file as
// long as they make a call to registerWddxRecordsetExtension() with the
// name of the method and the function object that implements the method.
// The WddxRecordset constructor will automatically register all these
// methods with instances of the class.
//
// Example:
//
// If I want to add a new WddxRecordset method called addOneRow() I can
// do the following:
//
// - create the method implementation
//
// function wddxRecordset_addOneRow()
// {
// this.addRows(1);
// }
//
// - call registerWddxRecordsetExtension()
//
// registerWddxRecordsetExtension("addOneRow", wddxRecordset_addOneRow);
//
// - use the new function
//
// rs = new WddxRecordset();
// rs.addOneRow();
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// registerWddxRecordsetExtension(name, func) can be used to extend
// functionality by registering functions that should be added as methods
// to WddxRecordset instances.
function registerWddxRecordsetExtension(name, func)
{
// Perform simple validation of arguments
if (typeof(name) == "string" && typeof(func) == "function")
{
// Guarantee existence of wddxRecordsetExtensions object
if (typeof(wddxRecordsetExtensions) != "object")
{
// Create wddxRecordsetExtensions instance
wddxRecordsetExtensions = new Object();
}
// Register extension; override an existing one
wddxRecordsetExtensions[name] = func;
}
}
///////////////////////////////////////////////////////////////////////////
//
// WddxBinary
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// wddxSerialize() serializes a binary value
// returns true/false
function wddxBinary_wddxSerialize(serializer)
{
serializer.write(
"" + this.data + "");
return true;
}
///////////////////////////////////////////////////////////////////////////
// WddxBinary() constructs an empty binary value
// WddxBinary(base64Data) constructs a binary value from base64 encoded data
// WddxBinary(data, encoding) constructs a binary value from encoded data
function WddxBinary(data, encoding)
{
this.data = data != null ? data : "";
this.encoding = encoding != null ? encoding : "base64";
// Custom serialization mechanism
this.wddxSerialize = wddxBinary_wddxSerialize;
}
// WddxRecordset extension functions
// File: wddxExtensions.js
// Contributions from (in alphabetical order):
// - David Dawes (ddawes@connectwise.com)
// - Rob Edgar (robedgar@mersey.com.hk)
// - Simeon Simeonov (simeons@allaire.com)
// - Nate Weiss [nmw] (nweiss@icesinc.com)
// PLEASE POST NEW CONTRIBUTIONS TO THE WDDX PUBLIC FORUM AT Wddx.org
// Utility function to take data from a 2D JavaScript
// array and return a corresponding wddxRecordset.
// Does NOT become a method of new wddxRecordset objects
function ArrayToWddxRecordset(RSArr, colNames, RSObj) {
var Rows = RSArr.length;
var ColName;
var Row, Col, i;
// If RSObj was not passed to function, create new WddxRecordset object
if (arguments.length < 3) {
if (typeof(RSArr.getRowCount != 'function')) {
RSObj = new WddxRecordset;
for (i = 0; i < colNames.length; i++) {
RSObj.addColumn(colNames[i]);
}
RSObj.addRows(Rows);
}
}
// Iterate through each cell of array, by Column then by Row
for (Col = 0; Col < colNames.length; Col++) {
ColName = colNames[Col];
for (Row = 0; Row < Rows; Row++) {
RSObj.setField(Row, ColName, RSArr[Row][Col]);
}
}
return RSObj;
}
// Function to add columns to a recordset, from an array of strings
function wddxRecordset_addColumns(colNamesAsArray) {
for (i = 0; i < colNamesAsArray.length; i++) {
this.addColumn(colNamesAsArray[i]);
}
}
// Function to insert a row into a recordset at the
// specified postition (new row is inserted after).
// Uses JS 1.2 Array.splice() as shortcut if available.
function wddxRecordset_insertRow(RowNum, arValues) {
var numRows = this.getRowCount();
// if RowNum is specified as -1, then add to end of recordset
if (RowNum == -1) RowNum = numRows; // Added 5/24/99 by nmw
if (RowNum <= numRows) {
var colNames = this.getFieldNames();
var isSpliceOK = (typeof(colNames.splice) == 'function');
if (!isSpliceOK) this.addRows(1);
for (Col = 0; Col < colNames.length; Col++) {
if (isSpliceOK) {
this[colNames[Col]].splice(RowNum, 0, "");
} else {
for (Row = numRows; Row > RowNum; Row--) {
this.setField(Row, colNames[Col], this.getField(Row-1, colNames[Col]));
}
this.setField(RowNum, colNames[Col], "");
}
}
if (arguments.length > 1) {
this.setFields(RowNum, arValues);
}
}
}
// Function to remove a row from a recordset.
// Uses JS 1.2 Array.splice() as shortcut if available.
function wddxRecordset_deleteRow(rowNum) {
var ColNames = this.getFieldNames();
var isSpliceOK = (typeof(ColNames.splice) == 'function');
for (Col = 0; Col < ColNames.length; Col++) {
if (isSpliceOK) {
this[ColNames[Col]].splice(rowNum, 1);
} else {
for (Row = rowNum; Row < this.getRowCount(); Row++) {
this.setField(Row, ColNames[Col], this.getField(Row+1, ColNames[Col]));
}
this[ColNames[Col]].length = this[ColNames[Col]].length -1;
}
}
}
/*
Function to add values to a recordset's row all at once
Becomes a method of all new wddxRecordset objects.
*/
function wddxRecordset_setFields(RowNum, arValues) {
var ColNames = this.getFieldNames();
var numCols = ColNames.length <= arValues.length ? ColNames.length : arValues.length;
for (var Col = 0; Col < numCols; Col++) {
this.setField(RowNum, ColNames[Col], arValues[Col]);
}
}
/*
Function to get a "row" from a recordset as a 1D array.
Could be passed to the insertRow or setFields function of another WddxRecordset object.
Becomes a method of all new wddxRecordset objects.
Added 5/24/99 by nmw
*/
function wddxRecordset_getFields(RowNum) {
var ColNames = this.getFieldNames();
var arValues = new Array;
for (var Col = 0; Col < ColNames.length; Col++) {
arValues[Col] = this.getField(RowNum, ColNames[Col]);
}
return arValues;
}
// Function to "find" a value in a recordset
// Additions of "toString" added 5/25/99 by nmw, from suggestions by David Dawes
function wddxRecordset_findValue(ColName, Value, bWholeStrings, bCaseSensitive, bMultiple) {
if (arguments.length < 2) bWholeStrings = true;
if (arguments.length < 3) bCaseSensitive = true;
if (arguments.length < 4) bMultiple = false;
if (bMultiple)
var arFoundRows = new Array();
else
var FoundRow = -1;
Value = Value.toString();
if (bCaseSensitive) Value = Value.toLowerCase();
if (bWholeStrings) {
if (bCaseSensitive) {
for (Row = 0; Row < this.getRowCount(); Row++) {
if (this.getField(Row, ColName).toString() == Value) {
if (bMultiple)
arFoundRows[arFoundRows.length] = Row;
else {
FoundRow = Row;
break;
}
}
}
} else {
for (Row = 0; Row < this.getRowCount(); Row++) {
if (this.getField(Row, ColName).toString().toLowerCase() == Value) {
if (bMultiple)
arFoundRows[arFoundRows.length] = Row;
else {
FoundRow = Row;
break;
}
}
}
}
} else {
if (bCaseSensitive) {
for (Row = 0; Row < this.getRowCount(); Row++) {
if (this.getField(Row, ColName).toString().indexOf(Value) >= 0) {
if (bMultiple)
arFoundRows[arFoundRows.length] = Row;
else {
FoundRow = Row;
break;
}
}
}
} else {
for (Row = 0; Row < this.getRowCount(); Row++) {
if (this.getField(Row, ColName).toString().toLowerCase().indexOf(Value) >= 0) {
if (bMultiple)
arFoundRows[arFoundRows.length] = Row;
else {
FoundRow = Row;
break;
}
}
}
}
}
if (bMultiple)
return arFoundRows;
else
return FoundRow;
}
// Function to get column names from a wddxRecordset
// object. Returns the names as 1D array of strings.
function wddxRecordset_getFieldNames() {
var Names = new Array();
var Rows = this.getRowCount();
// Assume that any object with the right number of rows is a "column"
for (x in this) {
if ( (typeof(this[x]) == 'object') && (this[x].length == Rows)) {
Names[Names.length] = x;
}
}
return Names;
}
// Function to return empty recordset with the same columns/rows
// as the original
function wddxRecordset_createEmptyCopy() {
var newRS = new WddxRecordset;
newRS.addColumns(this.getFieldNames());
return newRS;
}
// Function to return normal, JS-style "array of arrays"
// from data in a wddxRecordset object. WddxRS.title[0]
// becomes Array[0].title, and so on.
function wddxRecordset_toArray() {
var Rec, Col, Row;
// Create the new array (will be a 2D array)
var Records = new Array();
// Get the column names for the recordset
var colNames = this.getFieldNames();
var RowCount = this.getRowCount();
// For each row in the recordset, add an element to the array
for (Row = 0; Row < this[colNames[0]].length; Row++) {
Rec = new Array(RowCount);
for (Col = 0; Col < colNames.length; Col++)
Rec[colNames[Col]] = this[colNames[Col]][Row];
Records[Row] = Rec;
}
// Return array to calling process
return Records;
}
// WddxRecordset sorting extension
// Author: Simeon Simeonov (simeons@allaire.com)
///////////////////////////////////////////////////////////////////////////
// wddxRecordsetSimpleComparator_compareAsc(i, j)
// Compares the elements at positions i and j in a recordset column
// Maintains ascending order
function wddxRecordsetSimpleComparator_compareAsc(i, j)
{
var a = this.rs[this.col][i];
var b = this.rs[this.col][j];
if (! _wddxRecordset_isSortCaseSensitive) {
a = (typeof(a.valueOf()) == "string" ? a.toLowerCase() : a);
b = (typeof(b.valueOf()) == "string" ? b.toLowerCase() : b);
}
return (a == b) ? 0 : (a > b) ? 1 : -1;
}
///////////////////////////////////////////////////////////////////////////
// wddxRecordsetSimpleComparator_compareDesc(i, j)
// Compares the elements at positions i and j in a recordset column
// Maintains descending order
function wddxRecordsetSimpleComparator_compareDesc(i, j)
{
var a = this.rs[this.col][i];
var b = this.rs[this.col][j];
// We want a case-insensitive sort by default. Thanks to David Dawes for this.
if (! _wddxRecordset_isSortCaseSensitive) {
a = (typeof(a.valueOf()) == "string" ? a.toLowerCase() : a);
b = (typeof(b.valueOf()) == "string" ? b.toLowerCase() : b);
}
return (a == b) ? 0 : (a > b) ? -1 : 1;
}
///////////////////////////////////////////////////////////////////////////
// wddxRecordsetSimpleComparator(rs, col)
// Constructor for the default comparator object for recordset sorting
// rs : recordset to sort
// col : column to sort
function wddxRecordsetSimpleComparator(rs, col, func)
{
this.rs = rs;
this.col = col;
this.compare = func;
}
///////////////////////////////////////////////////////////////////////////
// _wddxRecordset_sortComparatorFunc(i, j)
// Delegates comparison of rows i and j to the active comparator object
function _wddxRecordset_sortComparatorFunc(i, j)
{
return _wddxRecordset_activeComparator.compare(i, j);
}
///////////////////////////////////////////////////////////////////////////
// wddxRecordset_sort
// Builds an auxilliary index array, quicksorts based it, and then creates
// the sorted columns based on the sorted index.
// Returns the sorted recordset or null on failure.
//
// There are two versions of the function:
//
// wddxRecordset_sort(cmpObj)
// Sorts using a comparator object. The comparator object must have a
// compare(i, j) function defined where i and j are two row indexes.
//
// wddxRecordset_sort(sortField)
// wddxRecordset_sort(sortField, sortOrder)
// Sorts the recordset based on an ascending | descending comparison of a
// given field. Ascending sort is specified by "asc", descending by "desc".
// The default order is ascending.
function wddxRecordset_sort()
{
// Is there anything to sort?
var rowCount = this.getRowCount();
if (rowCount < 2) return this;
// Comparator object
var cmpObj = null;
// Validate arguments and determine sort type
if (arguments.length == 0 || arguments.length > 3) return null;
if (typeof(arguments[0]) == "object")
{
// Comparator sort?
if (typeof(arguments[0].compare) == "function")
{
cmpObj = arguments[0];
}
}
else if (typeof(arguments[0]) == "string")
{
// Simple field sort
// Validate field name
if (typeof(this[arguments[0]]) == "object")
{
// Validate and determine sort order
var isError = false;
var isAscending = true;
_wddxRecordset_isSortCaseSensitive = false;
if (arguments.length >= 2)
{
var orderSpec = arguments[1].toLowerCase();
if (orderSpec == "asc")
{
isAscending = true;
}
else if (orderSpec == "desc")
{
isAscending = false;
}
else
{
isError = true;
}
}
// determine case-sensitivity option (default to no sensitivity)
if (arguments.length >= 3)
{
_wddxRecordset_isSortCaseSensitive = (arguments[2] == true);
}
if (! isError)
{
cmpObj = new wddxRecordsetSimpleComparator(
this,
arguments[0],
isAscending ?
wddxRecordsetSimpleComparator_compareAsc :
wddxRecordsetSimpleComparator_compareDesc);
}
}
}
// If no comparison object has been established the arguments were invalid
if (cmpObj == null) return null;
// Create an array of row indexes
var indexes = new Array(rowCount);
for (var i = 0; i < rowCount; ++i)
{
indexes[i] = i;
}
// Sort the array
// __SIM: no check for presence of Array.sort()
// __SIM: can use quicksort() from http://proxy.uiggm.nsc.ru/doc/WEBPAGES/java/sejava16.htm#listing1614
_wddxRecordset_activeComparator = cmpObj;
indexes.sort(_wddxRecordset_sortComparatorFunc);
// Create a sorted recordset
for (var col in this)
{
if ( (typeof(this[col]) == "object") && (this[col].length == rowCount) ) // changed 5/24/99 by nmw; was: if (typeof(this[col]) != "function")
{
// Create sorted column
var colArray = new Array(rowCount);
for (var i = 0; i < rowCount; ++i)
{
colArray[i] = this[col][indexes[i]];
}
// Put it in the recordset
this[col] = colArray;
}
}
return this;
}
// Utility function to provide a "replace" function that can safely
// be called regardless of whether String.replace() from JS 1.2 is available
// This brings core JS 1.1 compatibility, but still requires String.split()
function replaceAny(strString, strFind, strRep) {
var newString = '';
if (typeof 'teststring'.replace == 'function') {
newString = strString.replace(strFind, strRep);
} else {
tempArray = strString.split(strFind);
for (var x = 0; x < tempArray.length-1; x++) {
newString = newString + tempArray[x] + strRep;
}
newString = newString + tempArray[tempArray.length-1];
}
return newString;
}
///////////////////////////////////////////////////////////////////////////
// WDDXDeserializeRecordset()
// Deserializes a packet and returns new WddxRecordset object
// Code and concept contributed by Rob Edgar - Thanks, Rob! :)
// * For WDDX SDK Beta 2, Nate Weiss added:
// * - eliminated JS 1.2-specific code (slice, switch and replace statements)
// * - support for elements
// * - support for elements (parseSpecialChars in code)
// Case-sensitivity option added by Nate Weiss on 5/25/99, based on suggestions from David Dawes
function wddxRecordset_readFromPacket(WDDXPacket) {
WDDXPacket = WDDXPacket.toString() + '';
// * Optional parseSpecialChars argument determines whether elements are processed
// * If not provided, sniff packet for the presence of a element to obtain default
var parseSpecialChars;
if (arguments.length > 1)
parseSpecialChars = arguments[1];
else parseSpecialChars = (WDDXPacket.toLowerCase().indexOf('');
var xmlheader = data[0];
//the recordset set is in the second element, remove everything after the trailing data
var recordset = data[1].split('');
//split off the recordset header from the data
var nfirstfield = recordset[0].indexOf('>',0);
//recordsetheader = recordset[0].slice(0, nfirstfield);
recordsetheader = recordset[0].substring(0, nfirstfield);
//strip the trailing recordset tag
fields = recordset[0].substring( nfirstfield+1, recordset[0].length - 12);
//split into fields
var fields = fields.split('');
//now process the fields array
for (var i = 0; i < fields.length-1; i++){
//process a single field
var field = fields[i];
var fielddata = field.indexOf('>',0);
var fieldname = field.substring(0,fielddata);
fieldname = replaceAny(fieldname, '',0) + 1);
datatype = replaceAny(datatype, '<', '');
fielddata = fielddata.split(datatype);
datatype = replaceAny(datatype, '/' ,'');
fname = new Array;
// Branch according to datatype element
if (datatype.toLowerCase() == '') {
for (var y = 0; y < fielddata.length - 1; y++){
// Split date string into component parts
var Value = replaceAny(fielddata[y], datatype,'');
Value = Value.split('T');
var dtDateParts = Value[0].split('-');
var dtTimeParts = Value[1].split(':');
// create native JS Date object
fname[y] = new Date(dtDateParts[0], dtDateParts[1]-1, dtDateParts[2], dtTimeParts[0], dtTimeParts[1], 0); //dtTimeParts[1], dtTimeParts[2]);
}
} else if (datatype == '') {
for (var y = 0; y < fielddata.length - 1; y++){
fname[y] = parseFloat(replaceAny(fielddata[y], datatype,''));
}
} else if (datatype == '') {
for (var y = 0; y < fielddata.length - 1; y++){
fname[y] = ( replaceAny(fielddata[y], datatype,'') == 'true' );
}
} else {
for (var y = 0; y < fielddata.length - 1; y++){
fname[y] = replaceAny(fielddata[y], datatype,'');
if (parseSpecialChars) {
fname[y] = replaceAny(fname[y], "", '\r');
fname[y] = replaceAny(fname[y], "", '\f');
fname[y] = replaceAny(fname[y], "", '\n');
fname[y] = replaceAny(fname[y], "", '\t');
}
}
}
this[fieldname] = fname; // * Rob's code was: eval('this["'+fieldname+'"]=fname');
}
return 0;
}
// Register the functions, so they become available
// as methods for all new WddxRecordset objects
registerWddxRecordsetExtension("getFieldNames", wddxRecordset_getFieldNames);
registerWddxRecordsetExtension("toArray", wddxRecordset_toArray);
registerWddxRecordsetExtension("sort", wddxRecordset_sort);
registerWddxRecordsetExtension("addColumns", wddxRecordset_addColumns);
registerWddxRecordsetExtension("deleteRow", wddxRecordset_deleteRow);
registerWddxRecordsetExtension("insertRow", wddxRecordset_insertRow); // modified 5/24/99 by nmw
registerWddxRecordsetExtension("setFields", wddxRecordset_setFields);
registerWddxRecordsetExtension("getFields", wddxRecordset_getFields); // added 5/24/99 by nmw
registerWddxRecordsetExtension("findValue", wddxRecordset_findValue);
registerWddxRecordsetExtension("createEmptyCopy", wddxRecordset_createEmptyCopy); // added 5/24/99 by nmw
registerWddxRecordsetExtension("readFromPacket", wddxRecordset_readFromPacket);
////////////////////////////////////////////////////////////////////////////////
// WDDX DATA
qOpt=new WddxRecordset();_t2=new Array();_t2[0]=36;_t2[1]=34;_t2[2]=12;_t2[3]=9;_t2[4]=13;_t2[5]=5;_t2[6]=25;_t2[7]=7;_t2[8]=41;_t2[9]=23;_t2[10]=26;_t2[11]=11;_t2[12]=29;_t2[13]=37;_t2[14]=10;_t2[15]=8;_t2[16]=19;_t2[17]=20;_t2[18]=21;_t2[19]=28;_t2[20]=22;_t2[21]=24;_t2[22]=38;_t2[23]=31;_t2[24]=27;_t2[25]=16;_t2[26]=14;_t2[27]=35;_t2[28]=39;_t2[29]=40;qOpt["opt_id"]=_t2;_t2=new Array();_t2[0]="anonftp";_t2[1]="antivirus_mail";_t2[2]="asp";_t2[3]="cgiperl";_t2[4]="cf";_t2[5]="enablemail";_t2[6]="morenames";_t2[7]="ipbased";_t2[8]="backup_none";_t2[9]="space";_t2[10]="backup_monthly";_t2[11]="php";_t2[12]="shell_access";_t2[13]="antispam_mail";_t2[14]="ssi";_t2[15]="ssl";_t2[16]="sup_emailprio";_t2[17]="sup_phone";_t2[18]="sup_phone_extended";_t2[19]="backup_daily";_t2[20]="user";_t2[21]="traffic";_t2[22]="mailcombiprot";_t2[23]="moremailnames";_t2[24]="backup_weekly";_t2[25]="access";_t2[26]="mysql";_t2[27]="postgresql";_t2[28]="relayservice";_t2[29]="relayservice_pro";qOpt["opt_name"]=_t2;_t2=new Array();_t2[0]="Anonymous FTP Server";_t2[1]="Antivirus Mail";_t2[2]="ASP";_t2[3]="CGI / Perl";_t2[4]="ColdFusion 4.5x";_t2[5]="Email enabled";_t2[6]="Hostnamen";_t2[7]="IP-basierend";_t2[8]="Kein spezielles Backup der Site";_t2[9]="MB Speicherplatz inkl. Mail";_t2[10]="Monatliches Backup";_t2[11]="PHP";_t2[12]="Shell Zugriff";_t2[13]="Spamschutz Mail";_t2[14]="SSI/XSSI";_t2[15]="SSL";_t2[16]="Support Email priority";_t2[17]="Support telefonisch priority";_t2[18]="Support telefonisch priority / extended";_t2[19]="Tägliches Backup";_t2[20]="User (Mail/FTP)";_t2[21]="Verkehr inkl. Mail (pro 16 GB)";_t2[22]="Viren-/Spamschutz Kombi";_t2[23]="Weitere Email Domain";_t2[24]="Wöchentliches Backup";_t2[25]="Access DB ueber ODBC";_t2[26]="MySQL Datenbank";_t2[27]="PostgreSQL Datenbank";_t2[28]="Email Relay Dienst (max. 500MB/Monat)";_t2[29]="Email Relay Dienst Pro (f. Firmen, max. 1200MB/Monat)";qOpt["opt_text"]=_t2;_t2=new Array();_t2[0]=54;_t2[1]=78;_t2[2]=180;_t2[3]=54;_t2[4]=330;_t2[5]=24;_t2[6]=12;_t2[7]=120;_t2[8]=1;_t2[9]=0.07000000000000001;_t2[10]=1.1;_t2[11]=60;_t2[12]=1.1;_t2[13]=78;_t2[14]=24;_t2[15]=180;_t2[16]=90;_t2[17]=380;_t2[18]=600;_t2[19]=1.45;_t2[20]=4.8;_t2[21]=51;_t2[22]=90;_t2[23]=24;_t2[24]=1.25;_t2[25]=100;_t2[26]=84;_t2[27]=78;_t2[28]=54;_t2[29]=108;qOpt["opt_preis"]=_t2;_t2=new Array();_t2[0]="7";_t2[1]="5";_t2[2]="0";_t2[3]="0";_t2[4]="0";_t2[5]="0";_t2[6]="0";_t2[7]="0";_t2[8]="0";_t2[9]="0";_t2[10]="0";_t2[11]="0";_t2[12]="0";_t2[13]="5";_t2[14]="0";_t2[15]="7";_t2[16]="0";_t2[17]="0";_t2[18]="0";_t2[19]="0";_t2[20]="0";_t2[21]="0";_t2[22]="5";_t2[23]="5";_t2[24]="0";_t2[25]="0";_t2[26]="0";_t2[27]="0";_t2[28]="0";_t2[29]="0";qOpt["opt_prereq"]=_t2;_t2=new Array();_t2[0]="0";_t2[1]="38";_t2[2]="0";_t2[3]="16";_t2[4]="30";_t2[5]="0";_t2[6]="0";_t2[7]="0";_t2[8]="26,27,28";_t2[9]="0";_t2[10]="27,28,41";_t2[11]="16";_t2[12]="0";_t2[13]="38";_t2[14]="16";_t2[15]="0";_t2[16]="20,21";_t2[17]="19,21";_t2[18]="19,20";_t2[19]="26,27,41";_t2[20]="0";_t2[21]="0";_t2[22]="34,37";_t2[23]="0";_t2[24]="26,28,41";_t2[25]="9,10,11,15";_t2[26]="0";_t2[27]="0";_t2[28]="0";_t2[29]="0";qOpt["opt_notreq"]=_t2;_t2=new Array();_t2[0]="Ihr eigener oeffentlicher FTP Server";_t2[1]="Kontrolle der eingehenden Mails auf Viren";_t2[2]="Microsoft® Active Server Pages";_t2[3]="Dynamische Webseiten mit Perl oder anderen, unter Unix lauffähigen, CGI Programmen";_t2[4]="Populärer Webapplikationsserver (Details)";_t2[5]="Die Möglichkeit mit Ihrem Hostingpaket Email zu empfangen. Die Email Adressen und Aliases können nach der Aufschaltung von Ihnen selbst konfiguriert werden.";_t2[6]="Weitere Namen unter denen Ihre Website erreichbar ist, z.B.: web.firma-a.ch, www.firma-b.com, shop.firma-c.ch etc. \nInklusive Betrieb der DNS.";_t2[7]="Anstatt eines IP-losen virtuellen Servers, haben Sie eine eigene IP-Adresse für Ihren Mail- und Webserver. Wird z.B. für die SSL Option benötigt.";_t2[8]="Kein Backup, dies hat keinen Einfluss auf die Verfuegbarkeit Ihrer Site. Wenn Sie unbeabsichtigt Daten löschen auf Ihrem Hosting koennen diese durch uns nicht zurueckgespeichert werden.";_t2[9]="Speicherplatz (beinhaltet Mail und Web) in MB";_t2[10]="Monatliches Backup";_t2[11]="PHP, eine populäre Scriptsprache zur Programmierung von dynamischem Inhalt (Homepage). Unterstützt werden Version 3 und 4.";_t2[12]="Zugriff auf Ihren Server via Telnet oder SSH";_t2[13]="Spamschutz fuer alle User Ihrer Site, individuell fuer jeden User konfigurierbar";_t2[14]="Serverside Includes";_t2[15]="Wird benötigt, um den Datentransfer zu Ihrer Homepage zu verschüsseln (z.B. Kreditkarten - Übermittlung, etc.)";_t2[16]="Priority Email-Support bei allen Problemen mit Ihrem Hosting (2 Stunden Antwortzeit an Wochentagen, 4 Stunden an Wochenenden und Feiertagen)";_t2[17]="Priority Phone-Support bei allen Problemen mit Ihrem Hosting (2 Stunden Reaktionszeit an Werktagen)";_t2[18]="Priority Phone-Support bei allen Problemen mit Ihrem Hosting (7*24, 2 Stunden Reaktionszeit)";_t2[19]="Tägliches Backup";_t2[20]="Weitere Email- resp. FTP-Accounts.\nDie Email Adressen und Aliases können nach der Aufschaltung von Ihnen selbst konfiguriert werden.\nAliase sind für jeden einzelnen Account unlimitiert. Auch Single User Account ist ohne weiteres moeglich.";_t2[21]="Verkehrsvolumen pro Monat und 16 Gigabyte Verkehr";_t2[22]="Kombiniertes Viren-/Spamschutz Paket, jedoch ohne Einstellmöglichkeiten für den Spamschutz";_t2[23]="Weitere Domains unter denen Ihre Site Mail empfangen kann, z.B.: firma-a.ch, firma-a.com";_t2[24]="Wöchentliches Backup";_t2[25]="Microsoft ® Access Datenbank Anbindung über ODBC";_t2[26]="Datenbank auf leistungsfähigem Datenbankserver bis 25MB Grösse";_t2[27]="Leistungsfähige Datenbankserver";_t2[28]="Authentisierter EMail Versand von jedem Standort";_t2[29]="Authentisierter EMail Versand von jedem Standort, grosse Mengen";qOpt["opt_help"]=_t2;_t2=new Array();_t2[0]=2;_t2[1]=2;_t2[2]=2;_t2[3]=2;_t2[4]=2;_t2[5]=2;_t2[6]=1;_t2[7]=2;_t2[8]=3;_t2[9]=1;_t2[10]=3;_t2[11]=2;_t2[12]=3;_t2[13]=2;_t2[14]=2;_t2[15]=2;_t2[16]=2;_t2[17]=2;_t2[18]=2;_t2[19]=3;_t2[20]=1;_t2[21]=1;_t2[22]=2;_t2[23]=1;_t2[24]=3;_t2[25]=1;_t2[26]=1;_t2[27]=1;_t2[28]=1;_t2[29]=1;qOpt["opt_typ"]=_t2;_t2=new Array();_t2[0]=0;_t2[1]=0;_t2[2]=0;_t2[3]=0;_t2[4]=0;_t2[5]=1;_t2[6]=1;_t2[7]=0;_t2[8]=1;_t2[9]=20;_t2[10]=0;_t2[11]=0;_t2[12]=0;_t2[13]=0;_t2[14]=0;_t2[15]=0;_t2[16]=0;_t2[17]=0;_t2[18]=0;_t2[19]=0;_t2[20]=1;_t2[21]=1;_t2[22]=0;_t2[23]=0;_t2[24]=0;_t2[25]=0;_t2[26]=0;_t2[27]=0;_t2[28]=0;_t2[29]=0;qOpt["opt_default"]=_t2;_t2=new Array();_t2[0]="";_t2[1]="";_t2[2]="";_t2[3]="";_t2[4]="";_t2[5]="";_t2[6]="";_t2[7]="";_t2[8]="";_t2[9]="";_t2[10]="";_t2[11]="";_t2[12]="";_t2[13]="";_t2[14]="";_t2[15]="";_t2[16]="";_t2[17]="";_t2[18]="";_t2[19]="";_t2[20]="";_t2[21]="";_t2[22]="";_t2[23]="";_t2[24]="";_t2[25]=1;_t2[26]=2;_t2[27]=3;_t2[28]=4;_t2[29]=5;qOpt["opt_sort"]=_t2;_t0=null;_t1=null;_t2=null;
//qOpt.sort("opt_sort");
////////////////////////////////////////////////////////////////////////////////
// DHTML and From JavaScript libraries /////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// optionen.js -- kalkuliert den gesamtpreis fuer Hosting optionen
//
// Author: Simon Wunderlin [swunderlin@telemedia.ch
// Date : 28.11.2000
//
// Notes:
// Preise werden IMMER in Rappen/Jahr gerechnet und am Schluss in
// SFr./Monat umgewandelt um moeglichst Rundungsfehler zu vermeiden.
//
// this script needs wddx.js AND wddxRsEx.js. this scripts can be downloaded
// from http://www.wddx.org !
//
q = qOpt; // WDDX Query Name
s = 'id_'; // Schema im namen des Formfelds (z.B. id_xx) wobei xx die DB id ist
inputLength = 7 // laenge des Total Feldes
////////////////////////////////////////////////////////////////////////////////
// initialisieren der Seite
//
// wenn formularfelder mit name wie 'id_xx' gefunden werden (wobei xx eine
// nummer sein muss) werden diesen Objekten zusaetzliche properties
// vom entsprecheden Datensatz zugewiesen.
//
function initForms() {
// loop ueber alle formulare
var formCounter = 0;
with ( document ) {
while ( forms[ formCounter ] ) {
var elementCounter = 0;
// loop ueber alle elemente im Formular formulare
while ( forms[ formCounter ].elements[ elementCounter ] ) {
var currentElement = forms[ formCounter ].elements[ elementCounter ];
// is name = 'id_xxx' ?
myId = getIdFromFormName( currentElement )
if ( myId ) {
currentRow = q.findValue( "opt_id", myId ); // WDDXrow ist nicht = id!
currentElement.data = new Object(); // Daten Obj. anlegen
// alle formfeld-objekte werden um ihre properties in der Datenbank
// erweitert. Verwendung: object.data.name
// (z.B. document.forms[0].id_5.data.name)
with ( currentElement ) {
data.id = myId;
data.name = q.getField( currentRow, "opt_name" );
data.text = q.getField( currentRow, "opt_text" );
data.preis = q.getField( currentRow, "opt_preis" );
data.prereq = q.getField( currentRow, "opt_prereq" );
data.notreq = q.getField( currentRow, "opt_notreq" );
data.help = q.getField( currentRow, "opt_help" );
data.typ = q.getField( currentRow, "opt_typ" );
data.def = q.getField( currentRow, "opt_default" );
}
}
//myId = o.name.substring(3, o.name.length);
elementCounter++;
} // end element loop
formCounter++;
} // end form loop
}
}
////////////////////////////////////////////////////////////////////////////////
// ueberprueffen, ob das uebergebene Formularfeld ein eine ID im NAmen hat, wenn
// ja: id zurueckgeben sonst 'false'
//
// input: Formelement (Object)
// output: ID (Int) / false
//
function getIdFromFormName( o ) {
if ( o.name.substring(0, 3) == s ) {
return o.name.substring(3, o.name.length);
}
return false;
}
function backToDefault(o) {
if(stopvalidation) {
o.value = o.data.def;
stopvalidation = false;
}
}
stopvalidation = false;
////////////////////////////////////////////////////////////////////////////////
// Preis neu rechnen und anzeigen
//
function recalcPrice( o, validate ) {
stopvalidation = false;
ask = true;
// check if current value is lower than the default value
if( o.type == 'text' ) {
thisO = o;
if ( o.data ) {
if ( o.value < o.data.def ) {
stopvalidation = true;
setTimeout('backToDefault(thisO)',1300);
}
if ( o.value == '' ) {
stopvalidation = true;
setTimeout('backToDefault(thisO)',1300);
}
}
}
// get the current id
if (validate)
myId = o.name.substring(3, o.name.length);
// check dependencies
if ( validate )
checkDependenciesOpt( myId, o );
if ( o.data ) {
currentFormElement = o;
}
var sum = basispreis;
var faktor = 1;
var formCounter = 0;
with ( document ) {
while ( forms[ formCounter ] ) {
var elementCounter = 0;
// loop ueber alle elemente im Formular formulare
while ( forms[ formCounter ].elements[ elementCounter ] ) {
var currentElement = forms[ formCounter ].elements[ elementCounter ];
if ( currentElement.data ) {
// Menge
if ( currentElement.data.typ == 1 ) {
// default value is 0, if user has deleted --> add it!
if (isNaN(currentElement.value)) {
currentElement.value = currentElement.data.def;
forms[ formCounter ].elements[ elementCounter ].value = currentElement.data.def;
}
sum = sum + currentElement.data.preis*100*currentElement.value;
}
// Ja/Nein
if ( currentElement.data.typ == 2 && currentElement.checked ) {
sum = sum + currentElement.data.preis*100;
}
// Faktor
if ( currentElement.data.typ == 3 && currentElement.checked ) {
faktor = faktor + (currentElement.data.preis -1);
}
}
elementCounter++;
} // end element loop
formCounter++;
} // end form loop
sum = sum * faktor;
}
if ( calcmwst ) {
sum = sum * mwst;
}
sumMt = Math.round(sum/12);
sum = Math.round(sum);
sum = decimalFormat( sum/100 );
sum = fill( sum );
sumMt = decimalFormat( sumMt/100 );
sumMt = fill( sumMt );
document.myForm.total.value = sumMt;
document.myForm.total_jahr.value = sum;
}
////////////////////////////////////////////////////////////////////////////////
// sub functions
//
function fill( txt ) {
gap = inputLength - txt.length; i = 0;
while ( gap > i ) { txt = ' ' + txt; i++; }
return txt;
}
// make decimal numbers, e.g .1 -> 0.10
function decimalFormat( nr ) {
nr = Math.round(nr*100)/100; // cut everything after x.xx
nr = nr.toString(); // need string for string operation!
if ( nr.indexOf('.') == -1 ) { nr = nr + '.00' ; }
// add trailing zero
if ( nr.charAt(0) == '.' ) { nr = '0' + nr; }
// add leading zeros
while ( nr.indexOf('.') > nr.length-3 ) { nr = nr + '0'; }
return nr;
}
////////////////////////////////////////////////////////////////////////////////
// MM Functions
//
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
// MM_reloadPage(true);
////////////////////////////////////////////////////////////////////////////////
//
// VALIDATE DEPENDENCIES!
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Alert Window
//
function alertWindow( txt, type ) {
if ( !alertWindow ) {
var alertWindow = window.open("","displayWindow","scrolling=yes,width=300,height=250");
if ( !document.all )
alertWindow.document.open();
alertWindow.document.write('Message window');
alertWindow.document.write('');
}
alertWindow.document.write( '
' + q.getField( row, 'opt_text' ) + '\n';
}
}
if (msg != '') {
if (!type) {
msg = 'Folgende Optionen koennen nicht mit \'' + self + '\'\ngewaehlt werden!
\n\n'+msg+'
';
} else {
msg = 'Folgende Optione kann nicht abgewaehlt werden!
\n\n'+msg+'
';
}
alertWindow( msg, type );
}
}
////////////////////////////////////////////////////////////////////////////////
// change status of the calling object
//
function changeStatus( values, setStatus ) {
if ( isNaN(values) ) {
values = values.toString();
arr = values.split(','); i = 0;
while ( arr[i] ) {
document.myForm[ 'id_' + arr[i] ].checked = setStatus;
i++;
}
} else {
document.myForm[ 'id_' + values ].checked = setStatus;
}
}
function copyAdress() {
with ( document.adressForm ) {
// copy text fields from top of the form to invoice section
// the naming convention of the text fields looks like follows:
// top eg. name = 'strasse'
// invoice eg. name = 'invoice_strasse'
// so, loop over all textfields, check if it's pendant is present and
// copy value
i=0;
while ( elements[i] ) {
if ( elements[i].type == 'text' ) {
var fldName = elements[i].name;
if ( fldName.substring(0,7) != 'invoice_' ) { // NOT 'invoice_*'
if (elements[ 'invoice_' + fldName ])
elements[ 'invoice_' + fldName ].value = elements[i].value;
}
}
i++;
}
// the 'anrede is a select box ... need a different proceture here:
i_opt = elements[ 'anrede' ].options.selectedIndex;
elements[ 'invoice_anrede' ].options[ i_opt ].selected = true;
i_opt = elements[ 'country_sid' ].options.selectedIndex;
elements[ 'invoice_country_sid' ].options[ i_opt ].selected = true;
}
}
////////////////////////////////////////////////////////////////////////////////
// splitParameters() -- gets parameters from an url and returns them in an array
//
////////////////////////////////////////////////////////////////////////////////
//
// Author : Simon Wunderlin [swunderlin@telemedia.ch]
// Revision : 1.0, 06.12.00 - first release
//
////////////////////////////////////////////////////////////////////////////////
//
// input: (string) actual URL
// return: (Object) parameter
// parameter., returns value OR
// getValue( ) returns the value of name or
// false if not found
//
// usage:
// URL looks like this: ?domain=www.mydom.com&bla=1&x=2
//
// myVar = splitParameters();
// alert(myVar.getValue( 'bla' )); // will return '1'
// alert(myVar.domain); // will return 'www.mydom.com'
// myVar.setValue( String name, String value); // will set a name to value
//
// methods for returned object /////////////////////////////////////////////////
//
// get a value from the object
function _getValueOfURLParam( _name ) {
for ( i=0; i= pairs by '='.
//
// create a new object and assign values as discribed in function return
// description at the beginning of this function
//
var pairs = qString.split('&');
for ( i=0; i = true
// eingeschaltet werden) wird ein neues Objekt angelegt. Dies ist
// noetig, da IE und NN verschiedene eventobjekte haben.
//
// oEvent:
//
// PROPERTIES
// oEvent.o : objekt, welches den Event ausgeloest hat
// oEvent.type : string, typ des events (siehe weiter unten)
// oEvent.button : int, 0=default, 1=links, 2=mitte, (3=rechts)
// oEvent.keyCode : int, ASCII keycode der gedrueckten taste
// oEvent.keyLetter : char, Zeichen, dass gedrueckt wurde
// oEvent.keyAlt : bool, alt Taste
// oEvent.keyControl : bool, control Taste
// oEvent.keyShift : bool, Shift Taste
// oEvent.pageX : int, X-position vom ausloesenden objekt, die
// koordinaten sind immer absolut zu dokument
// und nicht zum Fenster!
// oEvent.pageY : int, Y-position vom ausloesenden objekt
// oEvent.screenX : int, X-position vom ausloesenden objekt zum bildschirmrand
// oEvent.screenY : int, Y-position vom ausloesenden objekt zum bildschirmrand
//
// METHODS
// oEvent.focus() : void, setzt den focus auf das ausloesende element
// oEvent.clear() : void, setzt value auf '', wenn das objekt ein
// Formular-Elemt ist
// oEvent.submit() : void, uebermittelt das Formular, welches den event
// ausloeste (oder eines dessen elemente)
// oEvent.enter() : bool, true wenn letzte Taste enter war, sonst false
//
//
// Event typen (case-sensitive!):
//
// mouse Events
var switchClick = false; var switchDblClick = false;
var switchMouseDown = false; var switchMouseUp = false;
var switchMouseOut = false; var switchMouseMove = false;
var switchMouseOver = false;
//key events
var switchKeyDown = false; var switchKeyUp = false;
var switchKeyPress = false;
// window events
var switchAbort = false; var switchLoad = false;
var switchResize = false; var switchUnload = false;
// other
var switchBlur = false; var switchChange = false;
var switchDragDrop = false; var switchError = false;
var switchFocus = false; var switchMove = false;
var switchReset = false; var switchSelect = false;
var switchSubmit = false;
//------------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
// Da das event Objekt in IE und NN verschieden sind, wird hier ein eigenes,
// einheitliches Event Objekt zusammen getrickt.
//
function initEventObject(e) {
oEvent.keyAlt = false;
oEvent.keyControl = false;
oEvent.keyShift = false;
oEvent.keyLetter = false;
if ( document.all ) { // IE 4+
oEvent.o = window.event.srcElement; // Object which caused event
oEvent.type = window.event.type; // Event type
oEvent.button = window.event.button; // mouse button
oEvent.keyCode = window.event.keyCode; // ASCII key code
oEvent.keyAlt = window.event.altKey;
oEvent.keyControl = window.event.ctrlKey;
oEvent.keyShift = window.event.shiftKey;
oEvent.pageX = window.event.clientX + document.body.scrollLeft;
oEvent.pageY = window.event.clientY + document.body.scrollTop;
oEvent.screenX = window.event.screenX;
oEvent.screenY = window.event.screenY;
} else { // NN 4+
oEvent.o = e.target; // Object which caused event
oEvent.type = e.type; // Event type
if ( oEvent.type == 'mousedown' || oEvent.type == 'mousemove' ||
oEvent.type == 'mouseout' || oEvent.type == 'mouseover' ||
oEvent.type == 'mouseup' || oEvent.type == 'click' ) {
oEvent.button = e.which; // mouse button
oEvent.keyCode = 0; // ASCII key code
} else {
oEvent.button = 0; // mouse button
oEvent.keyCode = e.which; // ASCII key code
}
if ( e.modifiers == 1 ) { oEvent.keyAlt = true; }
if ( e.modifiers == 2 ) { oEvent.keyControl = true; }
if ( e.modifiers == 4 ) { oEvent.keyShift = true; }
oEvent.pageX = e.pageX;
oEvent.pageY = e.pageY;
oEvent.screenX = e.screenX;
oEvent.screenY = e.screenY;
}
oEvent.keyLetter= String.fromCharCode(oEvent.keyCode); // Zeichen
// fire the function for this event
eval( 'EV' + oEvent.type + '()' );
}
// eventcapturing initialisieren
function initEvent() {
// mouse Events
if (switchClick) { document.onclick = initEventObject; }
if (switchDblClick) { document.ondblclick = initEventObject; }
if (switchMouseDown) { document.onmousedown = initEventObject; }
if (switchMouseUp) { document.onmouseup = initEventObject; }
if (switchMouseOut) { document.onmouseout = initEventObject; }
if (switchMouseMove) { document.onmousemove = initEventObject; }
if (switchMouseOver) { document.onmouseover = initEventObject; }
//key events
if (switchKeyDown) { document.onkeydown = initEventObject; }
if (switchKeyUp) { document.onkeyup = initEventObject; }
if (switchKeyPress) { document.onkeypress = initEventObject; }
// window events
if (switchAbort) { document.onabort = initEventObject; }
if (switchLoad) { document.onload = initEventObject; }
if (switchResize) { document.onresize = initEventObject; }
if (switchUnload) { document.onunload = initEventObject; }
// other
if (switchBlur) { document.onblur = initEventObject; }
if (switchChange) { document.onchange = initEventObject; }
if (switchDragDrop) { document.ondragdrop = initEventObject; }
if (switchError) { document.onerror = initEventObject; }
if (switchFocus) { document.onfocus = initEventObject; }
if (switchMove) { document.onmove = initEventObject; }
if (switchReset) { document.onreset = initEventObject; }
if (switchSelect) { document.onselect = initEventObject; }
if (switchSubmit) { document.onsubmit = initEventObject; }
if ( !document.all ) { // NN only
// mouse Events
if (switchClick) { document.captureEvents(Event.CLICK); }
if (switchDblClick) { document.captureEvents(Event.DBLCLICK); }
if (switchMouseDown) { document.captureEvents(Event.MOUSEDOWN); }
if (switchMouseUp) { document.captureEvents(Event.MOUSEUP); }
if (switchMouseOut) { document.captureEvents(Event.MOUSEOUT); }
if (switchMouseMove) { document.captureEvents(Event.MOUSEMOVE); }
if (switchMouseOver) { document.captureEvents(Event.MOUSEOVER); }
//key events
if (switchKeyDown) { document.captureEvents(Event.KEYDOWN); }
if (switchKeyUp) { document.captureEvents(Event.KEYUP); }
if (switchKeyPress) { document.captureEvents(Event.KEYPRESS); }
// window events
if (switchAbort) { document.captureEvents(Event.ABORT); }
if (switchLoad) { document.captureEvents(Event.LOAD); }
if (switchResize) { document.captureEvents(Event.RESIZE); }
if (switchUnload) { document.captureEvents(Event.UNLOAD); }
// other
if (switchBlur) { document.captureEvents(Event.BLUR); }
if (switchChange) { document.captureEvents(Event.CHANGE); }
if (switchDragDrop) { document.captureEvents(Event.DRAGDROP); }
if (switchError) { document.captureEvents(Event.ERROR); }
if (switchFocus) { document.captureEvents(Event.FOCUS); }
if (switchMove) { document.captureEvents(Event.MOVE); }
if (switchReset) { document.captureEvents(Event.RESET); }
if (switchSelect) { document.captureEvents(Event.SELECT); }
if (switchSubmit) { document.captureEvents(Event.SUBMIT); }
}
}
// prototype functions of oEvent ///////////////////////////////////////////////
function __focus() {
this.o.focus();
}
function __focusNext( step ) {
if ( !step )
step = 1;
if ( this.o.form ) {
ix = -1;
ix = __findCurrentElement( this.o );
if ( ix > -1 ) {
if ( this.o.form.elements[ix+step]) {
this.o.form.elements[ix+step].focus();
}
} else {
return false;
}
} else if ( this.o.href ) {
oNext = this.o.href;
} else {
return false;
}
/*name = this.o.name;
myself = __findCurrentElement( oNext, name );
if ( oNext[ myself+1 ] && myself ) {
oNext[ myself+1 ].focus();
} */
}
function __findCurrentElement( o ) {
// find the position of the current element in o.form or or o.href
// array.
i=0;
while ( o.form.elements[i] ) {
if ( o.form.elements[i].name == o.name ) {
return i;
}
i++;
}
return false;
}
/*
function __focusNext() {
}
*/
function __clear() {
if ( this.o.value )
this.o.value = '';
}
function __submit() {
if ( this.o.form )
this.o.form.submit();
}
function __enter() {
if ( this.keyCode == 13 || this.keyCode == 10 )
return true;
else
return false;
}
////////////////////////////////////////////////////////////////////////////////
// assignt prototype funxtions as methods to oEvent
//
oEvent.focus = __focus;
oEvent.clear = __clear;
oEvent.submit = __submit;
oEvent.enter = __enter;
oEvent.focusNext = __focusNext;
////////////////////////////////////////////////////////////////////////////////
// $Id: validateForm.js,v 1.5 2006/07/19 13:02:23 spliffy Exp $
//
// Known problems:
//
////////////////////////////////////////////////////////////////////////////////
// FORM VALIDATION FOR NN 4+ and IE 4+
//
//
// extend the formfileds with the following parameters and it will
// be validated:
// o.dataType = string | float[ing[point]] | int[eger]
// o.required = yes/1 | no/0/undefined
// (not yet implemented) o.errMsg = (string) "Error message".
////////////////////////////////////////////////////////////////////////////////
// CONFIGURATION
//
var stdErr = "Invalid Form data.\nPlease correct the following field : \n\n";
var reqErr = 'The following fields cannot be blank:\n'
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// validate Form
//
function Validator() {
// delete darts before images (if any):
clearImages();
var required = new Array(1);
var incompat = new Array(1);
imgs = document.images;
// loop over all forms
var idxForm = 0; f = '';
with ( document ) {
while ( forms[idxForm] ) {
f = forms[idxForm]
// loop over all elements in this form
var idxElement = 0; var e = '';
while ( f.elements[idxElement] ) {
e = f.elements[idxElement]
myName = e.name;
// here you can extend all the form objects with your own methods
// and properties :)
////////////////////////////////////////////////////////////////////////
// check if required
//
if ( e.required ) {
val = 1;
if ( e.type == 'select-one' || e.type == 'select-multiple' ) {
val = e.options[e.selectedIndex].value;
} else {
val = e.value;
}
if ( val == '' && ( e.required == 'yes' || e.required == 1 ) ) {
required[required.length] = myName.toUpperCase();
highlightImage( myName );
}
}
////////////////////////////////////////////////////////////////////////
// Do a type validation if needed
//
if ( e.dataType ) {
switch ( e.dataType ) {
case "string": {
// check for string
// alert(isNaN( e.value ) + ' ' + idxForm + ' ' + idxElement);
if ( !isNaN( e.value ) ) {
incompat[incompat.length] = myName.toUpperCase() + ', String expected';
highlightImage( myName );
}
break;
} // end string
case "int": {
// check for integer
}
case "integer": { // check for integer
ix=0; myValue = e.value.toString();
// Char Codes
// . = 46
// 0 = 48
// 9 = 57
while ( myValue.length > ix) {
if ( myValue.charCodeAt( ix ) < 48 ||
myValue.charCodeAt( ix ) > 57 ) {
incompat[incompat.length] = myName.toUpperCase() + ', Integer expected';
highlightImage( myName );
break; // done, exit loop
}
ix++;
}
break;
} // end integer
case "mobile": {
ix=0; myValue = e.value.toString();
while ( myValue.length > ix) {
if ( myValue.charCodeAt( ix ) < 48 ||
myValue.charCodeAt( ix ) > 57 ) {
incompat[incompat.length] = myName.toUpperCase() + ', Integer expected';
highlightImage( myName );
break; // done, exit loop
}
ix++;
}
if (myValue.length > 2 && myValue.substr(0,2) != "07")
incompat[incompat.length] = myName.toUpperCase() + ', Ungültige Natel Nummer';
break;
} // end integer
case "float": {
// check for float
}
case "floating": {
// check for float
}
case "floatingpoint": { // check for float
ix=0; myValue = e.value.toString();
while ( myValue.length > ix) {
if ( myValue.charCodeAt( ix ) < 48 ||
myValue.charCodeAt( ix ) > 57 ) {
if ( myValue.charCodeAt( ix ) != 46 ) {
incompat[incompat.length] = myName.toUpperCase() + ', Float expected';
highlightImage( myName );
break; // done, exit loop
}
}
ix++;
}
break;
} // end float
}
}
idxElement++;
} // end element loop
idxForm++;
} // end form loop
// check wether we have email or fax
with ( document.adressForm ) {
/* if ( fax.value == '' && email.value == '') {
required[required.length] = 'EMail oder Fax muss angegeben werden!';
} */
if ( !__alphanum( login.value ) ) {
required[required.length] = 'Ihr Login darf nur Zahlen und Buchstaben enthalten!';
}
}
}
// get strings from arrays
resultIncomp = __notifie( incompat );
resultRequir = __notifie( required );
result = '';
// construct the error message
if ( resultIncomp != '' || resultRequir != '' ) {
if ( resultIncomp != '' )
result = stdErr + resultIncomp;
if ( resultRequir != '' ) {
if (result != '' ) {
result = result + '\n\n';
}
result = result + reqErr + resultRequir;
}
// display error messgae
alert( result );
}
if ( result == '' )
return true;
else
return false;
}
////////////////////////////////////////////////////////////////////////////////
// loop over array and concatinate all contents into one string with the
// following format:
//
// ' - element1\n
// - element2\n
// - elementN\n'
//
// Expect : (Array)
// Returns: (string)
//
function __notifie( arr ) {
str = ''; i=0;
while ( i < arr.length ) {
if ( arr[i] ) {
if ( arr[i] != '' ) {
str = str + ' - ' + arr[i] + '\n';
}
}
i++
}
return str;
}
////////////////////////////////////////////////////////////////////////////////
// loop over a character array and check if the character is a letter, '_'
// or a number
//
//
// check charcode
// a-z : 97-122
// A-Z : 65-90
// _ : 95
// 0-9 : 48-59
//
// Expect : string
// Returns: (bool) true if alphanum else false
//
function __alphanum( str ) {
var ret = true; mylen = str.length;
for( i=0; i < mylen; i++ ) {
chr = str.charAt(i);
if ( chr < 97 && chr > 122 && chr < 65 && chr > 90 && chr != 95 && chr < 48 && chr > 59 ) {
ret = false;
}
}
return ret;
}
////////////////////////////////////////////////////////////////////////////////
// Clear all reminder image
// following format:
//
function clearImages() {
for ( var i=0; document.images[i]; i++) {
if ( document.images[i].required ) {
document.images[i].src = downimage;
document.images[i].required = 0;
}
}
}
function highlightImage( nm ) {
if ( imgs[ nm ] ) {
imgs[ nm ].src = upimage;
imgs[ nm ].required = 1;
}
}
// Global Javascript parameters ////////////////////////////////////////////////
// validation default messages:
var basispreis = 0.0*100;
var stdErr = "Bitte korrigieren Sie folgende Fehler : \n\n";
var reqErr = 'Folgende Felder duerfen nicht leer sein: \n'
var upimage = '/images/icons/dart-left.gif';
var downimage = '/images/transparent.gif';
var rooturl = '/';
var imgurl = '/images/';
p('');
// get and use url parameters //////////////////////////////////////////////////
oUrl = splitParameters();
////////////////////////////////////////////////////////////////////////////////
//
// output.js -- print the WDDX recodset with JS document.write
//
// Author: Simon Wunderlin [swunderlin@telemedia.ch
// Date : 28.11.2000
//
////////////////////////////////////////////////////////////////////////////////
// chech, that domain is not empty
function checkdom( o ) {
if ( o.domain.value != '' ) {
return true;
} else {
alert('Bitte geben Sie eine Domainnamen ein!');
o.domain.focus();
return false;
}
}
// sort RS by text
//qOpt.sort( 'opt_text' );
////////////////////////////////////////////////////////////////////////////////
// opens the document ( all stuff after and before the actual
// form data
//
function pageOpen() {
if ( oUrl.getValue( 'confirm' ) ) {
var page = 'hostnames.cfm';
} else {
var page = 'main.cfm';
}
p( ' and after the actual
// form data
//
function pageCloser() {
p( '
' );
p( '
' );
p( '
Total :
' );
p( '
' );
p( '
SFr. / Monat
' );
p( '
inkl. MWSt. exkl. MWSt.
');
p( '
' );
p( '
' );
p( '
Total :
' );
p( '
' );
p( '
SFr. / Jahr
' );
if ( oUrl.getValue( 'readonly' ) ) {
p( '
' );
} else {
p( '
' );
}
p( '
' );
p( '
' );
p( '' );
p( '' );
}
////////////////////////////////////////////////////////////////////////////////
// print a section title
//
function pTitle( title ) {
p( '
'+ title +'
' );
p( '' );
}
////////////////////////////////////////////////////////////////////////////////
// fire up all the stuff !
//
function initPage() {
// print form
pageOpen();
// domin input field
pTitle( 'Domain' ); var dom = '';
if ( oUrl.getValue( 'domain' ) ) { dom = oUrl.getValue( 'domain' ); }
display_dom = dom;
if ( oUrl.getValue( 'subdomainname' ) )
display_dom = oUrl.getValue( 'subdomainname' );
if ( oUrl.getValue( 'confirm' ) ) {
p( '