﻿var shopping_url = null;
function SubmitPayPayRequest(Args)
{
var hosted_button_id = Args.OBJ;
while(hosted_button_id != null)
    {if (/hosted_button_id/i.test(hosted_button_id.name))
        {break;
        }
    hosted_button_id = hosted_button_id.previousSibling;
    }

if (hosted_button_id != null)
	{if (!/undefined/i.test(typeof(document.forms[0].elements["hosted_button_id"].length)))
		{document.forms[0].elements["hosted_button_id"][document.forms[0].elements["hosted_button_id"].length-1].value = hosted_button_id.value;
		}
	}
if (ViewingItem)
	{if (!/undefined/i.test(typeof(document.forms[0].elements["shopping_url"])))
		document.forms[0].elements["shopping_url"].value = location.href;
	}
ViewingItem = true;

document.forms[0].action='https://www.paypal.com/cgi-bin/webscr'
}
var ViewingItem = true;
function SendToShoppingCart(Args)
{if (/ShoppingCart/i.test(location))
	{var ImageButton = Args.OBJ;
	while(ImageButton != null)
		{if (/image/i.test(ImageButton.type))
			{break;
			}
		ImageButton = ImageButton.previousSibling;
		}
	if (ImageButton != null)
		{ImageButton.onclick();
		ViewingItem = false;
		var shopping_url = null;
		if (/shopping_url/i.test(location.search))
			{var KeyVals = location.search.split('&');
			for (var x = 0;x<KeyVals.length;x++)
				{if (/shopping_url/i.test(KeyVals[x]))
					{shopping_url = unescape(KeyVals[x].split('=')[1]);
					}
				}
			}
		if (shopping_url != null)
			document.forms[0].elements["shopping_url"].value = shopping_url;
		ImageButton.click();
		}
	}
}
