function openWindow() {
  window.open("","image",'titlebar=0,toolbar=0,status=0,menubar=0,location=0,scrollbars=1,width=600,height=400,resizable=1,top=20,left=20')
}
function setWindow(width, height){
  window.resizeTo(width, height)
}
function checkEmailById(mailId){
	var el = document.getElementById(mailId);
	if (el == null || el == undefined)
		return true;
	return checkEmail(el.value);
}
function checkEmail(mail){
			var re = new RegExp('(^[\\w\\.-]+@(([\\w-]+[\\.])+[a-zA-Z]{2,})$)');
			var m = re.test(mail);
			if (!m)
			{
				alert("Email "+mail+" is not valid!");
			}
			return m;
}

function sendMailToFriend(button)
{
	var valid = true;
	if (!checkEmailById('sendMailYourEmail'))
	{
		$('#sendMailYourEmail').addClass('invalid');
		valid = false;
	}
	if (!checkEmailById('sendMailEmail'))
	{
		$('#sendMailEmail').addClass('invalid');
		valid = false;
	}

	if (!valid) return;
	
	$.ajax({url:"sendMail.php",
		data: {name: $('#sendMailName').val(), youremail: $('#sendMailYourEmail').val(), email: $('#sendMailEmail').val(), captcha: $('#sendMailCaptchaCode').val(), url: $('#sendMailUrl').val()},
		async: false,
		cache: false,
		dataType: "json",
		success: function(data) {
			$('#sendMail .captcha').attr('src', 'txt2img.php?time=' + (new Date()).getTime());
			$('#sendMailCaptchaCode').val('');
			if (!data.success) {
				alert ('spatny kod');
				return;
			}
			alert ('Geschickt');
			$('#sendMail').slideToggle();
		}
	});
}

	ContentFlowGlobal.setAddOnConf("slideshow", {duration: 5000, startOnLoad: true, showControlls: false});
	if ($('newTitlesFlow').length > 0)
		window.newTitlesFlow = new ContentFlow('newTitlesFlow', { scrollWheelSpeed: 0, circularFlow: true, scaleFactor: 1.25 });

	$(document).ready(function(){
		$('ul.jcarousel').each(function(index, el){
			if ($(el).children().length > 4) {
				$(el).addClass('jcarousel-skin-tango');
				$(el).jcarousel({ start: 1, scroll:1, auto: 12, wrap: "both", animation: "slow"});
			}
		});

		$('.facebook_zalozka').bind('click', function(){
			$('.twitter_widget').css('display','none');
			var el = $('.facebook_widget')
			if (el.css('display') == 'none')
				el.show('slide',{},'slow');
			else
				el.hide('slide');
		});
		$('.twitter_zalozka').bind('click', function(){
			$('.facebook_widget').css('display','none');
			var el = $('.twitter_widget');
			if (el.css('display') == 'none')
				el.show('slide',{},'slow');
			else
				el.hide('slide');
		});
		$('.widget .close').bind('click', function(){
			$(this).parents('.widget').hide('slide');
		});
	});

/* plugin facebook like button starts */
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/cs_CZ/all.js#xfbml=1&appId=167393613344839";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
/* plugin facebook like button ends */

/* plugin facebook starts */
		$(function(){
			$('#fb_wall').fbWall({
				id:'residenzverlag',
				accessToken:'206158599425293|be9ec626f3574fe8166f861f.1-1656935031|xBGaGnMuezjONDY_nlg8C_56D4E',
				showGuestEntries:true,
				showComments:true,
				max:3,
				timeConversion:24
			});
		});
/* plugin facebook ends */

/* plugin tweeter starts */
     jQuery(function($){
         $(".tweet").tweet({
             username: "ResidenzVerlag",
             join_text: "auto",
             avatar_size: 32,
             count: 4,
             auto_join_text_default: "we said,", 
             auto_join_text_ed: "we",
             auto_join_text_ing: "we were",
             auto_join_text_reply: "we replied to",
             auto_join_text_url: "we were checking out",
             loading_text: "loading tweets..."
         });
     });
/* plugin tweeter ends */

switchCalendar = function(elem, year, month) {
	$.ajax({url:"ajaxCalendar.php?year="+year+"&month="+month,
		async: false,
		cache: true,
		success: function(data) {
			$(elem).parents('.calendar').html(data);
		}
	});
}

