jQuery.fn.tagName = function(){
        if(1 === this.length){
                return this[0].tagName.toLowerCase();
        } else{
                var tagNames = [];
                this.each(function(i, el){
                        tagNames[i] = el.tagName.toLowerCase();
                });
                return tagNames;
        }
};

jQuery(document).ready(function() {
	
	$('A[rel="external"]').click( function() {
        window.open( $(this).attr('href') );
        return false;
    });
	
	$('IMG[class="lightbox"]').wrap(function() {
		var img = "/" + $(this).attr("src");
		var h3 = $(this).parents("div.project").find("h3").text();
		return '<a rel="shadowbox[' + h3 + ']" href="' + img + '" title="OVERDICK: ' + h3 + '" />'
	});
	
	Shadowbox.init();
	
	$("#cinfo #cinfo_content").hide();
	
	$("#cinfo h3").click(function() {
		var c = $("#cinfo #cinfo_content");
		var cs = $(c).css("display");
		if(cs == "none") {
		// open it
			$(c).show("fast");
			$("#cinfo h3").css("background-position", "0px -40px");
		} else {
		// close it
			$(c).hide("fast");
			$("#cinfo h3").css("background-position", "0px 0px");
		}
	});
	
});

