$(document).ready(function() {
	$('a').focus(function() { this.blur(); });
	$('input[type="submit"]').focus(function() { this.blur(); });
	initLinks();
	$('.cms_content table.cms').each(function() {
		initTables($(this), 'both');
	});
	$('.cms_content_left table.cms').each(function() {
		initTables($(this), 'left');
	});
	$('.cms_content_right table.cms').each(function() {
		initTables($(this), 'right');
	});
});

function initLinks() {
	$('a.cms span.cms_big').each(function() {
		var span = $(this);
		var a = span.parent();
		a.addClass('button');
	});
}

function initTables(tbl, dir) {
	var rows = tbl.find('tr').length;
	if (rows == 1) {
		var cols = tbl.find('td');
		if (cols.length == 2) {
			var lc = (cols[0].firstChild.nodeName.toLowerCase() == 'img')? 'img' : 'txt';
			var rc = (cols[1].firstChild.nodeName.toLowerCase() == 'img')? 'img' : 'txt';
			var str = lc + '_' + rc;
			switch(str) {
				case 'img_txt':
					if (dir != 'right') tbl.addClass('cc_links');
					break;
				case 'txt_img':
					if (dir != 'left') tbl.addClass('cc_rechts');
			}
		}
	}
}
