var util = {
	log : function(message) {
        if (typeof (console) != 'undefined' && window.console) {
            console.log(message);
        } 
	},
	queryString : (function(key) {

		var params = {};
		var qs = location.search.substring(1, location.search.length);

		// Turn <plus> back to <space>
		// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
		qs = qs.replace(/\+/g, ' ');
		var args = qs.split('&'); // parse out name/value pairs separated via &
		
		// split out each name=value pair
		for (var i = 0; i < args.length; i++) {
			var pair = args[i].split('=');
			var name = decodeURIComponent(pair[0]);
			
			var value = (pair.length==2)
				? decodeURIComponent(pair[1])
				: name;
			
			params[name] = value;
		}

		return {
			get : function(key, fallback) {
				var value = params[key];
				return (value != null) ? value : fallback;
			},	
			contains : function(key) {
				var value = params[key];
				return (value != null);
			}
		};

	})(),
	youtubeFrame : function(id, w, h, attrs) {
		var frame = document.createElement("iframe");

		frame.setAttribute("type", "text/html");
		frame.setAttribute("frameborder", "0");
		frame.setAttribute("width", w);
		frame.setAttribute("height", h);
		frame.setAttribute("src", "http://www.youtube.com/embed/"+id+"?hd=1");

		// Add any extra attributes
		for(var key in attrs) {
			frame.setAttribute(key, attrs[key]);
		}
		return frame;
	}
};

