var slidetimer;
var yon=-1;

$(document).ready(function(){
	slidetimer=setTimeout('imageslider()',2000);
	var count=$('#imagesholder img').size();
	var $stool=$('#slidetoolbox');
	for (var i=1; i<=count; i++)
	{
		$stool.append("<a id=\"slidelink_"+i+"\" href=\"javascript:slideto("+i+")\">"+i+"</a>");
	}
	
	if ($('#tabs').size()>0)
	{
		$('#tabs').css('width',($('.otab').size()*640));
	}
	
	$(".colorbox").colorbox();
	$(".colorbox2").colorbox();
	$('#otelmarq').width($('.marq').size()*260);
	marqayar();

	$('#bolgelist').hover(function(){
		$(this).css('display','block'); $('#bolged').addClass('selected');
	},function()
	{
		$(this).css('display','none'); $('#bolged').removeClass('selected');
	});
});

function marqayar()
{
	var durationv=$('.marq').size()*2500;
	var ll=-($('#otelmarq').width()-1200);
	//$('#otelmarq').stop();
	yon=yon*-1;
	if (yon==1)
	{
		$('#otelmarq').animate({'left':ll},{
			duration:durationv,
			complete:function(){marqayar();}
		});
	}else
	{
		$('#otelmarq').animate({'left':0},{
			duration:durationv,
			complete:function(){marqayar();}
		});
	}
}

function imageslider()
{
	clearTimeout(slidetimer);
	if (($('#imagesholder').css('top').replace('px','')/1)<=-($('#imagesholder').height()-292))
	{
		$('#imagesholder').animate({'top':'0'},{complete:function(){slidetoolsayar()}});
		
	}else
	{
		var t=$('#imagesholder img:first').height();
		$('#imagesholder').animate({'top':'-='+t+'px'},{complete:function(){slidetoolsayar()}});
	}
	slidetimer=setTimeout('imageslider()',5000);
}

function slidetoolsayar()
{
	var t=$('#imagesholder img:first').height();
	var top=-($('#imagesholder').css('top').replace('px','')/t)+1;
	$('#slidetoolbox a').css('color','#fff');
	$('#slidelink_'+top).css('color','#000');
}


function slideto(i)
{
	clearTimeout(slidetimer);
	$('#imagesholder').stop();
	$('#imagesholder').animate({'top':-((i-1)*289)},{complete:function(){slidetoolsayar();}});
	slidetimer=setTimeout('imageslider()',5000);
}

function slidestop()
{
	clearTimeout(slidetimer);
}

function tabsel(to)
{
	to=to-1;
	to=-to*630;
	$('#tabs').stop();
	$('#tabs').animate({'left':to});
}

function gosterbolge(bolge)
{
	$.ajax({type:'GET',
	url:'otellist.php?bolge='+bolge,
	success:function(msg)
	{
		$('#oteller').html(msg);
	}
	});
}

function tarihsec(tarihler)
{
	tarihler=tarihler.split('-');
	tarih1=tarihler[0].split('.');
	tarih2=tarihler[1].split('.');

	$('#t1g').val((tarih1[1]/1)+"");
	$('#t1a').val(tarih1[0]);
	$('#t1y').val(tarih2[2]);

	$('#t2g').val((tarih2[1]/1)+"");
	$('#t2a').val(tarih2[0]);
	$('#t2y').val(tarih2[2]);
}

function mailat(text,konu)
{
	$.post("mailat.php", {'text': text, 'konu': konu } );
}

function tavsiyet()
{
	
}

function rezervet()
{
	var adsoyad=$('#adsoyad').val();
	var tel=$('#tel').val();
	var tarih1=$('#t1g').val()+'.'+$('#t1a').val()+'.'+$('#t1y').val();
	var tarih2=$('#t2g').val()+'.'+$('#t2a').val()+'.'+$('#t2y').val();
	var mail=$('#mail').val();
	var yetiskin=$('#yetiskin').val();
	var cocuk=$('#cocuk').val();
	var ekbilgi=$('#ekbilgi').val();


	var t="Ad Soyad: "+adsoyad+"\nMail: "+mail+"\nTel :"+tel+"\nGiriş Tarihi: "+tarih1+"\nÇıkış Tarihi: "+tarih2+"\nYetişkin: "+yetiskin+"\nÇocuk: "+cocuk+"\nEk Bilgi:"+ekbilgi;
	mailat(t,'Rezervasyon');

	$('#mailform').html("<strong style=\"padding:50px; font-size:12pt; display:block; text-align:center;\">Rezervasyon formunuz iletilmiştir, en kısa zamanda geri dönüş yapılacaktır...</strong>");
}