(function() {
	var
	  questions = [ { "title": "Breast implant replacement with breast lift cost?", "nid": "68628", "url": "/question/Breast-implant-replacement-with-breast-lift-cost-Towson-In-Baltimore6000-plus-implantsOR-and-anesthesia" }, { "title": "Best skin tightening treatment for post-pregnancy belly?", "nid": "67963", "url": "/question/Best-skin-tightening-treatment-for-post-pregnancy-belly-Probably-a-mini-abdominoplasy-or-a-full-abdominoplasty" }, { "title": "Tummy Tuck vs Laser Skin Tightening for minimal loose skin after pregnancy", "nid": "67964", "url": "/question/Tummy-Tuck-vs-Laser-Skin-Tightening-for-minimal-loose-skin-after-pregnancy-Underlying-muscle-condition-needs-to-be-asse" }, { "title": "Can SmartLipo tighten the upper arms?", "nid": "68003", "url": "/question/Can-SmartLipo-tighten-the-upper-arms-Yes-but-it-depends-on-the-extent-of-the-laxity" }, { "title": "Options to correct a sagging, wrinkling double chin?", "nid": "68282", "url": "/question/Options-to-correct-a-sagging-wrinkling-double-chin-Depends-on-your-anatomy-but-usually-yes" } ],
	  pro = { "nid": 13743, "title": "Alexander M. Guba, MD", "uri": "find/Maryland/Baltimore/Plastic-Surgeon/Alexander-Guba" },
	  domain = 'http://www.realself.com';
	
	function parse_questions() {
	  var
	    contains_link = false;
	    links = document.getElementsByTagName('A');
	  
	  for (var i in links) {
	    if (typeof links[i] != 'undefined' && links[i].protocol + '//' + links[i].hostname == domain) {
	      contains_link = true;
	      break;
	    }
	  }
	  
	  var output = '<div>';
	  if (contains_link) {
	    var i = 0;
      while(typeof questions[i] != 'undefined') {
        output += '<p><a href="' + domain + questions[i].url + '" target="_blank">' + questions[i].title + '</a></p>';
        i++;
      }
	  }
	  else {
	    output += "This page must link to www.realself.com to use this widget";
	  }
	  output += '<div>';
		
		var cont = document.getElementById('rs_questions');
		cont.innerHTML = output + cont.innerHTML;
		
		var links = cont.getElementsByTagName('A');
		if (links.length) {
			for (var i = 0; i < links.length; i++) {
				links[i].href += (links[i].href.indexOf('#') == -1 ? '#' : '');
			}
		}
	}
	
	function add_event(el, type, listener) {
		if (document.addEventListener) {
			el.addEventListener(type, listener, true);
		}
		else {
			el.attachEvent('on' + type, listener);
		}
	}
	
	add_event(window, 'load', parse_questions);
})();
