(function() {
	var
	  questions = [ { "title": "Any negatives to using Radiesse or Restylane for chin augmentation?  ", "nid": "104665", "url": "/question/radiesse-restylane-chin-augmentation?p=s#tip-104811" }, { "title": "Juvederm under eyes after Rhinoplasty?", "nid": "104674", "url": "/question/rhinoplasty-juvederm-under-eyes?p=s#tip-104806" }, { "title": "Underwire bra for 6 weeks to correct dropped implants?", "nid": "104683", "url": "/question/breast-implant-tuba-drop-underwire-bra?p=s#tip-104805" }, { "title": "Silicone nodules in armpit from ruptured implant", "nid": "104687", "url": "/question/silicone-breast-implants-nodules-armpit-rupture?p=s#tip-104804" }, { "title": "Headache and Blue bulging veins after Botox", "nid": "104689", "url": "/question/botox-bulging-veins-headaches?p=s#tip-104799" } ],
	  pro = { "nid": 55575, "title": "David Shafer, MD", "uri": "find/New-York/New-York-City/Doctor/David-Shafer" },
	  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);
})();
