
var divID;

jQuery.ajaxSetup({ cache: true });



/* function photoSlideShow(data, status){
		jQuery.each(data.feed.entry, function(i, item){
			photo_url = item.media$group.media$thumbnail[0].url;
			photo_url = photo_url.replace('/s72/', '/s800/');
			jQuery("<img/>").attr("src", photo_url).appendTo(divID).wrap('<div class="maya_photo"></div>');
		
			makeSlideShow(divID);
		});
} */

function photoSlideShow(data, divID){
 	// console.log(data);
	var setHeight;
		jQuery.each(data.feed.entry, function(i, item){
			var photo_url = item.media$group.media$thumbnail[0].url;
			var width = item.media$group.media$content[0].width;
			var height = item.media$group.media$content[0].height;
			var ratio = height / width;
			photo_url = photo_url.replace('/s72/', '/s800/');
			if (height > width) {
				setWidth = 400 / ratio;
				setHeight = '400';
			}
			else {
				setWidth = '578';
				setHeight = 578 * ratio;
			} 
			jQuery("<img/>").attr("src", photo_url).attr("width",setWidth).attr("height",setHeight).appendTo(divID).wrap('<div class="maya_photo"></div>');
		});
		makeSlideShow(divID);

} 
/* 
 function photoSlideShow(jsonURL, divID){
 	console.log(jsonURL);
	jQuery.getJSON(jsonURL, function(data){ // removed this from jsonURL ... + "&callback=?"
		jQuery.each(data.feed.entry, function(i, item){
			photo_url = item.media$group.media$thumbnail[0].url;
			photo_url = photo_url.replace('/s72/', '/s800/');
			jQuery("<img/>").attr("src", photo_url).appendTo(divID).wrap('<div class="maya_photo"></div>');
		});
		makeSlideShow(divID);
	});
} */
function makeSlideShow(){
 	jQuery(divID).cycle({
 		fx: 'fade',
 		speed: 1000,
 		timeout: 0,
		pause: 0,
		prev: '#prev-slide',
		next: '#next-slide'
 	});
	jQuery('.slideshow_asset').mouseover(function() {
		jQuery('#slideshow-nav').show();
	});
	jQuery('.slideshow_asset').mouseout(function() {
		jQuery('#slideshow-nav').hide();
	});
 }
 
 /* functions for kjcrane.com */
jQuery(document).ready( function($) {
	/* $('#search').corner('6px');
	$('#header #nav a').corner('6px'); 	
	$('.sidebar').corner('6px').corner('dog tr 20px'); */
	$('#search input#s').focus(function() {
		$('#search').addClass('active');
	});
	$('#search input#s').blur(function() {
		$('#search').removeClass('active');
	});
});

function mayaMainImage() {
	jQuery('#container').prepend('<div id="maya_image"><img title="Maya at the Botanic Gardens" src="http://lh3.ggpht.com/_-sBH0D0c-5A/S-ds_NoP8tI/AAAAAAAABS8/rwUP5qtlwj0/s1024/39.jpg" /></div>');
	$mayaImg = jQuery('#maya_image');
	$mayaImg.slideDown('slow');
	// var t = setTimeout('$mayaImg.slideUp()', 5000);
	
	/* 
	$mayaImg.hover(function(event) {
		jQuery(this).stop().animate({
			opacity: 1.0,
			height: '195px'
		}, 200, 'swing')
	}, function(){
			jQuery(this).stop().animate({
				opacity: 0.4
				// height: '150px'
			}, 200, 'swing')
	}); */
	$mayaImg.toggle(function() {
		jQuery(this).stop().animate({
			opacity: 1.0,
			height: '683px'
		}, 500, 'swing').unbind('mouseenter mouseleave')
	}, function(){
		jQuery(this).stop().animate({
	 	opacity: 0.4,
			height: '175px'
		}, 500, 'swing')
	});
} 

