$(document).ready(function(){
	$('a[rel*=external]').click( function() {
    window.open(this.href);
    return false;
  });

	// CYCLE
	$('.top').cycle();
	
	
	// ==== TOOL TIPS ====
	$('.TT').tooltip({showURL: false});
	$('.person-hint').tooltip({showURL: false, track: true, delay: 200, left: -34, fade: 200, bodyHandler: function() { return $('#'+$(this).attr("rel")).html(); }});

	$('.slideshow').cycle();
	
	$('.notarget').click(function() {
		return false;
	});
	

	$('#galeria-lista a').click(function() {
		$('#main-photo img').attr('src',$(this).attr('href'));
		$('#galeria-lista a').each(function() {
			$(this).removeClass('activePhoto');
		});
		$(this).addClass('activePhoto');
		return false;
	});
	
	swfobject.embedSWF("flash/flash.swf",
		"home-flash", "940", "336", "9.0.0",
		"flash/expressInstall.swf", {}, { wmode: 'transparent' }, {});
		

	Cufon.replace("#side-nav a, .osoby .osoba-box h3 a, .osoby .osoba-box .position", { hover: true, fontFamily: "Dax" });
	Cufon.replace("#nav > li > a", { fontFamily: "Dax", textShadow: "1px 1px #212122" });
	Cufon.replace(".schedule-menu a, .schedule2 th", { fontFamily: "DaxMedium", textShadow: "1px 1px #9a6a0d" });
	Cufon.replace(".header h1, .contact .box .header h2, .sidebar .inner h2, .top3 .place, .schedule2 .hour-label .hour-box span", { fontFamily: "DaxMedium" });
	Cufon.replace(".hp .box .header h2",{ fontFamily: "Dax" });
	
	
	$(function (){
 
		//facebook widget

		$(".social").hover(function(){

				$(this).stop(true, false).animate({right:"0"},"medium");

		},function(){

				$(this).stop(true, false).animate({right:"-205"},"medium");

		},500);

		return false;

	});// ==== COLOR BOX ====
	$("a[rel='lightbox']").colorbox({opacity: 0.85, loop: true});
	$("a[rel='youtube']").colorbox({iframe:true, innerWidth:425, innerHeight:344,	opacity: 0.85});
	/*
	// ==== DYNAMIC LABELS ====
	$("#contact-form .div").each(function(){
		var TITLE = $('label',this).html();
		
		var VALUE = $('input[type=text]',this).attr('value');
			if (VALUE == '')
				$('input[type=text]',this).attr('value',TITLE);
			
			var VALUE = $('textarea',this).html();
			if (VALUE == '')
				$('textarea',this).html(TITLE);
	});

	
	$("#contact-form input[type=text], #contact-form textarea").each(function(){
			var this1 = $(this).parent('.div');
			var thisf = $(this);
			if (thisf.get(0).tagName == "INPUT") {
				var fieldVal = this1.children('label').html();
				
				if (thisf.val() == '') {
					thisf.val(fieldVal);
				}
				thisf.focus(function() { if (thisf.val() == fieldVal) thisf.val(''); })
				.blur(function() { if (thisf.val()=='') thisf.val(fieldVal); });

			}
			if (thisf.get(0).tagName == "TEXTAREA") {
				var fieldVal = this1.children('label').html();
				if (thisf.html() == '') {
					thisf.html(fieldVal);
				}
				thisf.focus(function() { if (thisf.html() == fieldVal) thisf.html(''); })
				.blur(function() { if (thisf.html()=='') thisf.html(fieldVal); });
			}
	});
	
	$("#contact-form form").submit(function() {
		$("#contact-form .div").each(function(){
			var TITLE = $('label',this).html();
			
			var VALUE = $('input[type=text]',this).attr('value');
			if (VALUE == TITLE)
				$('input[type=text]',this).attr('value','');
			
			var VALUE = $('textarea',this).html();
			if (VALUE == TITLE)
				$('textarea',this).html('');
		});
		return true;
	});
*/

		var currentTime = new Date()
		var month = currentTime.getMonth() + 1
		var day = currentTime.getDate()
		var year = currentTime.getFullYear()



		$('#RFData').datePicker({
			horizontalOffset: 28,
			startDate: day+'.'+month+'.'+year
			});

	/*
	// ==== DYNAMIC LABELS ====
	$("#contact-form .div").each(function(){
		var TITLE = $('label',this).html();
		
		var VALUE = $('input[type=text]',this).attr('value');
			if (VALUE == '')
				$('input[type=text]',this).attr('value',TITLE);
			
			var VALUE = $('textarea',this).html();
			if (VALUE == '')
				$('textarea',this).html(TITLE);
	});

	
	$("#contact-form input[type=text], #contact-form textarea").each(function(){
			var this1 = $(this).parent('.div');
			var thisf = $(this);
			if (thisf.get(0).tagName == "INPUT") {
				var fieldVal = this1.children('label').html();
				
				if (thisf.val() == '') {
					thisf.val(fieldVal);
				}
				thisf.focus(function() { if (thisf.val() == fieldVal) thisf.val(''); })
				.blur(function() { if (thisf.val()=='') thisf.val(fieldVal); });

			}
			if (thisf.get(0).tagName == "TEXTAREA") {
				var fieldVal = this1.children('label').html();
				if (thisf.html() == '') {
					thisf.html(fieldVal);
				}
				thisf.focus(function() { if (thisf.html() == fieldVal) thisf.html(''); })
				.blur(function() { if (thisf.html()=='') thisf.html(fieldVal); });
			}
	});
	
	$("#contact-form form").submit(function() {
		$("#contact-form .div").each(function(){
			var TITLE = $('label',this).html();
			
			var VALUE = $('input[type=text]',this).attr('value');
			if (VALUE == TITLE)
				$('input[type=text]',this).attr('value','');
			
			var VALUE = $('textarea',this).html();
			if (VALUE == TITLE)
				$('textarea',this).html('');
		});
		return true;
	});
*/



// ==== CAPTCHA ====
	$('#captcha_image').click(function() {
		var random_value = new Math.random(9999);
		$('#captcha_image').attr('src','./captcha.png?random='+random_value);
		$('#CFCaptcha').attr('value','');
		$('#CFCaptcha').focus();

		return false;
	});


});
