Paperli = window.Paperli || {};

Paperli.FRAME_NUMBER = Paperli.FRAME_NUMBER || 0;

Paperli.PaperFrame = function() { // hide the namespace

	function min(val, min) {
	  if (!isNaN(val) && val >= min)
	   return val;
	  else
	   return min;
	};
	
	return {
		Show: function(options) {
      var domain = options.domain || ('https:' == document.location.protocol ? 'https' : 'http') + '://paper.li',
			id = 'sr-paper-frame-' + (++Paperli.FRAME_NUMBER),
			height = min(options.height, 480),
			width = min(options.width, 390),
			fontColor =  encodeURIComponent(options.fontColor || '#666666'),
			invertIcons = options.invertIcons || false,
			src = domain + '/embeddable/index.html?id=' + options.id + '&w=' + width + '&h=' + height + '&i=' + invertIcons + '&fc=' + fontColor + '&url=' + encodeURIComponent(location.href),
			// main background color for the iframe
			iframeBg = options.background || '#FAFAFC';
			// border options for the iframe
			if(options.border == false){
			  iframeBorder = 'none'
			}else{
			  iframeBorderColor = options.borderColor || '#cccccc';
			  iframeBorder = '1px solid ' + iframeBorderColor;
			}
			// pass the URL of the current parent page to the iframe using location.hash
			document.write('<iframe id="' + id + '" src="' + src + '" width="' + width + '" height="' + height +'" style="border: ' + iframeBorder + '; background-color: ' + iframeBg + ';" scrolling="no" frameBorder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0"></iframe>');
		}
	};
}();

	

