window.addEvent('domready', function() {
	//Change href on read_more links to what's in rel.
	$$('.show_product_overlay').each(function(el) {
		//el.set('href', el.get('rel'));
		el.addEvent('click', function(e) {
			e.stop();
			$('product_iframe').set('src', el.get('rel'));
			$('product_iframe_container').removeClass('hidden');
			$('product_iframe_overlay').removeClass('hidden');
		})
	})
	
	$$('#product_iframe_close').addEvent('click', function(e) {
		e.stop();
		$('product_iframe_container').addClass('hidden');
		$('product_iframe_overlay').addClass('hidden');
		$('product_iframe').set('src', 'wwwdocs/empty.php');
	})
	
	
	// Toggle disable state on inputs related to invoice payment
	$$('input#webshop_invoice_adress_toggle').addEvent('click',function() {
		if (this.checked) {
			this.getParent('fieldset').getElements('input[type=text]').set('disabled', 'disabled').addClass('disabled');
			$$('.delivery_address').addClass('hidden');
		} else {
			this.getParent('fieldset').getElements('input[type=text]').set('disabled', '').removeClass('disabled');
			$$('.delivery_address').removeClass('hidden');
		}
	})
	
	// If choosen payment is online - change caption on submit button
	/*$$('input[name=payment_method]').addEvent('click',function() {
		if (this.checked && this.get('id') == "webshop_payment_card") {
			this.getParent('form').getElement('button').set('html', 'Bekräfta order &amp; betala nu');
		} else {
			this.getParent('form').getElement('button').set('html', 'Bekräfta order');
		}
		
		if (this.checked && this.get('id') == "webshop_payment_invoice") {
			$('webshop_invoice_address').removeClass('hidden');
		} else {
			$('webshop_invoice_address').addClass('hidden');
		}
		
	})*/
	
})
