$(document).ready(function() {

/*
	var descriptionText = $('#images img').attr('alt');
	
	$('#text p').html(descriptionText);
*/
	
	$('A[rel="external"]').click(function(){
        window.open( $(this).attr('href') );
        return false;
    });
	
	$('#txtbutton').click(function(){
		var pos = $('#txt').position();
		if(pos.left==0){
		$('#txt').animate({
			left: '+312' 
			//width:'toggle'
		}, 500, function(){
			$('#txtbutton').addClass('closed');	
		});
		}else {
			$('#txt').animate({
			left: '0' 
			//width:'toggle'
		}, 500, function(){
			$('#txtbutton').removeClass('closed');	
		});		
		}
	});

	$('#project #project-images').cycle({
    fx: 'fade',
    speed: 1000,
    timeout: 0,
    pager: '#cycle-controls',
    containerResize: false
	});
	
	$('#page #project-images').cycle({
    fx: 'fade',
    speed: 2000,
    containerResize: false
	});
	
/* Matt tried this @ 5:42pm on May 6th, 2010 and it didn't work.
	$('#cycle-controls').click(function() {
    $('#project-images').cycle({
      timeout: 0
    });
	});
*/

/*
	$('#project-images').mouseover(function() {
    $(this).cycle('stop');
    $('#cycle-controls a').remove();
	}).mouseout(function(){
    $('#project-images').cycle({
    fx: 'fade',
    speed: 2500,
    pager: '#cycle-controls'
	});
	});
*/
	
	$('li.dd-projects div').mouseover(function() {
    $('li.dd-projects a').addClass('hover');
	}).mouseout(function(){
    $('li.dd-projects a').removeClass('hover');
  });
  
  $('li.dd-services div').mouseover(function() {
    $('li.dd-services a').addClass('hover');
	}).mouseout(function(){
    $('li.dd-services a').removeClass('hover');
  });
  
  $('a#projects').click(function(){
    $('li.dd-projects span').fadeIn(500).delay(2000).fadeOut(500);
    if($('li.dd-services span').is(':visible')){$('li.dd-services span').hide();}
    return false;
  });
  
  $('a#services').click(function(){
    $('li.dd-services span').fadeIn(500).delay(2000).fadeOut(500);
    if($('li.dd-projects span').is(':visible')){$('li.dd-projects span').hide();}
    return false;
  });
  
  $('#contacts li:first-child').addClass('first-child');

}); // ends jQuery

/*
		if(jQuery('#project-images').children().size()>1){
		jQuery('#project-images').addClass('jcarousel-skin-bcj');
		var num = ($('#project-images').children().size());
		$('#put-controls-here').append("<ul id='controls'>");
		for(var i=0; i<num; i++){
		var n=i+1;
		$('#controls').append("<li class='jcarousel-control'><a href='#'>"+n+"</a></li>");
		if(i==0){
		$('.jcarousel-control').addClass('active');	
		}
		}
		$('#project-images').before("</ul>");
		jQuery('#project-images').jcarousel({
		auto: 4,
		scroll: 1,
		wrap: 'last',
        initCallback: mycarousel_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
		});
	}
	});

	function mycarousel_itemVisibleInCallbackBeforeAnimation(carousel, item, idx, state) {
	
		$('.jcarousel-control').each(function(i){
			if(i==idx-1){
				$(this).addClass('active');	
			}else {
				$(this).removeClass('active');							   
			}
		});

	}
	
	function mycarousel_itemVisibleInCallbackAfterAnimation(carousel, item, idx, state) {
							 
	}

	function mycarousel_initCallback(carousel) {
    jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
		carousel.startAuto(0);
		$('.jcarousel-control').each(function(i){
			$(this).removeClass('active');							   
		});
		$(this).parent().addClass('active');
        return false;
    });
	};
*/
