/* -- davidusher.com Scripts */
/* -- v 1.0 - January 2010 */
/* -- by Gallivan Media (http://www.gallivanmedia.com/) */

$(document).ready(function() {
	setupFlickrWall();
	checkDEQQHeight();
	$('.photobox').hover(function() {
		$(".infobox", this).stop().animate({top: '0px'}, { queue: false, duration: 160});
		$(".info", this).stop().animate({top: '0px'}, { queue: false, duration: 160});
	}, function() {
		$(".infobox", this).stop().animate({top: '172px'}, { queue: false, duration: 160});
		$(".info", this).stop().animate({top: '172px'}, { queue: false, duration: 160});
	});
});
	
// setupFlickrWall
function setupFlickrWall() {
	for(var i=1, n=7; i<n; ++i ) {
		changePhoto(i); 
	}
} 

// changePhoto
function changePhoto(e) {
	var flickrSetID = "";
	if (e == 1) { flickrSetID = "72157623180071745"; }
	if (e == 2) { flickrSetID = "72157623180074605"; }
	if (e == 3) { flickrSetID = "72157623304650306"; }
	if (e == 4) { flickrSetID = "72157623304652060"; }
	if (e == 5) { flickrSetID = "72157623304653536"; }
	if (e == 6) { flickrSetID = "72157623180084477"; }
	$.getJSON("http://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&photoset_id="+flickrSetID+"&sort=random&api_key=b9f5eb9d24de31b4dd525948f40a0dc4&extras=url_s&format=json&jsoncallback=?",
	function(data) {
		var numRand = Math.floor(Math.random()*data.photoset.photo.length);
		var fadeRand = Math.floor((9000-1000)*Math.random()) + 5;
		$("<img />").attr("src", data.photoset.photo[numRand].url_s).appendTo("#photo"+e).fadeIn(fadeRand);		
	});
}

// changeDEQQSize
function checkDEQQHeight() {
	var theHeight;
	if (window.innerHeight) {
		theHeight=window.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		theHeight=document.documentElement.clientHeight;
	} else if (document.body) {
		theHeight=document.body.clientHeight;
	}
	document.getElementById('deqq').style.height = theHeight - 290 + "px";
}
