function rightPhotoGallery(catGalleryId){
	$(".immageMainRight div.activeCatGalleryId").slideUp().removeClass("activeCatGalleryId");
	$(".immageMainRight div").css("display","none");
	$(catGalleryId).slideDown().addClass("activeCatGalleryId");
	$(".galleryBottomLink a").removeClass("cnnRed");
	$(".galleryBottomLink a[href='"+$(catGalleryId).attr("id")+"']").addClass("cnnRed");	
}

function automaticGalleryChanger(){
	activeGalleryIndex = $(".immageMainRight div").index($(".immageMainRight div.activeCatGalleryId"));
	//t = setTimeout("automaticGalleryChanger()", 5000);
	if((activeGalleryIndex+1) >= ($(".immageMainRight div").length))
		rightPhotoGallery($(".immageMainRight div:eq(0)"));
	else
		rightPhotoGallery($(".immageMainRight div:eq("+activeGalleryIndex+")").next());
}

$(function(){
	$(".galleryBottomLink a").click(function(){
		findDiv = $(".immageMainRight div#"+$(this).attr("href"));
		rightPhotoGallery(findDiv);
		
		window.clearTimeout(t);
		
		
		return false;
	});
	
	var t = window.setTimeout("automaticGalleryChanger()", 3000);

    //Round
    $(".roundMe").corner("6px");    
    $(".roundTop").corner("top");
    $(".roundBottom").corner("bottom");
    $(".roundWFMap").corner("tr br bl")
    //Program Details
    $(".contentWithBorder").corner("bottom 10px");
	
	$("a").focus(function(){ 
		this.blur();
	});	
	
	/** Left Part Other Sections Scroller **/
		$(".sectionContainer").jCarouselLite({
			btnNext: ".sectionNext",
			btnPrev: ".sectionPrev",
			scroll: 3
		});			
	
	/** Right Part Video Scroller **/
		$(".videoList").jCarouselLite({
			btnNext: ".next",
			btnPrev: ".prev",
			scroll: 3
		});
		
		$(".prev").click(function(){				
			changeActiveIcon("prev",3);
		});
		
		$(".next").click(function(){
			changeActiveIcon("next",3);
		});
		
		var activeIcon = 1;
		function changeActiveIcon(event, total){
			if(event == "next")
				activeIcon = activeIcon+1;
			else
				activeIcon = activeIcon-1;
			
			if(activeIcon == (total+1)){
				activeIcon = 1;
			}else if(activeIcon == 0){
				activeIcon = total;
			}
			$(".active").removeClass("active");
			$("#orderNum_"+activeIcon).addClass("active");
		}
		
	/** SelectBox Category Openers **/
		checkOpacityContainerClass = $(".categoryBoxOpacity").hasClass("openDiv");
		if(checkOpacityContainerClass)
			$(".categoryBoxOpacity").removeClass("openDiv").addClass("closeDiv")
			
		$(".categoryOpener").click(function(){
			var parentTag = $(this).parent().attr("class");
			//alert(parentTag)
			defPro = $("."+parentTag+" .categoryBoxOpacity").css("display");
			newDisplay = (defPro == "none" ? "block" : "none");
			$("."+parentTag+" .categoryBoxOpacity").css("display", newDisplay);
			$("."+parentTag+" .categoryBoxOpacity").addClass("activeBoxOpen");
			$("."+parentTag+" .categoryBoxOpacity").css("zIndex","999");
		});
		
		$(".categoryOpener2").click(function(){
			var parentTag = $(this).parent().attr("class");
			//alert(parentTag)
			defPro = $("."+parentTag+" .categoryBoxOpacity2").css("display");
			newDisplay = (defPro == "none" ? "block" : "none");
			$("."+parentTag+" .categoryBoxOpacity2").css("display", newDisplay);
			$("."+parentTag+" .categoryBoxOpacity2").addClass("activeBoxOpen");
			$("."+parentTag+" .categoryBoxOpacity2").css("zIndex","999");
		});
		
	    $(".categoryBoxOpacity2").bind("mouseleave", function(e){
		    $(this).css("display", "none");
		});		
		
		
		$(".categoryBoxOpacity").bind("mouseleave", function(e){
		    $(this).css("display", "none");
		});
	
	/** Finance Choose One **/
		$(".hisseSecin").change(function(){
			//alert($(".hisseSecin option:selected").text());
			
			window.open("http://www.cnnturk.com/finans/borsa/ayrintili.asp?kod="+$(".hisseSecin option:selected").text())
		});
		
			
		/**************************************************************************************************************************
		* AutoComplete
		* artuc not: 
		* .NET le yapılacağı içi kapatıldı, eğer kullanılacaksa, js klasöründen jquery.autocomplete.js dosyasının dahil edilmesi gerekiyor
		***************************************************************************************************************************/
		//$(".search").autocomplete("list.php");

		
		/**************************************************************************************************************************
		* 
		* Weather Forecast location Selector
		*
		***************************************************************************************************************************/
		$(".wF_LocationSelectorLink a").click(function(){ 
			$(".wF_LocationSelectorLink").hide(); 
			$(".wF_LocationSelector").show();
		});

		//initializeMiniGallery();
		
});


/**************************************************************************************************************************
* Make HomePage
***************************************************************************************************************************/
function MakeHomePage(e){
    e.style.behavior='url(#default#homepage)';
    e.setHomePage('http://www.cnnturk.com');
}
