var cmd  = "https://www.paypal.com/cgi-bin/webscr" +
            "?cmd=_cart";
var add = "&add=1";
var display = "&display=1";
var business  = "&business=mail@charlielandsborough.com";
var qty = "&quantity=";
var quantity = "";
var nm  = "&item_name=";
var itemname = "Test";
var amt  = "&amount=";
var Amount = "0.00";
var cs = "&cs=1";
var cn = "&cn=Further Information";
var currencycode = "&currency_code=GBP";
var lc = "&lc=GB";
var winpar = "width=930,height=400,scrollbars," +
             "location," +  // some users delete this
             "resizable,status";

function OpenNewWindow(theURL,winName,w,h,sbars)
{
	window.open(theURL,winName,"scrollbars="+sbars+",width="+w+",height="+h);
}

function AddPrice (strn) {  // add to current price
var r1,r2,pos;
  r1 = Amount * 1.0 + 0.005;
  r2 = strn * 1.0;
  strn = escape (r1 + r2);  // add and put back to string
  pos = strn.indexOf ("."); // find decimal point
  Amount = strn.substring (0, pos + 3);  // lop off extra
  
}

function AddStyle (strn) {  // add to current description
  itemname = itemname + "%2C%20" + escape (strn);
  CallPay ();
}

function CallPay () { // call the PayPal shopping car			   
  window.open (cmd + add + // open the cart window
               business +  
               nm + itemname + amt + Amount + qty + quantity + cs + cn + currencycode + lc,
               "paypal",
               winpar);			   
			   
			   
}

function CallView () { // call the PayPal shopping cart view
  window.open (cmd + display +  // open the PayPal cart window
               business,
               "paypal",
               winpar);
}

function MakeBuy (obj1) {  //get form data for PayPal
var i,obj,pick,pick2;
var itext = new Array ();
var ivalue = new Array ();
Amount="0.00";
i=1; // Where i is the element index of the quantity
	obj = obj1.elements[0];     // The form element object
	pick = obj.selectedIndex;   // which option selected
	itext[0] = obj.options[pick].text;  // isolate it
	ivalue[0] = obj.options[pick].value;
	if (ivalue[0]=="")
		{
		alert("You must choose an option from each of the menus.");
		return false;
		}
	AddPrice (ivalue[0]);
	quantity=obj1.elements[i].value;
  AddStyle (itext.join (", "));  // build desc and call cart
  
}

function SetDesc (strn) {  // set the desc field
  itemname = escape (strn);
}


function MakeBuyTeeshirt (obj1) {  //get form data for PayPal
var i,obj,pick,pick2;
var itext = new Array ();
var ivalue = new Array ();
//var Albumarray=new Array(4);
var xi,xobj,xpick,xsize;

Amount="0.00";
i=1; // Where i is the element index of the quantity

	obj = obj1.elements[0];     // The form element object
	pick = obj.selectedIndex;   // which option selected
	itext[0] = obj.options[pick].text;  // isolate it
	ivalue[0] = obj.options[pick].value;
	if (ivalue[0]=="")
		{
		alert("You must choose an option from each of the menus.");
		return false;
		}
	AddPrice (ivalue[0]);
	quantity=obj1.elements[i].value;
	xobj = obj1.elements[2];     // The form element object
	xpick = xobj.selectedIndex;   // w25/Nov/2004 19:35hich option selected
	xsize = xobj.options[xpick].value;  // isolate it
	
		if (xsize=="")
			{
			alert("You must select a size.");
			return false;
			}
  
  AddStyle (itext.join (", "));  // build desc and call cart
  
}




function SetDescTeeshirt (obj1,strn) {  // set the desc field
var i,obj,pick,size;
	obj = obj1.elements[2];     // The form element object
	pick = obj.selectedIndex;   // w25/Nov/2004 19:35hich option selected
	size = obj.options[pick].value;  // isolate it
	
  itemname = escape (strn + " [Size: " + size + "]");
}


function MakeBuyPen (obj1) {  //get form data for PayPal
var i,obj,pick,pick2;
var itext = new Array ();
var ivalue = new Array ();
var xi,xobj,xpick,xcolour;

Amount="0.00";
i=1; // Where i is the element index of the quantity
	obj = obj1.elements[0];     // The form element object
	pick = obj.selectedIndex;   // which option selected
	itext[0] = obj.options[pick].text;  // isolate it
	ivalue[0] = obj.options[pick].value;
	if (ivalue[0]=="")
		{
		alert("You must choose an option from each of the menus.");
		return false;
		}
	AddPrice (ivalue[0]); 
	quantity=obj1.elements[i].value;
	xobj = obj1.elements[2];     // The form element object
	xpick = xobj.selectedIndex;   // w25/Nov/2004 19:35hich option selected
	xcolour = xobj.options[xpick].value;  // isolate it
	
		if (xcolour=="")
			{
			alert("You must select a colour.");
			return false;
			}
  
  AddStyle (itext.join (", "));  // build desc and call cart
  
}




function SetDescPen (obj1,strn) {  // set the desc field
var i,obj,pick,colour;
	obj = obj1.elements[2];     // The form element object
	pick = obj.selectedIndex;   // w25/Nov/2004 19:35hich option selected
	colour = obj.options[pick].value;  // isolate it
  itemname = escape (strn + " [Colour: " + colour + "]");
}

