$(document).ready(function(){
	$('div.image img.news').wrap('<span class="titleImg"></span>');
	$('div.image img.fotogallery').wrap('<span class="titleImg"></span>');
	$('div.diskografie div.image a').wrap('<span class="titleImg"></span>');
	$('#deska div.image img.deska').wrap('<span class="titleImg"></span>');
	$('#content p img.left').wrap('<span class="titleImg left"></span>').removeAttr('style');
	$('#content p img.right').wrap('<span class="titleImg right"></span>').removeAttr('style');
	$('div.photos li a').wrap('<span class="titleImg"></span>');
	$('#vystoupeni table tbody tr:odd').addClass('odd');
	$('#vystoupeni table tbody tr:even').addClass('even');
	$('form.mailform').ajaxForm({ 
			dataType	: 'json', 
			success		: mailformProcessJson,
			data		: {json : 1}  
	});
	$('form.mailform2').ajaxForm({
			dataType	: 'json',
			success		: mailform2ProcessJson,
			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));
	});
});

	$(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();
	}
}
function mailform2ProcessJson(data) {
	$('form.mailform2 div.messageBox').remove();
	$('form.mailform2').prepend('<div class="messageBox"></div>');
	var messageBox = $('form.mailform2 div.messageBox');

    if(data.errorMessage && data.errorMessage.length > 0)	{
    	messageBox.addClass('error');
    	mailform2ProcessMessages('error', messageBox, data.errorMessage);
    } else {
    	messageBox.addClass('ok');
		mailform2ProcessMessages('ok', messageBox, data.okMessage);
    }

    var bgrColor = messageBox.css('background-color');
    messageBox.animate({backgroundColor: '#ffff88'}, 50).animate({backgroundColor: bgrColor}, 3000);
}

function mailform2ProcessMessages(style, box, messages) {
	box.append('<ul></ul>');
	jQuery.each(messages, function() {
		$('ul', box).append('<li>' + this + '</li>');
	});

	if(style == 'ok')	{
		$('form.mailform2').resetForm();
	}
}

