/**

Classic Charms & Classic Beads Facebook Like Button
Last Modified: August 6, 2011

**/

(function(){
	
	var init = function() {
		
		if ((!jQuery)||(!$)||($!=jQuery)) return;
		if ($("#fb_likebutton_iframe").length!=0) return;
		if ($("div.itemimg").length==0) return; //ugly hack for CB since item pages don't have different DOM structure
		
		var selectors = [
			"div#bodycontainer td.add-to-cart"/*"h1.pagebanner:first"*/, //classic beads
			"div.iteminfo:first" //classic charms
		];
		var selector = null;
		
		$.each(selectors, function(index, item) {
			if ($(item).length!=0) {
				selector = item;
				return false;
			}
		});
		
		if (selector==null) return;
		if ($(selector).length==0) return;
		
		var base = "http://www.facebook.com/plugins/like.php?layout=button_count&show_faces=false&width=90&action=like&colorscheme=light&height=35&href=";
		var url = base + escape(window.location.href);
		
		$("<iframe>").attr({
			"scrolling" : "no",
			"frameborder" : "0",
			"allowTransparency" : "true",
			"id" : "fb_likebutton_iframe",
			"src" : url
		}).appendTo(selector);
	
	};
	
	$(init);

})();
