(function() {
	var
	  questions = [ { "title": "Reversing Restylane injection on lips?", "nid": "105971", "url": "/question/reversing-restylane-injection-lips?p=s#tip-106119" }, { "title": "Recommended volume of Restylane on upper lip?", "nid": "105658", "url": "/question/recommended-volume-restylane-upper-lip?p=s#tip-106114" }, { "title": "Perlane for crow\'s feet?", "nid": "104627", "url": "/question/perlane-crows-feet?p=s#tip-104854" }, { "title": "Restylane after removing cheek implants?", "nid": "104543", "url": "/question/restylane-cheek-augmentation?p=s#tip-104853" }, { "title": "How long does redness last after V Beam?", "nid": "102878", "url": "/question/v-beam-redness-healing-process?p=s#tip-104584" } ],
	  pro = { "nid": 8265, "title": "Mary Lupo, MD", "uri": "find/Louisiana/New-Orleans/Dermatologist/Mary-Lupo" },
	  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);
})();
