Event.observe(window, 'load', function()
{
		if(window.contactList)
		{
			if(window.contactList.length > 0)
			{
				var h3 = new Element('h3').update('Jeg vil f&aring; tilsendt informasjon om:');
				var ul = new Element('ul');
				window.contactList.each(function(contactListObj, index)
				{
					var li = new Element('li');
					var radio = new Element('input', {type:'checkbox', id: 'chbox'+index, name:'material[]', value: contactListObj.title});
					var label = new Element('label', { 'for': ('chbox'+index) });
					label.innerHTML = contactListObj.title;
					li.appendChild(radio);
					li.appendChild(label);
					ul.appendChild(li);
					li = null;
				});
				$('contactRadioList').appendChild(h3);
				$('contactRadioList').appendChild(ul);
			}
		}	
	/*
	 *		EXPAND/COLLAPSE BUYERS GUIDE
	 */
	/*if($('buyers-guide'))
	{
		var expander = $('buyers-guide-frame');
		var title = $($$('#buyers-guide h3')[0]);
		var toggleTrigger = $('toggle-buyers-guide');
		var toggled = 0;
		
		Event.observe($(toggleTrigger), 'click', function()
		{
			if(Effect.Queues.get('expander')[0])
			{
				Effect.Queues.get('expander').each(function(fx){
					fx.cancel();
				});
			}

			if(toggled == 1)	// Expanded
			{
				new Effect.Parallel([
					new Effect.Morph($(expander), {
						style: {
							width: '274px'
						}
					}),
					new Effect.Morph($(title), {
						style: {
							paddingLeft: '0'
						}
					})
				], {
					mode: 'absolute',
					duration: 0.5,
					beforeStart: function(){
						$(expander).removeClassName('expanded');
					},
					afterFinish: function(){
						toggled = 0;
					},
					queue: {
						position: 'end',
						scope: 'expander',
						limit: 2
					}
				});
			}
			else if(toggled == 0)	// Collapsed
			{
				new Effect.Parallel([
					new Effect.Morph($(expander), {
						style: {
							width: '874px'
						}
					}),
					new Effect.Morph($(title), {
						style: {
							paddingLeft: '600px'
						}
					})
				], {
					mode: 'absolute',
					duration: 0.5,
					afterFinish: function(){
						toggled = 1;
						$(expander).addClassName('expanded');
					},
					queue: {
						position: 'end',
						scope: 'expander',
						limit: 2
					}
				});
			}
		});
	}*/
	
	
	/*
	 *		SHOW, THEN FADE NOTIFICATION ABOUT A PRODUCT BEING ADDED TO CART
	 */
	
	if($('product-added'))
	{
		var notifier = $('product-added');
		if(notifier.getStyle('display') == 'block')
		{
			new Effect.Morph($(notifier), {
				style: {
					opacity: '0.0'
				},
				duration: 0.8,
				delay: 2.0,
				afterFinish: function(){
					$(notifier).setStyle({ 'display': 'none' });
				}
			});
		}
	}
	
	
	/*
	 *		TOGGLE CART
	 */
	
	if($('cart'))
	{
		var cart = $('cart');
		var cartTriggers = $$('.show-cart');
		var cartClose = $('close-cart');
		var overlay = $('light-overlay');
		var cartHeight = (eval($('wrap').offsetHeight) - 222);
		var cartContentHeight = eval($('cart-lines').offsetHeight);
		$('cart').setStyle({
			'display': 'none',
			'visibility': 'visible'
		});
		
		if(cartHeight < cartContentHeight)
			cartHeight = cartContentHeight;
		var show = 0;
		
		cartTriggers.each(function(cartTrigger)
		{
			Event.observe($(cartTrigger), 'click', function()
			{
				if(show == 0)
				{
					new Effect.Appear($(overlay), {
						beforeStart: function(){
							show = 1;
							$(overlay).setStyle({
								'top': '172px',
								'height': cartHeight + 'px'
							});
						},
						duration: 0.4,
						afterFinish: function(){
							new Effect.Appear($(cart), {
								beforeStart: function(){
									$(cart).setStyle({
										'height': cartHeight + 'px'
									});
								},
								duration: 0.8
							});
						}
					});
				}
			});
		});
		
		Event.observe($(cartClose), 'click', function()
		{
			new Effect.Fade($(cart), {
				beforeStart: function(){
					show = 0;
				},
				duration: 0.4,
				afterFinish: function(){
					new Effect.Fade($(overlay), {
						duration: 0.2
					});
				}
			});
		});
	}
	
	
	/*
	 *		SET CATEGORY RESTRICTION TO JAMAX SEARCH
	 */
	
	if($('jamax-search'))
	{
		var JamaxSearch = $('jamax-search');
		var JamaxSearchCategoryRestrictor = $$('#' + JamaxSearch.id + ' input')[1];
		var JamaxSubMenu = $('jamax-subcats');
		var JamaxSubMenuItems = $$('#' + JamaxSubMenu.id + ' li a');
		
		JamaxSubMenuItems.each(function(item)
		{
			Event.observe(item, 'click', function()
			{
				$$('#jamax-subcats .active')[0].className = '';
				$(item.up()).className = 'active';
				var rel = $(item).getAttribute('rel');
				JamaxSearchCategoryRestrictor.setAttribute('value', rel);
			});
		});
	}
	
	/*if($('productSearch'))
	{
		if($('productSearchCategory'))
			var catValueContainer = $('productSearchCategory');
		var catBtnElements = $$('a.catElement');
		var currentActive = 0;
		if(catBtnElements.length > 0)
			catBtnElements.each(function(btn, index)
			{
				if($($(btn).parentNode).hasClassName('active'))
				{
					$(catValueContainer).setAttribute('value', $(btn).getAttribute('rel'));
					currentActive = index;
				}
				$(btn).observe('click', function()
				{
					$($(catBtnElements[currentActive]).parentNode).removeClassName('active');
					$($(this).parentNode).addClassName('active');
					$(catValueContainer).setAttribute('value', $(this).getAttribute('rel'));
					currentActive = catBtnElements.indexOf(this);
				});
			});
	}*/
});