//This javascript created by Ray at 2011-4-8
/*document.write('<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>');
function analytics()
{
 _uacct = "UA-17968634-1";
 urchinTracker();
}
if (document.all){
 window.attachEvent('onload',analytics);
}
else{
 window.addEventListener('load',analytics,false);
}*/

// created by zhanglei http://www.love4026.org  at 2011-2-23

function S(_asId) {
    return document.getElementById(_asId) || null;
}

function CPos(x, y) {
    this.x = x;
    this.y = y;
}

function GetObjPos(ATarget) {
    var target = ATarget;
    var pos = new CPos(target.offsetLeft, target.offsetTop);

    var target = target.offsetParent;
    while (target) {
        pos.x += target.offsetLeft;
        pos.y += target.offsetTop;

        target = target.offsetParent
    }

    return pos;
}

function createFloatBtn() {
	if(S("post-details")){
    var _body = document.getElementsByTagName('body')[0];
    var _html = document.createElement('div');
    _html.innerHTML = '<div class="quotePic"><span style="display:none">Get a Quote</span></div>';
    _html.id = "quotePhoto";
    _body.appendChild(_html);

    var img = S("post-details").getElementsByTagName("img");
    for (var i = 0; i < img.length; i++) {

        //alert(i);

        img[i].onmouseover = function () {
            var pos = GetObjPos(this);
            var w = this.width;
            var h = this.height;
            var x = pos.x + w - 115;
            var y = pos.y + h - 31;
            var cssData = "cursor:pointer; background:url(http://www.rockscrusher.com/images/get-prices-btn.png) no-repeat; _background-image:none; _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://www.rockscrusher.com/images/get-prices-btn.png', sizingMethod='scale');width:108px; height:27px;position:absolute;display:block;left:" + x + "px;top:" + y + "px";
            S(_html.id).setAttribute("style", cssData) || S(_html.id).style.setAttribute('cssText', cssData);
        };
        S(_html.id).onmouseover = function () {
            this.style.display = "block";
        };
        img[i].onmouseout = S(_html.id).onmouseout = function () {
            S(_html.id).style.display = "none";
        };
        S(_html.id).onclick = function () {
            popupChatWin();
            return false;
        };



    }
	}


}

function addLink() {
    var body_element = document.getElementsByTagName('body')[0];
    var selection;
    selection = window.getSelection();
    var pagelink = "<br /><br /> Read more at: <a href='" + document.location.href + "'>" + document.location.href + "</a><br />Copyright &copy; SME";
    var copytext = selection + pagelink;
    var newdiv = document.createElement('div');
    newdiv.style.position = 'absolute';
    newdiv.style.left = '-99999px';
    body_element.appendChild(newdiv);
    newdiv.innerHTML = copytext;
    selection.selectAllChildren(newdiv);
    window.setTimeout(function () {
        body_element.removeChild(newdiv);
    }, 0);
}
document.oncopy = addLink;
document.body.oncopy=function(){ 
event.returnValue=false; 
var s=document.selection.createRange().text; 
t = s+"<br /><br /> Read more at: <a href='"+document.location.href+"'>"+document.location.href+"</a><br />Copyright &copy; SME"; 
clipboardData.setData('Text',t); 
}

function addEvent(obj, type, fn) {
    if (obj.attachEvent) {
        obj["e" + type + fn] = fn;
        obj[type + fn] = function () {
            obj["e" + type + fn](window.event)
        };
        obj.attachEvent("on" + type, obj[type + fn]);
    } else {
        obj.addEventListener(type, fn, false);
    }
}
addEvent(window, 'load', createFloatBtn);

function popupChatWin() {
    comm100_Chat();
    return false;

    //comm100_Chat();return false;
}
