initTabSwitch = function (e) {
	tabsAnchors = $$('div.tabs li a');
	for (i=0,j=tabsAnchors.length;i<j;i++) {
		Element.observe(tabsAnchors[i],'click',clickTabSwitch);
		Element.observe(tabsAnchors[i],'mouseover',clickTabSwitch);
	}
}

clickTabSwitch = function (e) {
	Event.stop(e);
	clickedAnchor = Event.element(e);
	
	if (clickedAnchor.parentNode.className!='current') {
		$$('div.tabs li.current').each(function (oListItem) { oListItem.className='';});
		clickedAnchor.parentNode.className = 'current';
	}
}

initPricingTable = function (e) {
	tblPricing = $('pricing');
	if (!tblPricing) {
		return;
	}
	
	collapsePricingTable ('organization');
	collapsePricingTable ('website');
	
	decollapsePricingTable ('organization',1);
	decollapsePricingTable ('organization',5);
	decollapsePricingTable ('website',1);
	decollapsePricingTable ('website',2);
	decollapsePricingTable ('website',13);
	
	createMorePricingTable ('organization');
	createMorePricingTable ('website');
}

createMorePricingTable = function (colCategory) {
	tblRow = document.createElement('tr');
	tblCell1 = document.createElement('td');
	tblCell1.className = 'more';
	tblContent1 = document.createTextNode('...');
	tblContent23 = document.createTextNode('bekijk details');
	tblCell2 = tblCell1.cloneNode(true);
	
	tblCell1.appendChild(tblContent1);
	tblCell2.appendChild(tblContent23);
	
	tblCell3 = tblCell2.cloneNode(true);
	tblCell1.className = tblCell1.className + ' leftcol';
	

	
	tblRow.appendChild(tblCell1);
	tblRow.appendChild(tblCell2);
	tblRow.appendChild(tblCell3);
	
	Event.observe(tblCell1,'click',clickPricingTableMore);
	Event.observe(tblCell2,'click',clickPricingTableMore);
	Event.observe(tblCell3,'click',clickPricingTableMore);
	
	$$('#pricing tbody.'+colCategory).first().appendChild(tblRow);
}

collapsePricingTable = function (colCategory,number) {
	tblRows = $$('#pricing tbody.'+colCategory+' tr');
	if (number) {
		tblRows[number].style.display = 'none';
	} else {
		for (i=1,j=tblRows.length;i<j;i++) {
			tblRows[i].style.display = 'none';
		}
	}
}

decollapsePricingTable = function (colCategory,number) {
	tblRows = $$('#pricing tbody.'+colCategory+' tr');
	if (number) {
		tblRows[number].style.display = '';
	} else {
		for (i=1,j=tblRows.length;i<j;i++) {
			tblRows[i].style.display = '';
		}
	}
}

clickPricingTableMore = function (e) {
	colCategory = Event.findElement(e,'tbody').className;
	decollapsePricingTable(colCategory);
	el = Event.element(e);
	el.parentNode.parentNode.removeChild(el.parentNode);
}

document.observe('dom:loaded',initTabSwitch);
document.observe('dom:loaded',initPricingTable);