function mycarousel_initCallback(carousel){
       // Disable autoscrolling if the user clicks the prev or next button.
       carousel.buttonNext.bind('click', function() {carousel.startAuto(0);});
       carousel.buttonPrev.bind('click', function() {carousel.startAuto(0);});
       // Pause autoscrolling if the user moves with the cursor over the clip.
       carousel.clip.hover(function() {carousel.stopAuto();}, function() {carousel.startAuto();});
}; 

$(document).ready(function(){
	
	
	/**** general functions *****/
	/* rt_rail */
	$('.rt_rail .block:first').css('borderTop', 'none').css('paddingTop', 0);
	$('.rt_rail .block:last').css('borderBottom', 'none');
	
	if($('.ct_rail').height() > $('.rt_rail').height()){
		$('.rt_rail .rt_rail_body').css({'min-height' : $('.ct_rail').height() - 154 + "px"});
	}
			
	$('.rt_rail .block_title').click(function(){
		$(this).parent().find('ul').slideToggle();
	});
	
	$('.rt_rail li').mouseenter(function(){
		$(this).animate({right : '+=5px'});
	}).mouseleave(function(){
		$(this).animate({right : '-=5px'});
	});
	
	$('#logo').hover(
		function(){
    		$('#lt_cloud').animate({left : '-=10px' }, 'slow', 'easeOutBack');
    	},
    	function(){
    		$('#lt_cloud').animate({left : '+=10px' }, 'slow', 'easeOutBack');
    	}
	);
	
	$('#nav li:last').hover(
		function(){
    		$('#rt_cloud').animate({right : '-=10px' }, 'slow', 'easeOutBack');
    	},
    	function(){
    		$('#rt_cloud').animate({right : '+=10px' }, 'slow', 'easeOutBack');
    	}
	);
	

	$('.view_div').show();
	$('.entry blockquote').addClass("blockquote");
	$('.entry').hover(
		function(){
			$(this).find('.post_date').animate({top : '-=10px'});
		},
		function(){
			$(this).find('.post_date').animate({top : '+=10px'});
		}
	);
	
	if($.browser.mozilla){
		$('.rounded, #login_bar, #register_user, #forgot_pswd_form, #disable_account_form, .rt_rail .block li, .rt_rail .block li .num, #user_settings_loader, .pager li a, .customize_res fieldset, .search_page .page ul.photo_res li, .block_title, .btn, #login_bar table, #register_user table, #forgot_pswd_form table, #disable_account_form table, li.entry, li.entry .tag_list, .entry blockquote, .view_div').corner();
		$('.login_form .txt, .login_form .btn').corner('5px');
	}
	
	if($.browser.safari){
		if($.browser.version >= parseInt('531.21.8') ){
			$('.rounded, #login_bar, #register_user, #forgot_pswd_form, #disable_account_form, .rt_rail .block li, .rt_rail .block li .num, #user_settings_loader, .pager li a, .customize_res fieldset, .search_page .page ul.photo_res li, .block_title, .btn, #login_bar table, #register_user table, #forgot_pswd_form table, #disable_account_form table, li.entry, li.entry .tag_list, .entry blockquote, .view_div').corner();
			$('.login_form .txt, .login_form .btn').corner('5px');
		}
	}

	
	$('#contact_us .txt, #login_bar input.txt, #register_user input.txt, #forgot_pswd_form input.txt, #disable_account_form input.txt').focus(function(){
		$(this).addClass('active');
	});
	$('#contact_us .txt, #login_bar input.txt, #register_user input.txt, #forgot_pswd_form input.txt, #disable_account_form input.txt').blur(function(){
		$(this).removeClass('active');
	});
	
	$('#contact_us').css('opacity', 0.98);
	$('#user_settings_loader').css('opacity', 0.98);
	$('#contact_us').prepend("<span class='close'></span>");
	
	$('#contact_nav a, a.contact').unbind('click').click(function(){
		$('.contact_form').fadeIn().animate({right: '50px'});
		$(this).parent().addClass('selected');
		$('#contact_name').focus();
		return false;
	});
	$('#contact_us .close').click(function(){
		$('.contact_form').animate({right: '-1px'}).fadeOut();
		$('#contact_nav').removeClass('selected');
	});
	
    
    $('.user_page input, .user_page .page .ct_rail textarea').focus(function(){
    	$(this).addClass('active');
    });
    $('.user_page .page .ct_rail input, .user_page .page .ct_rail textarea').blur(function(){
    	$(this).removeClass('active');
    });
		
		
	/**** projects ****/
	
	
	//photo gallery
	$('.albums_page .ctrl .next').corner('right');
	$('.albums_page .ctrl .prev').corner('left');
	
	$('.photo_list').wrap('<div class="photo_list_wrap"></div>');
	$('.photo_list li img').each(function(){
        $(this).attr('src', '/themes/teddyproductions/images/ajax_loader_b.gif');//$(this).attr('rel')
        $('.photo_list li:first img').attr('src', $('.photo_list li:first img').attr('rel'));
        $('.photo_list li:first').addClass('index');
        $('.photo_list li').delay(700).animate({'opacity' : 1}, 200);
    });
    
    //control functions
    $('.prev').addClass('disable');
    
    $('.albums_page .ctrl .next').click(function(){
    	$('.photo_list').animate({'top' : '-' + $('.index').next().position().top + 'px'});
    	$('.index').next().addClass('index');
    	$('.index:first').removeClass('index');
    	if($('.index').position().top == $('.photo_list li:last').position().top){
    		$('.next').addClass('disable');
    	}else{
    		$('.albums_page .ctrl li').removeClass('disable');
    	}
    	$('.index img').attr('src', $('.index img').attr('rel'));
    });
    
    $('.albums_page .ctrl .prev').click(function(){
    	$('.photo_list').animate({'top' : '-' + $('.index').prev().position().top + 'px'});
    	$('.index').prev().addClass('index');
    	$('.index:last').removeClass('index');
    	if($('.index').position().top == $('.photo_list li:first').position().top){
    		$('.prev').addClass('disable');
    	}else{
    		$('.albums_page .ctrl li').removeClass('disable');
    	}
    	$('.index img').attr('src', $('.index img').attr('rel'));
    });
    
    $('.thumb_list li img').css('opacity', 0.3);
    $('.thumb_list li').hover(
    	function(){
    		$(this).find('img').animate({'opacity': 1}, 500);
    	},
    	function(){
    		$(this).find('img').animate({'opacity': 0.3}, 500);
    	}
    
    );
    
    $('.thumb_list li').each(function(){
    	$(this).click(function(){
    		var item = '#' + $(this).find('img').attr('class');
    		$('.photo_list').animate({'top' : '-' + $(item).position().top + 'px'});
    		$('.photo_list li').removeClass('index');
    		$(item).addClass('index');
    		$(item).find('img').attr('src', $(item).find('img').attr('rel'));
    		
    		if($(item).position().top == $('.photo_list li:last').position().top){
    			$('.next').addClass('disable');
    		}else{
    			$('.albums_page .ctrl li').removeClass('disable');
    		}
    		
    		if($(item).position().top == $('.photo_list li:first').position().top){
    			$('.prev').addClass('disable');
    		}else{
    			$('.albums_page .ctrl li').removeClass('disable');
    		}
    		
    	});
    });
    
    //$('li.entry').jScrollPane();
    
	//photo gallery
	
	
	
	/**** about ****/	
	
	/**** pager ****/
	$('.jobs_page .pager li a').hover(
		function(){
			$(this).animate({top: '-3px'});
		},
		function(){
			$(this).animate({top: '0'});
		}
	);
		
})