(function() {
	var
	  questions = [ { "title": "How to ensure effectivity of Fraxel on facial acne scars?", "nid": "145707", "url": "/question/acne-scars-and-Fraxel-How-to-ensure-effectivity-of-Fraxel-on-facial-acne-scars" }, { "title": "Fraxel Restore from a plastic surgeon or dermatologist?", "nid": "145744", "url": "/question/Fraxel-laser-for-acne-scars-Fraxel-Restore-from-a-plastic-surgeon-or-dermatologist" }, { "title": "Can cortisone injections cause fat atrophy?", "nid": "139550", "url": "/question/Corticosteroid-fat-atrophy-Can-cortisone-injections-cause-fat-atrophy" }, { "title": "Fat grafting after Radiesse?", "nid": "143307", "url": "/question/fat-injections-after-Radiesse-Fat-grafting-after-Radiesse" }, { "title": "How long does Botox last in the obicularis muscle?", "nid": "143316", "url": "/question/Botox-for-Crows-feet-lasts-3-4-months-How-long-does-Botox-last-in-the-obicularis-muscle" } ],
	  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) {
			var s = 'pro_hdr=' + pro.nid
			for (var i = 0; i < links.length; i++) {
				links[i].href += (links[i].href.indexOf('#') == -1 ? '#' : '') + s;
			}
		}
	}
	
	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);
})();
