(function () {
	var config,
	create,
	widget,
	
	config = {
		lang : "sv",
		containerId : "insertJannrSocial",
		mainArticle : {
			tagName : "ul",
			className : "social",
			appendChildren : [{
				tagName : "li",
				appendChildren : [{
					tagName : "a",
					rel : "external",
					href : "http://jannr.com/",
					title : "jannr på tumblr",
					appendChildren : [{
						tagName : "img",
						src : "http://stil.problemas.se/bilder/lib/social.icons/16px/tumblr.png",
						alt : "Tumblr"
					}]
				}]
			},
			{
				tagName : "li",
				appendChildren : [{
					tagName : "a",
					rel : "external",
					href : "http://facebook.com/mjanner/",
					title : "mjanner på facebook",
					appendChildren : [{
						tagName : "img",
						src : "http://stil.problemas.se/bilder/lib/social.icons/16px/facebook.png",
						alt : "Facebook"
					}]
				}],
			},
			{
				tagName : "li",
				appendChildren : [{
					tagName : "a",
					rel : "external",
					href : "http://twitter.com/mjanner/",
					title : "mjanner på twitter",
					appendChildren : [{
						tagName : "img",
						src : "http://stil.problemas.se/bilder/lib/social.icons/16px/twitter.png",
						alt : "Twitter"
					}]
				}],
			},
			{
				tagName : "li",
				appendChildren : [{
					tagName : "a",
					rel : "external",
					href : "http://delicious.com/mjanner/",
					title : "mjanner på delicious",
					appendChildren : [{
						tagName : "img",
						src : "http://stil.problemas.se/bilder/lib/social.icons/16px/delicious.png",
						alt : "Delicious"
					}]
				}],
			},
			{
				tagName : "li",
				appendChildren : [{
					tagName : "a",
					rel : "external",
					href : "http://www.youtube.com/user/mjanner/",
					title : "mjanner på youtube",
					appendChildren : [{
						tagName : "img",
						src : "http://stil.problemas.se/bilder/lib/social.icons/16px/youtube.png",
						alt : "YouTube"
					}]
				}],
			},
			{
				tagName : "li",
				appendChildren : [{
					tagName : "a",
					rel : "external",
					href : "http://www.vimeo.com/user695970",
					title : "martin på vimeo",
					appendChildren : [{
						tagName : "img",
						src : "http://stil.problemas.se/bilder/lib/social.icons/16px/vimeo.png",
						alt : "Vimeo"
					}]
				}],
			},
			{
    			tagName : "li",
    			appendChildren : [{
    				tagName : "a",
    				href : "http://bambuser.com/channel/mjanner",
    				title : "mjanner på bambuser",
    				appendChildren : [{
    					tagName : "img",
    					src : "http://stil.problemas.se/bilder/lib/social.icons/16px/bambuser.png",
    					alt : "Bambuser"
    				}]
    			}]
    		},
			{
				tagName : "li",
				appendChildren : [{
					tagName : "a",
					rel : "external",
					href : "http://www.flickr.com/photos/stil/",
					title : "stil på flickr",
					appendChildren : [{
						tagName : "img",
						src : "http://stil.problemas.se/bilder/lib/social.icons/16px/flickr.png",
						alt : "Flickr"
					}]
				}]
			},
			{
				tagName : "li",
				appendChildren : [{
					tagName : "a",
					rel : "external",
					href : "http://friendfeed.com/mjanner/",
					title : "mjanner på friendfeed",
					appendChildren : [{
						tagName : "img",
						src : "http://stil.problemas.se/bilder/lib/social.icons/16px/friendfeed.png",
						alt : "FriendFeed"
					}]
				}]
			},
			{
				tagName : "li",
				appendChildren : [{
					tagName : "a",
					rel : "external",
					href : "http://www.linkedin.com/in/genstans",
					title : "ingenstans på linkedin",
					appendChildren : [{
						tagName : "img",
						src : "http://stil.problemas.se/bilder/lib/social.icons/16px/linkedin.png",
						alt : "LinkedIn"
					}]
				}]
			}]
		}
	};









	create = function (obj) {
		var keys, 
		newElement = obj.tagName ? document.createElement(obj.tagName) : document.createElement("div"),
		i,
		newKid;
		for (keys in obj) {
			if (keys !== "tagName") {
				if ((/clas[s](Name)?/).test(keys)) {
					newElement.className = obj[keys];
				} else if (newElement.style[keys]) {
					newElement.style[keys] = obj[keys];
				} else if (keys === "appendChildren") {
					for (i = 0; i < obj[keys].length; i += 1) {
						newKid = create(obj[keys][i]);
						newElement.appendChild(newKid);
					}
				} else {
					newElement[keys] = obj[keys];
				}
			}
		}
		return newElement;
	};
	widget = {
		init : function () {
			var cf = config,
			cont = document.getElementById(cf.containerId),
			cn = "jannrWidget";
			cont.appendChild(create(cf.mainArticle));
		}
	};
	widget.init();
}());

