var portfolio = 
    [
     {"img":"codegenesys.png",
      "big":"big_codegenesys.png",
      "desc":'A web development firm was looking for a visual refresh for their site, and while they needed no help on the backend, I wrote them clean html and css. <a target="_blank" href="http://www.codegenesys.com">Visit the site</a>.'},
     {"img":"summermusicstore.png",
      "big":"big_summermusicstore.png",
      "desc":'<a target="_blank" href="https://www.summermusicstore.com/about">Mountaintop Studios</a> wanted a store where people could buy songs from the last ten years of the <a target="_blank" href="http://www.sonatina.com">Summer Sonatina Piano Camp</a>. What I built uses <a target="_blank" href="http://ocsigen.org">Ocsigen</a>, a web framework in <a target="_blank" href="http://caml.inria.fr">OCaml</a>, and <a target="_blank" href="http://www.postgresql.org/">Postgresql</a>. <a target="_blank" href="https://www.summermusicstore.com">Visit the site</a>.'},
     {"img":"kaplantutor.png",
      "big":"big_kaplantutor.png",
      "desc":'Kaplan Tutoring Services wanted a modern website to post information about services offered and background about standardized tests and the company. I built them a site that uses  <a target="_blank" href="http://ocsigen.org">Ocsigen</a>, a web framework in <a target="_blank" href="http://caml.inria.fr">OCaml</a>, and <a target="_blank" href="http://www.postgresql.org/">Postgresql</a>, and is completely dynamic and editable by the company. <a target="_blank" href="http://www.kaplantutor.com">Visit the site</a>.'},
     {"img":"facebook.png",
      "big":"big_facebook.png",
      "desc":'I spent three months working as an engineering intern for <a target="_blank" href="http://www.facebook.com">Facebook</a>, where I designed and implemented a publishing system for their public relations department, using <a target="_blank" href="http://www.php.net">php</a>, sql, html, css, and a little javascript (on the internal side, to make publishing easier). <a target="_blank" href="http://www.facebook.com/press.php">Visit the site</a>.'},
     {"img":"abingdonsquarepainters.png",
      "big":"big_abingdonsquarepainters.png",
      "desc":'An artist group in New York wanted to showcase their work. I built them a site where each artist could update their own work, using my library <a target="_blank" href="http://bitbucket.org/dbp/withweb/src/">withWeb</a> on top of <a target="_blank" href="http://www.webpy.org">web.py</a> and <a target="_blank" href="http://www.sqlite.org/">sqlite</a>. <a target="_blank" href="http://www.abingdonsquarepainters.com">Visit the site</a>.'},
     {"img":"mountainfilms.png",
      "big":"big_mountainfilms.png",
      "desc":'The Williamstown Mountain Film Festival wanted to let people know about films to be shown and allow film makers to submit films to be judged. I built them a site that used my <a target="_blank" href="http://bitbucket.org/dbp/withweb/src/">withWeb</a> library, <a target="_blank" href="http://www.webpy.org">web.py</a> and <a target="_blank" href="http://www.sqlite.org/">sqlite</a>. <a target="_blank" href="http://www.mountainfilms.org">Visit the site</a>.'},
     {"img":"lydiajohnston.png",
      "big":"big_lydiajohnston.png",
      "desc":'Textile and Oil painting artist Lydia Johnston had already had a website for many years when I custom built her a dynamic backend to give her the same control she had when managing the html herself without the time commitment of re-arranging pages worth of tables.  <a target="_blank" href="http://www.lydiajohnston.com">Visit the site</a>.'},
     {"img":"joelpatterson.png",
      "big":"big_joelpatterson.png",
      "desc":'Music journalist Joel Patterson was looking for a simple way to showcase his work. Utilizing my <a target="_blank" href="http://bitbucket.org/dbp/withweb/src/">withWeb</a> library for <a target="_blank" href="http://www.webpy.org">web.py</a>, I built him a simple website where he could put up audio clips and text articles. <a target="_blank" href="http://www.joelpatterson.us">Visit the site</a>.'}
     ];

/*
     {"img":"dbpatterson.png",
      "big":"big_dbpatterson.png",
      "desc":""},
*/

/*     {"img":"jkniffin.png",
      "big":"big_jkniffin.png",
      "desc":'Oil painting and watercolor artist Judith Kniffin already knew what she wanted her website to look like, and what I built her used python and an sqlite database to allows her to log in and change the contents of the whole site anytime she wants. <a target="_blank" href="http://www.judykniffin.com">Visit the site</a>.'},*/


function show() {
    portfolio = portfolio.slice(4).concat(portfolio.slice(0,4));
    return portfolio.slice(0,4);
}

function setup() {
    $(".big").tipTip({"edgeOffset":0, "defaultPosition":"left", "offScreen":true});
    $(".big").click(function ()
		    {
			$(this).parent().hide();
			$("#tiptip_holder").hide();
			$(".box").show();
		    });
    $(".big").hover(
		    function () {
			$(this).append("<a id='minus' href='#'><img src='minus.png'/></a>");
			// hack tooltip into position.
			var mar = $("#tiptip_holder").css("margin-top");
			mar = mar.slice(0,mar.length-2);
			$("#tiptip_holder").css({"margin-top":+mar + 235});
	
		    },
		    function () {
			$("#minus").remove();
		    }
		    ); 
    $(".box").tipTip({"edgeOffset":-5, "defaultPosition":"left", "offScreen":true});
    $(".box").hover(
		    function () {
			$(this).append("<a id='plus' href='#'><img src='plus.png'></a>");
			// hack tooltip into position.
			var mar = $("#tiptip_holder").css("margin-top");
			mar = mar.slice(0,mar.length-2);
			mar = +mar;
			$("#tiptip_holder").css({"margin-top":mar + 120});
		    },
		    function () {
			$("#plus").remove();
		    }
		    ); 
    
    $(".box").click(function () 
		    {
			$(this).parent().children(".big_holder").show();
			$("#tiptip_holder").hide();
			$(".box").hide();
		    });
}

$(function () {
	setup();
	$("#content").after('<div id="refresh" title="View more portfolio items."><a href="#"><img src="refresh.png" alt="reload portfolio" /></a></div>');
	$("#refresh").tipTip();
	$("#refresh").click(function ()
			    {
				var new_portfolio = show();
				var content = "";
				for(var i = 0; i < 4; i++){
				    content += '<div class="holder"><div class="box" title="Click for larger version / more info."><a href="#"><img src="';
				    content += new_portfolio[i]["img"];
				    content += '" /></a></div><div class="big_holder"><div class="big" title="Click to close."><a href="#"><img src="';
				    content += new_portfolio[i]["big"];
				    content += '" /></a></div><p>';
				    content += new_portfolio[i]["desc"];
				    content += '</p></div></div>';
				};
				$("#content").html(content);
				setup();
			    });
	
    })  

