/**
 * @author Knutpunkten.se
 * Modified by Samjacob on 7thDec08
 */
function tipsubmit(){
	if((document.tipform.urmail.value == "")){
		alert("Enter your e-mail!");
		document.tipform.urmail.focus();
		}	
	else if((document.tipform.frdemail.value == "")){
		alert("Enter your Friends's Email");
		document.tipform.frdemail.focus();		
		}
	
	if((document.tipform.urmail.value != "") && (document.tipform.frdemail.value!= "")){
		document.tipform.action = "friendtip_acwk.aspx";
		document.tipform.submit();
		}
	}
function german_tipsubmit(){
	if((document.tipform.urmail.value == "")){
		alert("Bitte geben Sie Ihre Mail Adresse an!");
		document.tipform.urmail.focus();
		}	
	else if((document.tipform.frdemail.value == "")){
		alert("Bitte geben Sie die Mail Adresse Ihres Bekannten an!");
		document.tipform.frdemail.focus();		
		}
	
	if((document.tipform.urmail.value != "") && (document.tipform.frdemail.value!= "")){
		document.tipform.action = "friendtip_acwk.aspx";
		document.tipform.submit();
		}
	}
	function checkqty(n) {
	    if (validate_email()) {
	        if (((document.paypalform.text1.value) == "") || (document.paypalform.text1.value) < 1) {
	            alert("Enter the number of copies you want");
	            document.paypalform.text1.focus();
	            return false;
	        }
	        else if ((document.paypalform.uname.value) == "") {
	            alert("Please enter your name");
	            document.paypalform.uname.focus();
	            return;
	        }
	        else if ((document.paypalform.box.value) == "") {
	            alert("Please enter your address");
	            document.paypalform.box.focus();
	            return;
	        }
	        else if ((document.paypalform.country_list.value) == "default") {
	            alert("Please select a country");
	            document.paypalform.country_list.focus();
	            return;
	        }
	        else if ((document.paypalform.tele.value) == "") {
	            alert("Please enter your telephone number");
	            document.paypalform.tele.focus();
	            return;
	        }
	        else if ((document.paypalform.epost.value) == "") {
	            alert("Please enter an email id");
	            document.paypalform.epost.focus();
	            return;
	        }
	        else if (((document.paypalform.text1.value) > 0) || ((document.paypalform.text1.value) != "")) {
	            document.paypalform.q0.value = document.paypalform.text1.value;
	            if ((document.paypalform.q0.value) < 11) {
	                if ((document.paypalform.currency.value) == "EUR") {
	                    document.paypalform.amount.value = document.paypalform.q0.value * 26;
	                    document.paypalform.price_per_book.value = 26;
	                }
	                else if ((document.paypalform.currency.value) == "USD") {
	                    document.paypalform.amount.value = document.paypalform.q0.value * 32;
	                    document.paypalform.price_per_book.value = 32;
	                }
	                else if ((document.paypalform.currency.value) == "CAD") {
	                    document.paypalform.amount.value = document.paypalform.q0.value * 36;
	                    document.paypalform.price_per_book.value = 36;
	                }
	                else if ((document.paypalform.currency.value) == "SGD") {
	                var pc = document.paypalform.procode.value;
	                pc = pc.replace(/^\s+|\s+$/g, '');
	                if (pc == "IKEA" || pc == "ikea") {
	                    //document.paypalform.amount.value = document.paypalform.q0.value * 35;
	                    document.paypalform.amount.value = document.paypalform.q0.value * 45;
	                    document.paypalform.price_per_book.value = 45;
	                } else {
	                    document.paypalform.amount.value = document.paypalform.q0.value * 45;
	                    document.paypalform.price_per_book.value = 45;
	                }
	                }
	            }
	            if (((document.paypalform.q0.value) > 10) && ((document.paypalform.q0.value) < 50)) {
	                if ((document.paypalform.currency.value) == "EUR") {
	                    document.paypalform.amount.value = document.paypalform.q0.value * 22;
	                    document.paypalform.price_per_book.value = 22;
	                }
	                else if ((document.paypalform.currency.value) == "USD") {
	                    document.paypalform.amount.value = document.paypalform.q0.value * 26;
	                    document.paypalform.price_per_book.value = 26;
	                }
	                else if ((document.paypalform.currency.value) == "CAD") {
	                    document.paypalform.amount.value = document.paypalform.q0.value * 30;
	                    document.paypalform.price_per_book.value = 30;
	                }
	                else if ((document.paypalform.currency.value) == "SGD") {
	                var pc = document.paypalform.procode.value;
	                pc = pc.replace(/^\s+|\s+$/g, '');
	                if (pc == "IKEA" || pc == "ikea") {
	                    document.paypalform.amount.value = document.paypalform.q0.value * 35;
	                    document.paypalform.price_per_book.value = 35;
	                } else {
	                    document.paypalform.amount.value = document.paypalform.q0.value * 40;
	                    document.paypalform.price_per_book.value = 40;
	                }
	                }
	            }
	            if ((document.paypalform.q0.value) > 49) {
	                if ((document.paypalform.currency.value) == "EUR") {
	                    document.paypalform.amount.value = document.paypalform.q0.value * 19;
	                    document.paypalform.price_per_book.value = 19;
	                }
	                else if ((document.paypalform.currency.value) == "USD") {
	                    document.paypalform.amount.value = document.paypalform.q0.value * 23;
	                    document.paypalform.price_per_book.value = 23;
	                }
	                else if ((document.paypalform.currency.value) == "CAD") {
	                    document.paypalform.amount.value = document.paypalform.q0.value * 26;
	                    document.paypalform.price_per_book.value = 26;
	                }
	                else if ((document.paypalform.currency.value) == "SGD") {
	                var pc = document.paypalform.procode.value;
	                pc = pc.replace(/^\s+|\s+$/g, '');
	                if (pc == "IKEA" || pc == "ikea") {
	                    document.paypalform.amount.value = document.paypalform.q0.value * 35;
	                    document.paypalform.price_per_book.value = 35;
	                } else {
	                    document.paypalform.amount.value = document.paypalform.q0.value * 35;
	                    document.paypalform.price_per_book.value = 35;
	                }
	                }
	            }
	            if ((document.paypalform.q0.value > 0) && (document.paypalform.epost.value != "")) {
	                document.paypalform.currency_code.value = document.paypalform.currency.value;
	                document.paypalform.countryRequest.value = document.paypalform.country_list.value;
	                if (n == 1) {
	                    document.paypalform.action = "http://www.interesting.org/Articles/orderpage.aspx?lang=&action=paypal";
	                    //document.paypalform.action = "http://localhost:1127/Interesting_newDB/articles/orderpage.aspx?lang=&action=paypal";
	                }
	                else if (n == 2) {
	                    document.paypalform.action = "http://www.interesting.org/Articles/orderpage.aspx?lang=&action=inv";
	                //document.paypalform.action = "http://localhost:1127/Interesting_newDB/articles/orderpage.aspx?lang=&action=inv";
	                }
	                document.paypalform.submit();
	            }
	        }
	    }
	}
function roundToPennies(n)
{
 pennies = n * 100;

 pennies = Math.round(pennies);

 strPennies = "" + pennies;
 len = strPennies.length;

 return strPennies.substring(0, len - 2) + "." + strPennies.substring(len - 2, len);
}

function validate_email() {
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    var address = document.paypalform.epost.value;
    if (reg.test(address) == false) {
        alert('Invalid Email Address');
        return false;
    }
    else
        return true;
}

function alert_price(){
    //Euro Values
    //Euro - UK
    var per_book;
    var ship_val;
    var ship_area;
    var obj1 = document.getElementById("currency");
    var obj2 = document.getElementById("region");
    var obj3 = document.getElementById("text1");
   
    var flag;
    obj2.remove(5);
    if ((document.paypalform.currency.value == "SGD") && (flag != true )) {
       // if ((obj3.value != "")||(obj3.value != 0)) {
            //var alertspan = document.getElementById("alertspan");
            //alertspan.innerHTML = "SGD Currency is allowed only for <b>SINGAPORE delivery address</b>";
            obj2.options.add(new Option('Singapore (SG)', 'sg'));
            flag = true;
            alert("SGD Currency is allowed only for SINGAPORE delivery address");
        //}
//        else {
//            alert("Please enter quantity for Shipping Cost calculation");
//            obj3.focus();
//        }
    }
    if (document.paypalform.text1.value == 0) {
        alert("Please enter quantity for Shipping Cost calculation");
        document.getElementById("valuespan").innerHTML = "";
        document.getElementById("text1").focus();
    }
    				
if ((document.paypalform.currency.value =="EUR") && (document.paypalform.region.value =="uk") && (document.paypalform.text1.value > 0))
	{
		var qty = parseInt(document.paypalform.text1.value);
		var tot_amt = 0.00;
		per_book = 5;
		ship_val = 4;
		ship_area = "UK";
		tot_amt = roundToPennies(per_book + (ship_val * (qty - 1)));
		document.getElementById("alertspan").innerHTML = "";
		var valuespan = document.getElementById("valuespan");
		valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) to " + ship_area + " is " + tot_amt + " Euro";
		var promodiv = document.getElementById("promoDIV");
		promodiv.innerHTML = "";
		//valuespan.innerHTML = "<b>Shipping cost</b>:"+ tot_amt +" Euro -> (" + per_book + "+("+ship_val +"*("+ (qty-1) + "))";
    }
	//Euro - US
	if ((document.paypalform.currency.value =="EUR") && (document.paypalform.region.value =="us") && (document.paypalform.text1.value > 0))
	{
		var qty = parseInt(document.paypalform.text1.value);
		var tot_amt = 0.00;
		per_book = 8;
		ship_val = 2;
		ship_area = "US";
		tot_amt = roundToPennies(per_book + (ship_val  * (qty - 1)));
		document.getElementById("alertspan").innerHTML = "";
		var valuespan = document.getElementById("valuespan");
		valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) to " + ship_area + " is " + tot_amt + " Euro";
		var promodiv = document.getElementById("promoDIV");
		promodiv.innerHTML = "";
		//valuespan.innerHTML = "<b>Shipping cost</b>:" + tot_amt + " Euro -> (" + per_book + "+(" + ship_val + "*(" + (qty - 1) + "))";
    }
	//Euro-Canada
	if ((document.paypalform.currency.value =="EUR") && (document.paypalform.region.value =="cn") && (document.paypalform.text1.value > 0) )
	{
		var qty = parseInt(document.paypalform.text1.value);
		var tot_amt = 0.00;
		per_book = 12;
		ship_val = 2;
		ship_area = "Canada";
		tot_amt =roundToPennies( per_book  + (ship_val  * (qty - 1)));
		document.getElementById("alertspan").innerHTML = "";
		var valuespan = document.getElementById("valuespan");
		valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) to " + ship_area + " is " + tot_amt + " Euro";
		var promodiv = document.getElementById("promoDIV");
		promodiv.innerHTML = "";
		//valuespan.innerHTML = "<b>Shipping cost</b>:" + tot_amt + " Euro -> (" + per_book + "+(" + ship_val + "*(" + (qty - 1) + "))";
    }
	//Euro-Rest of Europe
	if ((document.paypalform.currency.value =="EUR") && (document.paypalform.region.value =="eu") && (document.paypalform.text1.value > 0))
	{
		var qty = parseInt(document.paypalform.text1.value);
		var tot_amt = 0.00;
		per_book = 5;
		ship_val = 4;
		ship_area = "ROE";
		tot_amt = roundToPennies(per_book  + (ship_val  * (qty - 1)));
		document.getElementById("alertspan").innerHTML = "";
		var valuespan = document.getElementById("valuespan");
		valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) to " + ship_area + " is " + tot_amt + " Euro";
		var promodiv = document.getElementById("promoDIV");
		promodiv.innerHTML = "";
		//valuespan.innerHTML = "<b>Shipping cost</b>:" + tot_amt + " Euro -> (" + per_book + "+(" + ship_val + "*(" + (qty - 1) + "))";
    }
    //Euro - Rest of World
    if ((document.paypalform.currency.value == "EUR") && (document.paypalform.region.value == "rs") && (document.paypalform.text1.value > 0)  && (document.paypalform.text1.value < 11)) {
        var qty = parseInt(document.paypalform.text1.value);
        var tot_amt = 0.00;
        ship_area = "ROW";
        tot_amt = roundToPennies(qty * 13.5);
        document.getElementById("alertspan").innerHTML = "";
        var valuespan = document.getElementById("valuespan");
        valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) to " + ship_area + " is " + tot_amt + " Euro";
        var promodiv = document.getElementById("promoDIV");
        promodiv.innerHTML = "";
    }
    if ((document.paypalform.currency.value == "EUR") && (document.paypalform.region.value == "rs") && (document.paypalform.text1.value > 10) && (document.paypalform.text1.value < 50)) {
        var qty = parseInt(document.paypalform.text1.value);
        var tot_amt = 0.00;
        ship_area = "ROW";
        tot_amt = roundToPennies(qty * 10.8);
        document.getElementById("alertspan").innerHTML = "";
        var valuespan = document.getElementById("valuespan");
        valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) to " + ship_area + " is " + tot_amt + " Euro";
        var promodiv = document.getElementById("promoDIV");
        promodiv.innerHTML = "";
    }
    if ((document.paypalform.currency.value == "EUR") && (document.paypalform.region.value == "rs") && (document.paypalform.text1.value > 49)) {
        var qty = parseInt(document.paypalform.text1.value);
        var tot_amt = 0.00;
        ship_area = "ROW";
        tot_amt = roundToPennies(qty * 8.78);
        document.getElementById("alertspan").innerHTML = "";
        var valuespan = document.getElementById("valuespan");
        valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) to " + ship_area + " is " + tot_amt + " Euro";
        var promodiv = document.getElementById("promoDIV");
        promodiv.innerHTML = "";
    }	
//	if ((document.paypalform.currency.value == "EUR") && (document.paypalform.region.value == "rs") && (document.paypalform.text1.value > 0)) {
//	    var qty = parseInt(document.paypalform.text1.value);
//	    var tot_amt = 0.00;
//	    per_book = 42;
//	    ship_val = 4;
//	    tot_amt = per_book  + (ship_val  * (qty - 1));
//	    var valuespan = document.getElementById("valuespan");
//	    //valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) will be " + tot_amt + " Euro";
//	    valuespan.innerHTML = "<b>Shipping cost</b>:" + tot_amt + " Euro -> (" + per_book + "+(" + ship_val + "*(" + (qty - 1) + "))";
//	}
	//US Dollar values
	//USD - UK
	if ((document.paypalform.currency.value == "USD") && (document.paypalform.region.value == "uk") && (document.paypalform.text1.value > 0)) {

	    var qty = parseInt(document.paypalform.text1.value);
	    var tot_amt = 0.00;
	    per_book = 7;
	    ship_val = 5;
	    ship_area = "UK";
	    tot_amt = roundToPennies(per_book  + (ship_val  * (qty - 1)));
	    document.getElementById("alertspan").innerHTML = "";
	    var valuespan = document.getElementById("valuespan");
	    valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) to " + ship_area + " is " + tot_amt + " USD";
	    var promodiv = document.getElementById("promoDIV");
	    promodiv.innerHTML = "";
	    //valuespan.innerHTML = "<b>Shipping cost</b>:" + tot_amt + " USD -> (" + per_book + "+(" + ship_val + "*(" + (qty - 1) + "))";
	}
	//USD-US
	if ((document.paypalform.currency.value == "USD") && (document.paypalform.region.value == "us") && (document.paypalform.text1.value > 0)) {
	    var qty = parseInt(document.paypalform.text1.value);
	    var tot_amt = 0.00;
	    per_book =13;
	    ship_val = 2;
	    ship_area = "US";
	    tot_amt =roundToPennies(per_book  + (ship_val  * (qty - 1)));
	    document.getElementById("alertspan").innerHTML = "";
	    var valuespan = document.getElementById("valuespan");
	    valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) to " + ship_area + " is " + tot_amt + " USD";
	    var promodiv = document.getElementById("promoDIV");
	    promodiv.innerHTML = "";
	    //valuespan.innerHTML = "<b>Shipping cost</b>:" + tot_amt + " USD -> (" + per_book + "+(" + ship_val + "*(" + (qty - 1) + "))";
	}
	//USD - Canada
	if ((document.paypalform.currency.value == "USD") && (document.paypalform.region.value == "cn") && (document.paypalform.text1.value > 0)) {
	    var qty = parseInt(document.paypalform.text1.value);
	    var tot_amt = 0.00;
	    per_book =15;
	    ship_val = 2;
	    ship_area = "Canada";
	    tot_amt =roundToPennies( per_book  + (ship_val  * (qty - 1)));
	    document.getElementById("alertspan").innerHTML = "";
	    var valuespan = document.getElementById("valuespan");
	    valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) to " + ship_area + " is " + tot_amt + " USD";
	    var promodiv = document.getElementById("promoDIV");
	    promodiv.innerHTML = "";
	    //valuespan.innerHTML = "<b>Shipping cost</b>:" + tot_amt + " USD -> (" + per_book + "+(" + ship_val + "*(" + (qty - 1) + "))";
	}
	//USD - Rest of Europe
	if ((document.paypalform.currency.value == "USD") && (document.paypalform.region.value == "eu") && (document.paypalform.text1.value > 0)) {
	    var qty = parseInt(document.paypalform.text1.value);
	    var tot_amt = 0.00;
	    per_book =7;
	    ship_val = 5;
	    ship_area = "ROE";
	    tot_amt = roundToPennies(per_book + (ship_val * (qty - 1)));
	    document.getElementById("alertspan").innerHTML = "";
	    var valuespan = document.getElementById("valuespan");
	    valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) to " + ship_area + " is " + tot_amt + " USD";
	    var promodiv = document.getElementById("promoDIV");
	    promodiv.innerHTML = "";
	    //valuespan.innerHTML = "<b>Shipping cost</b>:" + tot_amt + " USD -> (" + per_book + "+(" + ship_val + "*(" + (qty - 1) + "))";
	}
	//USD - Rest of World
	if ((document.paypalform.currency.value == "USD") && (document.paypalform.region.value == "rs") && (document.paypalform.text1.value > 0) && (document.paypalform.text1.value < 11)) {
	    var qty = parseInt(document.paypalform.text1.value);
	    var tot_amt = 0.00;
	    ship_area = "ROW";
	    tot_amt = roundToPennies(qty * 17);
	    document.getElementById("alertspan").innerHTML = "";
	    var valuespan = document.getElementById("valuespan");
	    valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) to " + ship_area + " is " + tot_amt + " USD";
	    var promodiv = document.getElementById("promoDIV");
	    promodiv.innerHTML = "";
	}
	if ((document.paypalform.currency.value == "USD") && (document.paypalform.region.value == "rs") && (document.paypalform.text1.value > 10) && (document.paypalform.text1.value < 50)) {
	    var qty = parseInt(document.paypalform.text1.value);
	    var tot_amt = 0.00;
	    ship_area = "ROW";
	    tot_amt = roundToPennies(qty * 13.6);
	    document.getElementById("alertspan").innerHTML = "";
	    var valuespan = document.getElementById("valuespan");
	    valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) to " + ship_area + " is " + tot_amt + " USD";
	}
	if ((document.paypalform.currency.value == "USD") && (document.paypalform.region.value == "rs") && (document.paypalform.text1.value > 49)) {
	    var qty = parseInt(document.paypalform.text1.value);
	    var tot_amt = 0.00;
	    ship_area = "ROW";
	    tot_amt = roundToPennies(qty * 11.05);
	    document.getElementById("alertspan").innerHTML = "";
	    var valuespan = document.getElementById("valuespan");
	    valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) to " + ship_area + " is " + tot_amt + " USD";
	    var promodiv = document.getElementById("promoDIV");
	    promodiv.innerHTML = "";
	}	
//	if ((document.paypalform.currency.value == "USD") && (document.paypalform.region.value == "rs") && (document.paypalform.text1.value > 0)) {
//	    var qty = parseInt(document.paypalform.text1.value);
//	    var tot_amt = 0.00;
//	    per_book =63;
//	    ship_val=4;
//	    tot_amt = per_book  + (ship_val  * (qty - 1));
//	    var valuespan = document.getElementById("valuespan");
//	    //valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) will be " + tot_amt + " USD";
//	    valuespan.innerHTML = "<b>Shipping cost</b>:" + tot_amt + " USD -> (" + per_book + "+(" + ship_val + "*(" + (qty - 1) + "))";
//	}
	//Canadian Dollar values
	//CAD - UK
	if ((document.paypalform.currency.value == "CAD") && (document.paypalform.region.value == "uk") && (document.paypalform.text1.value > 0)) {

	    var qty = parseInt(document.paypalform.text1.value);
	    var tot_amt = 0.00;
	    per_book =8;
	    ship_val = 6;
	    ship_area = "UK";
	    tot_amt = roundToPennies(per_book  + (ship_val  * (qty - 1)));
	    document.getElementById("alertspan").innerHTML = "";
	    var valuespan = document.getElementById("valuespan");
	    valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) to " + ship_area + " is " + tot_amt + " CAD";
	    var promodiv = document.getElementById("promoDIV");
	    promodiv.innerHTML = "";
	    //valuespan.innerHTML = "<b>Shipping cost</b>:" + tot_amt + " CAD -> (" + per_book + "+(" + ship_val + "*(" + (qty - 1) + "))";
	}
	//CAD-US
	if ((document.paypalform.currency.value == "CAD") && (document.paypalform.region.value == "us") && (document.paypalform.text1.value > 0) && (document.paypalform.text1.value < 11)) {
	    var qty = parseInt(document.paypalform.text1.value);
	    var tot_amt = 0.00;
	    per_book =15;
	    ship_val = 2;
	    ship_area = "US";
	    tot_amt = roundToPennies(per_book  + (ship_val  * (qty - 1)));
	    document.getElementById("alertspan").innerHTML = "";
	    var valuespan = document.getElementById("valuespan");
	    valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) to " + ship_area + " is " + tot_amt + " CAD";
	    var promodiv = document.getElementById("promoDIV");
	    promodiv.innerHTML = "";
	    //valuespan.innerHTML = "<b>Shipping cost</b>:" + tot_amt + " CAD -> (" + per_book + "+(" + ship_val + "*(" + (qty - 1) + "))";
	}
	//CAD - Canada
	if ((document.paypalform.currency.value == "CAD") && (document.paypalform.region.value == "cn") && (document.paypalform.text1.value > 0)) {
	    var qty = parseInt(document.paypalform.text1.value);
	    var tot_amt = 0.00;
	    per_book=18;
	    ship_val = 2;
	    ship_area = "Canada";
	    tot_amt =roundToPennies( per_book  + (ship_val  * (qty - 1)));
	    document.getElementById("alertspan").innerHTML = "";
	    var valuespan = document.getElementById("valuespan");
	    valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) to " + ship_area + " is " + tot_amt + " CAD";
	    var promodiv = document.getElementById("promoDIV");
	    promodiv.innerHTML = "";
	    //valuespan.innerHTML = "<b>Shipping cost</b>:" + tot_amt + " CAD -> (" + per_book + "+(" + ship_val + "*(" + (qty - 1) + "))";
	}
	//CAD - Rest of Europe
	if ((document.paypalform.currency.value == "CAD") && (document.paypalform.region.value == "eu") && (document.paypalform.text1.value > 0)) {
	    var qty = parseInt(document.paypalform.text1.value);
	    var tot_amt = 0.00;
	    per_book =8;
	    ship_val = 6;
	    ship_area = "ROE";
	    tot_amt =roundToPennies( per_book  + (ship_val  * (qty - 1)));
	    document.getElementById("alertspan").innerHTML = "";
	    var valuespan = document.getElementById("valuespan");
	    valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) to " + ship_area + " is " + tot_amt + " CAD";
	    var promodiv = document.getElementById("promoDIV");
	    promodiv.innerHTML = "";
	    //valuespan.innerHTML = "<b>Shipping cost</b>:" + tot_amt + " CAD -> (" + per_book + "+(" + ship_val + "*(" + (qty - 1) + "))";
	}
	//CAD - Rest of World
	if ((document.paypalform.currency.value == "CAD") && (document.paypalform.region.value == "rs") && (document.paypalform.text1.value > 0) && (document.paypalform.text1.value < 11)) {
	    var qty = parseInt(document.paypalform.text1.value);
	    var tot_amt = 0.00;
	    ship_area = "ROW";
	    tot_amt = roundToPennies(qty * 19);
	    document.getElementById("alertspan").innerHTML = "";
	    var valuespan = document.getElementById("valuespan");
	    valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) to " + ship_area + " is " + tot_amt + " CAD";
	    var promodiv = document.getElementById("promoDIV");
	    promodiv.innerHTML = "";
	}
	if ((document.paypalform.currency.value == "CAD") && (document.paypalform.region.value == "rs") && (document.paypalform.text1.value > 10) && (document.paypalform.text1.value < 50)) {
	    var qty = parseInt(document.paypalform.text1.value);
	    var tot_amt = 0.00;
	    ship_area = "ROW";
	    tot_amt = roundToPennies(qty * 15.2);
	    document.getElementById("alertspan").innerHTML = "";
	    var valuespan = document.getElementById("valuespan");
	    valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) to " + ship_area + " is " + tot_amt + " CAD";
	    var promodiv = document.getElementById("promoDIV");
	    promodiv.innerHTML = "";
	}
	if ((document.paypalform.currency.value == "CAD") && (document.paypalform.region.value == "rs") && (document.paypalform.text1.value > 49)) {
	    var qty = parseInt(document.paypalform.text1.value);
	    var tot_amt = 0.00;
	    ship_area = "ROW";
	    tot_amt = roundToPennies(qty * 12.35);
	    document.getElementById("alertspan").innerHTML = "";
	    var valuespan = document.getElementById("valuespan");
	    valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) to " + ship_area + " is " + tot_amt + " CAD";
	    var promodiv = document.getElementById("promoDIV");
	    promodiv.innerHTML = "";
	}
//	if ((document.paypalform.currency.value == "CAD") && (document.paypalform.region.value == "rs") && (document.paypalform.text1.value > 0)) {
//	    var qty = parseInt(document.paypalform.text1.value);
//	    var tot_amt = 0.00;
//	    per_book =76;
//	    ship_val=4;
//	    tot_amt = per_book  + (ship_val  * (qty - 1));
//	    var valuespan = document.getElementById("valuespan");
//	    //valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) will be " + tot_amt + " CAD";
//	    valuespan.innerHTML = "<b>Shipping cost</b>:" + tot_amt + " CAD -> (" + per_book + "+(" + ship_val + "*(" + (qty - 1) + "))";
//	}
	//Singapore values
	if (document.paypalform.currency.value == "SGD") {
	    document.paypalform.region.value = "sg";
	    var qty = parseInt(document.paypalform.text1.value);
	    if (qty > 0) {
	        var tot_amt = 0.00;
	        per_book = 6; //changed from 8 to 6 by RV on 2010-10-18
	        ship_val = 5;
	        ship_area = "SG";
	        tot_amt = roundToPennies(per_book + (ship_val * (qty - 1)));
	        if (tot_amt > 30) {
	            tot_amt = 30;
	        }
	        var valuespan = document.getElementById("valuespan");
	        valuespan.innerHTML = "<b>Shipping cost</b> for " + qty + " book(s) to " + ship_area + " is " + tot_amt + " SGD";
	        var promodiv = document.getElementById("promoDIV");
	        promodiv.innerHTML = "Promotional Code <input type=\"text\" name=\"procode\" style=\"width:40px\">";
	        //valuespan.innerHTML = "<b>Shipping cost</b>:" + tot_amt + " SGD -> (" + per_book + "+(" + ship_val + "*(" + (qty - 1) + "))";
	    }
	}
	
    document.paypalform.shipping.value = tot_amt;
   return false;
}



