//

jQuery(window).resize(function(){
	// image slider auto width
	jQuery('#slideImage').each(function() {	
		var sliderWidth = jQuery(document).width();
		jQuery('.slides_container, .slides_container div, .slides_container div img').width(sliderWidth);
	});
});

jQuery(document).ready(function() {
	jQuery('#slideImage').slides({
		preload: true,
		preloadImage: '../images/loading.gif',
		effect: 'slide',
		slideSpeed: 1000,
		generateNextPrev: false,
		generatePagination: false,
		paginationClass: 'slideCategory',
		play: 10000
	});

	jQuery('#sliderNews').slides({
		preload: true,
		preloadImage: '../images/loading.gif',
		effect: 'fade',
		slideSpeed: 1000,
		generateNextPrev: true,
		generatePagination: true,
		play: 10000,
		container: 'slides_container_news',
		paginationClass: 'sliderNewsPagination'
	});

	jQuery('#sliderCommer').slides({
		preload: true,
		preloadImage: '../images/loading.gif',
		effect: 'slide',
		slideSpeed: 1000,
		generateNextPrev: false,
		generatePagination: true,
		play: 10000,
		container: 'slides_container_commer',
		paginationClass: 'sliderCommerPagination'
	});
	
	var cnt= jQuery('#mainPage .slideCategory li a').size();
	for (x=0; x < cnt; x++){
		jQuery('#mainPage .slideCategory li a').eq(x).text(x+1);
	}
	
	// image slider auto width
	jQuery('#slideImage').each(function() {	
		var sliderWidth = jQuery(document).width();
		jQuery('.slides_container, .slides_container div, .slides_container div img').width(sliderWidth);
	});
	
	// ---------------**************----------------------
	// animate slider buttons left to right  ___ESKI
	
	/*
	var i = false;
	
	jQuery(".slideCategory li a", this).hover(function(){
		jQuery(this).stop().animate({width:'250px'},250);
		jQuery(this).css('background-color','#f2f2f2');
	},function(){
		jQuery(this).animate({width:'66px'},250);
		jQuery(this).css('background-color','transparent');
	});
		
	if(i!=true) {
		jQuery(".slideCategory li a").click(function() {
			//jQuery(this).delay(800);
			//jQuery(".slideCategory li.current a").css('background-color','transparent');
			//jQuery(".slideCategory li.current a").css('width','66px');
		});
	}
	
	*/
	
	///////////////////////////////////////
	
	/*
	
	var i = true;
	//var isCurrent;
	
	jQuery(".slideCategory li a").hover(function(){
		jQuery(this).stop().animate({width:'250px'},250);
		jQuery(this).css('background-color','#f2f2f2');
		//jQuery(this).css('width','250px');
		//isCurrent = jQuery(this).parent().hasClass('current');
		//i = true;
	},function(){
		//jQuery(this).delay(500);
		if(i==true) {
			//if(isCurrent==false) {
				jQuery(this).animate({width:'50px'},250);
			//}
		} else if(i==false) {
			jQuery(this).animate({width:'66px'},250); 
			jQuery(this).css('background-color','transparent');
		}
			
			
		//jQuery(".slideCategory li").css('width','50px !important');
		//jQuery(".slideCategory li.current a").css('background-color','transparent');		
	});
	
	jQuery(".slideCategory li a").click(function(){
		i = false;
		jQuery(this).delay(100000);
		//jQuery(this).animate({width:'66px'},250);
		jQuery(this).css('width','66px');
		jQuery(this).css('background-color','transparent');
	});
	
	*/
	// ---------------****** ESKI___END ********----------------------
	
	
	
	// ---------------**************----------------------
	// animate slider buttons left to right ___YENI
	var i;
	var isCurrent;
	
	jQuery(".slideCategory li a").hover(function(){
		jQuery(this).show();
		jQuery(this).parent().find('.activeBtn').hide();
		
		jQuery(this).stop().animate({width:'250px'},250);
		jQuery(this).css('background-color','#f2f2f2');
		//jQuery(this).css('width','250px !important');
		isCurrent = jQuery(this).parent().hasClass('current'); // returns FALSE
		i = true;
	},function(){
		//jQuery(this).delay(500);
		if(i==true) { // eger hover olayi gerceklesiyorsa
			if(isCurrent==false) { // eger tiklandigi anda CURRENT degil ise
				jQuery(this).animate({width:'50px'},250);
			}
			else if(isCurrent==true) { // eger tiklandigi anda CURRENT ise
				jQuery(this).css('background-color','#f2f2f2');
				jQuery(this).animate({width:'66px'},250,function() { jQuery(this).css('background-color','transparent'); });
				//jQuery(this).css('background-color','transparent');
			}
		} else if(i==false) { // eger click olayi gerceklesiyorsa
			jQuery(this).animate({width:'66px'},250,function() { jQuery(this).css('background-color','transparent'); });
			//jQuery(this).css('background-color','transparent');
			// transparan yerine img yi show yap
			//jQuery(this).hide();
			//jQuery(this).parent().find('.activeBtn').show();
		}
	});
	
	jQuery(".slideCategory li a").click(function(){
		i = false;
		isCurrent = jQuery(this).parent().hasClass('current'); // returns TRUE
		jQuery(this).delay(1500);
		jQuery(this).animate({width:'66px'},250,function() { jQuery(this).css('background-color','transparent'); });
		//jQuery(this).css('width','66px');
		//jQuery(this).css('background-color','transparent');
	});
	
	//jQuery(".slideCategory li.current a").addClass('widthImp');
	//jQuery(".slideCategory li a").addClass('width');
	
	// ---------------******** YENI __END ******----------------------
	
	
	
	// slider news pagination add " / 5"
	//var newsCount = jQuery('.slides_container_news').children().length;
	jQuery('.sliderNewsPagination li a').append(' / 5');
	
	// newsletter input
	jQuery('.e-bulten-input').click(function() {
		if (this.value == this.defaultValue) {this.value = '';}
	});
	jQuery('.e-bulten-input').blur(function() {
		if (this.value == '') {
			this.value = this.defaultValue;
		}
	});
	
	// search area show/hide
	jQuery('#searchArea').hide();
	jQuery('#search, #searchArea').mouseenter(function() {
		jQuery('#searchArea').show();
	}).mouseleave(function() {
		jQuery('#searchArea').hide();
	});
	
	// search input
	jQuery('.search-input').click(function() {
		if (this.value == this.defaultValue) {this.value = '';}
	});
	jQuery('.search-input').blur(function() {
		if (this.value == '') {
			this.value = this.defaultValue;
		}
	});

});

