//function for size-guide popup
var ExternalLinks =
{
	init: function()
	{
		var extLinks = Core.getElementsByClass("size-guide");
		for (var i = 0; i < extLinks.length; i++)
		{
			Core.addEventListener(extLinks[i], "click", ExternalLinks.sizePopup);
		}
	},

	sizePopup: function(event)
	{
		window.open(this.href,'DP','resizable=0,top=20,left=20,location=0,status=0,width=600,height=600,scrollbars=yes');
		Core.preventDefault(event);
	}

};

function checkSize(catalogueid, productid, checkoutType, pageListingType)
{
	var selectedProductDiv = document.getElementById("catProdAttributes2_"+productid);
	var listArray = selectedProductDiv.getElementsByTagName("select");
	var sizeListbox = listArray[0];
	var selected = sizeListbox.selectedIndex;
	//if nothing has been selected return false and exit the function
	if(sizeListbox[selected].value == "")
	{
		alert("Please select a size");
		Core.preventDefault(event);
		return false;
	}
	else
	{
		if(checkoutType=="AddToCart" && pageListingType=="small")
			{
				//add to cart and small product listing
				AddToCart(catalogueid,productid,'',false,false);
			}
		if(checkoutType=="AddToCart" && pageListingType=="large")
			{
				//add to cart button and large product listing
				AddToCart(catalogueid,productid,'',true,false);				
			}
			
		if(checkoutType=="AddToCheckout" && pageListingType=="small")
			{
				//add to checkout and small product listing
				AddToCart(catalogueid,productid,'',false,true);
			}
		if(checkoutType=="AddToCheckout" && pageListingType=="large")
			{
				//add to checkout and large product listing
				AddToCart(catalogueid,productid,'',true,true);				
			}
	}
}

var Oshoplang = {
    RemoveError: 'ERROR: To remove or update quantities select the View Cart link.',    
    Added: ' item(s) added to your cart.',
    OutOfStock: 'Either product is out of stock or choose a smaller quantity',
    PreOrder: ' item(s) pre-ordered and added to your cart.',
    MinLimit: 'ERROR: Quantity entered is too small, please enter a larger quantity.',
    MaxLimit: 'ERROR: Quantity entered is too large, please enter a smaller quantity.',
    InvalidQuantity: 'ERROR: Quantity entered is not valid.',
    CartEmpty: 'Your Shopping cart is empty.',
    CartUpdateSuccess: 'Shopping cart updated successfully.',
    InvalidShip: 'ERROR: Please choose a valid shipping option.',
    ChooseState: 'ERROR: Please choose a destination state to calculate state tax.',
    EnterZip: 'ERROR: Please enter in your Zip/Postcode to calculate shipping costs for your order.',
    ChooseShip: 'ERROR: Please select a shipping charge for your order.',
    IncorrectGForm: 'ERROR: Your gift voucher form is not setup correctly. Please reset to original to restore.',
    EnterGName: 'ERROR: Please enter a name for the recipient of your gift voucher.',
    InvalidGEmail: 'ERROR: Please enter a valid email address for the recipient of your gift voucher.',
    EnterGMessage: 'ERROR: Please enter a personal message for the recipient of your gift voucher.',
    ChooseAttribute: 'ERROR: Please select a size before adding to cart.'
};



//On page load run the external links function - adds the event listener to size-guide class for size guide popup
Core.start(ExternalLinks);
