var SiteCModuleWebshopLight = {
	shippingToPaymentMethods : {},
	
	numbersOnly: function(evt, comma, point, minus){
		var e 		= (window.event) ? window.event : evt;
		var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
		var field 	= Event.element(evt);
		
		if(keyCode >= 48 && keyCode <= 57) {
			//numbers
			return true;
		};
		
		//allow commas	
		if(comma == true){
			if(keyCode == 44){
				return true;
			};
		};
		
		//allow points
		if(point == true){
			if(keyCode == 46 || keyCode == 110) {
				return true;
			};
		};
		
		//allow minus
		if(minus == true){
			if(keyCode == 45 || keyCode == 109){
				return true;
			};
		};
		
		if(keyCode == 13) {
			//enter
			return true;
		};
		
		if(keyCode == 8 || keyCode == 9 || keyCode == 46) {
			//backspace, tab, delete	
			return true;
		};
		
		if(keyCode == 37 || keyCode == 38 || keyCode == 39 || keyCode == 40) {
			//arrows	
			return true;
		};

		Event.stop(evt);
		return false;
	},
	
	showPaymentMethodsByShippingMethod: function() {
		var form = GuiPack.GuiForm['selectShippingAndPaymentMethod'];
		var shippingMethodId = parseInt(form.getElement('order_shipping_method_id').getValue());
		
		if(shippingMethodId > 0) {
			$('guiForm_Element_Radio_Container_order_payment_method_id').select('.guiForm_Element_Radio').each(function(element) {
				$(element).hide();									   
			});
			$('guiForm_Element_Radio_Container_order_payment_method_id').select('.guiForm_Element_Radio_Input').each(function(element) {
				$(element).disabled = true;									   
			});
			
			SiteCModuleWebshopLight.shippingToPaymentMethods[shippingMethodId].each(function(paymentMethodId){
				$('guiForm_Element_Radio_Item_order_payment_method_id_' + paymentMethodId).show();
				$('order_payment_method_id_' + paymentMethodId).disabled = false;
			});
		}
	},
	
	/*custom*/
	setProductImage: function(image, width, height) {
		$('product_image_container').update('<img src="'+image+'" width="'+width+'" height="'+height+'" id="product_image" border="0" class="module_webshop_light_productpage_thumbnail" onContextMenu="return false;" title="uitvergroten">');	
	},
	
	setClickEvent: function(title, width, height, url) {
		$('product_image').stopObserving('click');
		//$('zoom').stopObserving('click');
		$('product_image').observe('click', SiteCModuleWebshopLight.openPopUp.bind(SiteCModuleWebshopLight, title, width, height, url));
		//$('zoom').observe('click', SiteCModuleWebshopLight.openPopUp.bind(SiteCModuleWebshopLight, title, width, height, url));
	},
	
	openPopUp: function(title, width, height, url) {
		SiteCModuleWebshopLight.popup = new Window({id: 'webshopLightImages', className: 'guiWindow', blurClassName: 'guiWindow', title: title, width: width, height: height, resizable: false, closable: true, minimizable: false, maximizable: false, draggable: false, showEffect: Element.show, hideEffect: Element.hide, destroyOnClose: true, url: url});
		SiteCModuleWebshopLight.popup.showCenter(true);
		
		//$('overlay_modal').observe('click', SiteCModuleWebshopLight.popup.close());
	}
};
