jQuery(document).ready(function($) { 
	
	// resize images to fit content area
	jQuery('.featured_img_thumb img').addClass('resize');

	jQuery(".resize").resize({
    	scale: 0.5, // 0.5 = 50%
		maxWidth: 120
	});

	
	$('.gallery-item a').addClass('cboxModal');
	
    $('.cboxModalStallionImg, .cboxModalStallionTitle, .stallion_wrap .details').click(function() {
    	var thisURL = $(this).attr('href');
        $.colorbox({
        	href: thisURL + ' div#stallion_wrap_single',
        	opacity:0.8,
        	rel:'thumb-group',
        	width: '900px',
        	maxHeight: '670px',

        	onComplete: function(){

				$('#cboxPrevious').css('display', 'none');
				$('#cboxNext').css('display', 'none');
		
		        $("#gallery_thumbs a").live('click', function () {
		        	
		        	var htmlStr = $(this).attr("href");
		        	$(".stallion_window_image img.attachment-thumb").attr("src", htmlStr);
		
		            return false;
		            
		        });
		    	
		        $('.navigation a').live('click', function() {
		            $.fn.colorbox({href: $(this).attr('href') + ' #stallion_wrap_single',width:'900px',maxHeight:'670px'});
		            
		            return false;
		        });

/*
		        $(".stallionVideoLink").live('click', function() {
		        	//alert('howdy');
		        	$.fn.colorbox({open:true, href: $(this).attr('href'), iframe:true, width:'600px', height:'400px'});
		            return false;
		        });
*/
		        
	    	} // end onComplete

        
        });    	
        return false;
    });
    
    
    $(".stallionVideoLink").live('click', function() {
    	//alert('howdy');
    	$.fn.colorbox({open:true, href: $(this).attr('href'), iframe:true, width:'600px', height:'400px'});
        return false;
    });

    
    $(".cboxModalStallionTitle").colorbox({
    	opacity:0.8,
    	rel:'title-group',
    	width: '900px'
    	
    });

    $(".horse_video").colorbox({
    	opacity:0.8,
    	rel:'video-gallery',
    	width: '620px'
    	
    });
    
    
    
 // for stallions internal gallery...
     
/*  // embeded into the stallion single page so it's accesible in the modal window
     $("#gallery_thumbs a").click(function () {
     	//var htmlStr = $(this).parent().html();
     	var htmlStr = $(this).attr("href");
         //$(".stallion_window_image").html(htmlStr+"<span class=\"arrows_stallion\"></span>");
     	$(".stallion_window_image img.attachment-thumb").attr("src", htmlStr);

         return false;
         
       });
  */   
     
	
// add some classes to WP generated elements for styling purposes 
	
	$("#footer li:first-child").addClass("first-item");
	$("#footer li:last-child").addClass("last-item");
	$(".event_wrap:odd").addClass("odd-event");
	$('li.menu-item').children('ul.sub-menu').parent().addClass('hasSubMenu');
	$("ul.styled_list li:odd").addClass("odd");
	$(".stallion_wrap:odd").addClass("odd");
	$(".news_item:first").append("<div class='spacer clear'></div>");
	
	
	
// for form hover state	
	
	$('#email_signup.wide_signup #signup_btn').mouseover(function() {
		$('#email_signup form').css('background-position', "14px -113px")
	});

	$('#email_signup.wide_signup #signup_btn').mouseout(function() {
		$('#email_signup form').css('background-position', "14px -67px")
	});

	
////////////////////////////   using load() to load videos. 
    
    
    $('.video_post h2.entry-title a.video_link, .video_icon a').click(function() {
    	
    	$('.video_post h2.entry-title').css('display', 'none');

//		var parentClass = $(this).parent().attr('id');	

		var videoDataLocation = $(this).attr("href");
		var horseDataLink = videoDataLocation + " object"; 

		$('.video_holder').empty();
		$('.video_icon').css('display', 'none');
		$('.video_holder').load(horseDataLink, function() {
			//$('.video_post_single object').css('visibility', 'visible');	// forces visible just in case
			//alert('loaded!!!');
		});
		
		return false;
  
   	}); // stop load function


	
}); // STOP JQUERY



//love that cufon...
Cufon.replace('#access li a', { hover: true, fontFamily: 'Benguiat' });
Cufon.replace('h2', { fontFamily: 'Benguiat' });
window.setInterval( function() {Cufon.refresh();}, 100 ); // this prevents nav over states sticking (and allows for easy styling via firebug too!)



