var autoThumb = { x:0, y:0, wrapper:{}, img:null, ahref : null, dis: null, googleCSEID :'006435242846565645822:lz_6yzyr5oq', gForm: null, uName: null, lnk:null, timer:null, opacityTimer:null, errorTimer:null, hidden:true, linkPool: {}, baseURI: "./", thumbuseclassName: false, enableimagelinks: false, imageCache: [], init: function() { var lnks = document.getElementsByTagName('a'); var i = lnks.length || 0; var cnt = 0; var doc_domain=parseUrl(document.location.href); var clean_domain_link=''; if (!document.cookie.match("disable_cookie") && autoThumb.uName ){ while(i--) { if (!autoThumb.thumbuseclassName || (lnks[i].className && lnks[i].className.search(/autothumb/) != -1) ){ clean_domain_link =parseUrl(lnks[i].href); if(clean_domain_link && doc_domain && lnks[i].href.substr(0,4)=="http" && !clean_domain_link.match(doc_domain) &&autoThumb.enableimagelinks )
{ autoThumb.addEvent(lnks[i], ["focus", "mouseover"], autoThumb.initThumb); autoThumb.addEvent(lnks[i], ["blur", "mouseout"], autoThumb.hideThumb); autoThumb.linkPool[lnks[i].href] = cnt++;}
else
if (clean_domain_link && doc_domain && lnks[i].href.substr(0,4)=="http" && !clean_domain_link.match(doc_domain) && lnks[i].innerHTML.toUpperCase().indexOf('IMG')===-1){ autoThumb.addEvent(lnks[i], ["focus", "mouseover"], autoThumb.initThumb); autoThumb.addEvent(lnks[i], ["blur", "mouseout"], autoThumb.hideThumb); autoThumb.linkPool[lnks[i].href] = cnt++;}
}
}
if(cnt) { autoThumb.loadcss(); autoThumb.preloadImages(); if (autoThumb.googleCSEID !='006435242846565645822:lz_6yzyr5oq' && autoThumb.googleCSEID.length == 33){ autoThumb.gForm = autoThumb.createGoogleForm( ); autoThumb.importGoogleScript();}
else
{ autoThumb.gForm = autoThumb.createGenericForm( );}
autoThumb.wrapper = document.createElement('div'); autoThumb.mainthumb = document.createElement('div'); autoThumb.ind = document.createElement('div'); autoThumb.ahref = document.createElement('a'); autoThumb.ahreflink = document.createElement('a'); autoThumb.dis = document.createElement('a'); autoThumb.poweredby = document.createElement('a'); autoThumb.img = document.createElement('img'); autoThumb.wrapper.appendChild(autoThumb.mainthumb); autoThumb.mainthumb.appendChild(autoThumb.ind); autoThumb.mainthumb.appendChild(autoThumb.img); autoThumb.ahref.appendChild(autoThumb.img); autoThumb.mainthumb.appendChild(autoThumb.ahref); autoThumb.mainthumb.appendChild(autoThumb.dis); autoThumb.mainthumb.appendChild(autoThumb.poweredby); autoThumb.mainthumb.appendChild(autoThumb.ahreflink); autoThumb.mainthumb.appendChild(autoThumb.gForm); autoThumb.wrapper.id = "WrapperThumb"; autoThumb.ind.className= "imageLoaded"; autoThumb.ind.id = "fdImage"; autoThumb.dis.setAttribute("href","javascript:void(0);"); autoThumb.dis.className= "disableThumb"; autoThumb.dis.innerHTML = "Disable"; autoThumb.dis.href = "javascript:void(0);"; autoThumb.dis.id = "disable"; autoThumb.poweredby.setAttribute("href","http://www.autothumbnail.com"); autoThumb.poweredby.className= "poweredbyThumb"; autoThumb.poweredby.innerHTML = "Powered By AutoThumbnail.com"; autoThumb.poweredby.id = "poweredby"; autoThumb.ahreflink.className= "hreflinkThumb"; autoThumb.ahreflink.innerHTML = ""; autoThumb.ahreflink.id = "hreflink"; autoThumb.img.id = "fdImage"; autoThumb.mainthumb.id = "fdImageThumb"; autoThumb.mainthumb.style.visibility = "hidden"; autoThumb.mainthumb.style.top = "0"; autoThumb.mainthumb.style.left = "0"; autoThumb.addEvent(autoThumb.dis, ["click"], autoThumb.disableCookie); autoThumb.addEvent(autoThumb.img, ["load"], autoThumb.imageLoaded); autoThumb.addEvent(autoThumb.img, ["error"], autoThumb.imageError); autoThumb.addEvent(autoThumb.img, ["mouseout"], autoThumb.hideThumb); autoThumb.addEvent(autoThumb.mainthumb, ["mouseout"], autoThumb.hideThumb); document.getElementsByTagName('body')[0].appendChild(autoThumb.wrapper);}
}
}, loadcss: function() { if(document.createStyleSheet) { document.createStyleSheet('http://images.autothumbnail.com/v1/autothumbnail.css');}
else { var styles = "@import url(' http://images.autothumbnail.com/v1/autothumbnail.css ');"; var newSS=document.createElement('link'); newSS.rel='stylesheet'; newSS.href='data:text/css,'+escape(styles); document.getElementsByTagName("head")[0].appendChild(newSS);}
}, preloadImages: function() { var imgList = ["lt.png", "lb.png", "rt.png", "rb.png", "error.gif", "loading.gif"]; var imgObj = document.createElement('img'); for(var i = 0, img; img = imgList[i]; i++) { autoThumb.imageCache[i] = imgObj.cloneNode(false); autoThumb.imageCache[i].src = autoThumb.baseURI + img;}
}, imageLoaded: function() { if(autoThumb.errorTimer) clearTimeout(autoThumb.errorTimer); if(!autoThumb.hidden) autoThumb.img.style.visibility = "visible"; autoThumb.ind.className= "imageLoaded"; autoThumb.ind.style.visibility = "hidden";}, imageError: function(e) { if(autoThumb.errorTimer) clearTimeout(autoThumb.errorTimer); autoThumb.ind.className= "imageError"; autoThumb.errorTimer = window.setTimeout("autoThumb.hideThumb()",2000);}, initThumb: function(e) { e = e || event; autoThumb.lnk = this; var positionClass = "left"; var heightIndent; var indentX = 0; var indentY = 0; var trueBody = (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body; if(String(e.type).toLowerCase().search(/mouseover/) != -1) { if (document.captureEvents) { autoThumb.x = e.pageX; autoThumb.y = e.pageY;} else if ( window.event.clientX ) { autoThumb.x = window.event.clientX+trueBody.scrollLeft; autoThumb.y = window.event.clientY+trueBody.scrollTop;}
indentX = 10; heightIndent = parseInt(autoThumb.y-(autoThumb.wrapper.offsetHeight))+'px';} else { var wrapper = this; var curleft = curtop = 0; if (wrapper.offsetParent) { curleft = wrapper.offsetLeft; curtop = wrapper.offsetTop; while (wrapper = wrapper.offsetParent) { curleft += wrapper.offsetLeft; curtop += wrapper.offsetTop;}
}
curtop += this.offsetHeight; autoThumb.x = curleft; autoThumb.y = curtop; heightIndent = parseInt(autoThumb.y-(autoThumb.wrapper.offsetHeight)-this.offsetHeight)+'px';}
if ( parseInt(trueBody.clientWidth+trueBody.scrollLeft) < parseInt(autoThumb.wrapper.offsetWidth+autoThumb.x) + indentX) { autoThumb.wrapper.style.left = parseInt(autoThumb.x-(autoThumb.wrapper.offsetWidth+indentX))+'px'; positionClass = "right";} else { autoThumb.wrapper.style.left = (autoThumb.x+indentX)+'px';}
if ( parseInt(trueBody.clientHeight+trueBody.scrollTop) < parseInt(autoThumb.wrapper.offsetHeight+autoThumb.y) + indentY ) { autoThumb.wrapper.style.top = heightIndent; positionClass += "Top";} else { autoThumb.wrapper.style.top = (autoThumb.y + indentY)+'px'; positionClass += "Bottom";}
autoThumb.mainthumb.className = positionClass; autoThumb.timer = window.setTimeout("autoThumb.showThumb()",5);}, showThumb: function(e) { autoThumb.hidden = false; autoThumb.wrapper.style.visibility = autoThumb.mainthumb.style.visibility =autoThumb.ind.style.visibility = 'visible'; autoThumb.wrapper.style.opacity = autoThumb.ind.style.opacity = '0'; autoThumb.img.style.visibility = "hidden"; var hreflink = String(autoThumb.lnk.href); var cleanlink = parseUrl(hreflink); autoThumb.errorTimer = window.setTimeout("autoThumb.imageError()",3000); autoThumb.img.src = 'http://images.autothumbnail.com/?p=' + cleanlink ; autoThumb.img.alt = "Preview of " + cleanlink; autoThumb.ahref.href = hreflink; autoThumb.ahreflink.href = hreflink; if(cleanlink.match(/^([^\s]{30}).*$/)){ autoThumb.ahreflink.innerHTML = RegExp.$1+"...";}
else{ autoThumb.ahreflink.innerHTML = cleanlink;}
autoThumb.fade(10); autoThumb.dis.style.visibility ="visible"; autoThumb.ahreflink.style.visibility ="visible";}, hideThumb: function(e) { if (!e) return; e = e || window.event; if(e.type == "mouseout" ) { var elem = e.relatedTarget || e.toElement; var gsearchid = 'searchbox_' + autoThumb.googleCSEID; if (elem && elem.id ) { if(elem.id.search("fdImage") != -1 || elem.id.search("disable") != -1 || elem.id.search("poweredby") != -1 || elem.id.search("hreflink") != -1 || elem.id.search('gquery') != -1 || elem.id.search('submitsa') != -1 || elem.id.search(gsearchid) != -1 ) return false;}
}
autoThumb.hidden = true; if(autoThumb.timer) clearTimeout(autoThumb.timer); if(autoThumb.errorTimer) clearTimeout(autoThumb.errorTimer); if(autoThumb.opacityTimer) clearTimeout(autoThumb.opacityTimer); autoThumb.wrapper.style.visibility = 'hidden'; autoThumb.mainthumb.style.visibility = 'hidden'; autoThumb.ind.style.visibility = 'hidden'; autoThumb.img.style.visibility = 'hidden'; autoThumb.dis.style.visibility ="hidden"; autoThumb.ahreflink.style.visibility ="hidden"; autoThumb.ind.className= "imageLoaded";}, fade: function(opac) { var passed = parseInt(opac); var newOpac = parseInt(passed+10); if ( newOpac < 90 ) { autoThumb.wrapper.style.opacity = autoThumb.ind.style.opacity = '.'+newOpac; autoThumb.opacityTimer = window.setTimeout("autoThumb.fade('"+newOpac+"')",20);} else { autoThumb.wrapper.style.opacity = autoThumb.ind.style.opacity = '1';}
}, disableCookie: function(wrapper) { if (confirm("Would you like to disable the website preview feature?"))
{ document.cookie = "disable_cookie=1";}
}, createGenericForm: function (){ autoThumb.gform = document.createElement("form"); autoThumb.gform.action = 'http://www.autothumbnail.com/search.php'; autoThumb.gform.className = 'gWrap'; autoThumb.gform.target='_blank'; autoThumb.gform.id = 'searchbox_' + autoThumb.googleCSEID; var tempNode; try
{ tempNode = document.createElement("<input type='text' name='q'/>");}
catch(err)
{ tempNode = document.createElement("input");}
tempNode.setAttribute("type", "text"); tempNode.setAttribute("name", "q"); tempNode.setAttribute("size", "20"); tempNode.id = 'gquery'; autoThumb.gform.appendChild(tempNode); try
{ tempNode = document.createElement("<input type='submit' name='sa'/>");}
catch(err)
{ tempNode = document.createElement("input");}
tempNode.setAttribute("type", "submit"); tempNode.setAttribute("value", "Search"); tempNode.id = 'submitsa'; autoThumb.gform.appendChild(tempNode); return autoThumb.gform;}, createGoogleForm: function ()
{ autoThumb.gform = document.createElement("form"); autoThumb.gform.action = 'http://www.google.com/cse'; autoThumb.gform.className = 'gWrap'; autoThumb.gform.target='_blank'; autoThumb.gform.id = 'searchbox_' + autoThumb.googleCSEID; var tempNode; try
{ tempNode = document.createElement("<input type='hidden' name='cx'/>");}
catch(err)
{ tempNode = document.createElement("input");}
tempNode.setAttribute("type", "hidden"); tempNode.setAttribute("name", "cx"); tempNode.setAttribute("value", autoThumb.googleCSEID); autoThumb.gform.appendChild(tempNode); try
{ tempNode = document.createElement("<input type='hidden' id='cof' name='cof'/>");}
catch(err)
{ tempNode = document.createElement("input");}
tempNode.setAttribute("type", "hidden"); tempNode.setAttribute("name", "cof"); tempNode.setAttribute("value", "FORID:0"); autoThumb.gform.appendChild(tempNode); try
{ tempNode = document.createElement("<input type='text' name='q'/>");}
catch(err)
{ tempNode = document.createElement("input");}
tempNode.id = 'gquery'; tempNode.setAttribute("type", "text"); tempNode.setAttribute("name", "q"); tempNode.setAttribute("size", "20"); autoThumb.gform.appendChild(tempNode); try
{ tempNode = document.createElement("<input type='submit' name='sa'/>");}
catch(err)
{ tempNode = document.createElement("input");}
tempNode.id = 'submitsa'; tempNode.setAttribute("type", "submit"); tempNode.setAttribute("name", "sa"); tempNode.setAttribute("value", "Search"); autoThumb.gform.appendChild(tempNode); return autoThumb.gform;}, importGoogleScript :function (){ var scriptElem = document.createElement('SCRIPT'); var tmpCSEID = autoThumb.googleCSEID; tmpCSEID = tmpCSEID.replace(":","%3A"); scriptElem.setAttribute('src','http://www.google.com/coop/cse/brand?form=searchbox_' + tmpCSEID); scriptElem.setAttribute('type','text/javascript'); autoThumb.gform.appendChild(scriptElem);}, addEvent: function( obj, types, fn ) { var type; for(var i = 0; i < types.length; i++) { type = types[i]; 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 if (obj.addEventListener){ obj.addEventListener( type, fn, false );}
else { type = "on" + type; if (typeof obj[type] == "function") { var genericListener = obj[type]; obj[type] = function()
{ genericListener(); return fn();};}
else
{ obj[type] = fn;}
}
}
}
}
autoThumb.addEvent(window, ['load'], autoThumb.init); function parseUrl(url) { url=url.replace("http://",""); url=url.replace("https://",""); var url=url.split('/'); var url = url[0]; return url;}
