
	var isModernBrowser = document.createElement('canvas').getContext;
	
	//slider bekleme zamanı
	var slideTime = 3000;
	var animSpeed = 800;
	
	//bant images bekleme zamanı
	var bantImagesSlideTime = 3000;
	
	//news slider bekleme zamanı
	var  newsSlideTime = 3000;
	var newsSlideSpeed = 1000;
	
	
	//******************* FONT REPLACEMENT
	//********************************************************
	
	//Cufon Font Replacement			
	Cufon.replace('h2, h3, h4, .styled-form form label' , { hover: true,fontFamily: 'Myriad Pro Bold Condensed' }); 
	//baslik icinde light yazilar
	Cufon.replace('h2 span, h3 span, h4 span' , { hover: isModernBrowser, fontFamily: 'Myriad Pro Condensed' }); 
	//baslik icinde bold yazilar
	Cufon.replace('h2 b, h3 b, h4 b' , { hover: isModernBrowser, fontFamily: 'Myriad Pro Bold' });
	
	//nav menu links
	Cufon.replace('#nav a' , { hover: true,fontFamily: 'Myriad Pro Bold Condensed' }); 
	
	//slider captions
	Cufon.replace('.nivo-caption h5' , { hover: false, fontFamily: 'Myriad Pro Condensed', textShadow: '#555 -1px -1px' });
	Cufon.replace('.nivo-caption h5 b' , { hover: false, fontFamily: 'Myriad Pro Bold Condensed', textShadow: '#555 -1px -1px' });
	
	if(isModernBrowser) {
		Cufon.replace('div.kroki-big div.desc h5, div.kroki-big div.desc h6' , { hover: true,fontFamily: 'Myriad Pro Bold Condensed' }); 
		}
	
	//******************* FONT REPLACEMENT
	//********************************************************
	
	
	
	var activateHoverEffect = false;
	var handleOversize = "drag";
	
$(function() {
		
		if($('.gallery').length) {
			handleOversize = "resize";
			}
		 
		 //*************************************
		 // LIGTHBOX
		 if($('a[rel^=shadowbox]').length) {
			 Shadowbox.init({
				handleOversize: handleOversize,
				modal: true,
				counterType: 'skip',
				displayCounter: false,
				overlayColor: '#c17230',
				viewportPadding:40
			});
		 }
		 //*************************************
		 
		 
		 //*************************************
		 // KROKİ HTML LIGTHBOX
		 $('ul.kroki-wrap li a').click(function() {
				 Shadowbox.open({
					player:     "html",
					title:      $(this).attr("title"),
					content:    $(this).siblings('div.kroki-big-wrap').html(),
					height:     600,
					width:      900
				});
				if(isModernBrowser) { setTimeout('Cufon.refresh()',1200); }
			 });
		 //*************************************
		 
		 
		 
		 
		 //*************************************
		 // BANT IMAGES
		 $('#bant-images ul li:first').addClass('selected');
		 
		 makeScrollable("#bant-images", "#bant-images ul");
		 playBant();
		 
		 //hoverda durdur
		 $('#bant-images ul').hover(function() {
			 clearInterval(play);
			 },function() {
				 playBant();
				 });
		 
		 //subeler adress animation
		 
		 $('#bant-images ul li').hover(function() {
			 	hideAdress($('#bant-images ul li'));
			 	showAdress($(this));
			 },function() {
				 hideAdress($(this));
				 });
		 
		 //*************************************
		 
		 
		 
		 //*************************************
		 // MENUS HOVER
		 //$('div#menus').hover(function() {
//			 $(this).find('div').stop().animate({ top:'-=10' },200,'');
//			 },function() {
//				 $(this).find('div').stop().animate({ top:'+=10' },400,'');
//				 });
		 //*************************************
		  
		 
		 
		 //*************************************
		 // SCROLLABLE CONTENT
		 $("#scroll-wrap .scrollable").scrollable({ vertical: true, mousewheel: true, easing:'easeOutExpo',speed:600 });
		 //*************************************
		 
		 
		 
		 //*************************************
		 // GALLERY HOVER
		 $('ul.gallery li').hover(function() {
			 $(this).siblings().stop().fadeTo(350,0.3);
			 }, function() {
				 $(this).siblings().stop().fadeTo(400,1);
				 });
		 //*************************************
		 
		 $('ul.kroki-wrap li, div.menus a').hover(function() {
				 if(activateHoverEffect) {
					$(this).siblings().stop().fadeTo(350,0.3);
				 }
			 }, function() {
				 	if(activateHoverEffect) {
				 		$(this).siblings().stop().fadeTo(400,1);
					}
				 });
		
		
		//*************************************
		//validation
		if($('.validateForm').length) {
			$('.validateForm').each(function() {
					$(this).validate();
				});
			
		}
		//*************************************
		
		
		//*************************************
		//input watermark
		$(".watermark").each(function (i) {
				$(this).watermark($(this).attr('title'), {className: "watermark",useNative: false});	
        });
		//*************************************
		
		
		
		 //*************************************
		 // STYLED RADIOS
		 if($('.radio').length) {
		 	$(".radio").dgStyle();
		 }
		 //*************************************
		
		
		
		//**********************************
		//TABLE STYLING
		$('table tbody tr:even').addClass('alt');
		//**********************************
		
		
		 
		
	
	});// end doc load
	
	
	
	
	
	window.onload = function() {
			
			//*************************************
			// NEWS SLIDER
			$("#news").slideDown();
			$("#news .scrollable").scrollable({ vertical: true, mousewheel: true, circular:true, easing:'easeOutBack', speed:newsSlideSpeed }).autoscroll({ autoplay: true, interval : newsSlideTime});
			//*************************************
			
			
			//*************************************
			// KROKI PAGE ANIMATIONS
			if($('ul.kroki-wrap').length) {
				//$("ul.kroki-wrap li").animate({ margin:20 },700,'easeOutBounce');
				activateHoverEffect = true;
			}
			//*************************************
			
			
			//*************************************
			// MENUS PAGE ANIMATIONS
			if($('div.menus').length) {
				$("div#content-top div.menus a#menu01").animate({ top:60 },700,'easeOutExpo');
				$("div#content-top div.menus a#menu01b").animate({ top:220 },800,'easeOutExpo');
				
				$("div#content-top div.menus a#menu02").delay(300).animate({ top:100 },900,'easeOutExpo');
				$("div#content-top div.menus a#menu02b").delay(300).animate({ top:220 },900,'easeOutExpo');
				
				$("div#content-top div.menus a#menu03").delay(500).animate({ top:140 },900,'easeOutExpo');
				$("div#content-top div.menus a#menu03b").delay(500).animate({ top:170 },900,'easeOutExpo');
				
				$("div#content-top div.menus a#menu04").delay(900).animate({ top:296 },900,'easeOutExpo');
				$("div#content-top div.menus a#menu04b").delay(900).animate({ top:326 },900,'easeOutExpo', function(){ activateHoverEffect=true; } );
			}
			//*************************************
			
			
			//Logo Flip Animation
			if(isModernBrowser) {
				$('div#news #logo').fadeIn(2000);
				setTimeout('flipLogo()',animSpeed);
			} else {
				$('div#news #logo').show();
			}
			
			
			//menu animation
			//$('div#menus #menu1').delay(500).animate({ top:67 },800,'easeOutBack');
//			$('div#menus #menu2').delay(800).animate({ top:46 },700,'easeOutBack');
//			$('div#menus #menu3').delay(1100).animate({ top:10 },600,'easeOutBack');
//			$('div#menus #menu4').delay(1000).animate({ top:84 },600,'easeOutBack');
//			if(isModernBrowser) {
//				$('div#menus h3').delay(1500).fadeIn(1200);	
//			} else {
//				$('div#menus h3').show();	
//			}
			
			// logo animation
			if(isModernBrowser) {
				$('#logo').animate({ left:0 },1600,'easeOutExpo');
			} else {
				$('#logo').css( "left", 0 );
			}	
			
			// nav menu animation
			//$('#nav').delay(300).animate({ right:0 },2600,'easeOutExpo');
			
			// face link animation
			$('#face').delay(2000).animate({ bottom:65 },2500,'easeOutBounce');
			
			// newsletter form animation
			$('#newsletter').delay(2500).fadeIn(1000);
			
			// logo animation
			$('#slider').fadeIn(2000);
			
			
			var slideAni = isModernBrowser ? 'sliceDown' : 'fade';
			//MAIN SLIDER	
			//**********************************
			if($('#slider').length) {
				$('#slider').nivoSlider({
					effect:slideAni, // Specify sets like: 'fold,fade,sliceDown'
					slices:15, // For slice animations
					boxCols: 4, // For box animations
					boxRows: 3, // For box animations
					animSpeed:animSpeed, // Slide transition speed
					pauseTime:slideTime, // How long each slide will show
					startSlide:0, // Set starting Slide (0 index)
					directionNav:true, // Next & Prev navigation
					directionNavHide:false, // Only show on hover
					controlNav:false, // 1,2,3... navigation
					controlNavThumbs:false, // Use thumbnails for Control Nav
					keyboardNav:true, // Use left & right arrows
					pauseOnHover:true, // Stop animation while hovering
					manualAdvance:false, // Force manual transitions
					captionOpacity:1,
					prevText: '', // Prev directionNav text
					nextText: '',
					customChange: function(){ Cufon.refresh(); }
				});
			}
			//MAIN SLIDER	
			//**********************************
			
		};//end window.onload	
		
		
		
		
		
		
		//FUNCTIONS
		//*****************************************************************

		//Logo Flip Function
		function flipLogo() {
				
				$('div#news #logo').rotate3Di('-=360', 2000, {direction: 'clockwise',easing:'easeOutExpo',completed:setTimeout('flipLogo()', slideTime ) });
			}
		
		
		// BANT IMAGES
		//**********************************
		var play = null;
		function playBant() {
				play = setInterval(function(){
					scrollToImage();
				} ,bantImagesSlideTime)
			}
		
		function scrollToImage() {
			 	var index = $('#bant-images ul li.selected').index();
				var total = $('#bant-images ul li').length;
				var dif = $('#bant-images').hasClass('branches') ? 1 : 4;
				var scrollTop = $('#bant-images').hasClass('branches') ? (index)*115 : (index+1)*115;
				
				if(total - index > dif) {
					$('#bant-images').stop().animate({ scrollTop:scrollTop },800,'easeOutBack');
					$('#bant-images ul li').removeClass('selected').eq(index+1).addClass('selected');
				} else {
					$('#bant-images').stop().animate({ scrollTop:0 },1800,'easeOutExpo');
					$('#bant-images ul li').removeClass('selected').eq(0).addClass('selected');	
				}
				hideAdress($('#bant-images ul li'));
				showAdress($('#bant-images ul li.selected'));
				
		 }
		 
		function showAdress(li) {
			li.find('div').stop(true,true).animate({ left:155});
			}
		function hideAdress(li) {
			li.find('div').stop(true,true).animate({ left:0});
			}
		
		function makeScrollable(wrapper, scrollable){
			// Get jQuery elements
			var wrapper = $(wrapper), scrollable = $(scrollable);
			
			// Hide images until they are not loaded
			scrollable.hide();
			var loading = $('<div class="loading"></div>').appendTo(wrapper);
			
			// Set function that will check if all images are loaded
			var interval = setInterval(function(){
				var images = scrollable.find('img');
				var completed = 0;
				
				// Counts number of images that are succesfully loaded
				images.each(function(){
					if (this.complete) completed++;	
				});
				
				if (completed == images.length){
					clearInterval(interval);
					// Timeout added to fix problem with Chrome
					setTimeout(function(){
						
						loading.hide();
						// Remove scrollbars	
						wrapper.css({overflow: 'hidden'});						
						
						scrollable.slideDown(1000, function(){
							enable();
							showAdress($('#bant-images ul li:first'));	
						});					
					}, 100);	
				}
			}, 100);
		
		function enable(){			
			// height of area at the top at bottom, that don't respond to mousemove
			var inactiveMargin = 100;
			// Cache for performance
			var wrapperWidth = wrapper.width();
			var wrapperHeight = wrapper.height();
			// Using outer height to include padding too
			var scrollableHeight = scrollable.outerHeight() + 2*inactiveMargin;
			// Do not cache wrapperOffset, because it can change when user resizes window
			// We could use onresize event, but it's just not worth doing that 
			// var wrapperOffset = wrapper.offset();
			
			//When user move mouse over menu			
			wrapper.mousemove(function(e){
				var wrapperOffset = wrapper.offset();
				// Scroll menu
				var top = (e.pageY -  wrapperOffset.top) * (scrollableHeight - wrapperHeight) / wrapperHeight - inactiveMargin;	
				
				if (top < 0){
					top = 0;
				}
				
				wrapper.stop().animate({scrollTop:top},300,'easeOutCirc');
			});		
		}
	}
	// BANT IMAGES
	//**********************************

		
		
		
		

		
		
		
		
