





function dsqToggleReply(linkEl, parentPostId) {
	
		var ifrs = (typeof(disqus_iframe_css) != 'undefined') ? disqus_iframe_css : '';
	

	if(linkEl.innerHTML == 'reply') {
		
			document.getElementById('dsq-reply-' + parentPostId).innerHTML = '<iframe marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" style="filter: chroma(color=#FFFFFF)" allowtransparency="true" width="100%" class="dsq-post-reply" height="320" src="http://disqus.com/forums/webnotes/usability_not_a_dream/reply.html?f=webnotes&t=usability_not_a_dream&parent_post=' + parentPostId + '&to_redirect=' + encodeURI(window.location) + '" style="border: 0px"></iframe>';
		

		
			document.getElementById('dsq-post-video-' + parentPostId).style.display = 'inline';
		

		if(document.getElementById('dsq-edit-' + parentPostId)) {
			document.getElementById('dsq-edit-' + parentPostId).style.display = 'none';
		}

		linkEl.innerHTML = 'cancel';
	} else if(linkEl.innerHTML == 'cancel') {
		document.getElementById('dsq-reply-' + parentPostId).innerHTML = '';

		linkEl.innerHTML = 'reply';

		
			document.getElementById('dsq-post-video-' + parentPostId).style.display = 'none';
			document.getElementById('dsq-post-video-' + parentPostId).innerHTML = '<img src="http://media.disqus.com/images/seesmic/record.png" class="dsq-record-img"> record video comment';
		
	}
}


	if(typeof(Dsq.Thread.videoReply == 'function')) {
		var dsqVideoReply = Dsq.Thread.videoReply;
	} else {
		// For backwards compatibility with old plugin.
		function dsqVideoReply(linkEl, parentPostId) {
			
				var ifrs = (typeof(disqus_iframe_css) != 'undefined') ? disqus_iframe_css : '';
			

			
				var def_email = (typeof(disqus_def_email) != 'undefined') ? disqus_def_email : '';
			

			
				var def_name = (typeof(disqus_def_name) != 'undefined') ? disqus_def_name : '';
			

			if(parentPostId) {
				var toggleVideo = '<img src="http://media.disqus.com/images/seesmic/record.png" class="dsq-record-img"> record video comment';
				var toggleText = 'text comment';
				var container = document.getElementById('dsq-reply-' + parentPostId);
				var parentPostQueryStr = 'parent_post=' + parentPostId + '&';
			} else {
				var toggleVideo = '<img src="http://media.disqus.com/images/seesmic/record.png" class="dsq-record-img"> Record video comment';
				var toggleText = 'Text comment';
				var container = document.getElementById('dsq-post-add');
				var parentPostQueryStr = '';
			}

			if(linkEl.innerHTML.toLowerCase() == toggleVideo.toLowerCase()) {
				linkEl.innerHTML = toggleText;
				container.innerHTML = '<iframe name="dsq-video_' + parentPostId + '-frame" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" allowtransparency="true" width="100%" style=" height: 370px; "class="dsq-post-video" src="http://disqus.com/embed/video.html?' + (new Date()).getTime() + '&f=webnotes&t=usability_not_a_dream&' + parentPostQueryStr + 'to_redirect=' + encodeURIComponent(window.location) + '"></iframe>';
			} else if(linkEl.innerHTML == toggleText) {
				linkEl.innerHTML = toggleVideo;
				container.innerHTML = '<iframe name="dsq-reply_' + parentPostId + '-frame" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" allowtransparency="true" width="100%" class="dsq-post-reply" src="http://disqus.com/forums/webnotes/usability_not_a_dream/reply.html?' + (new Date()).getTime() + '&f=webnotes&t=usability_not_a_dream&' + parentPostQueryStr + 'to_redirect=' + encodeURIComponent(window.location) + '&ifrs=' + ifrs + '&def_email=' + def_email + '&def_name=' + def_name + '"></iframe>';
			}
		}
	}





	if(typeof seesmic == 'undefined') { var seesmic = {}; }
	seesmic.widget = new function () {
		this.callback =  function (data) {
			playerVersion  = data.disqusplayer;
		}
	};

	
	var scriptEl = document.createElement('script');
	scriptEl.setAttribute('type', 'text/javascript');
	scriptEl.setAttribute('src', 'http://seesmic.com/version.js?callback=seesmic.widget.callback');
	document.getElementsByTagName('head')[0].appendChild(scriptEl);

	
	var scriptEl = document.createElement('script');
	scriptEl.setAttribute('type', 'text/javascript');
	scriptEl.setAttribute('src', 'http://media.disqus.com/javascript/library/swfobject.js');
	document.getElementsByTagName('head')[0].appendChild(scriptEl);

	function see_play_video(_videoUri, _add) {
		var swf = !!playerVersion ? playerVersion : "http://seesmic.com/embeds/StandalonePlayer.swf";

		flashcontentDiv = document.getElementById(_videoUri+"_content");
		previewDiv = document.getElementById(_videoUri+"_preview");
		hideDiv = document.getElementById(_videoUri+"_hide");
		showDiv = document.getElementById(_videoUri+"_show");
		if(_add) {
			// push flash widget
			var so = new SWFObject(swf, "sotester", "300", "270", "9", "#000000");
			so.addVariable("video", _videoUri);
			so.addParam("allowFullScreen", "true");
			so.addParam("allowScriptAccess","always");
			so.useExpressInstall('swfobject/expressinstall.swf');
			so.write(_videoUri+"_content");

			previewDiv.style.display="none";
			hideDiv.style.display="block";
			showDiv.style.display="none";
		}
		else {
			flashcontentDiv.innerHTML="";
			previewDiv.style.display="block";

			//previewDiv.style.display="none";
			hideDiv.style.display="none";
			showDiv.style.display="block";
		}
	}



(function() {
	
		var ifrs = (typeof(disqus_iframe_css) != 'undefined') ? disqus_iframe_css : '';
	

	
		var def_email = (typeof(disqus_def_email) != 'undefined') ? disqus_def_email : '';
	

	
		var def_name = (typeof(disqus_def_name) != 'undefined') ? disqus_def_name : '';
	


	if(!disqus_post_container) {
		// For plugin 1.1 and 2.0
		disqus_post_container = document.getElementById('dsq-reply') || document.getElementById('dsq-post-add');
	}

	if(disqus_post_container) {
		
			
			   	disqus_post_container.innerHTML += '<div id="dsq-post-add"><iframe id="dsq-post-add-iframe" name="dsq-reply-frame" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" allowtransparency="true" src="http://disqus.com/forums/webnotes/usability_not_a_dream/reply.html?' + (new Date()).getTime() + '&f=webnotes&t=usability_not_a_dream&to_redirect=' + encodeURIComponent(window.location) + '&ifrs=' + ifrs + '&def_email=' + def_email + '&def_name=' + def_name + '"></iframe><a href="#" onclick="dsqVideoReply(this); return false"><img src="http://media.disqus.com/images/seesmic/record.png" class="dsq-record-img"> Record video comment</a></div>';
			
		
	}

	
	var disqus_auth_wrap = document.getElementById('dsq-auth-wrap'); // deprecated

	if(disqus_auth_wrap) {
		
			disqus_auth_wrap.innerHTML = 'You are not logged in. <a id="dsq-login-toggle" href="http://disqus.com/profile/login/?next=article:4190874" onclick="Dsq.Thread.login(this); return false">(Log in)</a>';
		
	} 	
})()

	var isMashable = false;
	if (isMashable) {
		var facebookXdReceiverPath = '/facebook_xd_receiver.html';	
	}
	window.DisqusFbcParentController = (function (){
	var obj = {};
	
	// Private
	var rpcServer = null;
	var initted = false;
	var onInit = [];
	var user = null;
	var defaultRpcClient = null;
	var receiverUrl = "http://disqus.com/facebook-connect/xd_receiver.htm";
	var loginNode = document.getElementById('dsq-fbc-login');
	var authenticatedNode = document.getElementById('dsq-fbc-authenticated');
	var fbName = document.getElementById('dsq-fbc-name');
	var fbPic = document.getElementById('dsq-fbc-profilepic');
	var iframes = { 
		// Map of rpcServerName -> (rpcClient, iframeDomNode) pairs
		// Main Disqus iframe is added by init()
	};
	var makeRpcServerName = function(opt_postId) {
		// this method should be identical here and in iframeController factored out 
		if (opt_postId === undefined) {
			return 'disqusIframeFbcRpcServer';
		} else {
			return 'disqusIframeFbcRpcServer-' + opt_postId;
		}
	};
	var makeRpcClientName = function(opt_postId) {
		if (opt_postId === undefined) {
			return 'disqusParentFbcRpcClient';
		} else {
			return 'disqusParentFbcRpcClient-' + opt_postId;
		}
	};
	var makeIframeName = function(opt_postId) {
		if (opt_postId === undefined) {
			return 'dsq-reply-frame';
		} else {
			return 'dsq-reply_' + opt_postId + '-frame';
		}
	};
	var updateFrame = function(rpcServerName) {
		var rpcClient = iframes[rpcServerName][0];
		var iframeNode = iframes[rpcServerName][1];
		rpcClient.send('setConnected', user);
		if (!window.isMashable) {
			// TODO: kill with fire
			iframeNode.style.height = user ? '172px' : '340px';
		} else {
			iframeNode.style.height = user ? '220px' : '415px';
		}
	};
	var setUser = function(userNow) {
		user = userNow;
		// pass null user data to signify logout
		var rpcServerName = null;
		for (rpcServerName in iframes) {
			updateFrame(rpcServerName);
		}
	};
	var createRpcClient = function(frameNode, opt_postId) {
		// Creates an XdRpcClient for communication with the iframe frameNode with parent comment 
		// equal to opt_postId. If this argument is undefined, creates a client for communicating with 
		// the main Disqus iframe. The XdRpcClient and frameNode are added to the "iframes" array.
		//
		// Returns the rpcServerName that the client is accessing. This name is also the index into
		// the "iframes" array.
		var ifName = makeIframeName(opt_postId);
		var rpcServerName = makeRpcServerName(opt_postId);
		var rpcClientName = makeRpcClientName(opt_postId);
		var endpoint = new FB.XdComm.EndPoint(ifName, FB.XdComm.PageRelation.child, receiverUrl);
		var rpcClient = new FB.XdComm.XdRpcClient(rpcServerName, rpcClientName, endpoint, receiverUrl);
		iframes[rpcServerName] = [rpcClient, frameNode];
		if (window.isMashable) {
			// TODO: does this belong here?
			// Right now only Mashable needs this, because only they have a Connect button
			// inside the iframe, and that's the only iframe-> server communication
			rpcClient.send('createRpcClient', FBConnect.xdReceiverUrl);
		}
		return rpcServerName;
	};
	var postToNewsfeed = function(siteName) {
		if (!siteName) {
			return;
		}
		params = {
			'site_name': siteName,
			'comment_url': document.URL
			};
		FB.Connect.showFeedDialog(64074648976, params, null, null, null, FB.RequireConnect.require);
	};
	var requireSession = function() {
		// Used when the iframe wants to initiate an FB Connect session
		FB.Connect.requireSession(obj.onLogin);
	};

	// Public
	obj.onLogin = function() {
		var dsqReplyAuth = Dsq.Utils.getElementsByClassName(document, 'div', 'dsq-reply-bar-auth');
		
		// This is triggered either when the user connects or when they're already connected on visit
		loginNode.style.display='none';
		for(var i=0; i<dsqReplyAuth.length; i++) {
			dsqReplyAuth[i].style.display = 'none';
		}
		
		authenticatedNode.style.display='block';
		FBConnect.RenderXFBML([
			'dsq-fbc-profilepic',
			'dsq-fbc-name'
		]);
		FB.Facebook.apiClient.auth_getSignedPublicSessionData(setUser);
	};
	obj.logout = function() {
		var dsqReplyAuth = Dsq.Utils.getElementsByClassName(document, 'div', 'dsq-reply-bar-auth');
		
		FB.Connect.logout();
		if (!window.isMashable) {
			loginNode.style.display='inline';
		}
		
		for(var i=0; i<dsqReplyAuth.length; i++) {
			dsqReplyAuth[i].style.display = 'block';
		}
		
		authenticatedNode.style.display='none';
		// Passing null user data to signify logout
		setUser(null);
		return false;
	 };
	obj.onCreateReplyIframe = function(postId, frameNode) {
		var rpcServerName = createRpcClient(frameNode, postId);
		updateFrame(rpcServerName);
		if(user && postId) {
			var node = document.getElementById('dsq-reply-bar-auth-' + postId);
			if (node) { // Not present in Mashable
				node.style.display = 'none';
			}
		}
	};
	obj.checkForNewsfeed = function() {
		defaultRpcClient.send('queryNewsfeed', null, postToNewsfeed);
	};
	obj.ensureInit = function(callback) {
		// If the controller hasn't already been initted, will wait until it has been before calling
		// callback; otherwise, calls it immediately. Does not attempt to call init.
		if (initted) {
			callback();
		} else {
			onInit.push(callback);
		}
	};
	obj.init = function() {
		// This method should be called after the FB scripts have loaded, FB.init has been called, 
		// and XdComm loaded.
		if (initted) {
			// I think this double init is caused by a bug with FB.ensureInit
			return;
		}
		var frameNode = document.getElementById('dsq-post-add-iframe');
		var rpcServerName = createRpcClient(frameNode);
		defaultRpcClient = iframes[rpcServerName][0];
		if (!window.isMashable) {
			FB.XFBML.Host.addElement(new FB.XFBML.LoginButton(loginNode));
		}
		if (window.isMashable) {
			// Right now only Mashable needs this, because only they have a Connect button
			// inside the iframe, and that's the only iframe-> server communication
			var exportedMethods = {
				requireSession : {'method': requireSession}
			};
			rpcServer = new FB.XdComm.XdRpcServer('disqusParentFbcRpcServer', exportedMethods);

		}
		initted = true;
		for (var i=0; i<onInit.length; i++) {
			onInit[i]();
		}
	};
	
	return obj;
})();

	window.ExecuteWhen = (function () {
	var obj = {}
	
	// Private
	var running = false;
	var timer = null;
	var pending = [];
	var startTimer = function() {
		running = true;
		timer = setInterval(obj.heartBeat, 100);
	};
	var stopTimer = function() {
		running = false;
		clearInterval(timer);
	};
	
	// Public
	obj.add = function (condition, code) {
		pending.push([condition,code]);
		this.heartBeat(); //!
		if (!running) {
			startTimer();
		}
	};
	obj.heartBeat = function() {
		if (!pending.length) {
			stopTimer();
		}
		var newPending = [];
		for (var i=0; i<pending.length; i++) {
			var cond = pending[i][0];
			var code = pending[i][1];
			if (cond()){
				code();
			}
			else {
				newPending.push([cond, code]);
			}
		}
		pending = newPending;
	};
	return obj;
})();

// also used in embed_thread.js:
window.fbIsReady = function () { return window.FB && window.FBConnect };
// NOTE: This script gets executed again without threadEl
//       set when we are loaded again as the fbc_receiver.
//       In this case, we don't need the hidden container.
if(typeof threadEl != 'undefined') {
	var fbDiv = document.createElement('div');
	fbDiv.id = "FB_HiddenContainer";	// Required or else FeatureLoader will execute a document.write.
	fbDiv.style.position = 'absolute';	// This is intentionally not setting display to none as this breaks
	fbDiv.style.top = '-10000px';		// Flash in Safari.
	fbDiv.style.left = '-10000px';
	fbDiv.style.width = '0px';
	fbDiv.style.height = '0px';
	threadEl.appendChild(fbDiv);
}
var fbJS = document.createElement('script');
fbJS.type = "text/javascript";
fbJS.src = "http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php";
var head = document.getElementsByTagName('head')[0];
head.appendChild(fbJS);
var fbJS2 = document.createElement('script');
fbJS2.type = "text/javascript";
fbJS2.src = "http://media.disqus.com/javascript/facebook_widget_load.js";
head.appendChild(fbJS2);

ExecuteWhen.add(window.fbIsReady,
	function () {
		FBConnect.init('e7728e3f0de0b96d53d47a0c6076aed5', window.facebookXdReceiverPath);
	});

	ExecuteWhen.add(window.fbIsReady,
		function() {
			FBConnect.ensureInit(function () {
				DisqusFbcParentController.init();
				FB.Connect.get_status().waitUntilReady(function(status) {
					if(status == FB.ConnectState.connected) {
						DisqusFbcParentController.onLogin();
					}
				});
			});
		});

