$(document).ready(function(){
	
	$(".home-gallery-images").cycle({	
		speed:    1000, 
		timeout:  4000 ,
		fx:  'fade', 
		pager: '#home-gallery-nav', 
		before:     function() {
            $('.home-gallery-description p').html(this.alt);
        }

	});  
	
	$("#single-product-gallery").cycle({	
		speed:    1000, 
		timeout:  0 ,
		fx:  'fade', 
		next: '#next',
		prev: '#prev',
		before:     function() {
            $('#single-product-gallery-description span').html(this.alt);
        }
	});

	$("div#testimonials").cycle({	
		speed:    1000, 
		timeout:  0 ,
		fx:  'fade', 
		next: '.next-testimonials',
		prev: '.prev-testimonials'
	});	
	
	$(".ovb-container div.ovb-content").eq(0).show();
	$("ul.home-tabs li a").click(function(event){

			$("ul.home-tabs li a").removeClass('selected');
			$(this).addClass('selected');
			$("div.ovb-content").hide();
			var index = $("ul.home-tabs li a").index(this);
			$("div.ovb-container div.ovb-content").eq(index).show();
			event.preventDefault();
	});
	
	
	$(".single-product-tabs ul li a").click(function(event){

			$(".single-product-tabs ul li a").removeClass('selected');
			$(this).addClass('selected');
			$(".single-product-content").hide();
			var index = $(".single-product-tabs ul li a").index(this);
			$(".single-product-content").eq(index).show();
			event.preventDefault();
	});
	 
	/*$(".studybed360").fancybox({
		'width'				: '75%',
		'height'			: '75%',
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});*/ 
	
	/*$("div.testimonial-navigation a#next").click(function(event){
			var items =  $("div#testimonials").children('div').length;
			//alert(items);
			var selected = $("div#testimonials div.selected").index();
			$("div#testimonials div").eq(selected).removeClass('selected').fadeOut();
			//alert(selected);
			alert(selected);
			if(items > selected + 1)
			{
				var next = selected + 1;
			}else{
				next = 0;
			}
			
			alert(next);
			
			$("div#testimonials div").eq(next).addClass('selected').fadeIn();
			event.preventDefault();
	});
	
	*/
	
	
	
	/*$("#single-product-gallery-descripton a").click(function(event){

			event.preventDefault();
			var gallery = $('#single-product-gallery img');
			$('#single-product-gallery img').fadeOut('slow');
			var img = $('img.current');
			var index = gallery.index(img);
			var children = $('#single-product-gallery').children().length;
			$(img).removeClass('current');
			$(img).hide();
			
			if(children == index + 1)  {
				index = 0;
			}else{
				index++;
			}
			
			
			
			$('#single-product-gallery img').eq(index).addClass('current');
			$('#single-product-gallery img').eq(index).fadeIn('slow');
			
			
			$('#single-product-gallery-descripton span').html(index);
			//$("#single-product-gallery img").hide();
	})*/ 
	
	// convert to desk ... convert to bed
	
	$("#convert-button").click(function(event){
		$("#convert img").toggle();
		var value = $(this).val();
		if(value == "Convert to bed")
		{
			$(this).val("Convert to desk");
		}else{
			$(this).val("Convert to bed");
		}
	});
	
	$("#nav-posts-below.navigation div.nav-next a").corner("5px");
	$("#nav-posts-below.navigation div.nav-previous a").corner("5px");
	
	$("#testimonial-youtube").fancybox({
				
				'autoScale'			: true,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
	});

	$(".home-video").fancybox({
				
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
	});
	

  
  	$('#special-message').SetScroller({	velocity: 50,	direction: 	 'horizontal',
											startfrom: 	 'right',
											loop:		 'infinite',
											movetype: 	 'linear',
											onmouseover: 'pause',
											onmouseout:  'play',
											onstartup: 	 'play',
											cursor: 	 'pointer'

										});

		
})
