var maxriveja = 40
var maxplus = maxriveja + 1
var CRLF = "   \r\n"
//var PRE1 = "\u003CPRE\u003E"
//var PRE2 = "\u003C\/PRE\u003E"
//var CRLF = "   <br>"
var myyja = "Toimittaja:" + CRLF + "Paratronic Oy                         Puh. 0400-297526" + CRLF + "Hynnilantie 414                       Fax. 06-5259160" + CRLF + "63250 RANTALA                         www.paratronic.fi" + CRLF + "                                      paratronic@paratronic.fi" + CRLF + CRLF
var alv = 23
koodit = new Array() ;
var tyhja=0
var today = new Date();

kulut = new Array() ;
kulut[0] = 0     //ei toimitusta
kulut[11] = 2    //helposti-kuori, pieni
kulut[12] = 3    //helposti-kuori, iso
kulut[13] = 5.5    //maksikirje
kulut[14] = 0     //VARALLA
kulut[15] = 9.5	 //Postipaketti 2kg
kulut[16] = 11	 //Postipaketti 5kg
kulut[17] = 12.5	 //Postipaketti 10kg
kulut[18] = 14    //Postipaketti 15kg
kulut[19] = 15    //Postipaketti 20kg
kulut[20] = 17   //Postipaketti 25kg
kulut[21] = 19   //Postipaketti 30kg
kulut[22] = 21     //Postipaketti 35kg
kulut[23] = 0     //VARALLA
kulut[24] = 0	  //VARALLA
kulut[25] = 14	 //Postipaketti 2kg ennakko
kulut[26] = 15.5	 //Postipaketti 5kg ennakko
kulut[27] = 17	 //Postipaketti 10kg ennakko
kulut[28] = 18.5   //Postipaketti 15kg ennakko
kulut[29] = 20   //Postipaketti 20kg ennakko
kulut[30] = 22   //Postipaketti 25kg ennakko
kulut[31] = 23.5   //Postipaketti 30kg ennakko
kulut[32] = 25     //Postipaketti 35kg ennakko
kulut[33] = 0     //VARALLA
kulut[34] = 0	  //VARALLA
kulut[35] = 0     //VARALLA
kulut[36] = 0     //VARALLA
kulut[37] = 0	  //VARALLA
kulut[38] = 0     //VARALLA
kulut[39] = 0     //VARALLA
kulut[40] = 0	 //Suunto kellot, ilmainen



// rahasumma(jokusumma) palauttaa rahasumman muodossa -####.##
function rahasumma(anynum) {
   anynum=eval(anynum)
   workNum=Math.abs((Math.round(anynum*100)/100));workStr=""+workNum
   if (workStr.indexOf(".")==-1){workStr+=".00"}
   dStr=workStr.substr(0,workStr.indexOf("."));dNum=dStr-0
   pStr=workStr.substr(workStr.indexOf("."))
   while (pStr.length<3){pStr+="0"}
   retval=dStr+pStr 
   if (anynum < 0) {retval="-"+retval}
   retval = retval
   if (anynum==0) {retval=""}
   return retval
}

//luottokunnan tilausnumeron muodostus
function LKtilausnumero() {
	lktilnro=""
	lktilnro=lktilnro+parseInt(Math.abs(today.getFullYear() - 2000))
	lktilnro=lktilnro+parseInt(today.getMonth()*31 + today.getDate())
	lktilnro=lktilnro+parseInt(today.getHours()*3600 + today.getMinutes()*60 +  today.getSeconds())
	lktilnro=Math.abs(lktilnro)
return lktilnro
}


function LskTilausnumero1() {
	lktilnro="Paratronic Oy: Tilaus "+LKtilausnumero()
return lktilnro
}

function LskTilausnumero2() {
	lktilnro="Paratronic Oy: Tilaus "+LKtilausnumero()+"."
return lktilnro
}

function vaihda (a, b){
	eval ('parent.window.ylaosa.document.kori.kdi'+maxplus+'.value = parent.window.ylaosa.document.kori.kdi'+a+'.value')
	eval ('parent.window.ylaosa.document.kori.kdi'+a+'.value = parent.window.ylaosa.document.kori.kdi'+b+'.value')
	eval ('parent.window.ylaosa.document.kori.kdi'+b+'.value = parent.window.ylaosa.document.kori.kdi'+maxplus+'.value')

	eval ('parent.window.ylaosa.document.kori.tuote'+maxplus+'.value = parent.window.ylaosa.document.kori.tuote'+a+'.value')
	eval ('parent.window.ylaosa.document.kori.tuote'+a+'.value = parent.window.ylaosa.document.kori.tuote'+b+'.value')
	eval ('parent.window.ylaosa.document.kori.tuote'+b+'.value = parent.window.ylaosa.document.kori.tuote'+maxplus+'.value')

	eval ('parent.window.ylaosa.document.kori.erahinta'+maxplus+'.value = parent.window.ylaosa.document.kori.erahinta'+a+'.value')
	eval ('parent.window.ylaosa.document.kori.erahinta'+a+'.value = parent.window.ylaosa.document.kori.erahinta'+b+'.value')
	eval ('parent.window.ylaosa.document.kori.erahinta'+b+'.value = parent.window.ylaosa.document.kori.erahinta'+maxplus+'.value')

	eval ('parent.window.ylaosa.document.kori.era'+maxplus+'.value = parent.window.ylaosa.document.kori.era'+a+'.value')
	eval ('parent.window.ylaosa.document.kori.era'+a+'.value = parent.window.ylaosa.document.kori.era'+b+'.value')
	eval ('parent.window.ylaosa.document.kori.era'+b+'.value = parent.window.ylaosa.document.kori.era'+maxplus+'.value')

	eval ('parent.window.ylaosa.document.kori.maara'+maxplus+'.value = parent.window.ylaosa.document.kori.maara'+a+'.value')
	eval ('parent.window.ylaosa.document.kori.maara'+a+'.value = parent.window.ylaosa.document.kori.maara'+b+'.value')
	eval ('parent.window.ylaosa.document.kori.maara'+b+'.value = parent.window.ylaosa.document.kori.maara'+maxplus+'.value')

	eval ('parent.window.ylaosa.document.kori.tk'+maxplus+'.value = parent.window.ylaosa.document.kori.tk'+a+'.value')
	eval ('parent.window.ylaosa.document.kori.tk'+a+'.value = parent.window.ylaosa.document.kori.tk'+b+'.value')
	eval ('parent.window.ylaosa.document.kori.tk'+b+'.value = parent.window.ylaosa.document.kori.tk'+maxplus+'.value')
}


function toimitustapam(nro) {    	//   Toimitustavan paivitys muutosten jlkeen
	parent.window.ylaosa.document.kori.toimitustapa.value = nro
	parent.window.ylaosa.paivitanayttouusi()
}       

function asiakastiedot() {    	//   Asiakastietojen paivitys muutosten jlkeen
eval('parent.window.ylaosa.document.kori.lisatiedot.value = parent.window.tuotteet.document.tilausrivit.MuutaTilattavaa.value')
eval('parent.window.ylaosa.document.kori.asi1.value = parent.window.tuotteet.document.tilausrivit.Ecom_ShipTo_Postal_Name_First.value')
eval('parent.window.ylaosa.document.kori.asi2.value = parent.window.tuotteet.document.tilausrivit.Ecom_ShipTo_Postal_Name_Last.value')
eval('parent.window.ylaosa.document.kori.asi3.value = parent.window.tuotteet.document.tilausrivit.Ecom_ShipTo_Postal_Street_Line1.value')
//eval('parent.window.ylaosa.document.kori.asi4.value = parent.window.tuotteet.document.tilausrivit.Ecom_ShipTo_Postal_Street_Line2.value')
eval('parent.window.ylaosa.document.kori.asi5.value = parent.window.tuotteet.document.tilausrivit.Ecom_ShipTo_Postal_PostalCode.value')
eval('parent.window.ylaosa.document.kori.asi6.value = parent.window.tuotteet.document.tilausrivit.Ecom_ShipTo_Postal_City.value')
eval('parent.window.ylaosa.document.kori.asi7.value = parent.window.tuotteet.document.tilausrivit.Ecom_ShipTo_Telecom_Phone_Number.value')
eval('parent.window.ylaosa.document.kori.asi8.value = parent.window.tuotteet.document.tilausrivit.Ecom_ShipTo_Online_Email.value')
if (parent.window.tuotteet.document.tilausrivit.toimitusehdot.checked){
parent.window.ylaosa.document.kori.toimitusehdot.value = 1
}else{
parent.window.ylaosa.document.kori.toimitusehdot.value = 0
}

}       

function maksutapam(nro) {    	//   Maksutavan paivitys muutosten jlkeen
	parent.window.ylaosa.document.kori.maksutapa.value = nro
	parent.window.ylaosa.paivitanayttouusi()
}       

function paivitamaara(rivi){			// Tuotteen tilauspaljouden muutos
	vikaa = false
	uusimaara = eval('parent.window.tuotteet.document.tilausrivit.rivi'+rivi+'.value')
	uusiluku = Math.round(uusimaara)
	if(uusiluku != uusimaara) {
		uusiluku = 0 ; vikaa = true
	}
	if(uusiluku < 1) { 
		uusiluku = 0 ; vikaa = true
	}
	if(vikaa) {
		alert('Tuotteiden paljoudet on annettava positiivisina kokonaislukuina.' + CRLF + 'Kirjoittamaasi muutosta ei hyvaksytty.' + CRLF + 'Jos haluat poistaa tuotteen ostoskorista, tee se oikean reunan "Poista"-painikkeella.') 
	} else {
		eval('parent.window.ylaosa.document.kori.maara'+rivi+'.value = uusiluku')
	}
	parent.window.ylaosa.paivitanayttouusi()
}


function poista(nro){
	tyhjaa=''
	eval ('parent.window.ylaosa.document.kori.kdi'+nro+'.value = tyhjaa')
	eval ('parent.window.ylaosa.document.kori.tuote'+nro+'.value = tyhjaa')
	eval ('parent.window.ylaosa.document.kori.erahinta'+nro+'.value = tyhjaa')
	eval ('parent.window.ylaosa.document.kori.era'+nro+'.value = tyhjaa')
	eval ('parent.window.ylaosa.document.kori.maara'+nro+'.value = tyhjaa')
	eval ('parent.window.ylaosa.document.kori.tk'+nro+'.value = tyhjaa')

	for (i = nro ; i <= maxriveja; i++) {
		j = i+1
		vaihda(i,j)
		if(eval('parent.window.ylaosa.document.kori.kdi'+i+'.value') == "") {
		korissa=i-1
		eval('parent.window.ylaosa.document.kori.korissa.value = korissa')
			i=maxriveja
		}
	}
parent.window.ylaosa.paivitanayttouusi()
}



function kori() {    //Korisivun muodostus

// annetaan alkuarvoja
ontavaraa = true
toimitustapa = parent.window.ylaosa.document.kori.toimitustapa.value
maksutapa = parent.window.ylaosa.document.kori.maksutapa.value
toimitusehdot = parent.window.ylaosa.document.kori.toimitusehdot.value

summa = 0
toimituskulut = 0
yhtsumma = 0
v = 1        //tuoterivin vri


//etsitaan ensimmainen tyhja rivi ja kallein rahti
tyhja = maxriveja+1
for (i = 1; i <= maxriveja; i++) {
		if(eval('parent.window.ylaosa.document.kori.kdi'+i+'.value') == "") {
			tyhja = i
			i = maxriveja + 1
		}
	if(eval('parent.window.ylaosa.document.kori.tk'+i+'.value') >= toimituskulut) {
		toimituskulut=eval('parent.window.ylaosa.document.kori.tk'+i+'.value')
	}
}
toimituskulut=kulut[toimituskulut]
korissa = tyhja-1
eval('parent.window.ylaosa.document.kori.korissa.value = korissa')

// Onko ostoskorissa tuotteita?
if (tyhja == 1) { 	// Ostoskorissa ei ole tuotteita
	ontavaraa = false
	html ='<B>Ostoskorissa ei ole tuotteita.</B><BR><BR>'
	html = html + '<a href=\"kayttoohjeet.shtml\">Kaupan ohjeet</a>'
}


if(ontavaraa == true) { //  Ostoskorissa on tuotteita

//jarjestetaan koodien mukaan aakkosjarjestykseen
for (i=1; i<=tyhja-1;i++) {
	koodit[i]=eval('parent.window.ylaosa.document.kori.kdi'+i+'.value')
}

koodit.sort()

for (i=0; i<=tyhja-2;i++) {
	for (j=1; j<=tyhja-1;j++) {
		if (koodit[i]==eval('parent.window.ylaosa.document.kori.kdi'+j+'.value')){
			vaihda(i+1,j)
		}
	}
}
// tuotteet koodijarjestyksessa


// Tulostetaan otsikkotiedot
html = '<FORM name=\"tilausrivit\">'
html = html + '<TABLE CLASS=\"koritaulukko\" align=\"center\">'
html = html + '<TR>'
html = html + '<TD colspan=\"7\" class=\"koriotsikkoKiso\">Ostoskorissa seuraavat tuotteet:<BR></TD>'
html = html + '</TR>'
html = html + '<TR>'
html = html + '<TD class=\"koriotsikkoV\"><B>Koodi</B></TD>'
html = html + '<TD class=\"koriotsikkoV\"><B>Tuote</B></TD>'
html = html + '<TD class=\"koriotsikkoV\"><B>Paljous</B></TD>'
html = html + '<TD class=\"koriotsikkoV\"><B>Yksikko</B></TD>'
html = html + '<TD class=\"koriotsikkoK\"><B>Hinta<BR>EUR</B></TD>'
html = html + '<TD class=\"koriotsikkoK\"><B>Rivi<BR>yht.</B></TD>'
html = html + '<TD class=\"koriotsikkoK\"><B>Poista<BR>rivi</B></TD>'
html = html + '</TR>'

// Tulostetaan rivitiedot
for (i = 1; i < tyhja; i++) {
v = 1 - v
kdi = eval ('parent.window.ylaosa.document.kori.kdi'+i+'.value')
tuote = eval ('parent.window.ylaosa.document.kori.tuote'+i+'.value')
erahinta = eval ('parent.window.ylaosa.document.kori.erahinta'+i+'.value')
era = eval ('parent.window.ylaosa.document.kori.era'+i+'.value')
maara = eval ('parent.window.ylaosa.document.kori.maara'+i+'.value')


rivisumma = rahasumma(erahinta * maara)
yhtsumma = yhtsumma + (erahinta * maara)


html = html + '<TR>' 
html = html + '<TD class=\"koririviV' + v + '\">' + kdi + '</TD>'
html = html + '<TD class=\"koririviV' + v + '\">' + tuote + '</TD>'
html = html + '<TD class=\"koririviV' + v + '\">' + '<INPUT type=\"text\" size=\"4\" name=\"rivi' + i +'\" title=\"Voit muuttaa tilauksesi kokoa suoraan lukua muuttamalla\" value=\"' + maara + '\" onChange=\"paivitamaara('+i+')\"></TD>'
html = html + '<TD class=\"koririviV' + v + '\">' + era + '</TD>'
html = html + '<TD class=\"koririviO' + v + '\">' + erahinta + '</TD>'
html = html + '<TD class=\"koririviO' + v + '\">' + rivisumma + '</TD>'
html = html + '<TD class=\"koririviK' + v + '\"><a href=\"javascript:poista(' + i +')\" title=\"Poista tuoterivi ostoskorista\"><img src=\"kuvat/poisto.gif\" width=\"16\" height=\"16\" border=\"0\"></TD>'
html = html + '</TR>'
}

// Tulostetaan tuotteiden yhteissumma
html = html + '<TR>'
html = html + '<TD colspan=\"5\" class=\"koriotsikkoV\">Tuotteiden yhteisarvo</TD>'
html = html + '<TD class=\"koriotsikkoO\">'+rahasumma(yhtsumma)+'</TD>'
html = html + '<TD class=\"koriotsikkoV\">&nbsp;</TD>'
html = html + '</TR>'
html = html + '<TR> <TD colspan=\"7\">&nbsp;</TD></TR>'


// Toimitustavan valinta
if(toimitustapa == 0){
	tota = '<INPUT TYPE=\"radio\" NAME=\"toimitustapa\" VALUE=\"Posti\" CHECKED onChange=\"toimitustapam(0)\" onClick=\"toimitustapam(0)\">Posti &nbsp<BR>'
	tota = tota + '<INPUT TYPE=\"radio\" NAME=\"toimitustapa\" VALUE=\"Matkahuolto\" onChange=\"toimitustapam(1)\" onClick=\"toimitustapam(1)\">Matkahuolto &nbsp<BR>'
	tota = tota + '<INPUT TYPE=\"radio\" NAME=\"toimitustapa\" VALUE=\"Muu\" onChange=\"toimitustapam(2)\" onClick=\"toimitustapam(2)\">Muu</td>'
}	
if(toimitustapa == 1){
	tota = '<INPUT TYPE=\"radio\" NAME=\"toimitustapa\" VALUE=\"Posti\" onChange=\"toimitustapam(0)\" onClick=\"toimitustapam(0)\">Posti &nbsp<BR>'
	tota = tota + '<INPUT TYPE=\"radio\" NAME=\"toimitustapa\" VALUE=\"Matkahuolto\" CHECKED onChange=\"toimitustapam(1)\" onClick=\"toimitustapam(1)\">Matkahuolto, kasittelykulut 2 EUR,<br> rahdin maksat erikseen vastaanotettaessa. <a href=javascript:tulostaToimituskulut2()>HUOM toimitusaika</a><BR>'
	tota = tota + '<INPUT TYPE=\"radio\" NAME=\"toimitustapa\" VALUE=\"Muu\" onChange=\"toimitustapam(2)\" onClick=\"toimitustapam(2)\">Muu</td>'
	toimituskulut = 2	
}	
if(toimitustapa == 2){
	tota = '<INPUT TYPE=\"radio\" NAME=\"toimitustapa\" VALUE=\"Posti\" onChange=\"toimitustapam(0)\" onClick=\"toimitustapam(0)\">Posti &nbsp<BR>'
	tota = tota + '<INPUT TYPE=\"radio\" NAME=\"toimitustapa\" VALUE=\"Matkahuolto\" onChange=\"toimitustapam(1)\" onClick=\"toimitustapam(1)\">Matkahuolto &nbsp<BR>'
	tota = tota + '<INPUT TYPE=\"radio\" NAME=\"toimitustapa\" VALUE=\"Muu\" CHECKED onChange=\"toimitustapam(2)\" onClick=\"toimitustapam(2)\">Muu &nbsp (kirjoita ohjeet lisatietoihin)</td>'
	toimituskulut = 0
}	
	
// Tulostetaan toimitustapa
toku = rahasumma(toimituskulut)
if(toku==""){toku="&nbsp;"}
html = html + '<TR>'
html = html + '<TD colspan=\"5\"><DIV class=\"koriotsikkoV\"><B>Toimitustapa ja <a href=javascript:tulostaToimituskulut()>toimituskulut</a> </B><BR></DIV>'
html = html + tota
html = html + '<TD class=\"koriotsikkoO\">'+toku+'</TD>'
html = html + '<TD class=\"koriotsikkoV\">&nbsp;</TD>'
html = html + '</TR>'
		
// Tulostetaan kokonaissumma
yhteensakaikki = yhtsumma + toimituskulut
parent.window.ylaosa.document.kori.korttisumma.value = rahasumma(yhteensakaikki)
parent.window.ylaosa.document.kori.korttisummasentteina.value = parseInt(100*yhteensakaikki+0.0001)
koksu = "(veroton " + vasentaytto(rahasumma((yhteensakaikki/(100+alv)*100)),10)+") (alv " + alv +"%" + vasentaytto(rahasumma(yhteensakaikki-(yhteensakaikki/(100+alv)*100)),10) + ")" 


html = html + '<TR>'
html = html + '<TD colspan=\"5\"><B>Kokonaissumma </B>' + koksu + '</TD>'
html = html + '<TD class=\"koriotsikkoO\"><B>'+rahasumma(yhteensakaikki)+'</B></TD>'
html = html + '<TD class=\"koriotsikkoV\"><B>EUR</B></TD>'
html = html + '</TR>'
html = html + '<TR> <TD colspan=\"7\">&nbsp;</TD></TR>'

// Maksutavan valinta
	
if(maksutapa == 0){
	mata = '<INPUT TYPE=\"radio\" NAME=\"maksutapa\" VALUE=\"Lasku/postiennakko/jalkivaatimus\" CHECKED onChange=\"maksutapam(0)\" onClick=\"maksutapam(0)\">Lasku tavaran mukana tai postiennakko/jalkivaatimus<BR>'
	mata = mata + '<INPUT TYPE=\"radio\" NAME=\"maksutapa\" VALUE=\"Luotto-/maksukortti\" onChange=\"maksutapam(1)\" onClick=\"maksutapam(1)\">Visa, Visa Electron tai Eurocard/Mastercard</td>' 
}	
if(maksutapa == 1){
	mata = '<INPUT TYPE=\"radio\" NAME=\"maksutapa\" VALUE=\"Lasku/postiennakko/jalkivaatimus\" onChange=\"maksutapam(0)\" onClick=\"maksutapam(0)\">Lasku tavaran mukana tai postiennakko/jalkivaatimus<BR>'
	mata = mata + '<INPUT TYPE=\"radio\" NAME=\"maksutapa\" VALUE=\"Luotto-/maksukortti\"  CHECKED onChange=\"maksutapam(1)\" onClick=\"maksutapam(1)\">Visa, Visa Electron tai Eurocard/Mastercard</td>' 
}	

// Tulostetaan maksutapa
html = html + '<TR>'
html = html + '<TD colspan=\"7\"class=\"koriotsikkoV\"><B>Maksutapa</B><br>'
html = html + mata
html = html + '</TR>'


// Tulostetaan lisatietokentta
html = html + '<TR>'
html = html + '<TD colspan=\"7\" class=\"koriotsikkoK\"><B><BR>Lisatietoja tuotteista, erityisohjeita, palautetta, tms:<BR>Yritykset: Eri laskutus- kuin toimitusosoite, tilausnro, merkki,<br> Finvoice-tunnukset tms:<br></B>'
html = html + '<TEXTAREA name=\"MuutaTilattavaa\" onChange=\"asiakastiedot()\" rows=5 wrap=physical cols=60></TEXTAREA></TD>'
html = html + '</TR>'

// Tulostetaan ostajatiedot

html = html + '<TR>'
html = html + '<TD colspan=\"7\" class=\"koriotsikkoK\"><BR><B>Toimitusosoite:</B><BR></TD>'
html = html + '</TR>'
html = html + '<TR>'
html = html + '<TD colspan=\"6\" class=\"koriotsikkoO\">Nimi: <font color=\"#FF0000\">*</font>&nbsp;<input name=\"Ecom_ShipTo_Postal_Name_First\" onChange=\"asiakastiedot()\" size=\"50\"><br>'
html = html + '<input name=\"Ecom_ShipTo_Postal_Name_Last\" onChange=\"asiakastiedot()\" size=\"50\"><br>'
html = html + 'Katuosoite/PL:  <font color=\"#FF0000\">*</font>&nbsp;<input name=\"Ecom_ShipTo_Postal_Street_Line1\" onChange=\"asiakastiedot()\" size=\"50\"><br>'
//html = html + '<input name=\"Ecom_ShipTo_Postal_Street_Line2\" onChange=\"asiakastiedot()\" size=\"50\"><br>'
html = html + 'Postinumero:  <font color=\"#FF0000\">*</font>&nbsp;<input name=\"Ecom_ShipTo_Postal_PostalCode\" onChange=\"asiakastiedot()\" size=\"50\"><br>'
html = html + 'Postitoimipaikka:  <font color=\"#FF0000\">*</font>&nbsp;<input name=\"Ecom_ShipTo_Postal_City\" onChange=\"asiakastiedot()\" size=\"50\"><br>'
html = html + 'Puhelin:  <font color=\"#FF0000\">*</font>&nbsp;<input name=\"Ecom_ShipTo_Telecom_Phone_Number\" onChange=\"asiakastiedot()\" size=\"50\"><br>'
html = html + 'Email:  <font color=\"#FF0000\">*</font>&nbsp;<input name=\"Ecom_ShipTo_Online_Email\" onChange=\"asiakastiedot()\" size=\"50\"><br>'
html = html + '<font color=\"#FF0000\">*</font>-merkityt tiedot ovat pakollisia. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><br></td>'
html = html + '<TD colspan=\"1\"class=\"koriotsikkoV\">&nbsp;</TD>'
html = html + '</TR>'

// Tulostetaan ehtojen hyvaksyminen
if (toimitusehdot == 0){
html = html + '<TR>'
html = html + '<TD colspan=\"7\" class=\"koriotsikkoK\"><BR><B>Olen tutustunut Paratronic Oy:n <a href=javascript:tulostaToimitusehdot()>toimitusehtoihin</a>, ja hyvaksyn ne </B>'
html = html + '<input type=\"checkbox\" name=\"toimitusehdot\"  VALUE=\"Toimitusehdot: Hyvaksytty\" onChange=\"asiakastiedot()\"></TD>'
html = html + '</TR>'
} else {
html = html + '<TR>'
html = html + '<TD colspan=\"7\" class=\"koriotsikkoK\"><BR><B>Olen tutustunut Paratronic Oy:n <a href=javascript:tulostaToimitusehdot()>toimitusehtoihin</a>, ja hyvaksyn ne </B>'
html = html + '<input type=\"checkbox\" checked name=\"toimitusehdot\"  VALUE=\"Toimitusehdot: Hyvaksytty\" onChange=\"asiakastiedot()\"></TD>'
html = html + '</TR>'
}


if(maksutapa == 0){
	html = html + '<TR>'
	html = html + '<TD colspan=\"7\" class=\"koriotsikkoK\"><BR>Jos haluat tulostaa tilauksen itsellesi, tee se ennen tilaamista.<BR> &quot;Tulostettava versio&quot;-painike avaa uuden ikkunan,<BR> jossa tilauksen kaikki tiedot tulostimelle sopivammassa muodossa. <BR> '
	html = html + '<INPUT VALUE=\"Tulostettava versio\" TYPE=\"button\" onClick=\"tulosta()\"><br><br><br>'

	html = html + 'Toimita tilaus Paratronic Oy:lle painamalla &quot;Tilaa tuotteet&quot; painiketta yhden kerran.<BR>Saat palautteen tilauksen onnistumisesta hetken kuluttua selaimessasi.<BR>'
	html = html + '<INPUT TYPE=\"button\"  NAME=\"lahetysnappula\" VALUE=\"Tilaa tuotteet\" onClick=\"lahetaTilaus()\"><BR><BR><TD>'
	html = html + '</TR>'
}

if(maksutapa == 1){
	html = html + '<TR>'
	html = html + '<TD colspan=\"7\" class=\"koriotsikkoK\"><BR>Jos haluat tulostaa tilauksen itsellesi, <BR>tee se ennen kuin siirryt korttitietojen antamiseen.<BR> &quot;Tulostettava versio&quot;-painike avaa uuden ikkunan,<BR> jossa tilauksen kaikki tiedot tulostimelle sopivammassa muodossa. <BR> '
	html = html + '<INPUT VALUE=\"Tulostettava versio\" TYPE=\"button\" onClick=\"tulosta()\"><br><br><br>'

	html = html + 'Siirry luotto-/maksukorttitietojesi antamiseen painamalla &quot;Korttitiedot&quot; painiketta, <BR>jolloin siirryt suojattuun yhteyteen Luottokunnan palvelimelle.<BR>Siirtymisvaiheessa saatat selaimesi asetuksista riippuen saada varoitussanoman.<BR>'
	html = html + '<INPUT TYPE=\"button\"  NAME=\"lahetysnappula\" VALUE=\"Korttitiedot \" onClick=\"lahetaTilausLuottokunta()\"><BR><BR><TD>'
	html = html + '</TR>'
}

html = html + '</TABLE><P>'




html = html + '</FORM><P>'
}   //                                               KAMAA KORISSA

parent.window.tuotteet.document.write(html)

if(tyhja > 1) { 
eval('parent.window.tuotteet.document.tilausrivit.MuutaTilattavaa.value = parent.window.ylaosa.document.kori.lisatiedot.value')
eval('parent.window.tuotteet.document.tilausrivit.Ecom_ShipTo_Postal_Name_First.value = parent.window.ylaosa.document.kori.asi1.value')
eval('parent.window.tuotteet.document.tilausrivit.Ecom_ShipTo_Postal_Name_Last.value = parent.window.ylaosa.document.kori.asi2.value')
eval('parent.window.tuotteet.document.tilausrivit.Ecom_ShipTo_Postal_Street_Line1.value = parent.window.ylaosa.document.kori.asi3.value')
//eval('parent.window.tuotteet.document.tilausrivit.Ecom_ShipTo_Postal_Street_Line2.value = parent.window.ylaosa.document.kori.asi4.value')
eval('parent.window.tuotteet.document.tilausrivit.Ecom_ShipTo_Postal_PostalCode.value = parent.window.ylaosa.document.kori.asi5.value')
eval('parent.window.tuotteet.document.tilausrivit.Ecom_ShipTo_Postal_City.value = parent.window.ylaosa.document.kori.asi6.value')
eval('parent.window.tuotteet.document.tilausrivit.Ecom_ShipTo_Telecom_Phone_Number.value = parent.window.ylaosa.document.kori.asi7.value')
eval('parent.window.tuotteet.document.tilausrivit.Ecom_ShipTo_Online_Email.value = parent.window.ylaosa.document.kori.asi8.value')
}
}


function tulostaToimitusehdot(){
	new_window = open("toimitusehdot.shtml","uusiIkkuna","resizable=yes,scrollbars=yes,width=800,height=480,left=10,top=10");
	new_window.window.focus()
}


function tulostaToimituskulut(){
	new_window = open("tk.shtml","uusiIkkuna","resizable=yes,scrollbars=yes,width=800,height=480,left=10,top=10");
	new_window.window.focus()
}

function tulostaToimituskulut2(){
	new_window = open("tk.shtml#mh","uusiIkkuna","resizable=yes,scrollbars=yes,width=800,height=480,left=10,top=10");
	new_window.window.focus()
}

// Tulosta tilauksen tiedot
function tulosta(){
	if(OnkoTiedotOk() == false){return false}
	html=Muodostadn()
	new_window = open("","uusiIkkuna","location=yes,resizable=yes,scrollbars=yes,width=850,height=480,left=10,top=10");
	new_window.document.open();
	new_window.document.write('<INPUT TYPE="button" VALUE="Tulosta" onclick="window.print()"> <INPUT TYPE="button" VALUE="Sulje" onclick="window.close()">');
	new_window.document.write('<html><title>Tilauksen tiedot</title>');
	new_window.document.write('<body bgcolor=\"#FFFFFF\" >');
	new_window.document.write('<pre>');
	new_window.document.write(html);
	new_window.document.write('</pre>');
	new_window.document.write('<BR></body></html>');
	new_window.document.close(); 
	new_window.window.focus()


}

function OnkoTiedotOk(){
	if (tekstia(parent.window.ylaosa.document.kori.asi1.value)
		&& tekstia(parent.window.ylaosa.document.kori.asi3.value)
		&& tekstia(parent.window.ylaosa.document.kori.asi5.value)
		&& tekstia(parent.window.ylaosa.document.kori.asi6.value)
		&& tekstia(parent.window.ylaosa.document.kori.asi7.value)
		&& tekstia(parent.window.ylaosa.document.kori.asi8.value)){
		} else {
			alert("Kaikki * merkityt yhteystiedot on annettava !!!")
    		return false
	}	

	if (parent.window.tuotteet.document.tilausrivit.toimitusehdot.checked){
		} else {
			alert("Et ole hyvaksynyt toimitusehtoja!")
    		return false
	}
}

function MuodostaLKform(){
lkform = '<form name=\"luottokunta\" method=\"post\" action=\"https:\/\/dmp2.luottokunta.fi/dmp/html_payments?order=' + LKtilausnumero() + '&summa=' + parent.window.ylaosa.document.kori.korttisummasentteina.value + '&email=' + parent.window.ylaosa.document.kori.asi8.value + '\">'
lkform = lkform + CRLF + '<INPUT TYPE=\"hidden\" NAME=\"Merchant_Number\" value=\"8637035\">'
lkform = lkform + CRLF + '<INPUT TYPE=\"hidden\" NAME=\"Card_Details_Transmit\" value=\"0\">'
lkform = lkform + CRLF + '<INPUT TYPE=\"hidden\" NAME=\"Device_Category\" value=\"1\">' 
lkform = lkform + CRLF + '<INPUT TYPE=\"hidden\" NAME=\"Order_ID\" value=\"' + document.luottokunta.Order_ID.value + '\">'
lkform = lkform + CRLF + '<INPUT TYPE=\"hidden\" NAME=\"Amount\" value=\"' + document.luottokunta.Amount.value + '\">'
lkform = lkform + CRLF + '<INPUT TYPE=\"hidden\" NAME=\"Currency_Code\" value=\"978\">'
lkform = lkform + CRLF + '<INPUT TYPE=\"hidden\" NAME=\"Order_Description\" value=\"' + document.luottokunta.Order_Description.value +'\">'
lkform = lkform + CRLF + '<INPUT TYPE=\"hidden\" NAME=\"Success_Url\" value=\"http:\/\/www.paratronic.fi/tilauslomake_lk_kiitos.php?order=' + LKtilausnumero() + '&summa=' + parent.window.ylaosa.document.kori.korttisummasentteina.value + '&email=' + parent.window.ylaosa.document.kori.asi8.value + '\">'
lkform = lkform + CRLF + '<INPUT TYPE=\"hidden\" NAME=\"Failure_Url\" value=\"http:\/\/www.paratronic.fi/tilauslomake_lk_ei_ok.php?order=' + LKtilausnumero() + '&summa=' + parent.window.ylaosa.document.kori.korttisummasentteina.value + '&email=' + parent.window.ylaosa.document.kori.asi8.value + '\">'
lkform = lkform + CRLF + '<INPUT TYPE=\"hidden\" NAME=\"Cancel_Url\" value=\"http:\/\/www.paratronic.fi/tilauslomake_lk_peruttu.php?order=' + LKtilausnumero() + '&summa=' + parent.window.ylaosa.document.kori.korttisummasentteina.value + '&email=' + parent.window.ylaosa.document.kori.asi8.value + '\">'
//lkform = lkform + CRLF + '<INPUT TYPE=\"hidden\" NAME=\"Cancel_Url\" value=\"http:\/\/www.paratronic.fi/tilauslomake_lk_kiitos.php?order=' + LKtilausnumero() + '&summa=' + parent.window.ylaosa.document.kori.korttisummasentteina.value + '&email=' + parent.window.ylaosa.document.kori.asi8.value + '\">'
lkform = lkform + CRLF + '<INPUT TYPE=\"hidden\" NAME=\"Transaction_Type\" value=\"0\">'

lkform = lkform + CRLF + '<INPUT VALUE=\"Jatka\" TYPE=\"button\" onclick=\"submit()\">'

lkform = lkform + CRLF + '</form>'
//alert(lkform)

return lkform
}

function Muodostadn(){
toimitustapa = parent.window.ylaosa.document.kori.toimitustapa.value
maksutapa = parent.window.ylaosa.document.kori.maksutapa.value
dn = myyja
dn = dn + "Ostaja:" + CRLF
dn = dn + parent.window.ylaosa.document.kori.asi1.value + CRLF
dn = dn + parent.window.ylaosa.document.kori.asi2.value + CRLF
dn = dn + parent.window.ylaosa.document.kori.asi3.value + CRLF
//dn = dn + siisti(parent.window.ylaosa.document.kori.asi4.value)
dn = dn + parent.window.ylaosa.document.kori.asi5.value + "  "
dn = dn + parent.window.ylaosa.document.kori.asi6.value + CRLF + CRLF
dn = dn + parent.window.ylaosa.document.kori.asi7.value +"  "
dn = dn + parent.window.ylaosa.document.kori.asi8.value + CRLF + CRLF
dn = dn + "Koodi              Paljous Yksikko        A-Hinta      Yht.EUR" + CRLF
dn = dn + "Tuote" + CRLF + CRLF


for (i = 1; i <= maxriveja; i++) {
		if(eval('parent.window.ylaosa.document.kori.kdi'+i+'.value') == "") {
			i = maxriveja + 1
		} else {
			dn = dn + oikeataytto(eval('parent.window.ylaosa.document.kori.kdi'+i+'.value'), 20)
			dn = dn + vasentaytto(eval('parent.window.ylaosa.document.kori.maara'+i+'.value'), 6)+" "
			dn = dn + oikeataytto(eval('parent.window.ylaosa.document.kori.era'+i+'.value'), 10)
			dn = dn + vasentaytto(eval('parent.window.ylaosa.document.kori.erahinta'+i+'.value'), 12) 
			dn = dn + vasentaytto(rahasumma(eval('parent.window.ylaosa.document.kori.erahinta'+i+'.value') * eval('parent.window.ylaosa.document.kori.maara'+i+'.value')), 13) + CRLF
			dn = dn + eval('parent.window.ylaosa.document.kori.tuote'+i+'.value')+ CRLF

		}
	}
dn = dn + vasentaytto("--------------", 62) + CRLF
dn = dn + oikeataytto("Tuotteiden yhteisarvo", 50) + vasentaytto(rahasumma(yhtsumma),12)+ CRLF
dn = dn + oikeataytto("Kulut", 50) + vasentaytto(rahasumma(toimituskulut),12)+ CRLF
dn = dn + "Kokonaissumma (veroton " + vasentaytto(rahasumma((yhteensakaikki/(100+alv)*100)),10)+")(alv" + alv +"%" + vasentaytto(rahasumma(yhteensakaikki-(yhteensakaikki/(100+alv)*100)),10) +")" + vasentaytto(rahasumma(yhteensakaikki),10) +  CRLF + CRLF
dn = dn + oikeataytto("Toimitustapa:", 15) + parent.window.tuotteet.document.tilausrivit.toimitustapa[toimitustapa].value + CRLF 
dn = dn + oikeataytto("Maksutapa:", 15) + parent.window.tuotteet.document.tilausrivit.maksutapa[maksutapa].value + CRLF 
dn = dn + parent.window.tuotteet.document.tilausrivit.toimitusehdot.value + CRLF 
dn = dn + "Muita tuotteita, erityisohjeita, palautetta:" + CRLF + parent.window.ylaosa.document.kori.lisatiedot.value + CRLF

//alert(dn)
return dn
}

function siisti(teksti){
	teksti=teksti
	if (teksti.length>0) {teksti=teksti + CRLF}
	else {teksti=""}
	return teksti
} 

//-- Muokkaa tekstin width-pituiseksi tayttaen oikealle valilyonteja
function oikeataytto(anytext,width) {
   retval=anytext
   while (retval.length<width){retval=retval+" "}
   return retval
}

//-- Muokkaa tekstin width-pituiseksi tayttaen vasemmalle valilyonteja
function vasentaytto(anytext,width) {
   retval=anytext
   while (retval.length<width){retval=" "+retval}
   return retval
}

function lahetaTilaus(){
	if(OnkoTiedotOk() == false){return false}
	document.tilaus.email.value = parent.window.ylaosa.document.kori.asi8.value
	document.tilaus.Order_Description.value = Muodostadn()
	if(eval('parent.window.ylaosa.document.kori.toimitustapa.value') == 0){
		   	document.tilaus.subject.value = LskTilausnumero1()
			}
	    else {
		   	document.tilaus.subject.value = LskTilausnumero2()
	} 
	document.tilaus.submit()
}

function lahetaTilausLuottokunta(){
if(OnkoTiedotOk() == false){return false}
document.luottokunta.Order_Description.value = Muodostadn()
document.luottokunta.Order_ID.value = LKtilausnumero()
document.luottokunta.Amount.value = parent.window.ylaosa.document.kori.korttisummasentteina.value
document.luottokunta.Success_Url.value = document.luottokunta.Success_Url.value + LKtilausnumero() + "&summa=" + parent.window.ylaosa.document.kori.korttisummasentteina.value 
document.luottokunta.Failure_Url.value = document.luottokunta.Failure_Url.value + LKtilausnumero() + "&summa=" + parent.window.ylaosa.document.kori.korttisummasentteina.value 
document.luottokunta.Cancel_Url.value = document.luottokunta.Cancel_Url.value + LKtilausnumero() + "&summa=" + parent.window.ylaosa.document.kori.korttisummasentteina.value 

	html=MuodostaLKform()
	new_window = open("","LkIkkuna","location=yes,resizable=yes,toolbar=yes,scrollbars=yes,width=1000,height=800,left=1,top=1");
	new_window.document.open();
	new_window.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">');
	new_window.document.write(CRLF);
	new_window.document.write('<html>'); 
	new_window.document.write(CRLF);
	new_window.document.write('<head>');
	new_window.document.write(CRLF);
	new_window.document.write('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />');
	new_window.document.write(CRLF);	
	new_window.document.write('<title>Paratronic Oy, luottokorttimaksu</title>');
	new_window.document.write(CRLF);
	new_window.document.write('</head>');
	new_window.document.write(CRLF);
	new_window.document.write('<body>');
	new_window.document.write('<body onLoad="document.luottokunta.submit()">');
	new_window.document.write(CRLF);
	new_window.document.write('<BR>Siirryt automaattisesti korttitietolomakkeelle. <BR>Jos siirtyminen ei kuitenkaan tapahdu automaattisesti, paina allaolevaa "Jatka"-painiketta. <BR>');
	new_window.document.write(CRLF);
	new_window.document.write(html);
	new_window.document.write(CRLF);
	new_window.document.write('<BR></body></html>');
	new_window.document.close(); 
	new_window.window.focus() 


}

//alert(document.luottokunta.Order_Number.value) 
//alert(document.luottokunta.Order_Description.value)
//alert(document.luottokunta.Success_Url.value)

function tekstia(text){
	text=text
	if (text.length == 0){return false}
	return true
}

function kori2(nappi) { 

alert('kori2')

}




