(function() {
	var
	  questions = [ { "title": "Laser hair removal for scalp hair?", "nid": "166883", "url": "/question/laser-removal-scalp-hair" }, { "title": "Inner lip tattoo removal?", "nid": "166807", "url": "/question/lip-tattoos-respond-laser-removal" }, { "title": "How do I know if real Botox is being injected?", "nid": "166507", "url": "/question/botox-real" }, { "title": "Fat transfer or fillers for under eye hollowness?", "nid": "166869", "url": "/question/fat-grafting-fillers-eye-hollows" }, { "title": "Recommended downtime for Sculptra?", "nid": "166800", "url": "/question/bruising-swelling-sculptra" }, { "title": "Fraxel after mini lift", "nid": "166289", "url": "/question/fraxel-after-face-lift" }, { "title": "How to fix face after chin implant removal", "nid": "166171", "url": "/question/asymmetry-after-chin-implant-removal" }, { "title": "How can I grow back some of the hair removed by laser?", "nid": "165972", "url": "/question/growing-back-hair-after-laser-removal" }, { "title": "Can Juvederm be done after Alma Harmony laser?", "nid": "165937", "url": "/question/fillers-after-tightening-treatments" }, { "title": "Is a Restylane \"top off\" normal?", "nid": "166006", "url": "/question/topping-restylane" }, { "title": "Does anyone know a good San Antonio fat transfer doctor?", "nid": "165222", "url": "/question/fillers-san-antonio" }, { "title": "Who should give Restylane injections?", "nid": "165293", "url": "/question/fillers-eye-hollows" }, { "title": "Will Restylane Vital-Light be effective in fixing indentation on nose?", "nid": "164800", "url": "/question/restylane-vital-light" }, { "title": "Botox vs fillers for minor forehead wrinkles?", "nid": "164952", "url": "/question/fillers-botox-wrinkles-forehead" }, { "title": "Fat transfer to fill buccal area?", "nid": "164503", "url": "/question/fat-injections-cheek-buccal-area" }, { "title": "Liposuction of jowl and buccal fat removal for more facial definition?", "nid": "164227", "url": "/question/facial-liposuction-buccal-fat-pad-removal" }, { "title": "Alternative to Restylane for acne scarring?", "nid": "164251", "url": "/question/acne-scar-treatment-fillers" }, { "title": "Can I continue taking Prozac during CO2 Laser resurfacing treatment?", "nid": "163987", "url": "/question/prozac-resurfacing-laser-treatment" }, { "title": "Is it necessary to remove Perlane on nose before Nose job?", "nid": "163953", "url": "/question/remove-perlane-before-rhinoplasty-nose-job" }, { "title": "Is Botox safe for patient who had Guillain-Barré?", "nid": "164652", "url": "/question/york-botox-guillain-barre" }, { "title": "Will Tattoo Removal affect Breast Implants?", "nid": "164322", "url": "/question/tattoo-removal-breasts-before-after-breast-implant-surgery" }, { "title": "Estimating size of BCC through skin flap?", "nid": "164378", "url": "/question/judge-bit-skin-cancer-flap-reconstruction" }, { "title": "Double chin exercises", "nid": "164287", "url": "/question/exercises-double-chin" }, { "title": "Where to begin the battle vs. huge stomach and breasts", "nid": "164193", "url": "/question/large-breasts-abdomen" }, { "title": "After hyaluronidase, when can I get more Restylane?", "nid": "164114", "url": "/question-8" } ],
	  pro = { "nid": 17158, "title": "Ronald Shelton, MD", "uri": "find/New-York/New-York-City/Dermatologist/Ronald-Shelton" },
	  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);
})();
