// JavaScript Document
function search_control() {
	var txt_search = document.SiteSearch.site_search.value ;
	if(txt_search.length<3 || txt_search=="" ||  txt_search=="Site içi arama") {
	alert("Lütfen en az 3 harften oluşan bir kelime giriniz!");
	document.SiteSearch.site_search.focus();
	return false;
	} else return true;
}
function search_clear() {
	var txt_search = document.SiteSearch.site_search ;
	txt_search.value = "";
}


$(document).ready(function(){
	setTimer();
				/*HUMAN INTERACT*/
				$("#slider-navig").animate({"opacity":0.80}, "fast");
				$(".slide-text").animate({"opacity":0.90}, "fast");
				
				$(".slide").not(":first").hide();
				$("#slider-navig a:eq(0)").css("background", "#4F84C6");
				$("#slider-navig a:eq(0)").css("color", "#FFF");

				$("#slider-navig a").mouseover(function() {
					var index = $("#slider-navig a").index(this);
					

					$(".slide").hide();
					$(".slide:eq(" + index + ")").show();

					//$(".slide-hook").css("color", "white");
					//$(".slide-hook").css("background", "#4F84C6");
					$("#slider-navig a").css("background", "#000");
					$(this).css("background", "#4F84C6");
					$(this).css("color", "#FFF");
					
					clearTimer(timer);
					
				});
				$("#slider-navig a").mouseout(function() {
					clearTimer(timer);
					setTimer();
					$(this).css("background", "#000");
					$(this).css("color", "#FFF");
					
				})
				/*AUTOSCROLL*/
				
				function setTimer() {
					timer = window.setInterval(rotate, 3000);
				}
				function clearTimer(timer) {
					window.clearInterval(timer);
					
				}
				
				//dr
				function rotate() {
					
					var cur_slide = $(".slide:visible");
					var ls_slide = $(".slide:last");
					var fr_slide = $(".slide:first");
					
					
					
					//alert(cur_slide.index());
					if(cur_slide.html() != ls_slide.html()) {
						//cur_slide.animate({"opacity":0}, "fast");
						//
						
						cur_slide.fadeOut("100",function() {
														 var index2 = $(this).index();
														//alert(Math.ceil(index2-2));
														$("#slider-navig a").css("background", "#000");
														$("#slider-navig a:eq(" + Math.ceil(index2) + ")").css("background", "#4F84C6");
														$("#slider-navig a:eq(" + Math.ceil(index2) + ")").css("color", "#FFF");
														//alert($(this).get());
														// $("#slider-navig a:eq(" + 2 + ")").css("background", "#4F84C6");
														// $("#slider-navig a:eq(" + index(this) + ")");
														  cur_slide.next(".slide").fadeIn("100");
														  });
						
						
						//alert(cur_slide.index());
						
						//$(this).css("color", "#FFF");
						
						
	
					} else {
						cur_slide.fadeOut("100",function() {
														 $("#slider-navig a").css("background", "#000");
														 $("#slider-navig a:eq(0)").css("background", "#4F84C6");
														 $("#slider-navig a:eq(0)").css("color", "#FFF");
														 fr_slide.fadeIn("100");
														 
														 });
						
					}
				}
	/*MANSET BEGIN*/
	
	/*MANSET END*/
	
	
	
	
	$.ajaxSetup ({     
				 // Disable caching of AJAX responses     
				 cache: false 
				 });
	$('#canli_obj').click(function () {
									

		
		$("#live_content").load('canli_yayin.inc.php?lang=<?=$SITE_LANG?>&page=<?=createRandomAlfanumericCode(16,2);?>');
		
		$(this).everyTime(5000, function() {
    		//alert("test");
			$("#live_content").load('canli_yayin.inc.php?lang=<?=$SITE_LANG?>&page=<?=createRandomAlfanumericCode(16,2);?>');

  		});
		
	});
	$("#live_content").ajaxStart(function(){

		$(this).html('<span class="loading" style="color:#ffffff;font-size:12px"><img src="images/loading.gif" width="32" height="32" />&nbsp;Loading...</span>');
		

	});
		
	$('#mac_prg').click(function () { 
									
		$('#canli_obj').stopTime();
		$("#live_content").load('mac_program2.inc.php');
	});
	
	$('#mac_sonuc').click(function () { 
									
		$('#canli_obj').stopTime();
		$("#live_content").load('mac_sonuc.inc.php');
	});
	
	
	
	
	
	$('#nivoSlider3').nivoSlider({
        effect:'fade', // Specify sets like: 'fold,fade,sliceDown'
        slices:15, // For slice animations
        boxCols: 1, // For box animations
        boxRows: 1, // For box animations
        animSpeed:1, // Slide transition speed
        pauseTime:3000, // How long each slide will show
        startSlide:0, // Set starting Slide (0 index)
        directionNav:true, // Next & Prev navigation
        directionNavHide:true, // Only show on hover
        controlNav:true, // 1,2,3... navigation
        controlNavThumbs:false, // Use thumbnails for Control Nav
        controlNavThumbsFromRel:true, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
        keyboardNav:true, // Use left & right arrows
        pauseOnHover:true, // Stop animation while hovering
        manualAdvance:false, // Force manual transitions
        captionOpacity:0.9, // Universal caption opacity
        prevText: '&laquo;', // Prev directionNav text
        nextText: '&raquo;', // Next directionNav text
        beforeChange: function(){}, // Triggers before a slide transition
        afterChange: function(){}, // Triggers after a slide transition
        slideshowEnd: function(){}, // Triggers after all slides have been shown
        lastSlide: function(){}, // Triggers when last slide is shown
        afterLoad: function(){} // Triggers when slider has loaded
    });
	
	
	
	
	$("#adv1_t1").click(function () { 
			
			$("#adv1_ul").css('background', 'url(images/fikstur_tab_menu_bg2.png)');
	
			
			
	});
	$("#adv1_t2").click(function () { 
								  
			$("#adv1_ul").css('background', 'url(images/fikstur_tab_menu_bg1.png)');								   
	});
	
	
});
