
$(document).ready(function() {
	initMenu();
	correctImageSpace();
	drawImageSubscription();
});

function initMenu() {

	if ($('#contentHome').length > 0) {
		$('#contentBox').css('width', '970px');
	}

	$('.lnkMM').mouseover(function() {
		if ($(this).parent().hasClass('last')) {
			$(this).parent().addClass('lastsel');
		}
		else {
			$(this).parent().addClass('sel');
		}
	});
	$('.lnkMM').mouseout(function() {
		if ($(this).parent().hasClass('last')) {
			$(this).parent().removeClass('lastsel');
		}
		else {
			$(this).parent().removeClass('sel');
		}
	});

	if ($('#submenuBox').length > 0) {

		$('#submenuBox').insertBefore($('#contentLft'));

		$('.lnkSM').each(function() {
			if ($(this).parent().height() == 36) {
				$(this).parent().addClass('sel36');
				$(this).addClass('lnkSM36');
				$(this).removeClass('lnkSM');
			}
			else if ($(this).parent().height() == 54) {
				$(this).addClass('lnkSM54');
				$(this).removeClass('lnkSM');
			}
		});

		$('.lnkSMSel').each(function() {
			if ($(this).height() == 36) {
				$(this).addClass('lnkSMSel36');
				$(this).removeClass('lnkSMSel');
			}
			else if ($(this).height() == 54) {
				$(this).addClass('lnkSMSel54');
				$(this).removeClass('lnkSMSel');
			}
		});

		$('.lnkSM, .lnkSM36, .lnkSM54').mouseover(function() {
			if ($(this).parent().height() == 36) {
				$(this).parent().addClass('sel36');
			}
			else if ($(this).parent().height() == 54) {
				$(this).parent().addClass('sel54');
			}
			else {
				$(this).parent().addClass('sel');
			}
		});
		$('.lnkSM, .lnkSM36, .lnkSM54').mouseout(function() {
			if ($(this).parent().height() == 36) {
				$(this).parent().removeClass('sel36');
			}
			else if ($(this).parent().height() == 54) {
				$(this).parent().removeClass('sel54');
			}
			else {
				$(this).parent().removeClass('sel');
			}
		});
	}
}

function correctImageSpace() {

	$('.csc-textpic-image').each(function() {

		if ($(this).children().length == 1) {
			$(this).find('img').css('margin-bottom', '27px');
		}
	});
}

function drawImageSubscription() {

	$('.csc-textpic-caption').each(function() {

		$(this).css('width', ($(this).width() + 2) + 'px');

		var sSubscription = $(this).text();

		$(this).text('');
		$(this).append('<div class="imgSubLft"></div><div class="imgSub">' + sSubscription + '</div>');
	});
}

