EZ Fanpage 0 Newbie Poster

Hai Fellow Developers,
I have one problem and appreciate if any of you could guide me on this.
I created a custom Paypal button with some Javascript and AJAX.

Why with AJAX? Because the script have a coupon acceptance code where i need some validation using AJAX.

The problem is i need it to fit to Facebook Fanpage and need to comply to FBJS compliant.

The sample is here:
http://iphone-supplier.us/test/protected_buy.html

I used to create an AJAX form in Fanpage and works fine but this code giving me problem
Appreciate your help!

Thanks

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Basic Coupon Discounts.</title>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />

<link rel="stylesheet" type="text/css" href="css/light_slate.css" media="screen" />

<meta http-equiv="Content-Language" content="en-US" />

<meta name="keywords" content="xhtml, javascript, paypal, modification, dynamic, coupons" />

<meta name="description" content="Giving basic discounts to PayPal." />

<script type="text/javascript"><!--

var discnt = 0; // no default percent discount

var coupons = new Array ( // place to put coupon codes

"BHW10", // 1st coupon value - comma seperated

"BHW50", // 2nd coupon value - add all you want

"BHW70" // 3rd coupon value

);

var coupdc = new Array ( // place to put discounts for coupon vals

10,

50,

70

);

var coupval = "(blanket)"; // what user entered as coupon code

function ChkCoup () { // check user coupon entry

var i;

discnt = 0; // assume the worst

for (i=0; i<coupons.length; i++) {

if (coupval == coupons[i]) {

discnt = coupdc[i]; // remember the discount amt

alert ("Valid coupon code! \n\n" + discnt +

"% discount now in effect.");

return;

}

}

alert ("'" + coupval + "' is not a valid code!");

}

function Dollar (val) { // force to valid dollar amount

var str,pos,rnd=0;

if (val < .995) rnd = 1; // for old Netscape browsers

str = escape (val*1.0 + 0.005001 + rnd); // float, round, escape

pos = str.indexOf (".");

if (pos > 0) str = str.substring (rnd, pos + 3);

return str;

}

function ReadForm (obj1) { // apply the discount

var amt,des;

amt = obj1.baseamt.value*1.0; // base amount

des = obj1.basedes.value; // base description

if (discnt > 0) { // only if discount is active

amt = Dollar (amt - (amt * discnt/100.0));

des = des + ", " + discnt + "% Discount, Coupon Code: " + coupval;

}

obj1.amount.value = Dollar (amt);

obj1.item_name.value = des;

}

//-->

</script>

</head>

<body link="#456387" bgcolor="#ffffff" alink="#456387" vlink="#456387"><strong></strong>

<script type="text/javascript"><!--

discnt = 10; // set blanket 10% discount

//--></script><!--

discnt = 0; // clear the coupon

//-->

<hr />

<h3>Coupon Test Start</h3>

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" onsubmit="this.target = 'paypal';

return ReadForm (this);">

<p> <input name="cmd" value="_cart" type="hidden" /> <input name="add" value="1" type="hidden" /> <input name="business" value="ezfanpage@gmail.com" type="hidden" /> <input name="item_name" value="2nd Item" type="hidden" /> <input name="amount" value="100.00" type="hidden" /> <input name="currency_code" value="USD" type="hidden" /> <input name="baseamt" value="100.00" type="hidden" /> <input name="basedes" value="Product Name Here" type="hidden" />


Enter Coupon code&nbsp; &gt; <input size="10" name="coupcode" ;="" type="text" />

&nbsp; &nbsp; <input value="Check It" onclick="coupval = this.form.coupcode.value;

ChkCoup();" type="button" /> <br />

<br />


Price: <strong>$100.00 each</strong> <br />

<br />


Input quantity &gt; <input name="quantity" value="1" size="4" type="text" />

&nbsp;</p>

<p> &nbsp; <input src="http://www.iphone-supplier.us/test/images/buynow.gif" name="submit" alt="cart add" type="image" /> </p> </form>

<h3>Coupon Test End</h3>

<hr />

<h3>Powered by: BlackMarket™</h3><strong>Instruction:</strong><br />

Enter Coupon Code (case sensitive)<br />

BHW10 - 10%<br />

BHW50 - 50%<br />

BHW70 - 70%<br />

</body>

</html>