var current = new Array();
var maximum = new Array();
function cCarousel(idName,ename,step,visible,liSize,carousel_height){
	
	current[ename] = 0;
	maximum[ename] = $('#'+idName+' ul li').size(); 
	
	var speed = 700; 
	//var liSize = 90;
	//var carousel_height = 335;

	var ulSize = liSize * maximum[ename];   
	var divSize = liSize * visible;  

	$('#'+idName+'').css("width", divSize+"px").css("height", carousel_height+"px").css("visibility", "visible").css("overflow", "hidden").css("position", "relative");
	$('#'+idName+' ul').css("width", ulSize+"px").css("left", -(current[ename] * liSize)).css("position", "absolute").css('padding',0);
	$('#'+idName+' ul li').css('float','left');

	$('.prev-'+idName).click(function() { 
		if(current[ename] - step < 0 || current[ename] - step > maximum[ename] - visible) {return;}
		else {
			current[ename] = current[ename] - step;
			$('#'+idName+' ul').animate({left: -(liSize * current[ename])}, speed, null);
		}
		return false;
	});

	$('.next-'+idName).click(function() { 
		if(current[ename] + step < 0 || current[ename] + step > maximum[ename] - visible) {
			current[ename] = 0;
			$('#'+idName+' ul').animate({left:0},speed*2,null);
			return; 
		}else {
			current[ename] = current[ename] + step;
			$('#'+idName+' ul').animate({left: -(liSize * current[ename])}, speed, null);
		}
		return false;
	});
}

//Logos'u otomatik başlatan fonksiyon.
function autoStartLogos(){
	$('.next-logos').trigger('click');
};

$(document).ready(function(){
	Cufon.replace('#slider_right h2', { fontFamily: 'Myriad Pro Regular', hover: true }); 
	Cufon.replace('.one,.two,.three,.four,.five,.six,.ms-title h2,.title,.title2', { fontFamily: 'Myriad Pro Condensed', hover: true }); 
	Cufon.replace('.adress h1', { fontFamily: 'Myriad Pro Bold Condensed', hover: true }); 
	$('.one a,.two a,.three a,.four a,.five a,.six a,.ms-title h2,.title,.title2,.prev-slider,.next-slider,#content').fadeIn().css('display','block');
	$('.cozum-colons li:eq(3)').css({'float':'right','width':'960px','margin-right':'0'}); // Çözümler sayfasının alttaki kısmının IE 7 ve 8 için fixler.
	
	//Setinterval ile 4 sn 'de bir değiştiren kısım.
	var carouselTimeLogos = setInterval("autoStartLogos()",2000);
	
	//cCarousel('slider',0,1,1,960,340);
	cCarousel('logos',1,1,5,130,140);
	
	var bth = $('#big_title > h1').height();
	$('span.dt').css('margin-top',bth-16);
	
	//SAYFADAKI TABLARIN KODLARI
	//When page loads...
	$('.tab_content').find('div.tabs_text').each(function(i,item){
		var tabelement = $(item);
		var currentHtml = tabelement.html();
		tabelement.html('');
		
		tabelement.append('<div class="scrollbar"><div class="track"><div class="thumb"><div class="end"></div></div></div></div>');
		tabelement.append('<div class="viewport"><div class="overview"></div></div>');
		tabelement.find('.viewport .overview').html(currentHtml);
		
	});
	
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("tabs_active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content

	$('.tab_content:first').find('.tabs_text').tinyscrollbar();
	//On Click Event
	$("ul.tabs li").click(function() {
		var tabs_activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the tabs_active tab + content
		
		if($(tabs_activeTab).is(':hidden')){
			$("ul.tabs li").removeClass("tabs_active"); //Remove any "tabs_active" class
			$(this).addClass("tabs_active"); //Add "tabs_active" class to selected tab
			$(".tab_content").slideUp(); //Hide all tab content

			$(tabs_activeTab).slideDown(); //Fade in the tabs_active ID content
			$(tabs_activeTab).find('div.tabs_text').tinyscrollbar();
			
			return false;
		}
	});
	
});
