

/* $().getCardUrl(); jQuery Plugin */
jQuery.fn.getCardUrl = function() {
	return this.each(function(){			
		var cardType = this.getAttribute('type');
		var cardType = cardType.split(',');
		var cardUrl = 'http://www.zachwong.com/tarot/'
		var position = cardType[2];
		//major highpriestess up
		//cups 02 down
		var arcana = cardType[0];
		if (arcana == 'major'){
			var card = cardType[1];
			$(this).append(' &sect;');
			cardUrl += arcana+'/'+card+'.html';
		} else {
			var suit = cardType[0];
			var card = cardType[1];
			cardUrl += suit+'/'+card+'.html';
		}
		if (position == 'down'){
			$(this).append(' (&darr;)')	
		} else {
			$(this).append(' (&uarr;)')
		}		
		$(this).attr('href',cardUrl)
		$(this).click(function(){											   
			//alert(cardUrl);			   
			window.open(cardUrl,'popcard','width=700,height=500');
			return false;
		})		
	});		
}


/*
 * End Custom Code, Start Plugins
 */
Happy = new function() {
	this.ui = new function(){		
		this.resizeImage = function (img,maxWidth) {		    		                
			$(img).attr("title","Click to View Larger");
			$(img).click(function(){			        				
			});			
		}//ends resizeImage 
		
		this.tooltip = function(obj,tip){
			xOffset = 10;
			yOffset = 20;			
			$("img",obj).attr("alt","");
			$("a",obj).each(function(e){											  				
				//this.title = "";									  
				$("body").append("<p id='tooltip'>"+ tip +"</p>");
				$("#tooltip")
					.css("top",(e.pageY - xOffset) + "px")
					.css("left",(e.pageX + yOffset) + "px")
					.fadeIn("fast");		
			});
			$("a",obj).mouseout(function(){
				this.title = this.t;		
				$("#tooltip").remove();
			});	
			$("a",obj).mousemove(function(e){
				$("#tooltip")
					.css("top",(e.pageY - xOffset) + "px")
					.css("left",(e.pageX + yOffset) + "px");
			});			
		};//ends tooltip		
		
	}//ends user interface object
}//ends happy object




/* Tweet Plugin */
$(function(){ // Start Custom Code, when the document is ready
	$('a.cardpop').getCardUrl();
	$("#flickr").flickr({     
    	api_key: "bf74783eb6051b87f61902d934263f4e",      
		type: "search",
		user_id: "97277980@N00",
		thumb_size: "s",
		size: "o",
		per_page: "50"
  	});
	$("#flickr a img").click(function(){		    											  
		window.open(img.src,'imageWindow','height='+popHeight+',width='+popWidth+'');	                
		return false;								  
	});	
	$(".tweet").tweet({
    	username: "dianenar",
        join_text: " ",
        count: 6
     });
})
