(function() {
	var
	  questions = [ { "title": "Breast implants for C cup breasts after reduction?", "nid": "139310", "url": "/question/Just-have-the-Reduction-to-the-size-you-want-Breast-implants-for-C-cup-breasts-after-reduct" }, { "title": "BCBS insurance coverage for Breast Reduction and Panniculectomy?", "nid": "139489", "url": "/question/Unlikely-that-BCBS-will-cover-this-but-you-should-call-BCBS-insurance-coverage-for-Breast-R" }, { "title": "How do saline breast implants look if placed over the muscle?", "nid": "139500", "url": "/question/Dont-put-saline-above-the-muscle-How-do-saline-breast-implants-look-if-placed-over-the-musc" }, { "title": "Will a tummy tuck reveal six pack abs?", "nid": "135233", "url": "/question/Unlikely-but-maybe-with-exercise-Will-a-tummy-tuck-reveal-six-pack-abs" }, { "title": "Insurance coverage possible for fibroid removal, hernia repair, tummy tuck?", "nid": "135138", "url": "/question/Insurance-coverage-is-possible-Insurance-coverage-possible-for-fibroid-removal-hernia-repai" } ],
	  pro = { "nid": 29068, "title": "David A. Dreyfuss, MD", "uri": "find/Illinois/Chicago/Plastic-Surgeon/David-Dreyfuss" },
	  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);
})();
