// JavaScript Document
// yazan : ismail kaplan
// 05.02.2011
	$(document).ready(function(){

			$("#writebtn").click(function(){

				$("#write").slideToggle('slow');

			});
					$('body').append('<div id="foooter" style="position:absolute;left:0;bottom:0;z-index:-2;width:100%;height:235px"></div> <div id="palyaco" style="position:absolute;right:0;bottom:0;z-index:101"><img src="design/palyaco.png" width="179" height="221" /></div>');
					$('#foooter').css({'top':$(document).height()-235+'px'});
					$('#palyaco').css({'top':$(document).height()-221+'px','left':($(document).width()/2)+390+'px'});


			var motionControl = false; // otomatik olarak kayıtlar arasında ilerleme kontrolü


				var obj = $('.list li') ;
				var bigObj = $('#picture-slider img');
				
				$('.list li').eq(0).addClass('selected');
					
			var z = 0;
			
			slideshow();

			function slideshow(){		
				var toplam = obj.length - 1;
				setInterval(function(){
					
					if(!motionControl){ // Eğer slide işlemi durmuş halde değilse
					
					if(z==toplam){	
						obj.removeClass('selected');	
						
						bigObj.animate({opacity:0},300,function(){
							$(this).attr("src",obj.eq(0).attr("bgpic"))
								   .animate({opacity:1},300,'easein');
							obj.eq(0).addClass('selected');
						});
						
						z = -1;
					}else{
				
						obj.removeClass('selected');	

						 bigObj.animate({opacity:0},300,function(){
							 $(this).attr("src",obj.eq(z).attr("bgpic"))
									.animate({opacity:1},300,'easein');
									$(this).css({'z-index':'-100'});
	
							obj.eq(z).addClass('selected');
						});
					} // if kapanır
					z=z+1;
							 } // if motionkontrol için
					},8000); // interval kapanır
				
				} // function kapanır


			bigObj.hover(function(){
					motionControl = true; // slide dursun.
				},function(){
					motionControl = false; // slide kaldığı yerden devam etsin.
				});

			obj.hover(function(){
					motionControl = true; // slide dursun.
				},function(){
					motionControl = false; // slide kaldığı yerden devam etsin.
				});


			obj.click(function(){
				
				obj.removeClass('selected');	
				var resim = $(this).attr('bgpic');
				var sira = obj.index($(this))
				
					bigObj.animate({opacity:0},200,function(){
						  bigObj.attr("src",resim)
								.animate({opacity:1},200,'easein');
										 
						  obj.eq(sira).addClass('selected');
						  $('.selected').animate({opacity:1},100,'linear');
						  });	
					z = sira;
							$('#slides').animate({'left':'0px'},400,'easeout');	
							$('#slidebuton').css({'background-position':'0px 0px'});					
		 	});     


	});



