
function changepostage(){

var state1 = document.Orderform.Stateclient.value;

var street1 = document.Orderform.Streetclient.value;

var city1 = document.Orderform.Cityclient.value;

var email1 = document.Orderform.Emailclient.value;

var tel = document.Orderform.Phone.value;

var name = document.Orderform.Nameclient.value;

var postcode1 = document.Orderform.Pcode.value;

var country1 = document.Orderform.Countryclient.value;

var shippingaddress1 = document.Orderform.shippingaddress.value;

var shippingcity1 = document.Orderform.shippingcity.value;

var shippingpostcode1 = document.Orderform.shippingpostcode.value;

var shippingstate1 = document.Orderform.shippingstate.value;

var shippingcountry1 = document.Orderform.shippingcountry.value;

var dvd = document.Orderform.DVD.value;

var currency2 = document.Orderform.currency1.value;

var stenonum = document.Orderform.Stenoqty.value;

var modenum = document.Orderform.Modeqty.value;

var classicnum = document.Orderform.Classicqty.value;

var premiernum = document.Orderform.Premierqty.value;

var foundout = document.Orderform.found.value;


var dvdprice

var dvdnum

var desc

var pinId

var char1

var char2

var char3

var char4

var indexau

var indexother

var handling

var postage

var totalweight

var currency

var cartId2


// _____________________DETERMINING WEIGHTS FOR EACH ITEM_______________________

var dvdgrams=150;
var pingrams=60;

pinnum=(+stenonum)+(+modenum)+(+classicnum)+(+premiernum);

dvdweight=(+dvd)*dvdgrams;

pinweight=(+pinnum)*pingrams;

// _____________________DETERMINING PRICE FOR EACH ITEM_______________________

var dvdau=74.95;
var stenoau=21.95;
var modeau=31.95;

var dvdus=74.95;
var stenous=19.95;
var modeus=29.95;

var dvdeu=43.95;
var stenoeu=12.95;
var modeeu=19.95;

// _____________________DETERMINING HANDLING FEES FOR EACH ITEM_______________________

var handlingau=4.50;
var handlingaupin=3;
var handlingeu=3;
var handlingus=5;

// _____________________AUSTRALIA POST PRICING_______________________

// first amounts are for one DVD only - itemised by Austraila Post as Large Letters
// you can change the actual Australia Post figures to suit rounding amounts

var postagetoau = new Array("1.65", "3.65","5.40","11.55","14.05");

var postagetous = new Array("6.15","9.05","14.85","20.65","26.45","32.25","38.05","43.85","49.65");

var postagetorest = new Array("6.15","10.70","18.15","25.60","33.05","40.50","47.95","55.40","62.85");

var postagetonz = new Array("6.15","6.85","10.45","14.05","17.65","21.25","24.85","28.45","32.05");

var postagetoasia = new Array("4.20","7.95","12.65","17.35","22.05","26.75","31.45","36.15","40.85");


if (country1==""){

country1="6AU";

}


// _____________________DETERMINE PRODUCT TOTALS DEPENDING ON CURRENCY_______________________


switch (currency2){

case "USD" : currency=1;
		dvdprice=dvdus*dvd;
		stenoprice=stenous*stenonum;
		modeprice=modeus*modenum;
		classicprice=modeus*classicnum;
		premierprice=modeus*premiernum;
		handling=handlingus;
		break;

case "EUR" : currency=0.7;
		dvdprice=dvdeu*dvd;
		stenoprice=stenoeu*stenonum;
		modeprice=modeeu*modenum;
		classicprice=modeeu*classicnum;
		premierprice=modeeu*premiernum;
		handling=handlingeu;
		break;
		
default : currency=1;
		dvdprice=dvdau*dvd;
		stenoprice=stenoau*stenonum;
		modeprice=modeau*modenum;
		classicprice=modeau*classicnum;
		premierprice=modeau*premiernum;
		handling=handlingau;
		break;

}


if (pinnum==0){
pinprice=0;
}


if (dvd=="0"){
dvdprice=0;
}

pintotal = (stenoprice+modeprice+classicprice+premierprice);
totalproduct = (dvdprice+pintotal);


// _____________________DETERMINE POSTAGE_______________________


totalweight = (dvdweight+pinweight);


if (totalweight<2010){

	indexau=4;
	indexother=8;
}


if (totalweight<1760){

	indexau=4;
	indexother=7;
}

if (totalweight<1510){

	indexau=4;
	indexother=6;
}

if (totalweight<1260){

	indexau=4;
	indexother=5;
}

if (totalweight<760){

	indexau=4;
	indexother=3;
}

if (totalweight<510){

	indexau=2;
	indexother=2;
}

if (totalweight<255){

	indexau=1;
	indexother=1;
}


if (totalweight==150 || totalweight==60){

	indexau=0;
	indexother=0;
}


switch(country1.charAt(0)){
	
	case "6":
		postage=parseFloat(postagetoau[indexau])*currency;
		break;
	case "5":
		postage=parseFloat(postagetorest[indexother])*currency;
		break;
	case "4":
		postage=parseFloat(postagetous[indexother])*currency;
		break;
	case "3":
		postage=parseFloat(postagetoasia[indexother])*currency;
		break;
	case "2":
		postage=parseFloat(postagetonz[indexother])*currency;
		break;
}	


totalshipprice = (postage+handling);

totalprice = (totalshipprice+totalproduct);


// _____________________ROUNDING AMOUNTS____________________________


num=dvdprice

num = num.toString().replace(/\$|\,/g,'');

if(isNaN(num))

num = "0";

sign = (num == (num = Math.abs(num)));

num = Math.floor(num*100+0.50000000001);

cents = num%100;

num = Math.floor(num/100).toString();

if(cents<10)

cents = "0" + cents;

for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)

num = num.substring(0,num.length-(4*i+3))+','+

num.substring(num.length-(4*i+3));

dvdprice=(((sign)?'':'-') + num + '.' + cents);

if (dvdprice<100)

dvdprice=(((sign)?'':'-') + " " + num + '.' + cents);



num=pintotal

num = num.toString().replace(/\$|\,/g,'');

if(isNaN(num))

num = "0";

sign = (num == (num = Math.abs(num)));

num = Math.floor(num*100+0.50000000001);

cents = num%100;

num = Math.floor(num/100).toString();

if(cents<10)

cents = "0" + cents;

for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)

num = num.substring(0,num.length-(4*i+3))+','+

num.substring(num.length-(4*i+3));

pintotal=(((sign)?'':'-') + num + '.' + cents);

if (pintotal<100)

pintotal=(((sign)?'':'-') + " " + num + '.' + cents);



num=totalproduct

num = num.toString().replace(/\$|\,/g,'');

if(isNaN(num))

num = "0";

sign = (num == (num = Math.abs(num)));

num = Math.floor(num*100+0.50000000001);

cents = num%100;

num = Math.floor(num/100).toString();

if(cents<10)

cents = "0" + cents;

for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)

num = num.substring(0,num.length-(4*i+3))+','+

num.substring(num.length-(4*i+3));

totalproduct=(((sign)?'':'-') + num + '.' + cents);

if (totalproduct<100)

totalproduct=(((sign)?'':'-') + " " + num + '.' + cents);


num=totalshipprice

num = num.toString().replace(/\$|\,/g,'');

if(isNaN(num))

num = "0";

sign = (num == (num = Math.abs(num)));

num = Math.floor(num*100+0.50000000001);

cents = num%100;

num = Math.floor(num/100).toString();

if(cents<10)

cents = "0" + cents;

for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)

num = num.substring(0,num.length-(4*i+3))+','+

num.substring(num.length-(4*i+3));

totalshipprice=(((sign)?'':'-') + " " + num + '.' + cents);

if (totalshipprice<10)

totalshipprice=(((sign)?'':'-') + "  " + num + '.' + cents);



num=totalprice

num = num.toString().replace(/\$|\,/g,'');

if(isNaN(num))

num = "0";

sign = (num == (num = Math.abs(num)));

num = Math.floor(num*100+0.50000000001);

cents = num%100;

num = Math.floor(num/100).toString();

if(cents<10)

cents = "0" + cents;

for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)

num = num.substring(0,num.length-(4*i+3))+','+

num.substring(num.length-(4*i+3));

totalprice=(((sign)?'':'-') + num + '.' + cents);

if (totalprice<100)

totalprice=(((sign)?'':'-') + "  " + num + '.' + cents);



num=stenoprice

num = num.toString().replace(/\$|\,/g,'');

if(isNaN(num))

num = "0";

sign = (num == (num = Math.abs(num)));

num = Math.floor(num*100+0.50000000001);

cents = num%100;

num = Math.floor(num/100).toString();

if(cents<10)

cents = "0" + cents;

for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)

num = num.substring(0,num.length-(4*i+3))+','+

num.substring(num.length-(4*i+3));

stenoprice=(((sign)?'':'-') + num + '.' + cents);

if (stenoprice<100)

stenoprice=(((sign)?'':'-') + "  " + num + '.' + cents);



num=modeprice

num = num.toString().replace(/\$|\,/g,'');

if(isNaN(num))

num = "0";

sign = (num == (num = Math.abs(num)));

num = Math.floor(num*100+0.50000000001);

cents = num%100;

num = Math.floor(num/100).toString();

if(cents<10)

cents = "0" + cents;

for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)

num = num.substring(0,num.length-(4*i+3))+','+

num.substring(num.length-(4*i+3));

modeprice=(((sign)?'':'-') + num + '.' + cents);

if (modeprice<100)

modeprice=(((sign)?'':'-') + "  " + num + '.' + cents);



num=classicprice

num = num.toString().replace(/\$|\,/g,'');

if(isNaN(num))

num = "0";

sign = (num == (num = Math.abs(num)));

num = Math.floor(num*100+0.50000000001);

cents = num%100;

num = Math.floor(num/100).toString();

if(cents<10)

cents = "0" + cents;

for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)

num = num.substring(0,num.length-(4*i+3))+','+

num.substring(num.length-(4*i+3));

classicprice=(((sign)?'':'-') + num + '.' + cents);

if (classicprice<100)

classicprice=(((sign)?'':'-') + "  " + num + '.' + cents);



num=premierprice

num = num.toString().replace(/\$|\,/g,'');

if(isNaN(num))

num = "0";

sign = (num == (num = Math.abs(num)));

num = Math.floor(num*100+0.50000000001);

cents = num%100;

num = Math.floor(num/100).toString();

if(cents<10)

cents = "0" + cents;

for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)

num = num.substring(0,num.length-(4*i+3))+','+

num.substring(num.length-(4*i+3));

premierprice=(((sign)?'':'-') + num + '.' + cents);

if (premierprice<100)

premierprice=(((sign)?'':'-') + "  " + num + '.' + cents);


// _____________________CLEAR FIELDS WHEN NO PRICE IS MADE______________________



if (dvdprice==0.00){

dvdprice="";

}


if (pintotal==0.00){

pintotal="";

}

if (modeprice==0){

modeprice="";

}


if (stenoprice==0){

stenoprice="";

}

if (classicprice==0){

classicprice="";

}


if (premierprice==0){

premierprice="";

}

if (totalproduct==0){

totalproduct="";

totalshipprice="";

total="";

totalprice="";
}


// _____________________DESC FOR PAYMENT RESPONSE________________________________

char1="";
char2="";
char3="";
char4="";



if (stenonum>0){

char1=stenonum+"s";

}


if (modenum>0){

char2=modenum+"m";

}


if (classicnum>0){

char3=classicnum+"c";

}


if (premiernum>0){

char4=premiernum+"p";

}


pinId= char1 + char2 + char3 + char4;


if (pinnum>0 && (+dvd)<1){

desc="pinholes";

cartId2="-" + pinId;

}



if ((+dvd)>0 && pinnum<1){

desc="eyerobics dvd";

cartId2="d";

}



if ((+dvd)>0 && pinnum>0){

desc="eyerobics dvd + pinholes";

cartId2="d" + pinId;

}



// _____________________RETURN VALUES TO FORM__________________________________


ret="&#10";


countrychar12=country1.charAt(1)+country1.charAt(2);

addressfull=street1+ret+city1+ret+state1;


document.Orderform.address.value=addressfull;

document.Orderform.name.value=name;

document.Orderform.email.value=email1;

document.Orderform.postcode.value=postcode1;

document.Orderform.tel.value=tel;

document.Orderform.M_shippingaddress.value=shippingaddress1;

document.Orderform.M_shippingcity.value=shippingcity1;

document.Orderform.M_shippingpostcode.value=shippingpostcode1;

document.Orderform.M_shippingstate.value=shippingstate1;

document.Orderform.M_shippingcountry.value=shippingcountry1;

document.Orderform.desc.value=desc;

document.Orderform.dvdprice.value=dvdprice;

document.Orderform.subtotal.value=totalproduct;

document.Orderform.shipping.value=totalshipprice;

document.Orderform.currency3.value=currency2;

document.Orderform.currency.value=currency2;

document.Orderform.amount1.value=totalprice;

document.Orderform.amount.value=totalprice;

document.Orderform.country.value=countrychar12;

document.Orderform.cartId.value="ER/"+foundout+cartId2;

document.Orderform.Stenoprice.value=stenoprice;

document.Orderform.Modeprice.value=modeprice;	

document.Orderform.Classicprice.value=classicprice;

document.Orderform.Premierprice.value=premierprice;

}