$(document).ready(function() {
	if ( $('#icon_yahoo').length > 0 ) {
		$.getScript('/yahoo.php');
	}
	
	if ( $('#photos > *').length > 0 ) {
		/* $('#carusel').bxSlider({
			displaySlideQty: 5,
			moveSlideQty: 2             
		});*/
		
		/*
		var sliderCache = new Array();
		$('#photos li').each(function(index) {
			sliderCache[index] = $(this).html();
			
			if(index>=1){
				$(this).empty();
			}
		});
		*/
					
		/*var photos_info = $('#photos_info').bxSlider({
			mode: 'fade',
			displaySlideQty: 1,
			speed: 1000,
			moveSlideQty: 1,
			controls: false
		});*/

		var isVideo = $('#gallery').hasClass('gallery_video');
		
		var oDirection;
		
		var photos = $('#photos').bxSlider({
			mode: 'fade',
			displaySlideQty: 1,
			speed: 1000,
			moveSlideQty: 1,
			auto: (!isVideo),
			pager:true, 
			buildPager: function(slideIndex){
				return '<a href="">#'+slideIndex+'</a>';
			},
			onNextSlide: function(currentSlide, totalSlides, currentSlideHtmlObject){
				oDirection = 1;
				if(isVideo &&  currentSlideHtmlObject.html().indexOf("<!--s7a")>=0) { currentSlideHtmlObject.html(currentSlideHtmlObject.html().replace("<!--s7a", "").replace("s7a-->", "")); }
				
				
			},
			onPrevSlide: function(currentSlide, totalSlides, currentSlideHtmlObject){
				oDirection = -1;
				
				if(isVideo && currentSlideHtmlObject.html().indexOf("<!--s7a")>=0) { currentSlideHtmlObject.html(currentSlideHtmlObject.html().replace("<!--s7a", "").replace("s7a-->", "")); }
				
				
				
				
			},
			onBeforeSlide:  function(currentSlide, totalSlides, currentSlideHtmlObject){
			  //  currentSlideHtmlObject.next().html(obs.html().replace("<!--s7a", "").replace("s7a-->", ""));
				
				/*if(currentSlide==0 && !isVideo){
					$(".photo_moreinfo").animate({opacity:0}, 800);
				}
				if(currentSlide==1 && !isVideo){
					$(".photo_moreinfo").removeClass("hidden").animate({opacity:1}, 800);
				}
				photos_info.goToSlide(currentSlide); 
				//alert($(currentSlideHtmlObject).find(".photo_info").html());
				
				//$("#c_middle").html($(currentSlideHtmlObject).find(".photo_info").html()); 
				
				*/
			},
			onAfterSlide:  function(currentSlide, totalSlides, currentSlideHtmlObject){
			  if(isVideo){
				if(currentSlideHtmlObject.html().indexOf("<!--s7a")>=0) { currentSlideHtmlObject.html(currentSlideHtmlObject.html().replace("<!--s7a", "").replace("s7a-->", "")); }
				
				
				oNext = currentSlideHtmlObject.next();
				if(currentSlide+1==totalSlides) 
					oNext = currentSlideHtmlObject.siblings().first();
				oPrev = currentSlideHtmlObject.prev(); 
				if(currentSlide==0) 
					oPrev = currentSlideHtmlObject.siblings().last();

				if(!document.all) {
					if(oDirection>0)
						oPrev.html(oPrev.html()+"  ");
					
					if(oDirection<0)
						oNext.html(oNext.html()+"  ");
					
				}
			  }
				/*
					if(oNext.html().indexOf("<!--s7a")>=0) { oNext.html(oNext.html().replace("<!--s7a", "").replace("s7a-->", "")); }
					//opresc filmul anterior
					if(oPrev.html().indexOf("<!--s7a")>=0) {  }else{oPrev.html("<!--"+oPrev.html()+"s7a-->");}
					
				
				if(!document.all && isVideo){

					ob = currentSlideHtmlObject.prev();
					
					if(ob.html()==null){
						ob = currentSlideHtmlObject.next();
					}
					var temp = ob.html();
					ob.empty();
					ob.html(temp);
				}
				
				*/
				
				
			}
		});
		
		$(".bx-next,.bx-prev").click(function(){
			if($(window).height()<=600){ 
				gogallery();
			} 
		});
		 
				
		/*$('#carusel a').click(function(){
			photos.goToSlide($('#photos a').index($('#photos a[rel="'+$(this).attr('rel')+'"]'))); 
		});	*/
	}	
});

function moreinfo(){
	//$("#c_top").fadeIn('fast');
	$("#c_top").removeClass("hidden").addClass("visible");
	
	$.scrollTo('#c_top', {axis:'y', duration:800}); 

}
function gogallery(){
		$.scrollTo('.gallery', {axis:'y', duration:800}); 
}

function goup(){
	if($(window).height()<=600){ 
		gogallery();
	}else{
		$.scrollTo(0, {axis:'y', duration:800}); 
	} 
}

