if (typeof window.console === 'undefined') {
	window.console = {
		log: function () {
			void(0);
		}
	};
}

jQuery(function($) {
	var currContentHeight = 0;
	var maxContentHeight = 0;
	var currTitleHeight = 0;
	var maxTitleHeight = 0;
	var rowLeveler = $('.rowLeveler');
	rowLeveler.each(function() {
		var titleLeveler = $(this).find('.titleLeveler');
		titleLeveler.each(function() {
			currTitleHeight = $(this).height();
			//console.log(this, 'title height:', currTitleHeight, 'px');
			if (currTitleHeight > maxTitleHeight) {
				maxTitleHeight = currTitleHeight;
			}
		});
		titleLeveler.height(maxTitleHeight);
		//console.log('Setting all above objects\' title height to:', maxTitleHeight, 'px');
		currTitleHeight = 0;
		maxTitleHeight = 0;
		
		var contentLeveler = $(this).find('.contentLeveler');
		contentLeveler.each(function() {
			currContentHeight = $(this).height();
			//console.log(this, 'content height:', currContentHeight, 'px');
			if (currContentHeight > maxContentHeight) {
				maxContentHeight = currContentHeight;
			}
		});
		contentLeveler.height(maxContentHeight);
		//console.log('Setting all above objects\' content height to:', maxContentHeight, 'px');
		currContentHeight = 0;
		maxContentHeight = 0;
	});
	
	/*$('input:text')
		.hint()
	;*/
	
	$('.target_blank')
		.attr('target', '_blank')
	;
	
	$('.submitCheck')
		.attr('value', '1')
	;
	
	$('a.inputButton')
		.click(function() {
			$(this)
				.parents('form')
					.submit()
			;
		})
	;
	
	var freecapCode = $('#freecapCode');
	freecapCode
		.click(function () {
			var src = $(this).attr('src');
			var pos = src.lastIndexOf('?');
			if (pos === -1) {
			    pos = src.length;
			}
			src = src.substring(0, pos);
			$(this)
				.attr('src', src + '?' + Math.round(Math.random() * 9999999999));
		})
	;
	
	$('#cycle')
		.cycle({ 
			fx: 'custom',
			cssBefore: {
				left: 175,
				top:  132,
				width: 0,
				height: 0,
				opacity: 1,
				zIndex: 1
			},
			animOut: {
				opacity: 0
			},
			animIn: {
				left: 0,
				top: 0,
				width: 350,
				height: 263
			},
			cssAfter: {
				zIndex: 0
			},
			timeout: 6000,
			speed: 2000
		})
	;
	
	$('#content .addTextShower')
		.click(function(e) {
			$(this)
				.parents('p')
					.next('.additionalText')
						.slideToggle()
			;
			e
				.preventDefault()
			;
		})
	;
});