//var cartWin;

function addToCart(itemID,purchaseLocation,handlingCharge){
			
	//update the handling charge
	if(!isNaN(handlingCharge)){
		$("#_cartForm_"+itemID+" .inputHandlingCharge").val(handlingCharge);				
	}
	
	var queryStr='?';
	var selectInput;
	
	//add values from the webform into a string (exlcuding the "select" lists)
	$('#_cartForm_'+itemID+' input').each(function(){						
		queryStr += $(this).attr('name')+'='+$(this).attr('value')+'&';												   	
    });
	
	//find out if there is a select list, and if so add the value in
	var selectInputValue=$('#_cartForm_'+itemID+' select').val();
	
	if(selectInputValue)
		queryStr += 'item_name='+selectInputValue;		

	
	//set up the url for the store
	cartURL=paypalUrl+queryStr;		
	
	//alert(cartWin);
	
	/*if (!cartWin){
		alert('new win');*/
		cartWin=window.open(cartURL,'PaypalCart');
/*	}else{
		alert('curr win');
		cartWin.location(cartURL);
	}*/
	
	
	//reload the current webpage.. because chrome and safari are annoying
	window.location.reload()
	
	//set the focus back to the cart window..	
	cartWin.focus(); 
	
	return false;
		
}	

/*

	//submit the form to paypal
	//$("#_cartForm_"+itemID).submit();	


	var queryStr='?';
	
	//add values from the webform into a string
	$('#_cartForm_'+itemID+' input').each(function(){	
		queryStr += $(this).attr('name')+'='+$(this).attr('value')+'&';												   	
    });

	
	//set up the url for the store
	cartURL=paypalUrl+queryStr;
		
	//alert(cartURL);
	window.open(cartURL,'Paypal Cart');
	*/	

/*$(document).ready(function () 
{
	
	$('.detailedViewRight ul.galleryThumbs li a').click(function() 
	{
		$('.detailedViewRight ul.galleryThumbs li').removeClass('active');
		var imageObj = $(this).find('img');
		
		var imageUrl = imageObj.attr('src').replace('/thumbGallery_','/gallery_');
		var imageCap = $(this).parent().attr('title');
		loadImage(imageUrl, imageCap);
		
		$(this).parent().addClass('active');
	});
	
	
});*/