
function insertAfter(referenceNode, newNode) {
    referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}

function show_window(loc){
	var loc = window.location.href;
	window.open("//cloudcma.com/api_widget/1e8c9814df462494b7b73eb0ec90a1ac/show?post_url=cloudcma.com&source_url="+loc);
}

var loc = window.location.href;
var el = document.createElement("a");
var style_tag = document.createElement("style");
el.href = '#';
el.className = "cloud_cma_button_class";

if(el.addEventListener){
    el.addEventListener('click', function(e) {
		e.preventDefault();
		show_window(loc);
	});
} else if(el.attachEvent){ // IE < 9
    el.attachEvent('onclick', function(e) {
		e.preventDefault();
		show_window(loc);
	});
}
el.innerHTML = "What's my home worth?";
style_tag.innerHTML = 'a.cloud_cma_button_class{font-family: helvetica, arial;position: relative;background-image: -webkit-linear-gradient(top, rgba(0,197,16,1) 0%,rgba(0,158,16,1) 100%);background-image:-moz-linear-gradient(top, rgba(0,197,16,1) 0%,rgba(0,158,16,1) 100%);background-image:-o-linear-gradient(top, rgba(0,197,16,1) 0%,rgba(0,158,16,1) 100%);background-image:linear-gradient(top, rgba(0,197,16,1) 0%,rgba(0,158,16,1) 100%);background-color:#00C510;-webkit-box-shadow: 1px 1px 3px 0px rgba(191,191,191,0.58);-moz-box-shadow: 1px 1px 3px 0px rgba(191,191,191,0.58);box-shadow: 1px 1px 3px 0px rgba(191,191,191,0.58);border: solid 1px rgba(2,137,13,1);-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;padding: 6px 6px;display: inline-block;font-size: 16px;text-align: center;color: rgba(255,255,255,1);text-decoration:none;text-shadow: 0px 1px 0px rgba(0,121,10,1);}';

var script = document.getElementById("cloudcma_api_widget_script");
insertAfter(script, el);
insertAfter(script, style_tag);
