// JavaScript Document
	$(document).ready(function(){

		var mrg = ($(window).height() - $('#container').height()) / 2;		
		
		if(mrg<0){
				mrgn = 0;
		}else{
			mrgn = mrg;
		}
		$('#container').css('marginTop',mrgn + 'px');		


			$('#altmenu ul li:last').css({'display':'none'});
			
			var motionControl = false; // otomatik olarak kayıtlar arasında ilerleme kontrolü

				$('.list').animate({'opacity':0},50,'linear');
				$('.list').delay(200).animate({'marginBottom':'25px','opacity':1},400,'linear');

				var obj = $('.list li') ;
				var bigObj = $('#genel img');
				
				$('.list li').eq(0).addClass('selected');
				
					$('#slidebuton').animate({'opacity':0},100,'linear');
				//	$(document).pngFix();
					
					$('#slides').css({'left':'0px'});	
					$('#slides').delay(1500).animate({'left':'-460px'},400,'easeout');	
					
			   		$('#logo').toggle(function(){
							$('#slides').animate({'left':'0px'},400,'easeout');	
							$('#slidebuton').css({'background-position':'0px 0px'});
						},function(){
							$('#slides').animate({'left':'-460px'},400,'easeout');								
							$('#slidebuton').css({'background-position':'30px 0px'});							
							});

			   		$('#slides').toggle(function(){
							$('#slides').animate({'left':'0px'},400,'easeout');	
							$('#slidebuton').css({'background-position':'0px 0px'});							
						},function(){
							$('#slides').animate({'left':'-460px'},400,'easeout');		
							$('#slidebuton').css({'background-position':'30px 0px'});							
							
						});
					
					$('#slides').hover(function(){
							$('#slidebuton').animate({'opacity':1},400,'linear');												
						},function(){
							$('#slidebuton').animate({'opacity':0},400,'linear');												
						});




			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');
	
							obj.eq(z).addClass('selected');
						});
					} // if kapanır
					z=z+1;
							 } // if motionkontrol için
					},8000); // interval kapanır
				
				} // function kapanır


			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'});					
		 	});     

			
			$('#up').hover(function(){
									ismail = setInterval(yukari,100);
									
									},function(){
										clearInterval(ismail);
										});

			$('#down').hover(function(){
									
									ismail1 = setInterval(asagi,100);
									
									},function(){
										clearInterval(ismail1);
									
									});

				$('#up1').hover(function(){
									ismail = setInterval(yukari1,100);
									
									},function(){
										clearInterval(ismail);
										});

			$('#down1').hover(function(){
									
									ismail1 = setInterval(asagi1,100);
									
									},function(){
										clearInterval(ismail1);
									
									});
			
			
			
			

			


	});

					function yukari(){
							var topumuz = $('#bilgiler').css('top');
								if(topumuz<'0px'){
									$('#bilgiler').animate({'top':'+=10px'},100,'easeout');												
								/*}else{
									return false;*/
								}
						}

					function asagi(){
							var bottomumuz = -($('#bilgiler').height()-250)+'px';
							var topumuz = $('#bilgiler').css('top');							
							if(topumuz=='auto'){
								topumuz = '-1px';
							}else{
								topumuz = topumuz;
							}	
							
							if(parseFloat(topumuz)>parseFloat(bottomumuz)){							
								$('#bilgiler').animate({'top':'-=10px'},100,'easeout');												
							}else{
								return false;
							}
						}
						


					function yukari1(){
							var topumuz = $('#bilgiler-bottom').css('top');
								if(topumuz<'0px'){
									$('#bilgiler-bottom').animate({'top':'+=10px'},100,'easeout');												
								/*}else{
									return false;*/
								}
						}

					function asagi1(){
							var bottomumuz = -($('#bilgiler-bottom').height()-50)+'px';
							var topumuz = $('#bilgiler-bottom').css('top');							
							if(topumuz=='auto'){
								topumuz = '-1px';
							}else{
								topumuz = topumuz;
							}	
							
							if(parseFloat(topumuz)>parseFloat(bottomumuz)){							
								$('#bilgiler-bottom').animate({'top':'-=10px'},100,'easeout');												
							}else{
								return false;
							}
						}


	$(window).resize(function() {
		var mrg1 = ($(window).height() - $('#container').height()) / 2;		
		
		if(mrg1<0){
				mrgn1 = 0;
		}else{
			mrgn1 = mrg1;
		}
							  
	//	$('#container').css('left', ($(window).width() - $('#container').width()) / 2+$(window).scrollLeft() + 'px');
		$('#container').css('marginTop',mrgn1 + 'px');		  
	});

	$(window).scroll(function() {
		var mrg2 = ($(window).height() - $('#container').height()) / 2;		
		
		if(mrg2<0){
				mrgn2 = 0;
		}else{
			mrgn2 = mrg2;
		}
											  
		$('#container').css('marginTop',mrgn2 + 'px');	
	});

