$(document).ready(function(){
	$('#studentWorksImages').cycle({
		before: function(){
			$('#studentWorks span.author').html($('img', this).attr('alt'));
		}
	});
	$('form.mailform').ajaxForm({ 
			dataType	: 'json', 
			success		: mailformProcessJson,
			data		: {json : 1}  
	});
	$('div.diskografie:odd').each(function (i){
		if(i%2 == 1)	{
			$(this).css('width', 'auto').css('margin-right', 0);
		}
	});
	$('#content div.fotogalerie').vjustify();
	$('a.blank').bind('click', function (){
		return !(window.open(this.href));
	});
	$('#content table tr:odd').addClass('odd');
	$('#content table tr td:nth-child(1)').addClass('first');
	$('#content table tr td:last-child').addClass('last');	
});

	$(document).ready(function(){
		$("div.photos ul a").addClass("thickbox");
		$("div.photos ul a").attr("rel", "gall");
		//$('#eshopItemDetail div.itemImg a').addClass("thickbox");
		TB_init();
		//$('#eshopItemsList div.eshopItem').vjustify();						
	});

function mailformProcessJson(data) { 
	$('form.mailform div.messageBox').remove();
	$('form.mailform').prepend('<div class="messageBox"></div>');
	var messageBox = $('form.mailform div.messageBox');

    if(data.errorMessage && data.errorMessage.length > 0)	{
    	messageBox.addClass('error');
    	mailformProcessMessages('error', messageBox, data.errorMessage);    	
    } else {
    	messageBox.addClass('ok');
		mailformProcessMessages('ok', messageBox, data.okMessage);
    }

    var bgrColor = messageBox.css('background-color');
    messageBox.animate({backgroundColor: '#ffff88'}, 50).animate({backgroundColor: bgrColor}, 3000);
}

function mailformProcessMessages(style, box, messages) {
	box.append('<ul></ul>');
	jQuery.each(messages, function() {
		$('ul', box).append('<li>' + this + '</li>');
	});

	if(style == 'ok')	{
		$('form.mailform').resetForm();
	}
}

