/**********  Begin Display Pop Up Window *************/ 
function displayImage(URL){
  window.open(URL,"winPop","toolbar=no,scrollbars=yes,resizable=yes,width=500,height=500")
  }
  
/**********  End Display Pop Up Window *************/   
  
/**********  Begin PayPal Transaction - Only Change When PayPal Setting Has Changed *************/  

function checkAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = true ;
}

function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = false ;
}


function checkMe(){
	var total = document.paypal.list.length;
	var counter;
	//alert('Total= '+total);
	
	for(counter = 0; counter < total; counter++){
		if (document.paypal.list[counter].checked)
		{ 
			//msg= 'this has been checked = ' + counter;
			//alert(msg);
			getValue = document.paypal.list[counter].value;
			//alert(getValue);
			splitString = getValue.split("#");
			//alert("[0]= "+ splitString[0] +"\n[1]= " + splitString[1]);
			toPaypal(splitString[0], splitString[1]);
				
		}

	}
}


function toPaypal(itemName, itemPrice, overwriteShip){
	var answer = confirm("Do you wish to add this item to your shopping cart?\n" + "Item Name\t: " + splitString[0] + "\nPrice \t\t: $" + splitString[1]);
	
	if(answer){
			paypalURL = "https://www.paypal.com/cgi-bin/webscr";
			fixCommand1 = "?add=1&cmd=_cart";
			fixBusinessEmail = "&business=jack@lilacsandlace.com";
			fixItemName = "&item_name=" + itemName;
			//alert("itemName= " + itemName);
			fixItemNum = "&item_number=";
			//alert("itemPrice= " + itemPrice);
			fixItemPrice = "&amount=" + itemPrice;
			//overwriteShipping ="&shipping=" + overwriteShip;
			fixReturn = "&return=http://www.lilacsandlace.com/thanks.htm";
			fixCancellation = "&cancel_return=http://www.lilacsandlace.com";
			fixCommand2 = "&cn=Special Request(eg. Gift Wrap)&currency_code=USD&bn=PP-ShopCartBF"
			realURL = paypalURL+fixCommand1+fixBusinessEmail+fixItemName+fixItemNum+fixItemPrice+fixReturn+fixCancellation+fixCommand2;
			 window.open(realURL, 'winPaypal');
			 //top.location.href = realURL;
			return true;
	} else {
		return false;
	}

}	

/************  End PayPal Transaction - Only Change When PayPal Setting Has Changed *************/ 

/******  Begining PayPal Transaction for Artwork - Only Change When PayPal Setting Has Changed **********/ 
function checkMeShip(){
	var total = document.paypal.list.length;
	var counter;
	//alert('Total= '+total);
	
	for(counter = 0; counter < total; counter++){
		if (document.paypal.list[counter].checked)
		{ 
			//msg= 'this has been checked = ' + counter;
			//alert(msg);
			getValue = document.paypal.list[counter].value;
			//alert(getValue);
			splitString = getValue.split("#");
			//alert("[0]= "+ splitString[0] +"\n[1]= " + splitString[1]);
			toPaypalShip(splitString[0], splitString[1], splitString[2]);
				
		}

	}
}


function toPaypalShip(itemName, itemPrice, overwriteShip){
	var answer = confirm("Do you wish to add this item to your shopping cart?\n" + "Item Name\t: " + splitString[0] + "\nPrice \t\t: $" + splitString[1]);
	
	if(answer){
			paypalURL = "https://www.paypal.com/cgi-bin/webscr";
			fixCommand1 = "?add=1&cmd=_cart";
			fixBusinessEmail = "&business=jack@lilacsandlace.com";
			fixItemName = "&item_name=" + itemName;
			//alert("itemName= " + itemName);
			fixItemNum = "&item_number=";
			//alert("itemPrice= " + itemPrice);
			fixItemPrice = "&amount=" + itemPrice;
			overwriteShipping ="&shipping=" + overwriteShip;
			fixReturn = "&return=http://www.lilacsandlace.com/thanks.htm";
			fixCancellation = "&cancel_return=http://www.lilacsandlace.com";
			fixCommand2 = "&cn=Special Request(eg. Gift Wrap)&currency_code=USD&bn=PP-ShopCartBF"
			realURL = paypalURL+fixCommand1+fixBusinessEmail+fixItemName+fixItemNum+fixItemPrice+overwriteShipping+fixReturn+fixCancellation+fixCommand2;
			 window.open(realURL, 'winPaypal');
			 //top.location.href = realURL;
			return true;
	} else {
		return false;
	}

}	

/****** End PayPal Transaction for Artwork - Only Change When PayPal Setting Has Changed **********/
