// globals
// =======

var charset="Windows-1251";
var OrderSum = 0;
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 paymentData;		// 
var recAction;                  // receiver (email or cgi) -> protocol (mailto/http) neccessary!!

// input form modes
var addVariable = false;        // in-/decrement productNum in textbox
var addDouble = false;          // in-/decrement productNum as double

// resource strings     (static)
// ================
var strProduct = "Продукт";
var strId = "Номер";
var strPrice = "Цена";
var strProductTotal = "Стоимость";
var strOrderTotal = "Сумма";
//var strOrderCost = "zzgl. Versandkosten";
var strShippingPrice = "Стоимость доставки";
var strOrderNum = "Количество";
var strTotal = "Итого";
//var strProductTitle = "Titel";

var strCheckFailure = "Ошибка в поле ";

var strPrename = "Фамилия";
var strName = "Имя";
var strStreet = "Улица";
var strZip = "Индекс";
var strCity = "Город";
var strCountry = "Страна";
var strTelephone = "Телефон";
var strFax = "Факс";
var strEmail = "E-Mail";
var strDate = "Дата";
var strOrderID = "Номер_Заказа";
var strNoOrder = "<CENTER><B>Товаров в корзине нет</B></CENTER>";

//var strPayment = "Zahlungsart";
//var Kreditdb = new Array("Visa","Eurocard/Mastercard","American Express","Diners Club");

var strVersionWarning = "Sie benцtigen eine aktuellere Version Ihres Browsers, um das Shopping System zu nutzen!";

var strEuroCur="USD";
var strEuroPrice="USD";

// resource strings     (dynamic)
// ================
var slocation;
var firstPage="";
var serverloc;
var sendmethod;
var attachType;
var sendCSVHeaders;
var action;
var strCurrency;
var strOrderOptional = "";


//*******************************************************************************************

// -----------------------------------------------------------------------------------------
// 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;
}
// -----------------------------------------------------------------------------------------
// 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 (params, payParams)
{
 //  source_location,action,
 //  max_products,max_items_per_product,
 //  currency, rate, delcost, lcolor

 if(!check_browser(3,2))
    alert(strVersionWarning);

 // set location of this source
 slocation = params.target;
 if(slocation.length > 0 &&
    slocation.charAt(slocation.length - 1) != ".")
    slocation += ".";

 strCurrency = params.currency;
 recAction = params.action;
 sendmethod = params.sendmethod;
 attachType = params.attachType;
 sendCSVHeaders = params.sendCSVHeaders;
 storemail = params.storemail;
 serverloc = params.serverloc;
 firstPage = params.firstpage;
 action = params.action;

 // init new user
 userData = new getUser();

 // init new orderList
 restart();
 
 linecolor = params.linecolor;
 paymentData = payParams;
 
 MAX = params.maxtypes;
 MAXITEMS = params.maxitems;
 strCurrency = paymentData.currency;

 return true;
}
// -----------------------------------------------------------------------------------------
// restart function (empty orderList)
function restart()
{
 initGlobals();
}
// -----------------------------------------------------------------------------------------
// 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.paymentType = "post";

/* this.bankname = "";
 this.ktnr = "";
 this.blz = "";

 this.kreditcompany = "";
 this.kreditnr = "";
 this.validation = "";

 this.fee = 0;*/
 this.date = "";

 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);
}
// -----------------------------------------------------------------------------------------
//returns quantity of good 'index' in order
function howMuch (index)
{
	qnt = 0;
	i = lookUp (index);
	if (i>0)
		qnt = orderList[i].anzahl;
	return qnt;		
}
// -----------------------------------------------------------------------------------------
// 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)
{

// blow (a);
 var i = lookUp(index);
 var preis;
 var num;
 var tmp;

// alert (numStr+":"+name+":"+bestnum+":"+preisStr+":"+link+":"+max+":"+index);

 // 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("It's a BUG !!!");
    return false;
 } else if((i <= 0) && (orderNum >= MAX) && (num > 0)) {
    // max orders reached
    alert("It's a BUG !!!");
    return false;
 }

 // 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;
}
// -----------------------------------------------------------------------------------------
// 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);
}
// -----------------------------------------------------------------------------------------
// 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 (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*paymentData.ECost) + " " + strEuroCur + "</TD>";
    s += "</TR>";
    OrderSum = sum;
    target.document.write(s);
 }


 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*paymentData.ECost) + " " + strEuroCur + "</b></TD>";
 s += "</TR>";

if (total !=0)
{
	s += "<TR>";
	s += "<TD COLSPAN=" + (colspan - 2) + " ALIGN=RIGHT>" + strShippingPrice + "</TD>";
	s += "<TD ALIGN=RIGHT>" + f2s(paymentData.sendprice) + " " + strCurrency + "</TD>";
	s += "<TD ALIGN=RIGHT>" + f2s(paymentData.sendprice*paymentData.ECost) + " " + strEuroCur + "</TD>";
	s += "</TR>";

	total += paymentData.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*paymentData.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=\" Пересчитать \" onClick=\"self.location.reload();\">";
    s += "</div></td>";
    s += "<td><div align=\"right\">";
    s += "<input type=\"button\" name=\"Button\" value=\" Заказать\" 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 + "\" onBlur=\"" + 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 += "&#160;";

 s += "<TR><TD ALIGN=LEFT><B>" + strPrename + ":" + blanks + "</B></TD>";
 s += "<TD COLSPAN=3 ALIGN=LEFT>" + printInput("prename",20,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",25,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=\"Заказать\" 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);
}
// -----------------------------------------------------------------------------------------
// ckeck a user data
function checkEMail(field, str, elem)
{
	if (str.indexOf("@") > 0)
			return(true);
	else
	{
		alert(strCheckFailure + " >" + field + "<");
		elem.focus();
		return(false);
	}
}
// -----------------------------------------------------------------------------------------
// 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(strPrename,userData.prename,target.document.userform.prename)) == 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((ret = checkEMail(strEmail,userData.email,target.document.userform.email)) == false)
    return(ret);

 return(true);
}
// -----------------------------------------------------------------------------------------
function do_submit(target, redirect)
{
 target.document.order.go.disabled = 'true';
 if (paymentData.paymentType != "dresdner")
	 alert (" Спасибо за заказ. Копию заказа Вы получите по электронной почте.");
 if (!target.doPayment (target, paymentData))
	return false;
 target.document.order.submit();
 if (paymentData.paymentType == "dresdner")
	target.document.order.target = "post";
 if (sendmethod=="1")
    setTimeout("parent.parent." + target.name + ".location='" + redirect + "'", 10000);

// restart();
 return true;
}
// -----------------------------------------------------------------------------------------
function countOrderSum ()
{
 sum = 0;
 for(var i = 1; i <= orderNum; i++) 
    sum += orderList[i].anzahl * orderList[i].preis;
 return sum;
}
// -----------------------------------------------------------------------------------------
function countEurOrderTotal ()
{
	return (countOrderSum() + paymentData.shippingPrice) * paymentData.ECost;
}
// -----------------------------------------------------------------------------------------
function storeOrderDate ()
{
	userData.date = new Date();
}
// -----------------------------------------------------------------------------------------
function printHidden (name, value)
{
	return "<input type=hidden name=" + name + " value=\"" + value + "\"/>";
}
// -----------------------------------------------------------------------------------------
function printAttachData (target)
{
 s = printHidden ("AttachType", attachType);

 if (attachType != "no_attach")
	{
		if (sendCSVHeaders)
		{	
			ucolnames  = "Дата,";
			ucolnames += strOrderID		+ ",";
			ucolnames += strPrename		+ ",";
			ucolnames += strName		+ ",";
			ucolnames += strStreet		+ ",";
			ucolnames += strZip		+ ",";
			ucolnames += strCountry		+ ",";
			ucolnames += strCity		+ ",";
			ucolnames += strTelephone	+ ",";
			ucolnames += strFax		+ ",";
			ucolnames += strEmail;
	
			s += printHidden ("UColnames", ucolnames);

			colnames  = strOrderID	+ ",";
			colnames += strId	+ ",";
			colnames += strProduct	+ ",";
			colnames += strOrderNum	+ ",";
			colnames += strPrice	+ ",";
			colnames += "Валюта";

			s += printHidden ("Colnames", colnames);
		}

		s += printHidden ("UDate",	userData.date.toGMTString ());
		s += printHidden ("UPrename",	userData.prename);
		s += printHidden ("UName",	userData.name);
		s += printHidden ("UStreet",	userData.street);
		s += printHidden ("UZip",	userData.zip);
		s += printHidden ("UCountry",	userData.country);
		s += printHidden ("UCity",	userData.city);
		s += printHidden ("UPhone",	userData.tel);
		s += printHidden ("UFax",	userData.fax);
		s += printHidden ("UEmail",	userData.email);

		s += printHidden ("OrderID", target.printOrderID (userData));
		s += printHidden ("Currency", strCurrency);

		for(var i = 1; i <= orderNum; i++)
		{
			s += printHidden ("ProductID_" + i,	orderList[i].bestnum);
			s += printHidden ("Product_" + i,	orderList[i].name);
			s += printHidden ("Quantity_" + i,	orderList[i].anzahl);
			s += printHidden ("Price_" + i,		f2s(orderList[i].preis));
		}

	}
 return s;	
}
// -----------------------------------------------------------------------------------------
function printSendButton(target, caption)
{               
 if(!isOrder())
    return;
 var s = "<center><form name='order' ";
 if (sendmethod=='1') s+= "enctype='text/plain'"; 
 s+= "encoding='iso-8859-1'";
 s+= " method='post' action=\"" + action;

 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";

 s += strOrderID + ": " + target.printOrderID (userData) + "\n";
 s += strDate + ": " + userData.date.toLocaleString () + "\n" +
      strPrename + ": " + userData.prename + "\n" +
      strName + ":    " + userData.name + "\n" +
      strStreet + ": " + userData.street + "\n" +
      strZip + ":     " + userData.zip + "\n" +
      strCity + ":   " + userData.city + "\n" +
      strCountry + ":    " + userData.country + "\n" +
      strTelephone + ":     " + userData.tel + "\n" +
      strFax + ":     " + userData.fax + "\n" +
      strEmail + ":   " + userData.email + "\n";

 sum = 0; 
 var d="\n";
 for(var i = 1; i <= orderNum; i++) {
    d += "----- Продукт ";
    d +=  i + "-----\n";
    d += strId + ": " + orderList[i].bestnum + "; \n";
    d += strOrderNum + ": " + orderList[i].anzahl + "; \n";
    d += strProduct + ": " + orderList[i].name + "; \n";   // always send something
    d += strPrice + ": " + f2s(orderList[i].preis) + " " + strCurrency + "; \n";
    d += "\n";
 }
 noquotes = d.split("\"");
 for (i=0;i<noquotes.length-1;i++)
   s+= noquotes[i] + "`";
   s += noquotes [noquotes.length-1]; 

    if (sum!=0)
    s += strShippingPrice + ": " + f2s(paymentData.sendprice) + " " + strCurrency; 
    s += "\n---------------------------\n";
    if (paymentData.paymentType != "post") 
	{
	  s += "Тип оплаты: " + paymentData.paymentType + "; Валюта: USD\n";
        }
    s += "\">";
 
 s += printAttachData (target);
 s += printHidden ("USubject",	"Заказ (копия)");
 s += printHidden ("Subject", "Заказ");
 s += printHidden ("Charset", charset);

 if (sendmethod != "1")
 {
   if (paymentData.paymentType != "dresdner")
	{
	   s+= "<input type=\"hidden\" name=\"Location\" value=\"";
	   s+= serverloc;
	   s += firstPage + "\"/>";
	}
 }
 s += "<INPUT TYPE=button name='go' VALUE=\"" + caption + "\"";
 s += " onClick=\"" + slocation;
 s += "do_submit(self, '" + serverloc;
 s += firstPage + "')\">";
 s += "</form></center>";
 s += target.printPaymentForm (target, userData);
 target.document.write(s);
}
// -----------------------------------------------------------------------------------------
isScriptLoaded = true;
