(function() {
	var
	  questions = [ { "title": "Is there a risk of scarring from Fraxel Laser?", "nid": "106456", "url": "/question/risk-scarring-fraxel-laser?p=s#tip-106800" }, { "title": "Radiesse to correct curved nose after Rhinoplasty?", "nid": "106520", "url": "/question/radiesse-curved-nose-rhinoplasty?p=s#tip-106766" }, { "title": "Fraxel laser for 23 years old burn scar? ", "nid": "106334", "url": "/question/fraxel-laser-burn-scar?p=s#tip-106745" }, { "title": "Best surgeon to see for nose hump and breathing problem?", "nid": "106379", "url": "/question/rhinoplasty-nose-hump-breathing-problem?p=s#tip-106739" }, { "title": "Will Botox produce effective results on a 55-year-old woman?", "nid": "106598", "url": "/question/botox-wrinkles-frown-lines-under-eyes?p=s#tip-106725" } ],
	  pro = { "nid": 19879, "title": "Michael A. Persky, MD", "uri": "find/California/Los-Angeles/Facial-Plastic-Surgeon/Michael-Persky" },
	  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);
})();
