if (document.images) {
	blogOver = '/img/button-blog.gif';
	blogOut = '/img/button-blog1.gif';
	galleriesOver = '/img/button-galleries.gif';
	galleriesOut = '/img/button-galleries1.gif';
	photographyOver = '/img/button-photography.gif';
	photographyOut = '/img/button-photography1.gif';
	graphicOver = '/img/button-graphic-design.gif';
	graphicOut = '/img/button-graphic-design1.gif';
	servicesOver = '/img/button-services.gif';
	servicesOut = '/img/button-services1.gif';
}

function myOn(myImg, nam) {
	document.getElementById("but_" + nam).setAttribute("src", eval(nam+ 'Out' ));
}

function myOut(myImg, nam) {
	document.getElementById("but_" + nam).setAttribute("src", eval(nam+ 'Over' ));
}

function jsonp(url, query)
{     
	if (query)
    	url += "&" + query;

	url += "&" + new Date().getTime().toString(); // prevent caching 

	$(document).ready(function(){
		$.getJSON(url + "&jsoncallback=?", function(data){

		});
	});
}

function nextPhoto()
{
	if((curPhoto*1)+1 <= maxPhoto)
	{
		doPhoto(setUrl, (curPhoto*1)+1);
	}
}

function prevPhoto()
{
	if((curPhoto*1)-1 > 0)
	{
		doPhoto(setUrl, (curPhoto*1)-1);
	}
}

function doPhoto(set, id)
{
	var photoObj = $('#photoObj');
	photoObj.attr("src", "/img/blank.gif");
	var pStyle = photoObj.attr("style");
	
	var photoBack = $('#photoBack');
	photoBack.attr("style", "background:url(/img/load.gif) center center no-repeat;");
	
	jsonp("/photos/" + set + "/view-" + id, "");
}

function doPhotoResults(resp)
{
	if(resp.status == 200)
	{
		var photoObj = $('#photoObj');
		curPhoto = resp.photo.id;
		
		photoObj.attr("style", "width: " + resp.photo.wd + "px; height: " + resp.photo.ht + "px;");
		photoObj.attr("src", resp.photo.url);
		
		var h3Viewing = document.getElementById("h3Viewing");
		h3Viewing.innerHTML = "Viewing Photo " + resp.photo.id;
		
		var photoCounter = document.getElementById("photoCounter");
		photoCounter.innerHTML = "<b>" + resp.photo.id + "</b> of <b>" + resp.gallery.total + "</b> Photos";
		
		var nextPhoto = $('#nextPhoto');
		var nextButton = $('#nextButton');
		var prevButton = $('#prevButton');
		
		if(resp.gallery.pagiPrev)
		{
			prevButton.attr("onClick", "doPhoto('" + resp.gallery.url + "', " + ((resp.photo.id*1)-1) + ");");
			prevButton.attr("class", "");
		} else
		{
			prevButton.attr("onClick", "");
			prevButton.attr("class", "disable");
		}
			
		if(resp.gallery.pagiNext)
		{
			//nextButton.attr("onClick", "doPhoto('" + resp.gallery.url + "', " + ((resp.photo.id*1)+1) + ");");
			nextButton.attr("class", "");
			nextPhoto.attr("onClick", "doPhoto('" + resp.gallery.url + "', " + ((resp.photo.id*1)+1) + ");");
			nextPhoto.attr("class", "");
			nextPhoto.attr("title", "Click to go to Next Photo");
		} else
		{
			//nextButton.attr("onClick", "");
			nextButton.attr("class", "disable");
			nextPhoto.attr("onClick", "");
			nextPhoto.attr("class", "disable");
			nextPhoto.attr("title", "");
		}
		
		var fbLike = $('#fbLike');
		fbLike.attr("src", "http://www.facebook.com/widgets/like.php?href=http://beger.com/photos/" + resp.gallery.url + "/photo-" + resp.photo.id);

		doPhotoTrack("/ajax/photos/" + resp.gallery.url + "/photo-" + resp.photo.id);

	}
}

function doPhotoTrack()
{
	try {
	if(pageTracker)
	{
		pageTracker._trackPageview();
	}
	} catch(err) {}
}