$(document).ready(function()
{
	$(".map, .tour").fancybox({
		'centerOnScroll'	: true,
		'width'				: '100%',
		'height'			: '100%',
		'autoScale'			: false,
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'titleShow'			: false,
		'type'				: 'iframe'
	});

	$(".date-pick").datePicker();
 
	$("#mp3").jmp3(
	{
		filepath	: "sbin/song.mp3",
		backcolor	: "60210c",
		forecolor	: "e3d7c1",
		width		: 150,
		autoplay : "false"
	});

});

function init_search(word, ser)
{
	$(document).ready(function()
	{
		$("#search").focusout( function() { if ($("#search").val() == word) { $("#search").val(''); } else if ($("#search").val() == "") { $("#search").val(word); }; } );
		$("#search").focusin( function() { if ($("#search").val() == word) { $("#search").val(''); } else { $("#search").select(); }; } );
	});
}

function get_captcha(id)
{
	var timestamp = new Date().getTime();
	$('#'+id).attr('src', 'captcha.php?time='+timestamp);
}

function init_fancy(image)
{
	$(document).ready(function()
	{
		$("a[rel*='photos_group'], a[rel*='photos_group_m']").fancybox({
			'centerOnScroll'	: true,
			'cyclic'			: true,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'titlePosition' 	: 'over',
			'titleFormat'		: function(title, currentArray, currentIndex, currentOpts)
			{
				return '<' + 'span' + ' id="fancybox-title-over">'+ image + ' ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</' + 'span>';
			}
		});

		$('.flash-images').cycle({ 
			fx:     'fade', 
			speed:   5000,
			timeout: 2500,
			pager : '#flash-preview',
			pagerAnchorBuilder	: function(idx, slide)
			{
				return '<a href="#"><img src="' + slide.src + '" width="30" height="15" alt="' + image + ' ' + (idx+1) + '" title="' + image + ' ' + (idx+1) + '" /></a>'; 
			},
			before: function() {
        		   var title = $(this).attr('title');
        		   $('.image_title').html(title);
						 }
		});
	});
}

function init_weather(image)
{
	$(document).ready(function()
	{
		$(".weather").fancybox({
			'scrolling'			: 'no',
			'centerOnScroll'	: true,
			'width'				: 350,
			'height'			: 350,
			'autoScale'			: false,
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'titlePosition'		: 'inside',
			'type'				: 'iframe',
			'titleFormat'		: function()
			{
				return '<span id="fancybox-title-over">'+image+': <a href="http://www.eweather.gr" target="_blank" title="'+image+'">http://www.eweather.gr</a></span>';
			}
		});
	});
}

function select_property(id, table, name)
{
	$(document).ready(function()
	{
		$.get("classes/select.php", { 'table': table, 'name': name }, 
		function(data) { $("#"+id).html(data); });
	});
}

function toggle_div(id) { $(document).ready(function() { $('#' + id).slideToggle('fast'); }); }
