this.slideshow = function(){
	var imgs = $('.slideshow img');
	var current = 0;
	
	this.change = function(){
		setTimeout(function(){
			slideshow.animation();
		}, 3000);
	}
	
	this.animation = function(){
		$(imgs[current]).fadeOut();
			current++;
		if (current == imgs.length) {
			current = 0;
		}
		$(imgs[current]).fadeIn();
		slideshow.change();
	}
	
	return this.change();
}

$(document).ready(function(){
													 $('div.betonik a.access').click(function(e){
			e.preventDefault();
			popup('hizli-erisim');
		});
		
													 
													 
	$($('.banner img')[0]).css("opacity", 0);
	setTimeout(function(){
		$($('.banner img')[0]).animate({opacity: 1}, 1000);
	}, 200);
	slideshow = new slideshow();
});



function Window_Navigation_Cufon_Replace(){
	Cufon.replace('.scroll-pane h1, .scroll-pane h2', {fontFamily: 'Myriad Pro'});
	Cufon.replace('.inner ul.navigation li a', {fontFamily: 'Myriad Pro'});
	Cufon.replace('.windowlist h4', {fontFamily: 'Myriad Pro'});
}


$(document).ready(function() {
	

	$("#manufacture").fancybox({
	    'padding'           : 0,
       'autoScale'     	: false,
			 width: 730,
			 height: 430,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});
													 
			$('div.language div ul').hover(function(){
		$(this).parent().css('overflow', 'visible');
		$(this).parent().addClass('hover');
	}, function(){
		$(this).parent().css('overflow', 'hidden');
		$(this).parent().removeClass('hover');
	});
										 
													 
													 
									$("select").selectmenu({
				style: 'dropdown',
				maxHeight: 400
		});				 
						
var pageURL = new String(window.location);
pageURL = pageURL.replace(_HOST,'');
if (pageURL.length>0){
pageURL = pageURL[1];
pageURL = pageURL.replace(/\?(.+)/gi, '');

	

	$('.leftmenu a[href=/'+ pageURL +']').each(function(){

			$(this).parent().addClass('active');
	});
	
	}
						
						
			$('.referanslist table tr').each(function(){
				$(this).click(function(){
					window.location.href = $(this).find('a').attr('href');
				});
			});
			$('.referanslist table tr').hover(function(){ $(this).addClass('tablehover'); }, function(){ $(this).removeClass('tablehover'); })
			$('.referanslist table tr').hover(function(){ $(this).find('.last').addClass('lasthover'); }, function(){ $(this).find('.last').removeClass('lasthover'); })
			$('.referanslist table tr').hover(function(){ $(this).find('.first').addClass('firsthover'); }, function(){ $(this).find('.first').removeClass('firsthover'); })
									 
													 
													 
			$('.tesislertab ul li a').click(function(e){
			e.preventDefault();
			var get = $(this).attr('href');
			$(' .tesislertab ul li.current').removeClass('current');
			$(this).parent().addClass('current');
			$(' div.tabs div.current-tab').removeClass('current-tab');
			$(get).addClass('current-tab');
		});												 
													 

	$('div.left').css({height: $('div.main-inner').height()});
	
	$('a[name=modal]').click(function(e) {
		e.preventDefault();
		var id = $(this).attr('href');
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		$('#mask').fadeTo("fast",0.3);	
		var winH = $(window).height();
		var winW = $(window).width();
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
		$(id).css({display: 'block', opacity:0});
		$(id).find('#tabs li a').each(function(){
			$($(this).attr('href')).addClass('ui-tabs-hide');
		});
		
		var tabCur = $(id).find('#tabs li.current a');
			$(tabCur.attr('href')).removeClass('ui-tabs-hide');
			$(id).find('div.inner img.image').attr('src', tabCur.attr('image'));
		$(id).find('.scroll-pane').jScrollPane({scrollbarWidth:15});
		$(id).find('#tabs li a').click(function(){
			$(id).find('#tabs li').removeClass('current');
			
			$(id).find('#tabs li a').each(function(){
				$($(this).attr('href')).addClass('ui-tabs-hide');
			});
					
				$($(this).attr('href')).removeClass('ui-tabs-hide');
				$(this).parent().addClass('current');
				$(id).find('div.inner img.image').attr('src', $(this).attr('image'));
				Window_Navigation_Cufon_Replace();
			return false;
		});
		
		Window_Navigation_Cufon_Replace();
		$(id).animate({opacity:1}, 500);
	});
});



function popup(id){
	var id = '#' + id;
	
	var maskWidth = $(window).width();
	var maskHeight = $(document).height();
	
	$('#mask').css({width: maskWidth, height: maskHeight});
	$('#mask').fadeTo('fast', 0.5);
	$(id).fadeTo('slow', 1);
	
	var winW = $(window).width();
	var winH = $(window).height();
	
	$(id).css({left: (winW-$(id).width())/2, top: (winH-$(id).height())/2});
	$(id).find('.scroll-pane').jScrollPane({scrollbarWidth:15});
	$("#mask").click(function(){
		$('#mask').fadeTo('slow', 0, function(){
			$(this).css({display: 'none'});
			$(id).css({display: 'none'});
		});
		$(id).fadeTo('slow', 0);
	});
	$(id).find('.close').click(function(e){
		e.preventDefault();	
		$('#mask').fadeTo('slow', 0, function(){
			$(this).css({display: 'none'});
			$(id).css({display: 'none'});
		});
		$(id).fadeTo('slow', 0);
	});
	
	Window_Navigation_Cufon_Replace();
	
	
		$("a[rel=popupGallery]").fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'titlePosition' 	: 'over',
			'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Fotograf ' +  (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';
			}
		});


}


// band
		var _animateTime = 3500;
		var current = 1;
		function c_animate(){
			var num = $('li', $('#band')).length;
			$('ul', $('#band')).animate({top: -(34*current)}, function(){
				if (current == num){
					$('ul', $('#band')).css({top: 34});
					$('ul', $('#band')).animate({top: 0});
					current = 1;
				}else{
					current++;
				}
				
				setTimeout(c_animate, _animateTime);
			});
		}
		
  	$(function(){ setTimeout(c_animate, _animateTime); });
