home *** CD-ROM | disk | FTP | other *** search
- //
- // Client side shopping system - based on remote JavaScript
- //
- //
- // public functions
- // ================
- // start(source_location,email, -> initialisation
- // max_products,
- // max_items_per_product,
- // currency,mwst_excl_incl)
- // restart() -> reinitialisation (empty orderlist)
- // addOrderElem(num,name,bestnum,preisStr
- // [,optStr]) -> selecting product
- // incrOrderElem(i) -> increment product counter of product (i)
- // decrOrderElem(i) -> decrement product counter of product (i)
- // deleteOrderElem(i) -> deselecting product (i)
- // isOrder() -> true/false (onSubmit)
- // printOrder(target,borderWidth,asform) -> print order list form in window 'target' as form or as label
- // printUserData(target,borderWidth,asform) -> print user data form in window 'target' as form or as label
- // checkUserData(target) -> true/false (onSubmit)
- // printSendButton(target,caption,
- // redirect_fax,redirect,
- // infotext) -> print hidden send message in window 'target' and send button 'caption'
- // ie 3.x redirect to side 'redirect_fax'
- // do redirect to location 'redirect' after email send in same window
- // attention: button click implicits restart()
- // define(image_or_str,variable,value) -> define "image": "+", "-", "x", "ok"
- // define "string": "NO_ORDER", "MAX_ORDER", "MAX_ITEM", "ORDER_NUM",
- // "ORDER_OPTIONAL", "SEARCH_NORESULT", "MAIL_SUBJECT"
- // define "boolean": "ORDER_VARIABLE", "ORDER_DOUBLE" -> "0/1"
- // define "payment": "NACHNAHME", "RECHNUNG", "BANK", "KREDIT" -> "float" for additional fee
- // search(pdname,pdnum,pdprice) -> define search query
- // printHitList(target,dbname,dbname_i, -> print hitlist for defined search query
- // dbnum,dbnum_i,dbprice,dbprice_i,dbref)
- // test() -> return messagebox of orderList
- // copyright(mode) -> check and alert version info
-
- // globals
- // =======
- var isScriptLoaded = false; // true, if script is completely loaded
- var MAX; // maximum numbers of orders
- var MAXITEM; // maximum numbers of items per order
- var orderList; // list of orders
- var orderNum; // actual number of orders
- var userData; // user data
- var recAction; // receiver (email or cgi) -> protocol (mailto/http) neccessary!!
- var definePayments = false; // true, if any payment method is manual defined; initialize payments first
-
- // configurable images
- var image_delete = "x"; // x image (delete)
- var image_incr = "+"; // + image (increment)
- var image_decr = "-"; // - image (delete)
- var image_upd = "ok"; // update image (update)
-
- // input form modes
- var addVariable = false; // in-/decrement productNum in textbox
- var addDouble = false; // in-/decrement productNum as double
-
- // payment modes
- var NACHNAHME = 1; // payment definition
- var strNACHNAHME = "Nachnahme";
- var feeNACHNAHME = 0;
- var RECHNUNG = 2; // payment definition
- var strRECHNUNG = "Rechnung";
- var feeRECHNUNG = 0;
- var BANKEINZUG = 4; // payment definition
- var strBANKEINZUG = "Bankeinzug";
- var feeBANKEINZUG = 0;
- var KREDITKARTE = 8; // payment definition
- var strKREDITKARTE = "Kreditkarte";
- var feeKREDITKARTE = 0;
-
- var ALLPAYMENT = (NACHNAHME | RECHNUNG | BANKEINZUG);
- var payment = NACHNAHME; // default payment
- var sendprice;
-
- // MwSt
- var mwst;
-
- // resource strings (static)
- // ================
- var strProduct = "Produkt";
- var strId = "ISBN";
- var strPrice = "Einzelpreis";
- var strProductTotal = "Gesamt";
- var strOrderTotal = "Bestellsumme";
- var strOrderCost = "zzgl. Versandkosten";
- var strTotal = "Gesamtsumme";
-
- var strCheckFailure = "Es fehlt die Eingabe des Feldes";
-
- var strPrename = "Vorname";
- var strName = "Name";
- var strStreet = "Stra▀e";
- var strZip = "Plz";
- var strCity = "Stadt";
- var strCountry = "Land";
- var strTelephone = "Telefon";
- var strFax = "Fax";
- var strEmail = "E-Mail";
-
- var strPayment = "Zahlungsart";
- var strBankname = "Name der Bank";
- var strKtnr = "Kontonummer";
- var strBlz = "Blz";
- var strPlus = "zzgl.";
- var strKreditinstitut = "Kreditinstitut";
- var strKreditnr = "Kartennummer";
- var strKreditdatum = "Gⁿltig bis";
- var Kreditdb = new Array("Visa","Eurocard/Mastercard","American Express","Diners Club");
-
- var strMaxOrder1 = "Die maximale Gesamtbestellmenge von";
- var strMaxOrder2 = "Produkten ist erreicht.";
- var strMaxItem1 = "Die maximale Bestellmenge dieses Produktes von";
- var strMaxItem2 = "ist erreicht.";
-
- var strCountIncr = "Anzahl erh÷hen";
- var strCountDecr = "Anzahl verringern";
- var strCountUpd = "Anzahl aktualisieren";
- var strCountDel = "Produkt entfernen";
-
- var strVersionWarning = "Sie ben÷tigen eine aktuellere Version Ihres Browsers, um das Shopping System zu nutzen!";
-
- var strMwst = "MwSt.";
- var strMwstIncl = "inklusive";
- var strMwstExcl = "zzgl.";
-
-
- var strEuroCur="EUR";
- var strEuroPrice="Euro";
- var ECost;
-
- // resource strings (dynamic)
- // ================
- var slocation;
- var strMaxOrder;
- var strMaxItem;
- var strCurrency;
- var strNoOrder = "<CENTER>Es liegt derzeit keine Bestellung vor</CENTER><BR>";
- var strOrderNum = "Anzahl";
- var strOrderOptional = "";
- var strSearchNoResult = "Es wurden keine Treffer zu den angegebenen Suchbegriffen gefunden.";
- var strMailSubject = "Bestellung von ½▒¢1/2⌡∙Ñτµ";
-
- //*******************************************************************************************
-
- // return text for horizontal line
-
- function hline ()
- {
- s = "<table height='1' width='100%' border='0' cellspacing='0' cellpadding='0' bgcolor='";
- s += linecolor;
- s += "'><tr><td><img src='Images/pixel.gif'></td></tr></table>"
- return s;
- }
-
- // copyright check function
- function copyright(msgbox)
- {
- var now = new Date();
- var till = new Date(Date.UTC(99,12-1,31));
-
- if(msgbox)
- alert("Shopping System Version " + VERSION + " (" +
- till.getDate() + "/" +
- (till.getMonth() + 1) + "/" +
- till.getYear() + ")" +
- ".");
- return(now.getTime() <= till.getTime());
- }
-
- // check browser version mimimum
- function check_browser(netscape_version, ie_version)
- {
- var name = navigator.appName;
- var version = parseInt("" + navigator.appVersion.substring(0,1));
-
- //alert("*" + name + "#" + version + "*");
- if(((name.indexOf("Netscape") > -1) && (version >= netscape_version)) ||
- ((name.indexOf("Microsoft") > -1) && (version >= ie_version)))
- return(true);
- else
- return(false);
- }
-
- // init function
- function start(source_location,action,
- max_products,max_items_per_product,
- currency, rate, mwst_excl_incl, delcost, lcolor)
- {
- // check client version
-
- if(!check_browser(3,2))
- alert(strVersionWarning);
-
- // set location of this source
- slocation = source_location;
- if(slocation.length > 0 &&
- slocation.charAt(slocation.length - 1) != ".")
- slocation += ".";
-
- // set globals from args
- MAX = max_products;
- strMaxOrder = strMaxOrder1 + " " + MAX + " " + strMaxOrder2;
- MAXITEM = max_items_per_product;
- strMaxItem = strMaxItem1 + " " + MAXITEM + " " + strMaxItem2;
- strCurrency = currency;
- recAction = action;
- mwst = mwst_excl_incl;
- if(mwst > 0)
- strMwstExcl += " " + mwst + "% " + strMwst; // exclusive (positive MwSt.)
- else if(mwst < 0)
- strMwstIncl += " " + Math.abs(mwst) + "% " + strMwst; // inclusive (negative MwSt.)
- else
- strMwstExcl = strMwstIncl = "";
-
- // init new user
- userData = new getUser();
-
- // init new orderList
- restart();
-
-
- sendprice=delcost;
- linecolor=lcolor;
- ECost=rate;
-
- return(copyright(0));
- }
-
- // restart function (empty orderList)
- function restart()
- {
- initGlobals();
- }
-
- // test function for debugging internals
- function test()
- {
- var s = "";
-
- for(var i = 1; i <= orderNum; i++)
- s += orderList[i].anzahl + " x " + orderList[i].name + " " + orderList[i].name + "\n";
-
- alert("DataBase Input:\n" + s);
- }
-
- // create a list of 'num' elements
- function getList(num)
- {
- this.length = num;
- for(var i = 1; i <= num; i++)
- this[i] = 0;
-
- return(this);
- }
-
- // create a user
- function getUser()
- {
- this.prename = "";
- this.name = "";
- this.street = "";
- this.zip = "";
- this.city = "";
- this.country = "";
- this.tel = "";
- this.fax = "";
- this.email = "";
-
- this.payment = "";
- this.bankname = "";
- this.ktnr = "";
- this.blz = "";
-
- this.kreditcompany = "";
- this.kreditnr = "";
- this.validation = "";
-
- this.fee = 0;
-
- return(this);
- }
-
- // init all globals
- function initGlobals()
- {
- orderList = new getList(MAX);
- orderNum = 0;
- }
-
- // lookup in orderList and return index
- function lookUp(index)
- {
- for(var i = 1; i <= orderNum; i++)
- if(orderList[i].index == index)
- return(i);
-
- return(0);
- }
-
- // create new order element
- function orderElem(num,name,bestnum,preis,hrf,maxitem,index)
- {
- this.anzahl = num;
- this.name = name;
- this.bestnum = bestnum;
- this.preis = preis;
- this.hrf = hrf;
- this.maxitem = maxitem;
- this.index = index;
- }
-
- // change a comma through dot
- function comma2dot(str)
- {
- var i;
- var tmp = str;
- var len = str.length;
-
- i = -1;
- while((i = str.indexOf(",",i+1)) >= 0) {
- tmp = tmp.substring(0,i) + "." + tmp.substring(i+1,str.length);
- }
-
- str = tmp;
- i = -1;
- while((i = str.indexOf(".",i+1)) >= 0) {
- if(len - (i+1) <= 2) {
- break;
- }
- tmp = tmp.substring(0,i) + tmp.substring(i+1,str.length);
- }
-
- return(tmp);
- }
-
- // add a new order in orderList
- function addOrderElem(numStr,name,bestnum,preisStr, link, max, index)
- {
- var i = lookUp(index);
- var preis;
- var num;
- var tmp;
-
- // get price
- preis = parseFloat(comma2dot(preisStr));
-
- // get number
- num = 0 + (addDouble ? parseFloat(comma2dot(numStr)) : parseInt(numStr));
-
- // determine max
- if(num > MAXITEM) {
- // max items reached
- alert(strMaxItem);
- return false;
- } else if((i <= 0) && (orderNum >= MAX) && (num > 0)) {
- // max orders reached
- alert(strMaxOrder);
- return false;
- }
-
- // control optStr
- // if(addOrderElem.arguments.length < 5)
- // optStr = "";
-
- // insert/update/delete order
- if(num <= 0) {
- if(i > 0)
- // delete
- deleteOrderElem(i);
- } else {
- if(i > 0)
- // update
- orderList[i].anzahl = num;
- else
- // insert
- orderList[++orderNum] = new orderElem(num,name,bestnum,preis,link, max, index);
- }
- return true;
- }
-
-
- // increment number of orders for orderListElem 'i'
- function incrOrderElem(i)
- {
- if(i <= orderNum && i > 0) {
- if(orderList[i].anzahl < MAXITEM)
- orderList[i].anzahl++;
- else
- alert(strMaxItem);
- }
- }
-
- // decrement number of orders for orderListElem 'i'.
- // if neccessary delete orderListElem 'i' and rearrange
- // orderList.
- function decrOrderElem(i)
- {
- if(i <= orderNum && i > 0) {
- orderList[i].anzahl--;
- if(orderList[i].anzahl <= 0)
- deleteOrderElem(i);
- }
- }
-
- // delete orderListElem 'i'
- function deleteOrderElem(i)
- {
- if(i <= orderNum && i > 0) {
- for(var j = i; j < orderNum; j++)
- orderList[j] = orderList[j + 1];
- orderNum--;
- }
- }
-
- // convert float to string
- function f2s(f)
- {
- var num = "" + Math.round(f * 100);
- var s;
-
- if(num.length == 0)
- s = "0,00";
- else if(num.length == 1)
- s = "0,0" + num;
- else if(num.length == 2)
- s = "0," + num;
- else {
- if(num.length > 5)
- s = num.substring(0,num.length - 5) + "." + num.substring(num.length - 5,num.length - 2) + ",";
- else
- s = num.substring(0,num.length - 2) + "," ;
- s += num.substring(num.length - 2, num.length);
- }
-
- return(s);
- }
-
- // retrieve file from local (\) or remote (/) URL target
- function getFile(url)
- {
- var delim = (url.indexOf("\\") > -1 ? "\\" : "/");
-
- return(url.substring(url.lastIndexOf(delim) + 1,url.length));
- }
-
- // function to reload target window
- function reload(target)
- {
- if(navigator.appName.indexOf("Netscape") > -1)
- target.location.reload(true);
- else
- // target.location = target.location.href does not work (cache!!!)
- target.location = getFile(target.location.href);
- }
-
- // check if there is a orderList
- function isOrder()
- {
- return(orderNum > 0);
- }
-
- // print complete orderList
- function printOrder(target,borderWidth,asform)
- {
- var sum;
- var total = 0;
- var tax = 0;
- var colspan;
-
- if(!isOrder()) {
- target.document.write(strNoOrder);
- return;
- }
- var s = "<FORM NAME=\"sel\"><TABLE align='center' BORDER=" + borderWidth + " WIDTH=\"725\" align='center'><TR>";
- if(asform) {
- // s += "<TH>" + strChoice + "</TH>";
- colspan = 6;
- }
- else {
- colspan = 6;
- }
- if(strOrderOptional > "")
- colspan++;
-
- s += "<TH ALIGN=CENTER>" + strId + "</TH>";
- s += "<TH ALIGN=LEFT>" + strProduct + "</TH>";
- s += "<TH ALIGN=CENTER>" + strOrderNum + "</TH>";
- if(strOrderOptional > "")
- s += "<TH ALIGN=CENTER>" + strOrderOptional + "</TH>";
- s += "<TH ALIGN=RIGHT>" + strPrice + "</TH>";
- s += "<TH ALIGN=RIGHT>" + strProductTotal + "</TH>";
- s += "<TH ALIGN=RIGHT>" + strEuroPrice + "</TH>";
- // if(asform)
- // s += "<TH></TH>";
-
- s += "</TR>";
- target.document.write(s);
-
- for(var i = 1; i <= orderNum; i++) {
- sum = orderList[i].anzahl * orderList[i].preis;
- total += sum;
- s = "<TR>";
- // éδó«ñ CheckBox
- /*
- if(asform) {
- s += "<td align=\"center\">"; // width=\"5%\"
- s += "<input type=\"checkbox\" name=\"ch" + i + "\" checked onClick=\"javascript:ChCheckBox(this, sel);\">";
- s += "</TD>";
- }
- */
- // éδó«ñ ISBN
- s += "<td>"; // width=\"10%\"
- s += "<p align=\"center\">" + orderList[i].bestnum;
- s += "<input type=\"hidden\" name=\"isbn" + i + "\"value=\"" + orderList[i].bestnum + "\"></p>";
- // s += (addDouble ? f2s(orderList[i].anzahl) : orderList[i].anzahl);
- s += "</TD>";
- // éδó«ñ Produkt
- s += "<TD><a href=\"" + orderList[i].hrf + "\">" + orderList[i].name + "</a>";
- s += "<input type=\"hidden\" name=\"title" + i + "\" value=\"" + orderList[i].name + "\">";
- s += "<input type=\"hidden\" name=\"link" + i + "\" value=\"" + orderList[i].hrf + "\"></TD>";
- // if(strOrderOptional > "")
- // s += "<TD ALIGN=LEFT>" + orderList[i].optstr + "</TD>";
- // éδó«ñ Anzahl
- if (asform) {
- s += "<TD><input type=\"text\" name=\"quantity" + i + "\" value=\"" + orderList[i].anzahl + "\" onBlur=\"ChangeTxt(this, sel);\" size=\"5\">";
- }
- else {
- s += "<TD ALIGN=RIGHT>" + orderList[i].anzahl;
- }
- s += "<input type=\"hidden\" name=\"num" + i + "\" value=\"" + orderList[i].maxitem + "\">";
- s += "<input type=\"hidden\" name=\"price" + i + "\" value=\"" + orderList[i].preis + "\">";
- s += "<input type=\"hidden\" name=\"index" + i + "\" value=\"" + orderList[i].index + "\">";
- s += "<input type=\"hidden\" name=\"prsh" + i + "\" value=\"" + orderList[i].preiship + "\"></TD>";
-
-
- s += "<TD ALIGN=RIGHT>" + f2s(orderList[i].preis) + " " + strCurrency + "</TD>";
- s += "<TD ALIGN=RIGHT>" + f2s(sum) + " " + strCurrency + "</TD>";
- s += "<TD ALIGN=RIGHT>" + f2s(sum*ECost) + " " + strEuroCur + "</TD>";
- // if(asform) {
- // s += "<TD ALIGN=CENTER>";
- // s += "<A HREF=\"javascript:" + slocation + "deleteOrderElem(" + i + ");" + slocation + "reload(self);\">" + image_delete + "</A>";
- // s += "</TD>";
- // }
- s += "</TR>";
- target.document.write(s);
- }
-
- // Hier: Achtung !! éδó«ñ ú«α¿º«¡Γá½∞¡«⌐ τÑαΓδ
- s = "<TR>";
- s += "<TD COLSPAN=" + colspan + ">" + hline() +"</TD></TR><TR>";
- s += "<TD COLSPAN=" + (colspan - 2) + " ALIGN=RIGHT><B>" + strOrderTotal + "</B></TD>";
- s += "<TD ALIGN=RIGHT><B>" + f2s(total) + " " + strCurrency + "</B></TD>";
- s += "<TD ALIGN=RIGHT><b>" + f2s(total*ECost) + " " + strEuroCur + "</b></TD>";
- s += "</TR>";
-
- s += "<TR>";
- s += "<TD COLSPAN=" + (colspan - 2) + " ALIGN=RIGHT>Versandkosten</TD>";
- s += "<TD ALIGN=RIGHT>" + f2s(sendprice) + " " + strCurrency + "</TD>";
- s += "<TD ALIGN=RIGHT>" + f2s(sendprice*ECost) + " " + strEuroCur + "</TD>";
- s += "</TR>";
- total += sendprice;
-
-
- s += "<TR>";
- s += "<TD COLSPAN=" + colspan + ">" + hline() + "</TD></TR><TR>";
- // s += "<TD COLSPAN=" + colspan + "><HR></TD></TR><TR>";
- s += "<TD COLSPAN=" + (colspan - 2) + " ALIGN=RIGHT><B>" + strTotal + "</B></TD>";
- s += "<TD ALIGN=RIGHT><B><U>" + f2s(total) + " " + strCurrency + "</U></B></TD>";
- s += "<TD ALIGN=RIGHT><b><u>" + f2s(total*ECost) + " " + strEuroCur + "</u></b></TD>";
- s += "</TR>";
-
- s += "<TD COLSPAN=" + colspan + ">" + hline() + "</TD></TR><TR>";
- if (asform) {
- s += "<tr>";
- s += "<td colspan=" + (colspan - 1) + "><div align=\"right\">";
- s += "<input type=\"button\" name=\"Count\" value=\" Neuberechnen \" onClick=\"self.location.reload();\">";
- s += "</div></td>";
- s += "<td><div align=\"right\">";
- s += "<input type=\"button\" name=\"Button\" value=\" Bestellen \" onClick=\"self.location='mailform.htm';\">";
- s += "</div></td></tr>";
- }
- s += "</TABLE></FORM>";
-
- target.document.write(s);
- }
-
- // print text or label
- function printInput(variable,len,value,valuename,astext)
- {
- if(astext)
- return("<INPUT TYPE=TEXT NAME=" + variable + " MAXLENGTH=" + len + " SIZE=" + len + " VALUE=\"" + value + "\" onChange=\"" + slocation + valuename + "=this.value;\">");
- else
- return(value);
- }
-
- // print user data form
- function printUserData(target,borderwidth,asform)
- {
- var s = "<FORM NAME=\"userform\"><TABLE align='center' BORDER=" + borderwidth + ">";
- var blanks = "";
- var i;
-
- for(i = 0; i < 5; i++)
- blanks += " ";
-
- s += "<TR><TD ALIGN=LEFT><B>" + strPrename + ":" + blanks + "</B></TD>";
- s += "<TD COLSPAN=3 ALIGN=LEFT>" + printInput("prename",10,userData.prename,"userData.prename",asform) + "</TD></TR>";
-
- s += "<TR><TD ALIGN=LEFT><B>" + strName + ":</B></TD>";
- s += "<TD COLSPAN=3 ALIGN=LEFT>" + printInput("name",40,userData.name,"userData.name",asform) + "</TD></TR>";
-
- s += "<TR><TD ALIGN=LEFT><B>" + strStreet + ":</B></TD>";
- s += "<TD COLSPAN=3 ALIGN=LEFT>" + printInput("street",40,userData.street,"userData.street",asform) + "</TD></TR>";
-
- s += "<TR><TD ALIGN=LEFT><B>" + strZip + ":</B></TD>";
- s += "<TD ALIGN=LEFT>" + printInput("zip",10,userData.zip,"userData.zip",asform) + blanks + "</TD>";
- s += "<TD ALIGN=LEFT><B>" + strCity + ":</B></TD>";
- s += "<TD ALIGN=LEFT>" + printInput("city",15,userData.city,"userData.city",asform) + "</TD></TR>";
-
- s += "<TR><TD ALIGN=LEFT><B>" + strCountry + ":</B></TD>";
- s += "<TD COLSPAN=3 ALIGN=LEFT>" + printInput("country",40,userData.country,"userData.country",asform) + "</TD></TR>";
-
- s += "<TR><TD ALIGN=LEFT><B>" + strTelephone + ":</B></TD>";
- s += "<TD ALIGN=LEFT>" + printInput("tel",15,userData.tel,"userData.tel",asform) + blanks + "</TD>";
- s += "<TD ALIGN=LEFT><B>" + strFax + ":</B></TD>";
- s += "<TD ALIGN=LEFT>" + printInput("fax",15,userData.fax,"userData.fax",asform) + "</TD></TR>";
-
- s += "<TR><TD ALIGN=LEFT><B>" + strEmail + ":</B></TD>";
- s += "<TD COLSPAN=3 ALIGN=LEFT>" + printInput("email",40,userData.email,"userData.email",asform) + "</TD></TR>";
-
- s += "</TABLE>";
- if (asform) {
- s += "<table align='center'><tr><td><INPUT type=button value=\"Bestellung absenden\" onClick=\"if(parent.shop.checkUserData(self)) self.location='confirm.htm';\"></td></tr></table>";
- }
- s += "</FORM>";
- target.document.write(s);
- }
-
- // ckeck a user data
- function check(field, str, elem)
- {
- if(str == "") {
- alert(strCheckFailure + " >" + field + "<");
- elem.focus();
- return(false);
- }
-
- return(true);
- }
-
- // check completeness of user data
- function checkUserData(target)
- {
- var ret;
-
- if((ret = check(strName,userData.name,target.document.userform.name)) == false)
- return(ret);
- if((ret = check(strStreet,userData.street,target.document.userform.street)) == false)
- return(ret);
- if((ret = check(strZip,userData.zip,target.document.userform.zip)) == false)
- return(ret);
- if((ret = check(strCity,userData.city,target.document.userform.city)) == false)
- return(ret);
- if((ret = check(strCountry,userData.country,target.document.userform.country)) == false)
- return(ret);
-
- if(userData.payment == strBANKEINZUG) {
- if((ret = check(strBankname,userData.bankname,target.document.userform.bank)) == false)
- return(ret);
- if((ret = check(strKtnr,userData.ktnr,target.document.userform.ktnr)) == false)
- return(ret);
- if((ret = check(strBlz,userData.blz,target.document.userform.blz)) == false)
- return(ret);
- }
-
- if(userData.payment == strKREDITKARTE) {
- if((ret = check(strKreditnr,userData.kreditnr,target.document.userform.kreditnr)) == false)
- return(ret);
- if((ret = check(strKreditdatum,userData.validation,target.document.userform.kreditvalidation)) == false)
- return(ret);
- }
-
- return(true);
- }
-
- function do_submit(target, redirect, infotext)
- {
-
- // parent.parent.content.order.submit();
- target.document.order.submit();
-
- if (sendmethod=="1")
- {
- setTimeout("parent.parent." + target.name + ".location='" + redirect + "'", 10000);
- // initialize order
- }
- restart();
- return(true);
- }
-
-
- // print email form or redirect to a faxable side
- function printSendButton(target,caption,redirect_fax,redirect,infotext)
- {
- if(!isOrder())
- return;
-
- if(!check_browser(0,4))
- {
- // ie does not support correctly mailto protocol, netscape does it
- target.location = redirect_fax;
- return;
- }
-
- var s = "<center><form name='order' ";
- if (sendmethod=='1') s+= "enctype='text/plain'";
- s+= "encoding='iso-8859-1'";
- s+= " method='post' action=\"" + recAction;
-
- // if(mailMode)
- // s += "?subject=" + strMailSubject + "\" enctype=\"text/plain" + NAME=\"mailform\" ;
-
- s += "\" onClick=\"" + slocation + "restart()\">";
-
- s += "<INPUT TYPE=HIDDEN NAME=\"To\" VALUE=\"" + storemail + "\">";
- s += "<INPUT TYPE=HIDDEN NAME=\"From\" VALUE=\"" + userData.email + "\">";
- s += "<INPUT TYPE=HIDDEN NAME=\"Order\" VALUE=\"\n";
- s += "\n------------------------------\n";
- var date=new Date();
- s += "Datum: " + date.toLocaleString() + "\n" +
- "Vorname: " + userData.prename + "\n" +
- "Name: " + userData.name + "\n" +
- "Strasse: " + userData.street + "\n" +
- "Plz: " + userData.zip + "\n" +
- "Stadt: " + userData.city + "\n" +
- "Land: " + userData.country + "\n" +
- "Tel: " + userData.tel + "\n" +
- "Fax: " + userData.fax + "\n" +
- "Email: " + userData.email + "\n\n";
- sum = 0;
- for(var i = 1; i <= orderNum; i++) {
- // sum = orderList[i].anzahl * orderList[i].preis;
- // s += "orderNum: " + orderNum + ":"+ i + "; "; // DEBUG MODE
- s += "----- Produkt " + i + "-----\n";
- s += "ISBN: " + orderList[i].bestnum + "; \n";
- s += "Anzahl: " + orderList[i].anzahl + "; \n";
- s += "Titel: " + orderList[i].name + "; \n"; // always send something
- s += "Preis: " + strCurrency + " " + f2s(orderList[i].preis) + "; \n";
- s += "\n";
- }
- // s += "Total Preis: " + sum + " ;"; // DEBUG
- s += "Versandkosten: " + f2s(sendprice) + strCurrency; //f2s(userData.fee)
- s += "\n---------------------------";
- s += "\">";
- if (sendmethod!="1")
- {
- s+= "<input type=\"hidden\" name=\"Location\" value=\""
- s+= serverloc;
- if (serverloc.charAt (serverloc.length-1) != '/');
- s+= "/";
- s += "tcat11.htm\">";
- }
- s += "<INPUT TYPE=button VALUE=\"" + caption + "\"";
- s += " onClick=\" disabled='true';" + slocation + "do_submit( self, '" + redirect + "','" + infotext + "')\">";
- s += "</form></center>";
- target.document.write(s);
- }
-
- // define some defaults
- function define(image_or_str,variable,value)
- {
- if(value.length <= 0)
- return;
-
- if(image_or_str == "image") {
- var s = "<IMG SRC=\"" + value + "\" BORDER=0 ALT=\"";
- if(variable == "+")
- image_incr = s + strCountIncr + "\">";
- else if(variable == "-")
- image_decr = s + strCountDecr + "\">";
- else if(variable == "x")
- image_delete = s + strCountDel + "\">";
- else if(variable == "ok")
- image_upd = s + strCountUpd + "\">";
- } else if(image_or_str == "string") {
- if(variable == "NO_ORDER")
- strNoOrder = value;
- else if(variable == "MAX_ORDER")
- strMaxOrder = value;
- else if(variable == "MAX_ITEM")
- strMaxItem = value;
- else if(variable == "ORDER_NUM")
- strOrderNum = value;
- else if(variable == "ORDER_OPTIONAL")
- strOrderOptional = value;
- else if(variable == "SEARCH_NORESULT")
- strSearchNoResult = value;
- else if(variable == "MAIL_SUBJECT")
- strMailSubject = value;
- } else if(image_or_str == "boolean") {
- if(variable == "ORDER_VARIABLE")
- addVariable = (parseInt(value) == 1 ? true : false);
- else if(variable == "ORDER_DOUBLE")
- addDouble = (parseInt(value) == 1 ? true : false);
- } else if(image_or_str == "payment") {
- if(definePayments == false) {
- // init payments, if first call
- payment &= 0;
- definePayments = true;
- }
- if(variable == "NACHNAHME") {
- feeNACHNAHME = parseFloat(comma2dot(value));
- payment |= NACHNAHME;
- } else if(variable == "RECHNUNG") {
- feeRECHNUNG = parseFloat(comma2dot(value));
- payment |= RECHNUNG;
- } else if(variable == "BANK") {
- feeBANKEINZUG = parseFloat(comma2dot(value));
- payment |= BANKEINZUG;
- } else if(variable == "KREDIT") {
- feeKREDITKARTE = parseFloat(comma2dot(value));
- payment |= KREDITKARTE;
- }
- }
- }
-
- // *****************************************************
- // ****************** search engine ********************
- // *****************************************************
-
- var pdname;
- var pdnum;
- var pdprice;
-
- // print one hitlist line (mode dependent)
- function printHitLine(target,pdname,pdnum,pdprice,pdref,mode)
- {
- var s;
-
- if(mode == 0) {
- s = "<TABLE BORDER=1>";
- s += "<TH ALIGN=LEFT>" + strProduct + "</TH>";
- s += "<TH ALIGN=LEFT>" + strId + "</TH>";
- s += "<TH ALIGN=RIGHT>" + strPrice + "</TH>";
- } else if(mode == 1) {
- s = "<TR>";
- s += "<TD ALIGN=LEFT>";
- if(pdref.length > 0) {
- s += "<A HREF=\"" + pdref + "\">" + pdname + "</A>";
- } else {
- s += pdname;
- }
- s += "</TD>";
- s += "<TD ALIGN=CENTER>" + pdnum + "</TD>";
- s += "<TD ALIGN=RIGHT>" + f2s(pdprice) + " " + strCurrency + "</TD>";
- s += "</TR>";
- } else if(mode == 2) {
- s = "</TABLE>";
- } else {
- s = strSearchNoResult;
- }
- target.document.write(s);
- }
-
- // bisearch
- function bisearch(db,dblen,word)
- {
- var l = 0;
- var r = dblen - 1;
- var i;
-
- while(r >= l) {
- i = parseInt((l + r) / 2);
- //alert(i + ":" + l + ":" + r);
- //alert(db[i].toUpperCase().substring(0,word.length));
- if(word < db[i].toUpperCase().substring(0,word.length))
- r = i - 1;
- else if(word > db[i].toUpperCase().substring(0,word.length))
- l = i + 1;
- else { // word == db[i].substring(0,word.length)
- i--;
- while((i >= 0) && (word == db[i].toUpperCase().substring(0,word.length)))
- i--;
- i++;
- return(i);
- }
- }
-
- return(-1);
- }
-
- // search for products
- function search(name,num,price)
- {
- pdname = name.toUpperCase();
- pdnum = num.toUpperCase();
- pdprice = comma2dot(price);
-
- //alert(pdname + ":" + pdnum + ":" + pdprice);
- }
-
- // search for products
- function printHitList(target,dbname,dbname_i,
- dbnum,dbnum_i,
- dbprice,dbprice_i,
- dbref)
- {
- var i;
- var num = 0;
- var searchmode;
- var printmode = 0;
- var price = parseFloat(pdprice) + 0;
- var dbMax = dbname.length;
-
- // check for valid args
- if((pdname.length == 0) &&
- (pdnum.length == 0) &&
- (pdprice.length == 0)) {
- // print all products
- for(i = 0;i < dbMax;i++) {
- // table header
- if(printmode == 0)
- printHitLine(target,"","","","",printmode++);
- // table row
- printHitLine(target,dbname[i],
- dbnum[dbname_i[i]],
- dbprice[dbnum_i[dbname_i[i]]],
- dbref[i],printmode);
- num++;
- }
- printHitLine(target,"","","","",++printmode);
- return(num);
- }
-
- // check for algorithm
- if((pdname.length >= 3 && pdnum.length <= 2) ||
- (pdname.length > 0 && pdnum.length == 0))
- searchmode = 1; // search for pdname
- else if(pdnum.length > 0)
- searchmode = 2; // search for pdnum
- else
- searchmode = 3; // search for price
-
- // search
- if((searchmode == 1) && // **** search for pdname ***
- ((i = bisearch(dbname,dbMax,pdname)) >= 0)) {
- //alert("Search for Name:" + dbname[i]);
- while((i < dbMax) &&
- (dbname[i].toUpperCase().substring(0,pdname.length) == pdname)) {
- if(((pdnum.length == 0) ||
- (dbnum[dbname_i[i]].toUpperCase().substring(0,pdnum.length) == pdnum)) &&
- ((pdprice.length == 0) || (dbprice[dbnum_i[dbname_i[i]]] <= price))) {
- // table header
- if(printmode == 0)
- printHitLine(target,"","","","",printmode++);
- // table row
- printHitLine(target,dbname[i],
- dbnum[dbname_i[i]],
- dbprice[dbnum_i[dbname_i[i]]],
- dbref[i],printmode);
- num++;
- }
- i++;
- }
- } else if((searchmode == 2) && // *** search for pdnum ***
- ((i = bisearch(dbnum,dbMax,pdnum)) >= 0)) {
- //alert("Search for Num:" + dbnum[i]);
- while((i < dbMax) &&
- (dbnum[i].toUpperCase().substring(0,pdnum.length) == pdnum)) {
- if(((pdname.length == 0) ||
- (dbname[dbprice_i[dbnum_i[i]]].toUpperCase().substring(0,pdname.length) == pdname)) &&
- ((pdprice.length == 0) || (dbprice[dbnum_i[i]] <= price))) {
- // table header
- if(printmode == 0)
- printHitLine(target,"","","","",printmode++);
- // table row
- printHitLine(target,dbname[dbprice_i[dbnum_i[i]]],
- dbnum[i],
- dbprice[dbnum_i[i]],
- dbref[dbprice_i[dbnum_i[i]]],printmode);
- num++;
- }
- i++;
- }
- } else { // *** search for price ***
- i = 0;
- while((dbprice[i] <= price) && (i < dbMax)) {
- // table header
- if(printmode == 0)
- printHitLine(target,"","","","",printmode++);
- // table row
- printHitLine(target,dbname[dbprice_i[i]],
- dbnum[dbname_i[dbprice_i[i]]],
- dbprice[i],
- dbref[dbprice_i[i]],printmode);
- num++;
- i++;
- }
- }
-
- if(num > 0) {
- // table trailer
- printHitLine(target,"","","","",++printmode);
- } else {
- // no result
- printHitLine(target,"","","","",-1);
- }
-
- return(num);
- }
-
- // *****************************************************
- // the following codeline must be the last one !!!
- // *****************************************************
- isScriptLoaded = true;
-