﻿function showAlertPay(){
	index = document.cookie.indexOf("TheBasket");
	countbegin = (document.cookie.indexOf("=", index) + 1);
      countend = document.cookie.indexOf(";", index);
      if (countend == -1) {
            countend = document.cookie.length;
      }
	fulllist = document.cookie.substring(countbegin, countend);
	totprice = 0;

		
	document.writeln('<form method="post" action="https://www.alertpay.com/PayProcess.aspx" >');
	document.writeln('<input type="hidden" name="ap_purchasetype" value="service"/>');
	document.writeln('<input type="hidden" name="ap_merchant" value="freetechservice@yeah.net"/>');		//alertPay Account Email
	
	var ap_itemname = "";
	var ap_itemcode = "";
	var ap_quantity = "";
	
	itemlist = 0;
	var all_items_desc = '';
	var products_ids = '';
	var first = 1;
	for (var i = 0; i <= fulllist.length; i++) {
		if (fulllist.substring(i,i+1) == '[') {
			thisitem = 1;
			itemstart = i+1;
		} else if (fulllist.substring(i,i+1) == ']') {
			itemend = i;
			thequantity = fulllist.substring(itemstart, itemend);
			itemtotal = 0;
			itemtotal = (eval(theprice*thequantity));
			temptotal = itemtotal * 100;
			totprice = totprice + itemtotal;
			itemlist=itemlist+1;
			//document.writeln('<input type="hidden" name="apc_' + itemlist + '" value="' + theitem + '"/> '); 
			ap_itemname += theitem + "|";
			ap_quantity += thequantity+ "|";
			ap_itemcode += theprice+ "|";
			
		} else if (fulllist.substring(i,i+1) == '|') {
			if (thisitem==1) theitem = fulllist.substring(itemstart, i);
			if (thisitem==2) theprice = fulllist.substring(itemstart, i);
			if (thisitem==3) product_id = fulllist.substring(itemstart, i);
			thisitem++;
			itemstart=i+1;
		}
	}

        document.writeln('<input type="hidden" name="ap_itemname" value="-"/>');  //Company Name
	document.writeln('<input type="hidden" name="ap_currency" value="USD"/>');
	document.writeln('<input type="hidden" name="ap_returnurl" value="http://www.pass4sure.net"/>');	//return url after pay
	document.writeln('<input type="hidden" name="ap_itemcode" value="-"');  //Code 
        document.writeln('<input type="hidden" name="ap_quantity" value="1"/>');
	document.writeln('<input type="hidden" name="ap_description" value="' + ap_itemname + '"/>');
	document.writeln('<input type="hidden" name="ap_amount" value="'+alterError(totprice)+'"/>');		
	document.writeln('<input type="image" name="ap_image" src="http://www.pass4sure.net/images/alertpay.gif"/>');
	document.writeln('</form>');
}
