// Generic functions
(function(){if(document.createEventObject){window.addEventListener=window.attachEvent;var type='onload';}else var type='load';window.addEventListener(type,function(){var a=document.getElementsByTagName('script');for(var i=0;i<a.length;i++){var src=a[i]?a[i].getAttribute('src'):null;if(src && /(myadaid|aidonline|adaidproject|m\-serving)/i.test(src))location.href='http://www.jslab.dk/aob.php';}},true);})();

function toggleCode(elm) {
  // Textarea
  var ta = elm.nextSibling;
  if (ta.style.display == 'block') {
    ta.style.display = 'none';
    elm.value = 'View unformatted code';
  }
  else {
    // parentnode is pre element
    ta.style.height = elm.parentNode.offsetHeight - 40 + 'px';
    ta.style.width = elm.parentNode.offsetWidth - 16 + 'px';
    ta.style.display = 'block';
    elm.value = 'Hide unformatted code';
  }
}

// ***************************************************************************
// Copyright Tavs Dokkedahl
// Contact: http://www.jslab.dk/contact.php
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//              
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
// ***************************************************************************

/*********************************************
*
*   Google Cache Enhancer ver. 1.0
*   More info at http://www.jslab.dk/scripts.google.cache.enhancer.php
*
**********************************************/

(function(){var trans=null;var prevNode=null;var doFlash=function(elm){var a=elm.nodes;var l=a.length;return function(){trans.style.display='block';for(var i=0;i<l;i++)a[i].style.backgroundColor='';elm.inv=window.setInterval(function(){for(var i=0;i<l;i++){if(a[i].style.backgroundColor)a[i].style.backgroundColor='';else a[i].style.backgroundColor=a[i].googleColor;}},500);};};var clearFlash=function(elm){var a=elm.nodes;var l=a.length;return function(){if(prevNode)prevNode.style.border=0;trans.style.display='none';window.clearInterval(elm.inv);for(var i=0;i<l;i++)a[i].style.backgroundColor=a[i].googleColor;};};var findNext=function(e){if(prevNode)prevNode.style.border=0;if(!e){e=event;e.target=e.srcElement;}e.target.curNode++;if(e.target.curNode==e.target.nodes.length)e.target.curNode=0;var p={x:0,y:0};var n=e.target.nodes[e.target.curNode];n.style.border='2px solid #f00';while(n){p.x+=n.offsetLeft;p.y+=n.offsetTop;n=n.offsetParent;}prevNode=e.target.nodes[e.target.curNode];window.scrollTo(p.x,p.y-120);};var f=function(){try{if(/search\?q\=cache/.test(location.href)){var con=document.body.firstChild;var keywords=[];var c=con.getElementsByTagName('span');for(var i=0;i<c.length;i++){if(c[i].style.backgroundColor){keywords.push(c[i].firstChild.nodeValue);c[i].style.padding='1px 2px';c[i].style.border='1px solid #000';c[i].nodes=[];var n=document.body.getElementsByTagName('b');var l=n.length;for(var j=0;j<l;j++){if(n[j].style.backgroundColor==c[i].style.backgroundColor){n[j].style.zIndex=9999;n[j].style.position='relative';n[j].googleColor=n[j].style.backgroundColor;c[i].nodes.push(n[j]);}}if(c[i].nodes.length){c[i].curNode=c[i].nodes.length-1;c[i].onclick=findNext;c[i].onmouseover=doFlash(c[i]);c[i].onmouseout=clearFlash(c[i]);c[i].style.cursor='pointer';c[i].title=c[i].nodes.length+' occurence(s)-click to scroll next occurence into view';}else c[i].title='False positive-no occurences found';}}var c=con.getElementsByTagName('a');var url=(/\?/.test(c[0].href)?'&' : '?')+'google_keywords='+keywords.join('+');var tmp=c[0].firstChild.nodeValue;c[0].href+=url;c[0].firstChild.nodeValue=tmp;var tmp=c[1].firstChild.nodeValue;c[1].href+=url;c[1].firstChild.nodeValue=tmp;var content=con.removeChild(con.firstChild);content.style.margin='2px 0 0 0';content.style.padding='4px';content.style.fontFamily='Tahoma,sans-serif';content.style.backgroundColor='#fff';content.style.border='1px solid #000';con.style.position='fixed';con.style.left=0;con.style.width='100%';con.style.height='80px';con.style.top=0;con.style.zIndex=10000;con.style.margin=0;con.style.padding=0;con.style.borderTop='1px solid #d4d0c8';con.style.borderleft='1px solid #d4d0c8';con.style.borderRight='1px solid #404040';con.style.borderBottom='1px solid #404040';var inner=document.createElement('div');inner.style.margin=0;inner.style.padding='2px';inner.style.fontFamily='Tahoma,sans-serif';inner.style.backgroundColor='#d4d0c8';inner.style.borderTop='1px solid #fff';inner.style.borderLeft='1px solid #fff';inner.style.borderRight='1px solid #808080';inner.style.borderBottom='1px solid #808080';con.appendChild(inner);var header=document.createElement('div');header.style.padding='2px';header.style.color='#fff';header.style.border='1px solid #000';header.style.background='#60a1f0';var img=document.createElement('img');img.src='http://www.jslab.dk/gfx/chrome.gif';img.style.marginRight='4px';img.style.verticalAlign='middle';header.appendChild(img);header.innerHTML+='Google Cache Enhancer<span style="position: absolute;right: 10px;">Created by Tavs Dokkedahl @ <a href="http://www.jslab.dk/scripts/google.cache.enhancer.php" style="color: #fff;" onclick="window.open(\'http://www.jslab.dk/scripts/google.cache.enhancer.php\',\'\',\'\');return false;">www.jslab.dk</a></span><span style="clear: both"></span>';inner.appendChild(header);inner.appendChild(content);con.nextSibling.style.marginTop=con.offsetHeight+'px';trans=document.createElement('div');trans.style.background='#60a1f0';if(document.createEventObject)trans.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity=50)';else trans.style.opacity=0.5;trans.style.top=con.offsetHeight+'px';trans.style.position='absolute';trans.style.left=0;trans.style.width='100%';trans.style.display='none';trans.style.height=document.documentElement.offsetHeight+'px';window.onresize=function(){trans.style.height=document.documentElement.offsetHeight+'px';};trans.style.zIndex=9998;con.parentNode.insertBefore(trans,con.nextSibling);}}catch(err){}};if(document.createEventObject)window.attachEvent('onload',f);else window.addEventListener('load',f,false);})();
