

//doc load
$(function() {
		
		
		//**********************************
		//MAIN SLIDER
		
		$('div#slider div').hide();
		
		
		// wait for the first slider image to be load before openning the door
		var interval = setInterval(function(){
		
		
			var images = $('div#slider div:first').find('img');
	
			
			images.each(function(i){
				
				if (this.complete) {
					clearInterval(interval);
					
					 $("div#slider div:first").fadeIn(1500,function() {
						 KapilarAcilsin(0,3000);
						 });
					}
					 
				});
			
		},200);
		
	
		$(".paging a:first").addClass("active");
		
		$('div#slider').hover(function() {
				
				//stop slider
				clearInterval(play);
				
			}, function(){

				clearInterval(play);
				
				//start slider
				rotateSwitch();
				
				});
		
		$(".paging a").click(function(){
				
				//stop slider and clear interval
				clearInterval(play);
				//reset timer
				
				
				$(this).siblings().removeClass('active');
				$(this).addClass('active');
				
				var div = $('div#slider div').eq($(this).index());
				div.siblings().fadeOut();
				div.fadeIn();
				
				//start slider
				rotateSwitch();
				
				
			});
		
		
		//Paging  and Slider Function
		rotate = function(){
			 var div = $('div#slider div').eq($active.index());
		
			 $(".paging a").removeClass('active'); //Remove all active class
			 $active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)
		
			 //Slider Animation
			 div.siblings().fadeOut();
			 div.fadeIn();
		
		}; 
		
		//Rotation  and Timing Event
		rotateSwitch = function(){
			 play = setInterval(function(){ //Set timer - this will repeat itself every 7 seconds
				  $active = $('.paging a.active').next(); //Move to the next paging
				  if ( $active.length === 0) { //If paging reaches the end...
						$active = $('.paging a:first'); //go back to first
				  }
				  rotate(); //Trigger the paging and slider function
			 }, 4000); //Timer speed in milliseconds
		};
		
		
		//MAIN SLIDER	
		//**********************************

		
		
		
		
		//KAPI
		//**********************************
		
		$('div.kapi-left,div.kapi-right ').click(function() {
				
				KapilarAcilsin(0,3000);
			
			});
		//**********************************
		
		
		
		
		
		//**********************************
		//Accordion Menu
		$('ul#menu li a').click(function() {
				
				//açık olan alt menüleri kapat.
				$(this).parent().siblings().find("ul").slideUp(300);
				$(this).parent().siblings().removeClass('selected');
				$(this).parent().siblings().find("a.active").removeClass('active');
				
				//alt menüsü varsa
				if($(this).parent().find('ul').length) {
					
					if($(this).parent().hasClass('selected')) {
						
						$(this).parent().removeClass('selected');
						$(this).removeClass('active');
						$(this).parent().find('ul:first').stop(true,true).hide(400);
						
					}
					else {
						
						$(this).addClass('active');
						$(this).parent().addClass('selected');
						$(this).parent().find('ul:first').stop(true,true).show(600);
							
					}
					return false;
				}
				
			});
			
		//açılı olan içerik sayfasının menüsü açık dursun...	
		$('ul#menu li.selected ul:first').show(800 , function() {
			
				$('ul#menu a.active').parent().find('ul').show(800);
			
			});
		
		
		//**********************************
		
		
		
		
		
		//**********************************
		//Search Box - iptall
		//$('div#search a').click(function() {
//			
//			if($('div#search').hasClass('active')) {
//				
//				
//				$('div#search').animate({
//				 width: 37
//			  }, 300, 'easeOutExpo', function() {
//				 $('div#search').removeClass('active');
//			  });
//			}
//			else { 
//			
//				$('div#search').addClass('active');
//				$('div#search').animate({
//					 width: 200
//				  }, 700,'easeOutExpo', function() {
//					 // Animation complete.
//				  });
//				
//			}
//			
//			  return false;
//			
//		});
		
		
		// header doc
		$('div#test-center a').hover(function() {
			
				$(this).stop().animate({ width: '337px'},700,'easeOutBack');
			
			},function() {
				
				$(this).stop().animate({ width: '100px'},500,'easeOutBack');
				
				});
		//**********************************
		
		
		
		
		//**********************************
		//input watermark
		$(".watermark").each(function (i) {
				$(this).watermark($(this).attr('title'), {className: "watermark",useNative: false});	
        });
		  //**********************************
		



		
		//**********************************	
		//Image Gallery Fancybox

			if($("div.galeri-images a").length) {	
				$("div.galeri-images a").fancybox();
			}

		//**********************************
		
		
		//**********************************	
		//Etkinlikler Fancybox

			if($("div.etkinlikler a").length) {	
				$("div.etkinlikler a").fancybox({hideOnContentClick:true});
			}

		//**********************************
		
		
		
		
		//**********************************	
		//Eczacı Videolar Fancybox

			if($("a.video").length) {	
				$("a.video").fancybox({hideOnContentClick:false, hideOnOverlayClick:false, padding:20, scrolling:'no', centerOnScroll:true});
			}

		//**********************************

		
		
		//**********************************	
		//TV Galeri links
		$('ul.tv-galeri li a').click(function() {
				
				$(this).parent().siblings().find('a').removeClass('selected');
				$(this).toggleClass('selected');
				
		});
		//**********************************
		
		
		//TABLE STYLING
		$('table.styled tbody tr:odd').addClass('alt');	
			
		
	});//end doc load
	
	
	
	
	
	
//****************************************************
//*******************FUNCTIONS
	
	
	
	//Açıl susam açıl!
	function KapilarAcilsin(gecikme,sure) {
		
		$('div.kapi-left').stop().delay(gecikme).animate({ left:-1000 },sure, function() {
					$(this).hide();
					
					
					//kapılar açılınca sliderlar başlasın...
					
					//main slider başla
					rotateSwitch(); //Run function on launch
					
					//**********************************
					//News Slider
					$(".scrollable").scrollable( {
							circular: true
						}).autoscroll({ autoplay: true, autopause:true });
					//**********************************
					
					
				});
				
				$('div.kapi-right').stop().delay(gecikme).animate({ right:-1000 },sure, function() {
					$(this).hide();
				});
			
	}
	
	
	
	
jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	easeInOutQuart: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158; 
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, 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;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
});

function callSacTesti(){
	window.open ("http://www.bioxcin.com.tr/bioxcinmerkez/v2/tr-TR/sactest.html","menubar=0,resizable=0,width=990,height=600");

}
