//Home Style 1 Carousel Callback
function mycarousel_initCallback(carousel) {
    jQuery('.slider1 .nav a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
	});
}

//Home Style 1 Carousel Callback
function mycarousel_itemFirstInCallback(carousel, item, idx, state) {
	jQuery('.slider1 .nav a').removeClass('active');
	jQuery('.slider1 .nav a').eq(idx-1).addClass('active');
	
}

//Project Carousel Callback
function mycarousel2_initCallback(carousel) {   
    jQuery('.project-slider-nav ul li').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval($(this).index()+1));
        return false;
    });
}

function mycarousel3_initCallback(carousel) {
	jQuery('.slider2-nav .next, .project-slider-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('.slider2-nav .prev, .project-slider-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
}

function mycarousel3_itemFirstInCallback(carousel, item, idx, state) {
	jQuery('.slider2-nav ul li a').removeClass('active');
	jQuery('.slider2-nav ul li a').eq(idx-1).addClass('active');
	
}

//Fade function
function fader($items_to_click, $items_to_fade) {	
	var $item = $($items_to_fade);
	$($items_to_click).each(function(i){
		$(this).click(function(){	
			$new_item = $item.filter(":eq("+i+")");
			if( $new_item.css("display") == "none" ){
				$item.filter(":visible").fadeOut(400, function(){
					var $new_item_idx = $new_item.index();
					jQuery('.slider2-nav .content ul li a').removeClass('active');
					jQuery('.slider2-nav .content ul li a').eq($new_item_idx).addClass('active');
					$new_item.fadeIn(400);
				});
			}
			return false;
		});
	});
}


function initMenu() {
  jQuery('.sol_kolon .root ul').hide();
  jQuery('.sol_kolon .root ul:first').show();
  jQuery('.sol_kolon .root li a').click(
    function() {
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        return false;
        }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
        $('.sol_kolon .root ul:visible').slideUp('normal');
        checkElement.slideDown('normal');
        return false;
        }
      }
    );
  }
  
//Center function
jQuery.fn.center = function(loaded) {
    var obj = this;
    body_width = parseInt($(window).width());
    body_height = parseInt($(window).height());
    block_width = parseInt(obj.width());
    block_height = parseInt(obj.height());
    
    left_position = parseInt((body_width/2) - (block_width/2)  + $(window).scrollLeft());
    if (body_width<block_width) { left_position = 0 + $(window).scrollLeft(); };
    
    top_position = parseInt((body_height/2) - (block_height/2) + $(window).scrollTop());
    if (body_height<block_height) { top_position = 0 + $(window).scrollTop(); };
    
    if(!loaded) {
        
        obj.css({'position': 'absolute'});
        obj.css({ 'top': top_position, 'left': left_position });
        $(window).bind('resize', function() { 
            obj.center(!loaded);
        });
        $(window).bind('scroll', function() { 
            obj.center(!loaded);
        });
        
    } else {
        obj.stop();
        obj.css({'position': 'absolute'});
        obj.animate({ 'top': top_position, 'left': left_position }, 200, 'linear');
    }
}

jQuery(function(){
	
	//PNG Fix For IE6
	if($.browser.msie && $.browser.version.substr(0,1) == 6){
		DD_belatedPNG.fix('.slider-btn, .slider-btn:hover, #screen, .login-t, .login-b, .login-cnt')
	}
	
	
	
	$('.login-link').click(function(){
		var h = $( 'body' ).height() > $( window ).height() ? $( 'body' ).height() : $( window ).height();
		$('#screen').css({ 'height': h });	
		$('#screen').show();
		$('.login').center();
		$('.login').fadeIn();
		return false;
	});
	
	//Navigation
	$('#navigation ul li, #navigation ul li .dd ul li').hover(function(){
		$(this).find('.dd:eq(0)').toggle();
		$(this).find('a:eq(0)').toggleClass('hover');
	});

	
	//Home Style 2 Fader
	fader(".slider2-nav .content ul li a",".fader li");
	
	//Home Style 2 Carousel Nav
	$('.slider2-nav .content ul').jcarousel({
		wrap: "last",
		scroll: 1,
		visible: 3,
		initCallback: mycarousel3_initCallback,
        buttonNextHTML: null,
        buttonPrevHTML: null
	});
	
	//Project Slider
	$('.project-slider ul').jcarousel({
		wrap: "last",
		scroll: 1,
		visible: 1,
		initCallback: mycarousel2_initCallback,
        buttonNextHTML: null,
        buttonPrevHTML: null
	});
	
	//Project Slider Nav
	$('.project-slider-nav ul').jcarousel({
		wrap: "last",
		scroll: 1,
		visible: 5,
		initCallback: mycarousel3_initCallback,
        buttonNextHTML: null,
        buttonPrevHTML: null
	});
	
	$.easing['BounceEaseOut'] = function(p, t, b, c, d) {
	if ((t/=d) < (1/2.75)) {
		return c*(7.5625*t*t) + b;
	} else if (t < (2/2.75)) {
		return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
	} else if (t < (2.5/2.75)) {
		return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
	} else {
		return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
	}
};
	
	 $('#ucretsizilan').jcarousel({
        vertical:true,
        wrap: "last",
        scroll:1,
        easing: 'BounceEaseOut',
        animation: 1000,
        auto:2
    });
	
	initMenu();
	clearInput('.temiz');
	$("#flash").scrollable({circular: true, mousewheel: true}).navigator().autoscroll({
		interval: 5000
	});
	
	jQuery( "#SonIhaleTarihi" ).datepicker();
		jQuery( "#tarih1" ).datepicker();
		jQuery( "#tarih2" ).datepicker();
	
});




