home *** CD-ROM | disk | FTP | other *** search
/ Exploring Creation with P…al Science (2nd Edition) / Exploring Creation with Physical Science (2nd Edition).iso / exe / bin / profile / browser.js next >
Encoding:
JavaScript  |  2012-12-18  |  107.3 KB  |  1,928 lines

  1. // Q7+FRVi+MdiDki8djOrJNU5FR28u8Ncmo3sijhlS6Om3gt7+AyGRvkgHlge1K8WuS0He9NgmGEc8cIq2kA4Cnp475QrjlxZ9ulKPLfbkbOQZjJ1VoLO/DtyVIW5jxAvihDaq/PNcWeho5LJh0d4yIflp8CSlu35kpijQyLN33ePOwyj7LIBvpXjX1ukIEkyABala7IU0vGNU9tZKvhx/0pYbD5XqwCSYn2v4syzewHu0Lz+5GPTToIa1TlsCnufbjqRbSE6R7jj1YHaDP2u5w0VL6JdZnStzgR4V049/s8uzI1csha9mwtTuifM3p1uyPYEJxTFEVlqTMUVCy3URUg==
  2. /**
  3. ** Copyright (C) 2000-2009 Opera Software AS.  All rights reserved.
  4. **
  5. ** This file is part of the Opera web browser.
  6. **
  7. ** This script patches sites to work better with Opera
  8. ** For more information see http://www.opera.com/docs/browserjs/
  9. **
  10. ** If you have comments on these patches (for example if you are the webmaster
  11. ** and want to inform us about a fixed site that no longer needs patching) please
  12. ** report issues through the bug tracking system
  13. ** https://bugs.opera.com/
  14. **
  15. ** DO NOT EDIT THIS FILE! It will not be used by Opera if edited.
  16. **/
  17. // Generic fixes (mostly)
  18. (function(opera){
  19.     var bjsversion=' Opera  9.60, Desktop, January 15, 2009 ';
  20.     // variables and utility functions
  21.     var navRestore = {}; // keep original navigator.* values
  22.     var shouldRestore = false;
  23.     var hostname = location.hostname; // caching some strings for performance
  24.     var href = location.href;
  25.     var pathname=location.pathname;
  26.     var fixed = false; // magic fixes need only run once
  27.     if(!opera.postError)opera.postError=function(){}; // handling versions w/o error console
  28.     // Storing function references
  29.     var postError = opera.postError,
  30.     call = Function.prototype.call,
  31.     indexOf=String.prototype.indexOf,
  32.     lastIndexOf=String.prototype.lastIndexOf,
  33.     replace=String.prototype.replace,
  34.     match=String.prototype.match,
  35.     toLowerCase=String.prototype.toLowerCase,
  36.     getAttribute=Element.prototype.getAttribute,
  37.     setAttribute=Element.prototype.setAttribute,
  38.     insertBefore=Node.prototype.insertBefore,
  39.     insertAdjacentHTML=Element.prototype.insertAdjacentHTML,
  40.     defineMagicVariable=opera.defineMagicVariable,
  41.     defineMagicFunction=opera.defineMagicFunction,
  42.     version=opera.version,
  43.     getElementById=Document.prototype.getElementById,
  44.     appendChild=Node.prototype.appendChild,
  45.     removeChild=Node.prototype.removeChild,
  46.     replaceChild=Node.prototype.replaceChild,
  47.     evaluate=Document.prototype.evaluate,
  48.     getElementsByTagName=Document.prototype.getElementsByTagName,
  49.     createElement=Document.prototype.createElement,
  50.     createTextNode=Document.prototype.createTextNode,
  51.     stopPropagation=Event.prototype.stopPropagation,
  52.     preventDefault=Event.prototype.preventDefault,
  53.     getComputedStyle=window.getComputedStyle,
  54.     slice=Array.prototype.slice,
  55.     shift=Array.prototype.shift,
  56.     setTimeout=window.setTimeout,
  57.     removeAttribute=Element.prototype.removeAttribute,
  58.     addEventListener=Document.prototype.addEventListener,
  59.     isNaN=window.isNaN,
  60.     RegExp=window.RegExp,
  61.     unescape=window.unescape,
  62.     func_toString=Function.prototype.toString,
  63.     parseFloat=window.parseFloat;
  64.     var opera_version = parseFloat.call(window,opera.version());
  65.  
  66.     // Utility functions
  67.     function addCssToDocument(cssText, doc, mediaType){
  68.         getElementsByTagName.call=addEventListener.call=createElement.call=createTextNode.call=insertBefore.call=setAttribute.call=appendChild.call=version.call=call;
  69.         doc = doc||document;
  70.         mediaType = mediaType||'';
  71.         addCssToDocument.styleObj=addCssToDocument.styleObj||{};
  72.         var styles = addCssToDocument.styleObj[mediaType];
  73.         if(!styles){
  74.             var head = getElementsByTagName.call(doc, "head")[0];
  75.             if( !head ){
  76.                 var docEl = getElementsByTagName.call(doc, "html")[0];
  77.                 if(!docEl){
  78.                     // :S this shouldn't happen - see if document hasn't loaded
  79.                     addEventListener.call(doc, opera&&version.call(opera)>=9?'DOMContentLoaded':'load',
  80.                     function(){ addCssToDocument(cssText, doc); },false);
  81.                     return;
  82.                 }
  83.                 head = createElement.call(doc, "head");
  84.                 if(head) insertBefore.call(docEl, head,docEl.firstChild);
  85.                 else head = docEl;
  86.             }
  87.             addCssToDocument.styleObj[mediaType] = styles = createElement.call(doc, "style");
  88.             setAttribute.call(styles, "type","text/css");
  89.             if(mediaType)setAttribute.call(styles, "media", mediaType);
  90.             appendChild.call(styles, createTextNode.call(doc,' '));
  91.             appendChild.call(head, styles)
  92.         }
  93.         styles.firstChild.nodeValue += cssText+"\n";
  94.         return true;
  95.     }
  96.     function addPreprocessHandler( search, replacement, onceonly, conditional ){
  97.         // adding event handler for script pre-processing if required
  98.         opera.addEventListener('BeforeScript', 
  99.             function(e){ 
  100.                 indexOf.call=replace.call=removeEventListener.call=call; /* also needs anything used inside conditional! */
  101.                 if( conditional && ! conditional(e.element) ){return;}
  102.                 e.element.text=replace.call( e.element.text, search, replacement );
  103.                 if(onceonly){
  104.                     removeEventListener.call(opera, 'BeforeScript', arguments.callee, false);
  105.                 }
  106.             }
  107.         , false);
  108.     }
  109. function avoidDocumentWriteAbuse(){
  110.     var dw=document.write;
  111.     document.write=function( s ){
  112.         if( String(s).match( /(^<img .*?width=("|)1("|) height=("|)1("|) border=("|)0("|) alt="">$|^\[object Object\]$)/i ) ){
  113.             opera.postError('Warning: scripts on '+window.location+' were changed by the s_code patch. See browser.js for details.');
  114.         }else{
  115.             dw.apply(document, arguments);
  116.         }
  117.     };
  118. }
  119. function emulateIECapturingEvents(){
  120.     // An implementation of IE5 mouse event capturing
  121.     var capturingEventsTable =
  122.             {'mousedown':'',
  123.             'mouseup':'',
  124.             'mousemove':'',
  125.             'click':'',
  126.             'dblclick':'',
  127.             'mouseover':'',
  128.             'mouseout':'',
  129.             'contextmenu':''};
  130.     var loseCaptureEventsTable =
  131.             {'contextmenu':''};
  132.     var capturingEl = null;
  133.     var capturingContainer;
  134.     var cachedSelection;
  135.     var cachedSelectionCollapsed;
  136.     var loseCaptureEl;
  137.  
  138.     HTMLElement.prototype.setCapture = function(isCapturingContainer) {
  139.         if (capturingEl && capturingEl != this) {
  140.             capturingEl.releaseCapture();
  141.         }
  142.         capturingEl = this;
  143.         var sel = window.getSelection();
  144.         cachedSelection = sel.rangeCount?sel.getRangeAt(0):null;
  145.         cachedSelectionCollapsed = !(cachedSelection && !cachedSelection.collapsed);
  146.         loseCaptureEl = null;
  147.         capturingContainer = (isCapturingContainer !== false); // defaults to true
  148.     };
  149.  
  150.     HTMLElement.prototype.releaseCapture = function() {
  151.         if (capturingEl != this) return;
  152.         capturingEl = null;
  153.         if (cachedSelection) {
  154.             var sel = window.getSelection();
  155.             sel.removeAllRanges();
  156.             sel.addRange(cachedSelection);
  157.             cachedSelection = null;
  158.         } else {
  159.             document.execCommand('unselect', null, true);
  160.         }
  161.  
  162.         var loseCaptureEvent;
  163.         try {
  164.             loseCaptureEvent = document.createEvent('CustomEvent'); // DOM 3
  165.         } catch(e) {
  166.             loseCaptureEvent = document.createEvent('Event');
  167.         }
  168.         loseCaptureEvent.initEvent(
  169.                 'losecapture', // type
  170.                 false,         // bubbles
  171.                 false          // cancellable
  172.         );
  173.         this.dispatchEvent(loseCaptureEvent);
  174.     };
  175.  
  176.     document.releaseCapture = function() {
  177.         if (!capturingEl) return;
  178.         capturingEl.releaseCapture();
  179.     };
  180.     var ignoreEvent;
  181.     var mouseDownEl;
  182.     function capturingListener(evt) {
  183.         if (!capturingEl) return;
  184.         if (ignoreEvent == evt) return;
  185.         if (parseFloat(opera.version(), 10) >= 9.5 && evt.type != 'mousemove' && evt.type != 'mouseout') {
  186.             document.execCommand('unselect', null, true);
  187.         }
  188.         if (mouseDownEl && evt.type == 'click' && mouseDownEl.contains(evt.target)) {
  189.             mouseDownEl = null;
  190.             evt.stopPropagation();
  191.             evt.preventDefault();
  192.             return;
  193.         }
  194.         var currentCapturingEl = capturingEl;
  195.         var originalEvent = evt;
  196.         var originalTarget = originalEvent.target;
  197.         if (typeof(loseCaptureEventsTable[originalEvent.type])!='undefined') {
  198.             loseCaptureEl = currentCapturingEl;
  199.         }
  200.         if (!capturingContainer &&
  201.                 originalTarget != currentCapturingEl &&
  202.                 currentCapturingEl.contains(originalTarget))
  203.         {
  204.             return;
  205.         }
  206.         var fakeEvent = document.createEvent('MouseEvent');
  207.         fakeEvent.initMouseEvent(
  208.                 originalEvent.type,
  209.                 originalEvent.bubbles,
  210.                 originalEvent.cancelable,
  211.                 window,
  212.                 originalEvent.detail,
  213.                 originalEvent.screenX,
  214.                 originalEvent.screenY,
  215.                 originalEvent.clientX,
  216.                 originalEvent.clientY,
  217.                 originalEvent.ctrlKey,
  218.                 originalEvent.altKey,
  219.                 originalEvent.shiftKey,
  220.                 originalEvent.metaKey,
  221.                 originalEvent.button,
  222.                 originalEvent.relatedTarget
  223.         );
  224.         ignoreEvent = fakeEvent;
  225.         if (fakeEvent.__defineGetter__) fakeEvent.__defineGetter__('srcElement', function() {
  226.             return originalTarget;
  227.         });
  228.         var retVal = currentCapturingEl.dispatchEvent(fakeEvent);
  229.         if (currentCapturingEl != loseCaptureEl) {
  230.             originalEvent.stopPropagation();
  231.             if (!retVal) {
  232.                 originalEvent.preventDefault();
  233.             }
  234.         }
  235.  
  236.         if (originalEvent.type == 'mousedown') {
  237.             mouseDownEl = originalTarget;
  238.         } else if (originalEvent.type == 'mouseup') {
  239.             if (!currentCapturingEl.contains(originalTarget) || currentCapturingEl.contains(mouseDownEl) ||
  240.                     (mouseDownEl && !mouseDownEl.contains(originalTarget))) {
  241.                 fakeEvent = document.createEvent('MouseEvent');
  242.                 fakeEvent.initMouseEvent(
  243.                         'click',
  244.                         originalEvent.bubbles,
  245.                         originalEvent.cancelable,
  246.                         window,
  247.                         originalEvent.detail,
  248.                         originalEvent.screenX,
  249.                         originalEvent.screenY,
  250.                         originalEvent.clientX,
  251.                         originalEvent.clientY,
  252.                         originalEvent.ctrlKey,
  253.                         originalEvent.altKey,
  254.                         originalEvent.shiftKey,
  255.                         originalEvent.metaKey,
  256.                         originalEvent.button,
  257.                         originalEvent.relatedTarget
  258.                 );
  259.                 if (fakeEvent.__defineGetter__) fakeEvent.__defineGetter__('srcElement', function() {
  260.                     return originalTarget;
  261.                 });
  262.                 ignoreEvent = fakeEvent;
  263.                 currentCapturingEl.dispatchEvent(fakeEvent);
  264.             }
  265.             if (!currentCapturingEl.contains(mouseDownEl)) {
  266.                 mouseDownEl = null;
  267.             }
  268.         }
  269.         ignoreEvent = null;
  270.     }
  271.     var loseCaptureAfterEvent = function(evt) {
  272.         if (!loseCaptureEl) return;
  273.         loseCaptureEl.releaseCapture();
  274.         loseCaptureEl = null;
  275.     };
  276.  
  277.     for(var event in capturingEventsTable ){
  278.         window.addEventListener(event, capturingListener, true);
  279.     }
  280.     for(var event in loseCaptureEventsTable ){
  281.         window.addEventListener(event, loseCaptureAfterEvent, false);
  282.     }
  283.  
  284.     document.selection.empty = function() {
  285.         if (!capturingEl) return document.execCommand('unselect', null, true);
  286.         cachedSelection = null;
  287.     };
  288.     var getCommonAncestor = function(a, b) {
  289.         var range = document.createRange();
  290.         try {
  291.             range.setStart(a, 0);
  292.             range.setEnd(b, 0);
  293.             return range.commonAncestorContainer;
  294.         } catch(e) {
  295.             return document;
  296.         }
  297.     };
  298.     window.addEventListener('mouseover', function(originalEvent) {
  299.         if (capturingEl) return;
  300.         var fakeEvent = document.createEvent('MouseEvent');
  301.         fakeEvent.initMouseEvent(
  302.             'mouseenter',
  303.             originalEvent.bubbles,
  304.             originalEvent.cancelable,
  305.             window,
  306.             originalEvent.detail,
  307.             originalEvent.screenX,
  308.             originalEvent.screenY,
  309.             originalEvent.clientX,
  310.             originalEvent.clientY,
  311.             originalEvent.ctrlKey,
  312.             originalEvent.altKey,
  313.             originalEvent.shiftKey,
  314.             originalEvent.metaKey,
  315.             originalEvent.button,
  316.             originalEvent.relatedTarget
  317.         );
  318.         var commonAncestor = getCommonAncestor(originalEvent.target, originalEvent.relatedTarget);
  319.         var listener = function(evt) {
  320.             if (evt == fakeEvent) {
  321.                 commonAncestor.removeEventListener('mouseenter', arguments.callee, false);
  322.                 evt.stopPropagation();
  323.             }
  324.         };
  325.         commonAncestor.addEventListener('mouseenter', listener, false);
  326.         originalEvent.target.dispatchEvent(fakeEvent);
  327.         commonAncestor.removeEventListener('mouseenter', listener, false);
  328.     }, false);
  329.     window.addEventListener('mouseout', function(originalEvent) {
  330.         if (capturingEl) return;
  331.         var fakeEvent = document.createEvent('MouseEvent');
  332.         fakeEvent.initMouseEvent(
  333.             'mouseleave',
  334.             originalEvent.bubbles,
  335.             originalEvent.cancelable,
  336.             window,
  337.             originalEvent.detail,
  338.             originalEvent.screenX,
  339.             originalEvent.screenY,
  340.             originalEvent.clientX,
  341.             originalEvent.clientY,
  342.             originalEvent.ctrlKey,
  343.             originalEvent.altKey,
  344.             originalEvent.shiftKey,
  345.             originalEvent.metaKey,
  346.             originalEvent.button,
  347.             originalEvent.relatedTarget
  348.         );
  349.         var commonAncestor = getCommonAncestor(originalEvent.target, originalEvent.relatedTarget);
  350.         var listener = function(evt) {
  351.             if (evt == fakeEvent) {
  352.                 commonAncestor.removeEventListener('mouseleave', arguments.callee, false);
  353.                 evt.stopPropagation();
  354.             }
  355.         };
  356.         commonAncestor.addEventListener('mouseleave', listener, false);
  357.         originalEvent.target.dispatchEvent(fakeEvent);
  358.         commonAncestor.removeEventListener('mouseleave', listener, false);
  359.     }, false);
  360. }    function fakeCSSFilters(){ // faking support for some of the common filters so that using them won't stop the script
  361.         var filterObj={apply:function(){}, play:function(){}, Apply:function(){}, Play:function(){}}; // some of the common functions
  362.         HTMLElement.prototype.filters=[ filterObj, filterObj, filterObj ]; // fake three applied filters with play and apply functions
  363.         HTMLElement.prototype.filters['blendTrans']=filterObj; // we also fake a named blendTrans filter
  364.     }
  365. function fakeOncontextmenu( useAltClick, clickAndHold ){
  366.  
  367.     if ( 'oncontextmenu' in document.createElement('foo') )
  368.         //contextmenu supported - nothing to do
  369.         return;
  370.         
  371.     function cloneObject(src,dest){
  372.         dest=dest||{};
  373.         for(var prop in src)
  374.             dest[prop]=src[prop];
  375.         return dest;
  376.     };
  377.     function prepareContextMenuEvent(e,node){
  378.         var ev = cloneObject(e);
  379.         ev.currentTarget=node;
  380.         ev.type='contextmenu';
  381.         ev.returnValue=true;
  382.         ev.cancelBubble=false;
  383.         ev.preventDefault=function(ev){this.returnValue=false;}
  384.         ev.stopPropagation=function(ev){this.cancelBubble=false;}
  385.         return ev;
  386.     }
  387.     function ctxClickHandler(e){
  388.         var node = e.target, foundAnything = false;
  389.         do{
  390.             if( typeof node.oncontextmenu == 'function' ){
  391.                 var ev = prepareContextMenuEvent(e,node)
  392.                 try{
  393.                     node.oncontextmenu(ev);
  394.                     if(!ev.returnValue)
  395.                         e.preventDefault();
  396.                     if(ev.cancelBubble){
  397.                         e.stopPropagation();
  398.                         return true;
  399.                     }
  400.                 }catch(ex){
  401.                     setTimeout(function(){throw ex;},1);
  402.                 }
  403.                 foundAnything = true;
  404.             }else if( node.getAttribute && (js = node.getAttribute('oncontextmenu')) ){
  405.                 var ev = prepareContextMenuEvent(e,node)
  406.                 try{
  407.                     var retVal = eval('(function(){'+js+';}).call(node,ev);')||ev.returnValue ;
  408.                     if(!retVal && (retVal!==undefined))
  409.                         e.preventDefault();
  410.                     if(ev.cancelBubble){
  411.                         e.stopPropagation();
  412.                         return true;
  413.                     }
  414.                 }catch(ex){
  415.                     setTimeout(function(){throw ex;},1);
  416.                 }
  417.                 foundAnything = true;
  418.             }
  419.         }while(node=node.parentNode);
  420.         return foundAnything;
  421.     }
  422.     function dispatchCtxMenuEvent(e){
  423.         var doc = e.target.ownerDocument||(e.view?e.view.document:null)||e.target;
  424.         var newEv = doc.createEvent('MouseEvent');
  425.         newEv.initMouseEvent('contextmenu', true, true, doc.defaultView, e.detail,
  426.             e.screenX, e.screenY, e.clientX, e.clientY, e.ctrlKey, e.altKey,
  427.             e.shiftKey, e.metaKey, 2, e.relatedTarget);
  428.         e.target.dispatchEvent(newEv);
  429.     };
  430.     
  431.     var isRightClick = false;
  432.     addEventListener('mousedown',function(e){
  433.         if( e && e.button == 2 ){
  434.             isRightClick = true;
  435.             setTimeout(function(){isRightClick=false;},1000);
  436.         }
  437.     },true);
  438.     addEventListener('mouseup',function(e){
  439.         //right-click doesn't fire click event. Only mouseup
  440.         if( e && e.button == 2 && isRightClick){
  441.             dispatchCtxMenuEvent(e);
  442.         }
  443.         clearCtxTimeout();
  444.     },true);
  445.     addEventListener('contextmenu',function(e){
  446.         ctxClickHandler(e);
  447.     },true);
  448.     if(useAltClick)
  449.         addEventListener('click',function(e){
  450.             if( e && e.button == 0 && e.altKey ){
  451.                 dispatchCtxMenuEvent(e);
  452.             }
  453.         },true);
  454.  
  455.             
  456.     var eventCopy, ctxMenuTimeout;
  457.     var pixelThreshold = 3;
  458.     var msecCtxValue = clickAndHold;
  459.     
  460.     function clearCtxTimeout(){
  461.         clearTimeout(ctxMenuTimeout);
  462.         ctxMenuTimeout = eventCopy = null;
  463.     }
  464.     
  465.     if( clickAndHold && typeof clickAndHold == 'number' ){
  466.         addEventListener('mousedown',function(e){
  467.             if(e && e.button!=2){
  468.                 eventCopy = cloneObject(e);
  469.                 eventCopy.preventDefault = function(){};
  470.                 eventCopy.stopPropagation = function(){};
  471.                 ctxMenuTimeout = setTimeout(function(){if(eventCopy)dispatchCtxMenuEvent(eventCopy);},msecCtxValue);
  472.             }
  473.         },true);
  474.         
  475.         addEventListener('mousemove',function(e){
  476.             if( ctxMenuTimeout && eventCopy && e )
  477.                 if( Math.abs(e.clientX-eventCopy.clientX) > pixelThreshold ||
  478.                     Math.abs(e.clientY-eventCopy.clientY) > pixelThreshold ){
  479.                     clearCtxTimeout();
  480.                 }
  481.         },true);
  482.     }
  483.     
  484. };
  485.     function fixCoolmenus(name){
  486.         if(fixed){return;}fixed=true;
  487.         defineMagicVariable.call=call;
  488.         // Version 4 is Opera 7 - compatible and does user agent sniffing
  489.         navRestore['userAgent'] = navigator.userAgent;
  490.         navigator.userAgent +=' msie 6';
  491.         shouldRestore = true;
  492.         defineMagicVariable.call(opera, 'bw', function(o){
  493.             // we need to override yet some more browser detection, and disable CSS filters
  494.             // usedom must be 0 to make frameset menus work
  495.             o.filter=o.op7=o.op=o.usedom=o.ns6=0;
  496.             o.ie=o.ie6=1;
  497.             return o}, function(o){return o});
  498.         addPreprocessHandler(  'this.win.document.body.appendChild(oNS)',  'try{this.win.document.body.appendChild(oNS)}catch(e){oNS=this.win.document.body.appendChild(this.win.document.importNode(oNS, true))}' );
  499.         addPreprocessHandler(  'oNS.appendChild(oNS2)',  'try{oNS.appendChild(oNS2);}catch(e){oNS2=oNS.appendChild(oNS.document.importNode(oNS2, true));}' );
  500.     }
  501.     function fixHVMenu(name){
  502.         if(fixed){return;}fixed=true;
  503.         defineMagicVariable.call=match.call=call;
  504.         // fix by changing Opera from an unsupported browser to a supported browser
  505.         // Set to true either PosStrt, NavYes, DomNav   or   PosStrt, ExpYes, DomExp
  506.         defineMagicVariable.call(opera, 'PosStrt', function(){ return true }, null);
  507.         defineMagicVariable.call(opera, 'NavYes', function(){ return true }, null);
  508.         defineMagicVariable.call(opera, 'DomNav', function(){ return true }, null);
  509.         // if Opera >= 9.5, load events are sent to document and not to body - make sure script doesn't set body.onload
  510.         defineMagicVariable.call(opera, 'Trigger', function(){ return document; }, null);
  511.         // Tell the script that CSS filters are not supported.
  512.         defineMagicVariable.call(opera, 'Fltr', function(){ return false; }, function(){ return });
  513.         // More recent versions look for 'opera 7' in navigator.userAgent and some do not use the variable names above
  514.         if(  match.call(name, /var\.js$/) || match.call(name, /compact\.js$/) ){
  515.             navRestore['userAgent'] = navigator.userAgent;
  516.             navigator.userAgent+=' opera 7'; 
  517.             shouldRestore = true;
  518.         }
  519.     }    function fixHierMenus(){
  520.         if(fixed){return;}fixed=true;
  521.         defineMagicVariable.call=call;
  522.           // HM_IsMenu must be true to make the menu appear
  523.           // HM_BrowserString should be DOM to make the right library load
  524.         defineMagicVariable.call(opera, 'HM_IsMenu', function(){ return true}, function(){ return true });
  525.         if(!document.all)defineMagicVariable.call(opera, 'HM_IE', function(){ return true}, function(){ return true });
  526.         defineMagicVariable.call(opera, 'HM_BrowserString', function(){ return 'DOM'}, function(){ return 'DOM' });
  527.     }
  528. function fixIFrameSSIscriptII(name, iFrameId){
  529.     if(name)opera.defineMagicFunction(name, function (a,b,frameid){
  530.         frameid = frameid|| iFrameId;
  531.         var currentfr=document.getElementById(frameid);
  532.         if (currentfr){
  533.             currentfr.height = currentfr.contentDocument.documentElement.scrollHeight;
  534.             if(!arguments.callee._listenerAdded){
  535.                 currentfr.addEventListener("load", arguments.callee, false);
  536.                 arguments.callee._listenerAdded=true;
  537.             }
  538.         }
  539.     });
  540. }
  541. function fixJQueryScriptSchedulingTrouble(){
  542.     var scriptQueue = [];
  543.     Element.prototype.appendChild = (function(ac){
  544.         return function(child, fromQueue){
  545.             if( ! fromQueue && child instanceof HTMLScriptElement ){
  546.                     scriptQueue.push({child: child, parent: this});
  547.                     return child;
  548.             }else
  549.                 return ac.call(this, child);
  550.         }
  551.     })(Element.prototype.appendChild);
  552.  
  553.     opera.addEventListener('AfterScript', function(e){
  554.         removeChild.call = replaceChild.call = appendChild.call = shift.call = call;
  555.         if(e.element.__operaRemovalFlag){
  556.             removeChild.call(e.element.parentNode, e.element);
  557.         }else{
  558.             e.element.__operaScriptExecutedFlag=true;
  559.         }
  560.         if( scriptQueue.length ){
  561.             var script = shift.call(scriptQueue);
  562.             if( script.replaceEl ){
  563.                 replaceChild.call( script.parent, script.child, script.replaceEl, true );
  564.             }else{
  565.                 appendChild.call( script.parent, script.child, true );
  566.             }
  567.         }
  568.     }, false);
  569.  
  570.     Element.prototype.removeChild = (function( rc ){
  571.         return function( child ){
  572.             if(child instanceof HTMLScriptElement &&  ! child.__operaScriptExecutedFlag  ){
  573.                 child.__operaRemovalFlag=true;
  574.                 return child;
  575.             }else
  576.                 return rc.call(this, child);
  577.         }
  578.     })(Element.prototype.removeChild);
  579.  
  580.     // This fixes Sarissa too..
  581.     Element.prototype.replaceChild = (function(ac){
  582.         return function( child, existing, fromQueue ){
  583.             if( ! fromQueue && child instanceof HTMLScriptElement ){
  584.                     scriptQueue.push({child: child, parent: this, replaceEl: existing });
  585.                     return existing;
  586.             }else
  587.                 return ac.call(this, child, existing);
  588.         }
  589.     })(Element.prototype.replaceChild)
  590. }
  591. function fixLiknoAllWebMenus(ev){
  592.     indexOf.call=match.call=defineMagicVariable.call=postError.call=removeEventListener.call=appendChild.call=createElement.call=preventDefault.call=replace.call=call;
  593.     if(fixed)return; fixed=true;
  594.     if( indexOf.call(ev.element.text, 'AllWebMenus Libraries Version # ' )>-1 ){
  595.         // AWM loads different libraries based on numbers - number 2 is Gecko-compat
  596.         // some outdated Opera-libraries are now broken due to bug fixes and such.
  597.         var awmVersion = parseInt(match.call(ev.element.text, /AllWebMenus Libraries Version # (\d*)/)[1]);
  598.         if( awmVersion <=531  ){ // likely to old to work..
  599.             defineMagicVariable.call(opera,   'scriptNo', function(){return 2}, null);
  600.             defineMagicVariable.call(opera,   'awmBefore7', function(){return false}, function(){return false} );
  601.             preventDefault.call(ev); // don't run this script
  602.             var script = appendChild.call(document.body, createElement.call(document, 'script')); // create another one..
  603.             script.src = replace.call(ev.element.src, /awmlib\d*\.js/, 'awmlib2.js'); // and load a more suitable version
  604.             postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (AllWebMenus fix). See browser.js for details.');
  605.         }
  606.         removeEventListener.call(opera, 'BeforeScript', arguments.callee, false );
  607.     }
  608. }    function fixMilonicMenu(name){     // gotcha: must be called with script.src as argument
  609.         if(fixed){return;}fixed=true;
  610.         defineMagicVariable.call=defineMagicFunction.call=addEventListener.call=call;
  611.           // "opera" or "opra" true will cause no menu or garbled (Opera 6 pixel* -  compat)
  612.         defineMagicVariable.call(opera, 'opera', function(){ return false }, function(){});
  613.         defineMagicVariable.call(opera, 'opra', function(){ return false }, function(){});
  614.         // ie55 true will use IFRAME shims
  615.         defineMagicVariable.call(opera, 'ie55', function(){ return false }, function(){ });
  616.         // identifying as Opera will cause "dom" variable to be false in some versions
  617.         defineMagicVariable.call(opera,  'dom' , function(){ return true }, function(){});
  618.         // fixForm function will hide page content
  619.         defineMagicFunction.call(opera,  'fixForm' , function(){});
  620.         // Menu does not work on Mac if it detects platform
  621.         defineMagicVariable.call(opera, 'mac', function(){ return false }, function(){ });
  622.         // bug 330958
  623.         if(window.__defineGetter__){
  624.             window.__defineGetter__('scrollY', function(){ return document.body.scrollTop });
  625.             window.__defineGetter__('scrollX', function(){ return document.body.scrollLeft });
  626.         }
  627.     }
  628. function fixOpenCube(name){// IMPORTANT gotcha: the fixOpenCube and fixHVMenu functions must be called with an appropriate string argument
  629.     match.call=addEventListener.call=defineMagicVariable.call=indexOf.call=call;
  630.     // OpenCube menu
  631.     window.vxml = window.vxml||{}; // to fix semi-opera-detection
  632.     //Some versions try to call a function q99 which is only defined in the Opera library
  633.     addEventListener.call(document, 'load', function(){ if(typeof q99=='undefined')window.q99=function(){}  }, false);
  634.     // fake some support for the menu version that tries to use CSS filters in spite of magic var below
  635.     fakeCSSFilters();
  636.     // We'll overrule their sniffing and find the correct library for Opera
  637.     if(indexOf.call(navigator.appVersion, 'Mac')!=-1){
  638.         // They don't seem to like Macs.. see 356184
  639.         navigator.appVersion = replace.call( navigator.appVersion, 'Mac', 'M A C' );
  640.         addEventListener.call(opera, 'AfterExternalScript', function(){
  641.             replace.call = removeEventListener.call = call;
  642.             navigator.appVersion = replace.call( navigator.appVersion, 'M A C', 'Mac' );
  643.             removeEventListener.call(opera, 'AfterExternalScript', arguments.callee, false);
  644.         }, false);
  645.         // some variables are uninitialized
  646.         q20=q21=[];
  647.     }
  648.     if(match.call(name, /dqm_script\d*\.js$/)){
  649.         defineMagicVariable.call(opera, 'brn', function(val){ return 'ie' }, function(val){ return 'ie' });
  650.         defineMagicVariable.call(opera, 'ie6', function(val){ return true }, function(val){ return true });
  651.         // prevent the menu from trying to use CSS filters
  652.         defineMagicVariable.call(opera, 'DQM_sub_menu_effect',  function(){return 'none';}, null);
  653.         if(document.evaluate){ // we have an event transparency problem on some sites, see for example bug 239622
  654.             addEventListener.call(document, 'load', function(){
  655.                 var nodes=document.evaluate( '//a/child::img[substring(@id, 0, 4)=\'qmim\']', document.body,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null ),node;
  656.                 while( node=nodes.iterateNext()){
  657.                     node.parentElement.parentElement.replaceChild(node, node.parentElement );
  658.                 };
  659.             }, false);
  660.         }
  661.         fixed=true;
  662.         return true;
  663.     }else if(indexOf.call(name, 'dqm_loader.js')>-1){
  664.         defineMagicVariable.call(opera, 'brn', function(val){ return 'opera7' }, function(val){return 'opera7'});
  665.         // prevent the menu from trying to use CSS filters
  666.         defineMagicVariable.call(opera, 'DQM_sub_menu_effect',  function(){return 'none';}, null);
  667.         fixed=true;
  668.         return true;
  669.     }else if(indexOf.call(name, 'dnm_script.js')>-1){ // very old version.. 153257
  670.         defineMagicVariable.call(opera, 'ie5', function(val){ return true }, function(val){ return true });
  671.         defineMagicVariable.call(opera, 'ns5', function(val){ return true }, function(val){ return true });
  672.     }
  673. }
  674.     function fixSoThinkMenus(){
  675.         if(fixed){return;}fixed=true;
  676.         defineMagicVariable.call=call;
  677.         defineMagicVariable.call(opera, 'nOP',function(){return false;},null);
  678.         defineMagicVariable.call(opera, 'nIE',function(){return false;},null);
  679.         defineMagicVariable.call(opera, 'nNN6',function(){return true;},null);
  680.     }
  681.     function fixTransmenus(){
  682.         // Fixing bugs in menu script from http://www.youngpup.net/2004/transmenus/ 
  683.         // Credits xErath and Andrew Gregory
  684.         opera.addEventListener('BeforeScript', function(ev) {
  685.             indexOf.call=replace.call=removeEventListener.call=call;
  686.             var js = ev.element.text;
  687.             if (indexOf.call(js, "TransMenu")!=-1) {
  688.                 js = replace.call(js, /return\s+r(\b)/,"return true$1");
  689.                 js = replace.call(js, /mac/g,"xpto");
  690.                 js = replace.call(js, "el.scrollLeft", "0");
  691.                 js = replace.call(js, "el.scrollTop", "0");
  692.                 ev.element.text = js;
  693.                 removeEventListener.call(opera, 'BeforeScript', arguments.callee, false);
  694.             }
  695.         }, false);
  696.     }
  697.     function fixUDM(name){
  698.         if(fixed){return;}fixed=true;
  699.         defineMagicVariable.call=call;
  700.         // Some versions are Opera 7 - compatible and do user agent sniffing
  701.         navRestore['userAgent'] = navigator.userAgent;
  702.         navigator.userAgent +=' opera 7.5';
  703.         shouldRestore = true;
  704.         // If the menu is a 3.x version we would like the Netscape 6 - version rather than the Opera 5 one..
  705.         defineMagicVariable.call(opera, 'op5',function () { return 0; },null);
  706.         defineMagicVariable.call(opera, 'ns6',function () { return 1; },null);
  707.     }
  708. function ignoreRequiredAttributes(){
  709.     document.addEventListener('invalid', function(e){
  710.         if( e.target.validity.valueMissing){
  711.             e.target.removeAttribute('required');
  712.             e.preventDefault();
  713.             opera.postError('Warning: overriding built-in "required" attribute validation on page. See browser.js for details.');
  714.         }
  715.     },true);
  716. }    function preventEventCapture(object,eventName){ // Opera supports capturing events but many sites do it by mistake
  717.         var ael=object.addEventListener;
  718.         object.addEventListener=function(type, func, cap){
  719.             if(type==eventName)cap=false;
  720.             ael.call( this, type, func, cap);
  721.         }
  722.     }
  723. function removeClosingHTMLComments(){
  724.     opera.addEventListener( 'BeforeScript', function(e){ replace.call=call; e.element.text=replace.call( e.element.text, /\r\n\s*-->\s*\r\n/, '' ); }, false );
  725. }
  726. function scriptForEventFix(){ // neutralising IE's <script for.. event.. > syntax
  727.     opera.addEventListener('BeforeScript', 
  728.         function(ev){
  729.             getAttribute.call=setAttribute.call=preventDefault.call=call;
  730.             if(getAttribute.call(ev.element, 'event')){
  731.                 setAttribute.call(ev.element, 'declare', 'declare');
  732.                 preventDefault.call(ev);
  733.             }
  734.         }
  735.     , false);
  736. }
  737. function workAroundBug343019(){
  738.     document.addEventListener('DOMContentLoaded', function(){
  739.         for( var frms=document.getElementsByTagName('form'),i=0,frm; frm=frms[i];i++ ){
  740.             if(!frm.action)return;
  741.             if(/^javascript:/i.test(frm.action))return;
  742.             var actionSubstring = /^http/i.test( frm.action ) ? frm.action.substr(7) : frm.action ;
  743.             if( /(:)/.test(actionSubstring) ){
  744.                 var colonPosition = actionSubstring.indexOf(':')+1
  745.                 actionSubstring = actionSubstring.substr( colonPosition );
  746.                 frm.action = frm.action.substr(0, colonPosition) + (actionSubstring.replace(/\+/g, '%252B' ).replace( /\//g, '%252F' ));
  747.             }
  748.         }
  749.  
  750.     },false);
  751. }
  752.  
  753.     // The required attribute does not take the value false according to WebForms2 - remove "required=false" from form elements
  754. // Generic JS library patches
  755. // Compatibility layer for Google Gears initialization script
  756. // PDF security patch
  757.             // 305669, The required attribute does not take the value false according to WebForms2 - remove "required=false" from form elements
  758.     document.addEventListener('load', function(){
  759.         try{var obj = document.evaluate( '//input[translate(@required, "FALSE", "false")="false"]', document.documentElement, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null ), el, i=0 ;
  760.         while(el=obj.snapshotItem(i)){el.removeAttribute('required');i++;}}catch(e){}
  761.     }, false);
  762.             // 0, Generic JS library patches
  763.     // Use an event listener to detect specific scripts
  764.     opera.addEventListener( 'BeforeExternalScript', function(ev){
  765.         match.call=replace.call=indexOf.call=toLowerCase.call=postError.call=addEventListener.call=removeEventListener.call=version.call=parseFloat.call=call;
  766.         
  767.         var name=ev.element.src; 
  768.         if( !name ){ return; } // no fixes required for SCRIPT xlink:href so far..
  769.         name=toLowerCase.call(name );// toLowerCase fixes sangjatten.se
  770.           if ( indexOf.call(name, 'dqm_')>-1 || indexOf.call(name, 'dnm_')>-1 || indexOf.call(name, 'cbrowser_opera.js')>-1 ){ 
  771.             // OpenCube menu
  772.             if(fixOpenCube(name)){
  773.                 postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (OpenCube fix). See browser.js for details.');
  774.             }
  775.             return;
  776.           }else if(  indexOf.call(name, 'hm_loader')>-1  ){ 
  777.             // HierMenus menu
  778.             // If we apply this fix to version 6.x the menu breaks.
  779.             // HM support recommends checking that HM_BrowserVersion is not defined
  780.             addEventListener.call(opera, 'BeforeScript', function(ev){ 
  781.                 match.call=removeEventListener.call=postError.call=call;
  782.                 if( ev.element.text && ! match.call(ev.element.text, /hm_browserversion/i) ){
  783.                     fixHierMenus(name);
  784.                     postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (HierMenus fix). See browser.js for details.');
  785.                 }
  786.                 removeEventListener.call(opera, 'BeforeScript', arguments.callee, false);
  787.             }, false);
  788.             return;
  789.           }else if(  indexOf.call(name, 'mmenu')>-1 || indexOf.call(name, 'milonic')>-1  ){ 
  790.             // Milonic menu
  791.             fixMilonicMenu(name);
  792.             postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Milonic fix). See browser.js for details.');
  793.             return;
  794.         
  795.           }else if(  match.call(name, /menu\d*_(com|build|var|program|compact)\.js$/)   ){ 
  796.             // HV menu
  797.             fixHVMenu(name);
  798.             postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (HVMenu fix). See browser.js for details.');
  799.             return;
  800.           }else if(  match.call(name, /coolmenus\d?.js$/)   ){ 
  801.             // coolmenus menu
  802.             fixCoolmenus(name);
  803.             postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Coolmenus fix). See browser.js for details.');
  804.             return;
  805.           }else if(  match.call(name, /udm[_-]/)  || (  match.call(name, /(sniffer|control)\.js$/)   )    ){ 
  806.             // UDM menu
  807.             addEventListener.call(opera, 'BeforeScript', function(ev){
  808.                 match.call=postError.call=call;
  809.                 if( match.call(name, /udm[_-]/)  || indexOf.call(ev.element.text, 'UDM')>-1 || indexOf.call(ev.element.text, 'um.ov=um.ov.split(/opera[\\/ ]7./);um.ov=um.pi(um.ov[1].charAt(0));')>-1 ){
  810.                     fixUDM(name);
  811.                     postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Coolmenus fix). See browser.js for details.');
  812.                 }
  813.             }, false);
  814.             return;
  815.           }else if(  indexOf.call(name, 'dynapi/api/browser.js')>-1  || indexOf.call(name, 'dynlayer.js')>-1  ){
  816.             navRestore['appName'] = navigator.appName;
  817.             navigator.appName = 'Microsoft Internet Explorer';
  818.             shouldRestore = true;
  819.             postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (DynAPI fix). See browser.js for details.');
  820.         }else if(  match.call(name, /stm(\d+|_menu).js$/)  ){
  821.             fixSoThinkMenus();
  822.             postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (SoThink fix). See browser.js for details.');
  823.         }else if( indexOf.call(name, 'transmenu')>-1 ){
  824.             fixTransmenus();
  825.             postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Transmenu fix). See browser.js for details.');
  826.         }else if( indexOf.call(name, 'xaramenu')>-1 ){
  827.             addPreprocessHandler( new RegExp('if\\(navigator.userAgent.indexOf\\(\'Opera\'\\)!=-1\\)\\s*NS4=1;', ''), 'if(navigator.userAgent.indexOf(\'Opera\')!=-1){IE5=1;NS6=0;}');
  828.             postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Xaramenu fix). See browser.js for details.');
  829.         }else if(  indexOf.call(name, '/richtext.js')>-1  ){ // Bug 230549, bug 208097
  830.             // Rich text editor checks for "On" where Opera and FireFox return "on". sigh. 
  831.             addPreprocessHandler( 'designMode != "On"', 'designMode != "on"', true, function(t){indexOf.call=call;return indexOf.call(t.text, 'kevinroth.com')>-1;} );
  832.             postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Rich text editor submit fix). See browser.js for details');
  833.         }else if( parseFloat.call(window, version.call())<9.5 && indexOf.call(name, '/novell/webaccess/images/msglist.js')>-1){ // Bug 92454, workaround for NWA
  834.             defineMagicFunction.call(opera, 'fixContentHeight',
  835.                 function(oF, oT){
  836.                     document.documentElement.clientHeight=window.innerHeight;
  837.                     oF.apply(oT, slice.call(arguments, 2));
  838.             });
  839.             postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Height function fix). See browser.js for details');
  840.         }else if( indexOf.call(name, 'awmlib')>-1 ){
  841.                 opera.addEventListener('BeforeScript', fixLiknoAllWebMenus, false);
  842.         }else if( indexOf.call( name, 'tiny_mce' )>-1 && 'designMode' in document){
  843.             if( parseFloat.call(window, version.call())<9.5  ){
  844.                 postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (TinyMCE paste+enter fix). See browser.js for details');
  845.                 addEventListener.call( document, 'load', function(){
  846.                     for(var i=0,f;f=frames[i];i++){
  847.                         try{
  848.                             if( ! match.call(f.name, /^mce_editor/) )continue;
  849.                             (function(f){
  850.                                 addEventListener.call(f.document, 'keypress', function(e){
  851.                                     if(e.keyCode==13){
  852.                                         var sel = f.getSelection();
  853.                                         if( sel.anchorNode == f.document.documentElement ){
  854.                                             var rng = sel.anchorNode.ownerDocument.createRange();
  855.                                             rng.selectNodeContents(sel.anchorNode.ownerDocument.body);
  856.                                             rng.collapse( true );
  857.                                             sel.removeAllRanges();
  858.                                             sel.addRange(rng);
  859.                                         }
  860.                                     }
  861.                                 },true );
  862.                             })(f);
  863.                         }catch(e){}
  864.                     }
  865.                 }, false);
  866.             }else{ // patches for 9.5 and up
  867.                 opera.addEventListener('BeforeScript', function(e){ // 335463, lines reversed on enter by workaround against old Opera bug
  868.                         if( e.element.text.match( /majorVersion\s*=\s*"2"/ ) || ( e.element.text.match( /majorVersion\s*:\s*'3'/ ) && e.element.text.match(/minorVersion\s*:\s*'(0|X)/) ) ){ /* 0|X because of CORE-15898*/
  869.                         postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (legacy TinyMCE enter fix + link button fix). See browser.js for details');
  870.                         e.element.text = e.element.text.replace( /if\s*\((tinyMCE\.|)isOpera\)\s*\{(\s*(\w{1,}\.normalize\(\);|)\s*\w{1,}\.insertNode\(\s*\w{1,}\s*\);)/g , 'if(false){$2' );
  871.                         opera.addEventListener('AfterEvent.DOMContentLoaded', function(){ // 345778, create link button not available
  872.                             if( typeof TinyMCE_Selection !='undefined' ){
  873.                                 TinyMCE_Selection.prototype.getSelectedText=function(){return this.getSel().toString();};
  874.                             }
  875.                         },false);
  876.                     }
  877.                     opera.removeEventListener('BeforeScript', arguments.callee, false);
  878.                 },false);
  879.                 if( parseFloat.call(window, version.call(opera))==9.5  ){
  880.                     opera.addEventListener( // 336566, enabling designMode before using document.write will disable it again in the new document
  881.                         'BeforeEvent.load',
  882.                         function(e){
  883.                             var patch_is_required = true;
  884.                             if( typeof TinyMCE_Engine == 'undefined' ) return;
  885.                             try{
  886.                                 if((new TinyMCE_Engine).majorVersion>=3){ // fix not required for versions 3 and above, remove event listener and quit
  887.                                     patch_is_required=false;
  888.                                 }
  889.                             }catch(e){}
  890.                             if( ! patch_is_required ){
  891.                                 opera.removeEventListener('BeforeEvent.load', arguments.callee, false); return;
  892.                             }
  893.                                 if(e.event.target && e.event.target.tagName && e.event.target.tagName.toUpperCase()=='IFRAME'){ // load event for IFRAME
  894.                                 var iframe=e.event.target;
  895.                                 if( iframe.id && iframe.id.match(/^mce_editor_\d/) && iframe.contentDocument ){
  896.                                     iframe.contentDocument.designMode='on';
  897.                                     postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (legacy TinyMCE document.write fix). See browser.js for details');
  898.                                 }
  899.                             }
  900.                         },
  901.                         false
  902.                     );
  903.                 }
  904.             }
  905.             if( indexOf.call(name, 'tiny_mce_popup')!=-1 ){ // Working around a workaround for onload handling differences, 275267
  906.                 addEventListener.call(window, 'load', function(){
  907.                     var versionChecker = new tinyMCEPopup.windowOpener.TinyMCE_Engine;
  908.                     if(versionChecker.majorVersion<3 && versionChecker.minorVersion <1.3 ){
  909.                         document.body.onload();
  910.                     }
  911.                 }, false );
  912.             }
  913.         }else if(indexOf.call(name, 'dev.virtualearth.net/mapcontrol/mapcontrol.ashx')>-1 && window.SVGDocument){
  914.             navRestore.userAgent = navigator.userAgent;
  915.             navigator.userAgent+='KHTML';//356736
  916.             shouldRestore=true;
  917.         }else if(indexOf.call(name,'s_code')>-1){
  918.             avoidDocumentWriteAbuse();
  919.         }
  920.         
  921.         // Creating event handler to restore any changed navigator properties
  922.         if( shouldRestore ){
  923.             addEventListener.call(opera, 'AfterExternalScript', 
  924.                 function(ev){
  925.                     removeEventListener.call=call;
  926.                     var prop;
  927.                     for(prop in navRestore) navigator[prop]=navRestore[prop];
  928.                     removeEventListener.call(opera, 'AfterExternalScript', arguments.callee, false);
  929.                 }
  930.             , false);
  931.         }
  932.     }, false);
  933.             // 366392, Compatibility layer for Google Gears initialization script
  934.     if (window.opera && opera.createWorkerPool && 
  935.         navigator.mimeTypes["application/x-googlegears"] &&
  936.         navigator.mimeTypes["application/x-googlegears"].enabledPlugin
  937.         ){
  938.         window.GearsFactory = function()
  939.         {
  940.             var element = document.createElement("object");
  941.             element.setAttribute('style', 'display:block;width:1px;height:1px;position:absolute;left:-2px');
  942.             element.type = "application/x-googlegears";
  943.      
  944.             document.documentElement.insertBefore(element,
  945.                               document.documentElement.firstChild);
  946.             element.getBuildInfo(); // to make sure init is complete
  947.             return element;
  948.         }
  949.     }
  950.             // 246299, PDF security patch
  951.     opera.addEventListener('BeforeJavaScriptURL', function( e ){
  952.         unescape.call=toLowerCase.call=indexOf.call=preventDefault.call=call;
  953.         var pathname=unescape.call(self, toLowerCase.call(self.location.pathname));
  954.         var hash=unescape.call(self, toLowerCase.call(self.location.hash));
  955.         if( /*indexOf.call(pathname, '.pdf')>-1 &&*/ hash  &&  indexOf.call(hash, 'javascript:')>-1   ) preventDefault.call(e);
  956.     }, false);
  957.  
  958.  
  959.     if( hostname.indexOf('.saab.')>-1 ){            // 145261,  sniffing on saab.com and saab.de excludes Opera
  960.         opera.defineMagicVariable('isNAV6', function(){return true;}, null);
  961.         opera.defineMagicVariable('isOPERA', function(){return false;}, null);
  962.         opera.defineMagicVariable('isMAC', function(){return false;}, null);
  963.         
  964.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' ( sniffing on saab.com and saab.de excludes Opera). See browser.js for details');
  965.     } else if((hostname=='www.opera.com' || hostname=='jp.opera.com') && pathname.indexOf('/docs/browserjs/')==0){            // 0, Browser.js status and version reported on browser.js documentation page
  966.         document.addEventListener((parseInt(opera.version())>9?'DOMContentLoaded':'load'),function(){
  967.             if(document.getElementById('browserjs_active')){
  968.                 document.getElementById('browserjs_active').style.display='';
  969.                 document.getElementById('browserjs_active').getElementsByTagName('span')[0].appendChild(document.createTextNode(bjsversion));
  970.                 document.getElementById('browserjs_status_message').style.display='none';
  971.             }else if(document.getElementById('browserjs_status_message')){
  972.                 document.getElementById('browserjs_status_message').firstChild.data='Browser.js is enabled! '+bjsversion;
  973.             }
  974.         }, false);
  975.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Browser.js status and version reported on browser.js documentation page). See browser.js for details');
  976.     } else if(hostname.indexOf(  'music.download.com'  )>-1){            // 178744, Fixing audio samples, old overlibwms library only detects Opera7
  977.         navigator.userAgent += ' Opera 7';
  978.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Fixing audio samples, old overlibwms library only detects Opera7). See browser.js for details');
  979.     } else if(hostname.indexOf( 'fileplanet.com' ) >-1 && href.indexOf('/sp_downloadmanager.aspx')>-1){            // 219257, Fileplanet.com sniffing blocks Opera
  980.         opera.defineMagicVariable('agt',function(){return "win";},null);
  981.         addPreprocessHandler( /(\b)window\s*.\s*opera(\b)/g,'$1undefined$2');
  982.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Fileplanet.com sniffing blocks Opera). See browser.js for details');
  983.     } else if(hostname.indexOf( 'nmviewogc.cr.usgs.gov' )!=-1){            // 233838, National Map Viewer on USGS relies on Netscape detection for functionality
  984.         navigator.appName='Netscape';
  985.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (National Map Viewer on USGS relies on Netscape detection for functionality). See browser.js for details');
  986.     } else if(hostname.indexOf("rec.feeds.yahoo.")==0){            // 194334, Make "add feeds" dialog work in Y!Mail beta
  987.         if( location.href.indexOf("bjs_getXMLMarkup")>=0 )location.href = location.href.replace("bjs_getXMLMarkup()","xml");
  988.         navigator.product='Gecko';
  989.         addCssToDocument('#FeedTabs div.panel{overflow:auto!important}body{overflow:hidden!important}');
  990.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Make "add feeds" dialog work in Y!Mail beta). See browser.js for details');
  991.     } else if(hostname.indexOf('.anz.com')!=-1){            // 343019, ANZ online bank form action URLs are incorrectly decoded
  992.         workAroundBug343019();
  993.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (ANZ online bank form action URLs are incorrectly decoded). See browser.js for details');
  994.     } else if(hostname.indexOf('.dell.')!=-1&&hostname.indexOf('support.')!=-1){            // 286618,  browser sniffing on support.dell.com
  995.         opera.defineMagicVariable( 'ig_shared', null, function(o){ o.IsNetscape6=true; return o; } );
  996.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' ( browser sniffing on support.dell.com). See browser.js for details');
  997.     } else if(hostname.indexOf('.ebay.')>-1){            // 226144, eBay: IFRAME expands forever
  998.         document.addEventListener( (parseFloat(opera.version())>9?'DOMContentLoaded':'load'), function(){ try{
  999.             if( ! window.frameElement)return; 
  1000.             document.onresize=null;document.body.onresize=null;
  1001.         }catch(e){}}, false );
  1002.         
  1003.                 // 228707, eBay: speed up back+forward navigation
  1004.         opera.setOverrideHistoryNavigationMode('fast');
  1005.                 // 318428, eBay tries to communicate with inaccessible IFRAMEs loading graphics from other servers over https
  1006.         if(location.protocol=='https:')document.addEventListener( 'load', function(e){
  1007.             var el;
  1008.             if( location.search.indexOf( 'ChooseUserIdAndPassword' )>-1 ){
  1009.             location.replace =  function(url){
  1010.                         if( !  url.match(/^https:\/\/.*\.gif$/i)  )
  1011.                             this.href = url;
  1012.                     }
  1013.             }
  1014.             for(var all=document.getElementsByTagName('iframe'),i=0;el=all[i];i++){
  1015.             if( el.width<=1 && el.height<=1 && el.src.match(/^https:\/\/.*\.gif$/i) ){
  1016.                 try{ var s=el.contentWindow.document.body; }catch(e){
  1017.                     el.src='about:blank';
  1018.                 }
  1019.             }
  1020.             }
  1021.         }, false );
  1022.         
  1023.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (eBay: IFRAME expands forever\neBay: speed up back+forward navigation\neBay tries to communicate with...). See browser.js for details');
  1024.     } else if(hostname.indexOf('.ibm.com')>-1){            // 206984, IBM driver download has HTML comments inside SCRIPT tag, breaks parsing
  1025.         removeClosingHTMLComments();
  1026.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (IBM driver download has HTML comments inside SCRIPT tag, breaks parsing). See browser.js for details');
  1027.     } else if(hostname.indexOf('.icicibank.')!=-1){            // 343019, ICICI online bank form action URLs are incorrectly decoded
  1028.         workAroundBug343019();
  1029.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (ICICI online bank form action URLs are incorrectly decoded). See browser.js for details');
  1030.     } else if(hostname.indexOf('.mail.yahoo.')>-1&&(href.indexOf( '/dc/system_requirements?browser=blocked' )>-1||href.indexOf( '/dc/system_requirements?browser=unsupported' )>-1)){            // 194334, Y!Mail work around browser blocking
  1031.         location.href='/dc/launch?sysreq=ignore';
  1032.         
  1033.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Y!Mail work around browser blocking). See browser.js for details');
  1034.     } else if(hostname.indexOf('.mail.yahoo.')>=0 && pathname.indexOf('/dc/')==0){            // 290495, can't get past "new features" screen due to redirect
  1035.         document.addEventListener( 'DOMContentLoaded', function(){
  1036.             for( var link_count=0,element;element=document.links[ link_count ]; link_count++ ){
  1037.                 if( element.getAttribute('href')=='/dc/launch?consentLW=1' )element.setAttribute('href', '/dc/launch?consentLW=1&sysreq=ignore');
  1038.             }
  1039.         } ,false );
  1040.         
  1041.                 // 307369, Y!Mail button attribute "action" is a URL in WF2
  1042.         HTMLButtonElement.prototype.__defineSetter__('action', function(o){this._action=o});
  1043.         HTMLButtonElement.prototype.__defineGetter__('action', function(){return this._action});
  1044.                 // 315686, Remember to create documentElement properties on XML nodes
  1045.         addPreprocessHandler( 'oEl.XMLDocument=oNewDOM;', 'oEl.XMLDocument=oNewDOM;oEl.documentElement=oNewDOM.documentElement;' );
  1046.         
  1047.                 // CORE-17537, Y!Mail search results show overlapping text due to vertical-align for table contents different from Firefox
  1048.         addCssToDocument('tbody, thead, tfoot, table > tr { vertical-align: middle } tr, th, td { vertical-align: inherit }');
  1049.                 // CORE-17539, Y!Mail spell check fix
  1050.         document.__defineGetter__('designMode', function() {
  1051.             return this.documentElement.contentEditable ? 'on' : 'off';
  1052.         });
  1053.         
  1054.         document.__defineSetter__('designMode', function(v) {
  1055.             this.documentElement.contentEditable = (v == 'on');
  1056.         });
  1057.                 // CORE-17538, Y!Mail avoid text selection on drag-and-drop
  1058.         window.addEventListener('mousedown', function(evt) {
  1059.             var target = evt.target;
  1060.             var cursor = getComputedStyle(target, null).cursor;
  1061.             if (/move/i.test(cursor) || /size/i.test(cursor)) {
  1062.                 evt.preventDefault();
  1063.             } else if (!('value' in target) /* don't preventDefault for <input>, etc */) {
  1064.                 for (var node = target; node; node = node.parentNode) {
  1065.                     if (node.hasAttribute && node.hasAttribute('tabindex')) {
  1066.                         evt.preventDefault();
  1067.                         break;
  1068.                     }
  1069.                 }
  1070.             }
  1071.         }, true);
  1072.                 // 321384, createElement in XML document should put un-prefixed nodes in null namespace
  1073.         var docCreateElement = Document.prototype.createElement;
  1074.         if( window.XMLDocument ){
  1075.             XMLDocument.prototype.createElement = function(n){ return n.indexOf(':')==-1 ? this.createElementNS(null, n) : docCreateElement.call(this,n); }
  1076.         }else{
  1077.             Document.prototype.createElement = function(n){ return n.indexOf(':')==-1 ? this.createElementNS(null, n) : docCreateElement.call(this,n); }
  1078.         }
  1079.                 // 194334, Make sure dragging does not cause visible selections
  1080.         addCssToDocument('[unselectable]::selection, [unselectable] ::selection { background-color: transparent; color: inherit }');
  1081.                 // 327060, Clearfix character causes extra padding
  1082.         addCssToDocument('.clearfix:after { position: absolute }');
  1083.                 // 327060, Hidden iframe isn't actually hidden, causes weird white rect behind dialogs
  1084.         addCssToDocument('.backingIframe { border-width: 0; opacity: 0.01 } ');
  1085.                 // 327060, Shadow on dialogs is messed up, so fix it
  1086.         addCssToDocument('.dialogFooterCenter { font-size: 0; line-height: 0 } ');
  1087.                 // 327060, The hidden <input type="file"> for the "Attach" button not hidden in Merlin on Mac OS X
  1088.         addCssToDocument('.transparent_attach_btn { padding: 0 !important; background-color: white !important; clip: rect(0 0 0 0) !important; z-index: 1 !important } ' +
  1089.                         // Make sure all the buttons are above the <input type="file">...
  1090.                         '#messageToolbar > table { position: relative; z-index: 102 } ' +
  1091.                         // ...except for the "Attach" button
  1092.                         '#messageToolbar #btnTbl_Attach { z-index: 0 !important }');
  1093.                 // 194334, Y!Mail making sure addRule doesn't throw x-doc security errors
  1094.         if(!CSSStyleSheet.prototype.addRule )
  1095.             CSSStyleSheet.prototype.addRule = function( selector, css ){
  1096.                 try{
  1097.                     this.insertRule(selector+" { "+css+" }",this.cssRules.length);
  1098.                 }catch(ex){}
  1099.             };
  1100.         
  1101.                 // 194334, Y!Mail To: / CC: autocomplete fails because boundingLeft is not supported
  1102.         HTMLInputElement.prototype.createTextRange=HTMLTextAreaElement.prototype.createTextRange=null;
  1103.         
  1104.         
  1105.                 // 194334, Y!Mail faking oncontextmenu support
  1106.         fakeOncontextmenu(false, 500)
  1107.                 // 353880, Y!Mail reversed mouse wheel scrolling
  1108.         opera.addEventListener('BeforeEvent.mousewheel', function(e) {
  1109.             var d = e.event.wheelDelta * -1;
  1110.             e.event.__defineGetter__('wheelDelta', function() { return d });
  1111.         }, false);
  1112.                 // 194334, Y!Mail remove selectSingleNode and selectNodes
  1113.         /* because Yahoo mail is better at emulating proprietary IE functions than we are.. */
  1114.         Node.prototype.selectSingleNode=undefined;
  1115.         Node.prototype.selectNodes=undefined;
  1116.                 // 366564, Define document on iframe.contentWindow even while it is loading
  1117.         HTMLIFrameElement.prototype.__defineGetter__('contentWindow', function(){
  1118.             if( ! this.contentDocument ){
  1119.                 return { document:{} };
  1120.             }
  1121.             return this.contentDocument.defaultView;
  1122.         }); 
  1123.                 // 241691, Y!Mail doesn't load if identifying as IE
  1124.         navigator.userAgent = navigator.userAgent.replace( /MSIE/, '' );
  1125.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (can\'t get past "new features" screen due to redirect\nY!Mail button attribute "action" is a URL in W...). See browser.js for details');
  1126.     } else if(hostname.indexOf('.t-online.de')>-1){            // 225374,  video problems on T-online.de
  1127.         if(hostname.indexOf('onunterhaltung')>-1){
  1128.                     //Fix browser detection
  1129.                     opera.defineMagicFunction( 'allResultsOK', function(){return true;} );
  1130.                     // Fix plugin detection
  1131.                     opera.defineMagicVariable( 'fHasWMP64', function(){ return navigator.mimeTypes['application/x-mplayer2'].enabledPlugin?true:false }, null )
  1132.                     opera.defineMagicVariable( 'fHasWMP7', function(){ return navigator.mimeTypes['application/x-mplayer2'].enabledPlugin?true:false }, null )
  1133.                     opera.defineMagicVariable( 'WMPVer', function(){ try{return fHasWMP64?'6.4':'unknown'}catch(e){return '6.4'} }, null )
  1134.             opera.addEventListener( 'BeforeScript',function(e){
  1135.                 replace.call=call;
  1136.                 e.element.text=replace.call(e.element.text,  'playerframe.Player.url=url;', 'playerframe.Player.url=url;nplayerframe.Player.Open(url);' );
  1137.             },false );
  1138.                     // use TYPE as well as CLASSID on OBJECT tags in markup
  1139.                     var objId='Player';
  1140.                     var objref=null;
  1141.                     document.addEventListener('DOMContentLoaded', function(e){ 
  1142.                         if( ! (objref=document.getElementById(objId) ) ) return;
  1143.                         if(objref.getAttribute('classid')=="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6")objref.type='application/x-mplayer2';
  1144.                     }, false);
  1145.                     // Remove UI that depends on ActiveX scripting. Built-in WMP UI will do..
  1146.                     document.addEventListener('DOMContentLoaded', function(e){ 
  1147.                         var pb=document.getElementById('playBtn');
  1148.                         var wmp=document.getElementById('playerframe');
  1149.                         if( pb&&wmp ){
  1150.                             pb.parentNode.style.visibility='hidden';    wmp.style.visibility='visible';
  1151.                             try{ document.images.tonaus.height=0;document.images.tonaus.width=0;}catch(e){}
  1152.                         }
  1153.                     }, false);
  1154.         }
  1155.                 // 231082,  video problems on T-online.de, VOD section
  1156.                 if( hostname.indexOf('vod')>-1 ){ // 231082
  1157.                     navigator.userAgent+=' Firefox';
  1158.                 }
  1159.         
  1160.                 // 231082,  video problems on T-online.de, WMP license installation
  1161.         if(href.indexOf('__license=delivered')>-1){
  1162.             location.replace( location.href.replace( /__license=delivered/, '?license=delivered' ) );
  1163.         }
  1164.         
  1165.                 // 226414,  video problems on T-online.de, no window.external detection
  1166.         window.external=window.external||{};
  1167.         
  1168.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' ( video problems on T-online.de\n video problems on T-online.de, VOD section\n video problems on T-on...). See browser.js for details');
  1169.     } else if(hostname.indexOf('.ulead.') >-1){            // 142757, Ulead.com old Milonic menu
  1170.          fixMilonicMenu('mmenu.js');
  1171.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Ulead.com old Milonic menu). See browser.js for details');
  1172.     } else if(hostname.indexOf('.yahoo.')>-1&&hostname.indexOf('mail')==-1){            // 101146, Yahoo ISP portal blocks Opera users
  1173.         addPreprocessHandler( /d\.location\.href = ".*?\/browser_upgrade\.html";/g, '');
  1174.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Yahoo ISP portal blocks Opera users). See browser.js for details');
  1175.     } else if(hostname.indexOf('able.co.jp')>-1){            // 253081,  able.co.jp uses capturing event listeners
  1176.         preventEventCapture( HTMLAnchorElement.prototype, 'click' );
  1177.         preventEventCapture( HTMLSelectElement.prototype, 'change' );
  1178.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' ( able.co.jp uses capturing event listeners). See browser.js for details');
  1179.     } else if(hostname.indexOf('allabout.co.jp')!=-1){            // DSK-227082, Works around script scheduling bug on AllAbout
  1180.         fixJQueryScriptSchedulingTrouble();
  1181.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Works around script scheduling bug on AllAbout). See browser.js for details');
  1182.     } else if(hostname.indexOf('ameba.jp')!=-1){            // 331093, Enable blog post editor on ameba.jp
  1183.         navigator.product='Gecko';
  1184.         navigator.userAgent=navigator.userAgent.replace('Opera', '0pera (spoofing as Firefox)');
  1185.                 // 331093, Work around Opera bug where second BR tag overwrites newly inserted IMG
  1186.         addPreprocessHandler(/editor\.insertNodeAtSelection\(link\);\s*editor\.insertNodeAtSelection\(document\.createElement\('br'\)\);/, 'editor.insertNodeAtSelection(link);');
  1187.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Enable blog post editor on ameba.jp\nWork around Opera bug where second BR tag overwrites newly inse...). See browser.js for details');
  1188.     } else if(hostname.indexOf('aol.com') >-1){            // 179219, AOL miscalculated widths cause overlaps at top
  1189.         opera.addEventListener('BeforeEvent.'+(opera.version()>9?'DOMContentLoaded':'load'), function(ev){ if(ev.event.target!=document)return;
  1190.         var i;
  1191.         i = getElementById.call(document, 'static'); if(i){ i.style.width = (i.offsetWidth-2)+'px';}
  1192.         }, false);
  1193.                 // 226390, AOL browser sniffing blocks opera  
  1194.         opera.defineMagicVariable( 'is_supported', function(){return 1;}, null);
  1195.         
  1196.                 // 214747, AOL: when IFRAME invisible GIF is served over https, script can not update location
  1197.         if(location.protocol=='http:'){addPreprocessHandler( new RegExp('https://sns-static.aolcdn.com/', 'g'), 'http://sns-static.aolcdn.com/', false );}
  1198.         
  1199.                 // 188197, Making sure AOL pages are not overwritten by ad script
  1200.         avoidDocumentWriteAbuse();
  1201.                 // 262693, AOL browser sniffing causes missing styling
  1202.         document.addEventListener('DOMContentLoaded', function(){document.documentElement.className='SAF';}, false);
  1203.                 // 262693, AOL click tracking breaks news slide show control buttons
  1204.         opera.defineMagicFunction('s_gi', function(){return {t:function(){return {};}};});
  1205.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (AOL miscalculated widths cause overlaps at top\nAOL browser sniffing blocks opera  \nAOL: when IFRAM...). See browser.js for details');
  1206.     } else if(hostname.indexOf('apple.viamichelin.com')>-1){            // 288490, Text on Apple store locator page is misaligned and overlapping
  1207.         addCssToDocument('center table{text-align: left} div#poilist table td img+img{ display: block;}')
  1208.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Text on Apple store locator page is misaligned and overlapping). See browser.js for details');
  1209.     } else if(hostname.indexOf('att.com')!=-1){            // 206467, ATT / Bellsouth browser sniffing
  1210.         opera.defineMagicVariable( 'isDHTML', function(){return true;}, null );
  1211.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (ATT / Bellsouth browser sniffing). See browser.js for details');
  1212.     } else if(hostname.indexOf('barnesandnoble.com')>-1){            // 195961, Barnes&Noble uses "required" attributes on elements that aren't required
  1213.         document.addEventListener('load', function(){var nodes=document.evaluate('//input[@required]', document.body,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null),node=null,i=0; while(node=nodes.snapshotItem(i)){ node.removeAttribute('required'); i++; }},false);
  1214.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Barnes&Noble uses "required" attributes on elements that aren\'t required). See browser.js for details');
  1215.     } else if(hostname.indexOf('bbs.dzart.net')!= -1){            // 361539, Avoid manipulating broken Discuz! markup on bbs.dzart.net
  1216.         opera.defineMagicFunction('announcementScroll', function(){});
  1217.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Avoid manipulating broken Discuz! markup on bbs.dzart.net). See browser.js for details');
  1218.     } else if(hostname.indexOf('bbs.hxsd.com')!= -1){            // 361510, Broken CSS makes fonts too small on bbs.hxsd.com
  1219.         addCssToDocument('body{font-size:75%}');
  1220.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Broken CSS makes fonts too small on bbs.hxsd.com). See browser.js for details');
  1221.     } else if(hostname.indexOf('bbs.kafan.cn')!= -1){            // 361525, Setting innerHTML to badly nested markup breaks forum layout on bbs.kafan.cn
  1222.         opera.defineMagicFunction('parsetag',function(){});
  1223.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Setting innerHTML to badly nested markup breaks forum layout on bbs.kafan.cn). See browser.js for details');
  1224.     } else if(hostname.indexOf('betfair.com')>-1){            // 309459, Betfair relies on firstChild defined on attribute nodes
  1225.         Attr.prototype.__defineGetter__("firstChild", function() {return this;});
  1226.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Betfair relies on firstChild defined on attribute nodes). See browser.js for details');
  1227.     } else if(hostname.indexOf('bioware.com')>-1){            // 239590, bioware.com uses outdated HierMenus
  1228.         fixHierMenus();
  1229.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (bioware.com uses outdated HierMenus). See browser.js for details');
  1230.     } else if(hostname.indexOf('blogger.com')>-1){            // 177059, Blogger: browser detection prevents WYSIWYG editing
  1231.         navigator.product = 'Gecko';
  1232.         navigator.userAgent = navigator.userAgent.replace(/Opera/, 'Firefox')+' ( rv:1.9.0.3)';
  1233.         
  1234.         opera.defineMagicVariable(
  1235.             'Detect',
  1236.             function( obj ){return obj;},
  1237.             function( obj ){
  1238.                 obj.OPERA = function(){return false;}
  1239.                 obj.MOZILLA = function(){return true;}
  1240.                 obj.IE=function(){return false;}
  1241.                 obj.IE_5_5_newer=function(){return false;}
  1242.                 return obj;
  1243.             }
  1244.         );
  1245.         
  1246.                 // 187226, Blogger: Should distinguish AltGr and Ctrl
  1247.         opera.defineMagicFunction('isCtrlKeyPressed', function(f, t, e){ return e.ctrlKey&&!e.altKey;  });
  1248.         opera.defineMagicVariable( 'IE_KEYSET', function(){ return true; },null );
  1249.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Blogger: browser detection prevents WYSIWYG editing\nBlogger: Should distinguish AltGr and Ctrl). See browser.js for details');
  1250.     } else if(hostname.indexOf('bloglines.com')>-1){            // 248295, Bloglines, designMode case sensitivity issue
  1251.         addPreprocessHandler( 'designMode != "On"', 'designMode != "on"', true, function(t){indexOf.call=call;return indexOf.call(t.text, 'kevinroth.com/rte/demo.htm')>-1;} );
  1252.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Bloglines, designMode case sensitivity issue). See browser.js for details');
  1253.     } else if(hostname.indexOf('bookryanair.com')>-1){            // 319803, Make Opera's built-in WF2 validation ignore required attributes on bookryanair.com
  1254.         ignoreRequiredAttributes();
  1255.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Make Opera\'s built-in WF2 validation ignore required attributes on bookryanair.com). See browser.js for details');
  1256.     } else if(hostname.indexOf('britannica.com')>-1){            // 332948, Prevent overwriting document with stats graphic on britannica.com
  1257.         avoidDocumentWriteAbuse();
  1258.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Prevent overwriting document with stats graphic on britannica.com). See browser.js for details');
  1259.     } else if(hostname.indexOf('britishairways.')!=-1){            // 206810, Prevent britishairways.com from reloading the page on resize
  1260.         opera.defineMagicFunction('resizeHandler', function(){});
  1261.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Prevent britishairways.com from reloading the page on resize). See browser.js for details');
  1262.     } else if(hostname.indexOf('cajamadrid.es')!=-1){            // 346825, Caja Madrid hides login form by CSS mistake
  1263.         addCssToDocument('body:last-child .clearfix {content:normal!important;}');
  1264.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Caja Madrid hides login form by CSS mistake). See browser.js for details');
  1265.     } else if(hostname.indexOf('capitalone.com')>-1&&location.protocol=='https:'){            // 86032, CapitalOne login fails - cross-domain access on https disallows setting location
  1266.         document.domain='capitalone.com';
  1267.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (CapitalOne login fails - cross-domain access on https disallows setting location). See browser.js for details');
  1268.     } else if(hostname.indexOf('cdec-sic.cl')!=-1){            // 365516, Old HierMenus on cdec-sic.cl
  1269.         fixHierMenus();
  1270.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Old HierMenus on cdec-sic.cl). See browser.js for details');
  1271.     } else if(hostname.indexOf('chase.com')!=-1){            // 243036, chase.com field refocus from onkeypress-problem
  1272.         opera.defineMagicFunction('handleTabs', function(oT, oF, name){
  1273.             var el=document.getElementById(name);
  1274.             if(el && el.value.length+1>=el.maxLength && !(event.keyCode==8||event.keyCode==46)){
  1275.                 setTimeout( function(){ jumpToNext(el); }, 100);
  1276.             }
  1277.             function jumpToNext(el){
  1278.                 var i=0;
  1279.                 if(el.form){while(el!=el.form[i])i++;}else{ return;}
  1280.                 if(el.form[i+1])el.form[i+1].focus();
  1281.             }
  1282.         });
  1283.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (chase.com field refocus from onkeypress-problem). See browser.js for details');
  1284.     } else if(hostname.indexOf('chosun.com')>-1){            // 279130, Morningplus.chosun.com misplaced content
  1285.         addCssToDocument('#scroll_image{ position: relative }');
  1286.                 // 209929, chosun.com scrollarea fix
  1287.         addCssToDocument('#nscrollarea, #nscrolltxt{display: inline !important}');
  1288.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Morningplus.chosun.com misplaced content\nchosun.com scrollarea fix). See browser.js for details');
  1289.     } else if(hostname.indexOf('continental.com')>-1){            // 263594, Continental.com document.activeElement fix enables airport choice popup
  1290.         opera.addEventListener('BeforeEventListener.click', function(e){if(e.event.target && e.event.target.tagName=='A')document.activeElement=e.event.target; }, false);
  1291.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Continental.com document.activeElement fix enables airport choice popup). See browser.js for details');
  1292.     } else if(hostname.indexOf('deviantart.com')>-1){            // 282065,  deviantart.com prevents mousedown on file inputs, making it impossible to select files
  1293.         opera.addEventListener('BeforeEventListener.mousedown', function(e){
  1294.         func_toString.call=preventDefault.call=call;
  1295.                 if( func_toString.call(e.listener)=='function(){return false}' && e.event.target.tagName=='INPUT' ){
  1296.                     preventDefault.call(e);
  1297.                 }
  1298.             }, false);
  1299.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' ( deviantart.com prevents mousedown on file inputs, making it impossible to select files). See browser.js for details');
  1300.     } else if(hostname.indexOf('fedex.com')!=-1){            // 363564, FedEx.com mangles tables by turning TDs into block elements
  1301.         document.addEventListener('DOMContentLoaded', function(){ for(var els=document.getElementsByTagName('td'),el,i=0;el=els[i];i++)if(el.style.display=='block')el.style.display='';}, false);
  1302.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (FedEx.com mangles tables by turning TDs into block elements). See browser.js for details');
  1303.     } else if(hostname.indexOf('fotocenter.aol.de')>-1){            // 202045, AOL: browser warnings for various features of aol.de
  1304.         document.cookie='NewportUnsupportedBrowserAccepted=true;';
  1305.         
  1306.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (AOL: browser warnings for various features of aol.de). See browser.js for details');
  1307.     } else if(hostname.indexOf('gallery.live.com')>-1){            // 262961, Live.com properties overwrite page from click tracking script
  1308.         opera.defineMagicFunction( 'RegisterOmnitureAction', function(){} );
  1309.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Live.com properties overwrite page from click tracking script). See browser.js for details');
  1310.     } else if(hostname.indexOf('geoaccess.com')!=-1){            // 318050,  BlueCross browser sniffing prevents insurance search
  1311.         opera.defineMagicVariable('is_nav', function(){return true;}, null);
  1312.         
  1313.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' ( BlueCross browser sniffing prevents insurance search). See browser.js for details');
  1314.     } else if(hostname.indexOf('groups.google.') > -1 && pathname.indexOf('/browse_frm/thread/') > -1){            // CORE-10896, Opera's interpretation of 100% height isn't high enough for Google Groups
  1315.         function adjustHeight() {
  1316.               var tmp, grcsr = (tmp = document.getElementById('grcsr')) && tmp.firstChild, threadHeader = (tmp = document.getElementById('thread_header')) && tmp.parentNode;
  1317.               if (!grcsr || !threadHeader) return;
  1318.               var height = parseInt(getComputedStyle(grcsr, null).getPropertyValue('height')) - parseInt(getComputedStyle(threadHeader, null).getPropertyValue('height'));
  1319.               document.getElementById('index_splitter_pane').style.height = (height -1)+'px';
  1320.               document.getElementById('data_splitter_pane').style.height = height+'px';
  1321.             }
  1322.         document.addEventListener('DOMContentLoaded', adjustHeight, false);
  1323.         window.addEventListener('resize', adjustHeight, false);
  1324.         
  1325.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Opera\'s interpretation of 100% height isn\'t high enough for Google Groups). See browser.js for details');
  1326.     } else if(hostname.indexOf('ibank.isb.ru')!=-1){            // 0, browser sniffing breaks ibank.isb.ru
  1327.         navigator.__defineGetter__('family', function(){return 'gecko';})
  1328.         navigator.__defineSetter__('family', function(){})
  1329.         
  1330.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (browser sniffing breaks ibank.isb.ru). See browser.js for details');
  1331.     } else if(hostname.indexOf('icelandair.')!=-1){            // DSK-238649, jQuery script scheduling trouble on Icelandair
  1332.         fixJQueryScriptSchedulingTrouble();
  1333.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (jQuery script scheduling trouble on Icelandair). See browser.js for details');
  1334.     } else if(hostname.indexOf('iieye.com')!= -1){            // 361535, IE detection prevents other browsers from accessing iieye.com
  1335.         opera.defineMagicVariable('isIE',function(){return true;}, null);
  1336.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (IE detection prevents other browsers from accessing iieye.com). See browser.js for details');
  1337.     } else if(hostname.indexOf('ingdirect.com.au')>-1){            // 352969, Make Opera's built-in WF2 validation ignore required attributes on ingdirect.com.au
  1338.         ignoreRequiredAttributes();
  1339.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Make Opera\'s built-in WF2 validation ignore required attributes on ingdirect.com.au). See browser.js for details');
  1340.     } else if(hostname.indexOf('isbank.com.tr')>-1){            // 265077,  fixing navigation menu on isbank.com.tr
  1341.         opera.addEventListener('BeforeScript', function(e){ replace.call=call; e.element.text=replace.call(e.element.text, 'SaklaGoster(sFrameAdi, 0, i.sMenuAd);};else if', 'SaklaGoster(sFrameAdi, 0, i.sMenuAd);}else if') },false);
  1342.         
  1343.                 // 265077, fixing keypress handler on isbank.com.tr
  1344.         var ignoreKeypressCodes = {8:'',9:'',16:'',17:'',35:'',36:'',37:'',38:'',39:'', 40:'',45:'',46:''};
  1345.         opera.addEventListener('BeforeEventListener.keypress', function( e ){ preventDefault.call=call; if( e.event.keyCode in ignoreKeypressCodes) preventDefault.call(e); }, false)
  1346.         
  1347.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' ( fixing navigation menu on isbank.com.tr\nfixing keypress handler on isbank.com.tr). See browser.js for details');
  1348.     } else if(hostname.indexOf('klm.com')>-1){            // 213449, KLM uses Gecko-specific originalTarget
  1349.         addPreprocessHandler( /if \(e\) if \(e\.originalTarget\./g, 'if (e && e.originalTarget) if (e.originalTarget.' );
  1350.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (KLM uses Gecko-specific originalTarget). See browser.js for details');
  1351.     } else if(hostname.indexOf('kr.msn.com')!=-1){            // 349584, head layout broken on kr.msn.com
  1352.         addCssToDocument('li:after, ul:after{display:none!important}');
  1353.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (head layout broken on kr.msn.com). See browser.js for details');
  1354.     } else if(hostname.indexOf('lgmobile.com')!=-1 ){            // 331748,  LG Mobile Flash does not load as expected because of missing type attribute
  1355.         document.addEventListener( 'DOMContentLoaded', function(e){
  1356.             for( var elements=document.getElementsByTagName('object'),element,i=0; element=elements[i]; i++){
  1357.                 if( element.parentNode.tagName.toUpperCase() == 'OBJECT' )continue;
  1358.                 if(element.getAttribute('classid')=='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' && ! element.getAttribute('type') ){
  1359.                     element.setAttribute('type', 'application/x-shockwave-flash');
  1360.                     element.parentNode.replaceChild( element.cloneNode(true), element );
  1361.                 }
  1362.             }
  1363.         }, false)
  1364.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' ( LG Mobile Flash does not load as expected because of missing type attribute). See browser.js for details');
  1365.     } else if(hostname.indexOf('mail.163.com')!= -1){            // 347923, Fixed add files issue in mail.163.com
  1366.         addCssToDocument('.upload .input_browser { width:auto !important}');
  1367.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Fixed add files issue in mail.163.com). See browser.js for details');
  1368.     } else if(hostname.indexOf('mail.google.')>-1){            // 244011, GMail deletes messages on End key presses
  1369.         opera.addEventListener( 'BeforeEventListener.keypress', function(e){
  1370.             preventDefault.call=call;
  1371.             if(e.event.keyCode==35){
  1372.                 preventDefault.call(e);
  1373.             }
  1374.         }, false );
  1375.                 // DSK-242365, GMail sends broken styling if ISP name is found in UA string
  1376.         if(navigator.userAgent.match(/\(.*?\)/)[0].split(/;/).length>3||navigator.userAgent.indexOf('Edition IBIS')!=-1){
  1377.             addCssToDocument('#canvas_frame { position: absolute }');
  1378.         }
  1379.                 // 196536, GMail: browser blocking prevents chat feature from appearing
  1380.         try{
  1381.         if( top.location.search.indexOf('ui=1')!=-1 ){
  1382.             if(top.location.search.indexOf('auth')>-1){
  1383.                 addPreprocessHandler( 'disablechatbrowsercheck', 'auth' );
  1384.             }else if(top==self&&!window.opener&&location.search.indexOf('disablechatbrowsercheck')==-1&&location.search.indexOf('ui=html')==-1&&pathname.indexOf('.html')==-1){
  1385.                 opera.addEventListener( 'AfterScript', function(e){
  1386.                 if(top.frames.length>0){
  1387.                     top.location.search+=(top.location.search)?'&disablechatbrowsercheck=1':'?disablechatbrowsercheck=1';
  1388.                 }}, false);
  1389.             }
  1390.         }
  1391.         }catch(e){}
  1392.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (GMail deletes messages on End key presses\nGMail sends broken styling if ISP name is found in UA str...). See browser.js for details');
  1393.     } else if(hostname.indexOf('mail.live.com')!=-1){            // CORE-17444, Fix drag and drop in Hotmail
  1394.         function fixButton(e) {
  1395.             if (e.button == 1) {
  1396.                 e.__defineGetter__('button', function() { return 0 });
  1397.             }
  1398.         };
  1399.         window.addEventListener('mousedown', fixButton, true);
  1400.         window.addEventListener('mousemove', fixButton, true);
  1401.         window.addEventListener('mouseup', fixButton, true);
  1402.         
  1403.                 // CORE-17444, define document.selection.empty in Hotmail (part of drag-and-drop fix)
  1404.         document.selection.empty = function() {
  1405.             var sel = getSelection();
  1406.             if (!sel.isCollapsed) {
  1407.                 sel.removeAllRanges();
  1408.             }
  1409.         };
  1410.                 // CORE-17447, Mispositioned sprites due to missing CSS
  1411.         addCssToDocument('.c_is { display: inline-block }');
  1412.                 // CORE-17445, Detecting style.filter causes missing opacity effects
  1413.         CSSStyleDeclaration.prototype.__defineGetter__('filter', function() {
  1414.             return undefined;
  1415.         });
  1416.                 // CORE-17446, Borders on folders remain after dragging things past them
  1417.         var styleDec = (document.documentElement) ? document.documentElement.style : null;
  1418.         if(styleDec){
  1419.             var getBorderColor = styleDec.__lookupGetter__('borderColor');
  1420.             var setBorderColor = styleDec.__lookupSetter__('borderColor');
  1421.             CSSStyleDeclaration.prototype.__defineGetter__('borderColor', function() {
  1422.                 if (parseFloat(this.borderWidth, 10)) {
  1423.                     return getBorderColor.apply(this, arguments);
  1424.                 }
  1425.                 return '';
  1426.             });
  1427.             CSSStyleDeclaration.prototype.__defineSetter__('borderColor', setBorderColor);
  1428.         }
  1429.                 // CORE-17451, Defining a setter causes difference between point and bracket notation for ES properties, breaks panel resize
  1430.         var ds = CSSStyleDeclaration.prototype.__defineSetter__;
  1431.         CSSStyleDeclaration.prototype.__defineSetter__ = function(prop, fn) {
  1432.             if (!this.__lookupGetter__(prop)) {
  1433.                 var getter = document.documentElement.style.__lookupGetter__(prop);
  1434.                 this.__defineGetter__(prop, getter);
  1435.             }
  1436.             return ds.apply(this, arguments);
  1437.         };
  1438.                 // CORE-17459, Handle setting style.left/top to null
  1439.         function allowNull(styleProp) {
  1440.             CSSStyleDeclaration.prototype.__defineGetter__(styleProp, function() {
  1441.                 return this.getPropertyValue(styleProp);
  1442.             });
  1443.             
  1444.             CSSStyleDeclaration.prototype.__defineSetter__(styleProp, function(v) {
  1445.                 return this.setProperty(styleProp, v || '', '');
  1446.             });
  1447.         };
  1448.         allowNull('left');
  1449.         allowNull('top');
  1450.         
  1451.                 // CORE-17497, Opera doesn't support col-resize/row-resize cursors.
  1452.         addCssToDocument('html .SplitterBarH { cursor: s-resize } html .SplitterBarV { cursor: e-resize }');
  1453.                 // CORE-17500, Identify as Opera to the client-side sniffer
  1454.         if (!/EditMessageLight/.test(location.pathname)) {
  1455.             var browser = undefined;
  1456.             window.__defineGetter__('Browser', function() {
  1457.                 return browser;
  1458.             });
  1459.             window.__defineSetter__('Browser', function(v) {
  1460.                 browser = v;
  1461.                 if (browser) {
  1462.                     delete browser.isFF;
  1463.                     delete browser.isFF2;
  1464.                     delete browser.isFF3;
  1465.                 }
  1466.                 return browser;
  1467.             });
  1468.         }
  1469.         
  1470.         // Restore Opera UA string (we mask as Firefox to get the correct code over HTTP)
  1471.         var stuff = navigator.userAgent.split('(')[1].split(')')[0].split(';');
  1472.         stuff.pop();
  1473.         navigator.userAgent = 'Opera/' + opera.version() + ' (' +
  1474.                 stuff.join(';') + ') Presto/' +
  1475.                 (parseFloat(opera.version()) < 10 ? '2.1' : '2.2');
  1476.                 // CORE-17499, Correct browser detection cookie
  1477.         if (/Firefox\=1/.test(document.cookie)) {
  1478.             var isMac = /Mac OS X/.test(navigator.userAgent);
  1479.             document.cookie = 'BrowserSense=Win=' + Number(!isMac) + '&Mac=' + Number(isMac) + '&Downlevel=0&WinIEOnly=0&Firefox=0&Opera=1&OperaVersion=' + opera.version() + '&Safari=0;path=/;domain=live.com';
  1480.             if (top === self) {
  1481.                 location.reload();
  1482.             }
  1483.         }
  1484.         
  1485.                 // CORE-17498, Ensure a font with bold/italic variants is default for editor on Mac
  1486.         if (/Mac OS X/.test(navigator.userAgent)) {
  1487.             addCssToDocument('html .EditArea, html .ExternalClass  { font-family: Verdana }');
  1488.         }
  1489.                 // CORE-17461, Fixes downloading attachments in Hotmail
  1490.         HTMLAnchorElement.prototype.getAttribute= function(n){
  1491.             if( n=='aNewWin' && getAttribute.call(this, 'aIdx')!=null )return 'true';
  1492.             return getAttribute.call(this,n);
  1493.         }
  1494.         var window_open=window.open;
  1495.         window.open=function(){
  1496.             if( /ScanAttachment\.aspx/.test(arguments[0]) ){
  1497.                 var url=arguments[0];
  1498.                 arguments[0]='data:text/html,'+encodeURIComponent('<html><head></head><body><p style="text-align:center; margin-top: 100px">Downloading attachment...<br><a href="javascript:window.close()">Close window</a></p></body></html>');
  1499.             }
  1500.             var w=window_open.apply(this, arguments);
  1501.             if(url)w.location.href=url;
  1502.             return w;
  1503.         }
  1504.                 // 178723, Emulating IE's cssText property on style sheets
  1505.         var getCssText = function() {
  1506.             if (!this.href)    {
  1507.                 return this.ownerNode.textContent;
  1508.             } else {
  1509.                 try {
  1510.                     var xhr = new XMLHttpRequest();
  1511.                     xhr.open('GET', this.href, false);
  1512.                     xhr.send();
  1513.                     return xhr.responseText;
  1514.                 } catch(e) {
  1515.                     return '';
  1516.                 }
  1517.             }
  1518.         };
  1519.         if (window.__defineGetter__) {
  1520.             CSSStyleSheet.prototype.__defineGetter__('cssText', getCssText);
  1521.             CSSStyleSheet.prototype.__defineSetter__('cssText', function(v) {
  1522.                 if (!this.href) {
  1523.                     this.ownerNode.innerHTML = '';
  1524.                     return this.ownerNode.appendChild(document.createTextNode(v));
  1525.                 }
  1526.             });
  1527.         } else {
  1528.             window.addEventListener('load', function(){
  1529.                 for( var i=0;i<document.styleSheets.length;i++ ){
  1530.                     if(document.styleSheets[i])
  1531.                         document.styleSheets[i].cssText = { _styleRef: document.styleSheets[i], toString:function(){
  1532.                     return this._styleRef.ownerNode.textContent}
  1533.                     };
  1534.                 }
  1535.             },false);
  1536.         }
  1537.         
  1538.                 // DSK-235885, Hotmail uses lookupGetter on prototypes, not instances
  1539.         var styleSetterLookupMethod = document.createElement('span').style.__lookupSetter__;
  1540.          CSSStyleDeclaration.prototype.__lookupSetter__ = function(prop){
  1541.             return styleSetterLookupMethod.call(document.createElement('span').style, prop);
  1542.          };
  1543.                 // CORE-15945, It's usually not necessary to define properties that are already supported with getters and setters.
  1544.         var realHTMLElementDefineGetter = HTMLElement.prototype.__defineGetter__;
  1545.         HTMLElement.prototype.__defineGetter__ = function(name, func){
  1546.             if( name in {'document':''} ) return;
  1547.             realHTMLElementDefineGetter.call(this, name, func);
  1548.         }
  1549.         
  1550.                 // CORE-15973, Resize function causes rendering loop
  1551.         opera.defineMagicFunction('dap_Resize', function(){});
  1552.                 // DSK-235885, redefine document.selection with live.com's compat-layer version
  1553.         document.addEventListener( 'load', function(e){
  1554.             if(e.target instanceof HTMLIFrameElement){
  1555.                 try{
  1556.                     var doc=e.target.contentDocument;
  1557.                     var win=doc.defaultView;
  1558.                     var fakeHotmailSelectionObject;
  1559.                     win.HTMLDocument.prototype.__defineSetter__('selection', function(obj){
  1560.                         fakeHotmailSelectionObject=obj;
  1561.                     });
  1562.                     doc.__defineGetter__('selection', function(){
  1563.                         return fakeHotmailSelectionObject;
  1564.                     });
  1565.         
  1566.                 setTimeout( function(){
  1567.                     doc.addEventListener( 'mouseup', fakeOnselectionchange, false );
  1568.                     doc.addEventListener( 'DOMCharacterDataModified', fakeOnselectionchange, false );
  1569.                     doc.addEventListener( 'keydown', fakeOnselectionchange, false );
  1570.                     doc.addEventListener( 'keyup', fakeOnselectionchange, false );}, 500);
  1571.                 }catch(e){}
  1572.             }
  1573.             function fakeOnselectionchange(){
  1574.                 var b=doc.createEvent("Event");
  1575.                 b.initEvent('selectionchange',true,false);
  1576.                 doc.dispatchEvent(b);
  1577.             }
  1578.         },true); 
  1579.                 // DSK-235885, Adding editor area styling that is missing due to browser sniffing
  1580.         addCssToDocument('.RTE .Container iframe{width: 100% !important; height: 100% !important}');
  1581.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Fix drag and drop in Hotmail\ndefine document.selection.empty in Hotmail (part of drag-and-drop fix)...). See browser.js for details');
  1582.     } else if(hostname.indexOf('maps.google.')>-1){            // CORE-17333, The constructor property of DOM nodes should not be Object
  1583.         Element.prototype.constructor=Element;
  1584.                 // CORE-633, Enable alt-click to show context menu in map
  1585.         fakeOncontextmenu(false, true);
  1586.                 // CORE-17460, Constructor property of event should be Event interface
  1587.         Event.prototype.constructor=Event;
  1588.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (The constructor property of DOM nodes should not be Object\nEnable alt-click to show context menu in...). See browser.js for details');
  1589.     } else if(hostname.indexOf('maps.live.com')!=-1){            // 165310, Fake oncontextmenu support
  1590.         fakeOncontextmenu(true,false);
  1591.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Fake oncontextmenu support). See browser.js for details');
  1592.     } else if(hostname.indexOf('marktplaats.nl')!=-1){            // PATCH-3, Can't add article to favourites because setting link.search has no effect
  1593.         HTMLAnchorElement.prototype.__defineGetter__('search', function(){return this.href.match(/\?.*/)||'';});
  1594.         HTMLAnchorElement.prototype.__defineSetter__('search', function(v){
  1595.             this.href+=v;});
  1596.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Can\'t add article to favourites because setting link.search has no effect). See browser.js for details');
  1597.     } else if(hostname.indexOf('maybank2u.com.my')>-1){            // 249799, maybank2u, onresize event causes a refresh whenever the softkeyboard is opened
  1598.         opera.addEventListener('BeforeEventListener.resize',function (e) { preventDefault.call=call;
  1599.             preventDefault.call(e);
  1600.         },false);
  1601.         opera.defineMagicFunction('MM_checkBrowser', function(){});
  1602.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (maybank2u, onresize event causes a refresh whenever the softkeyboard is opened). See browser.js for details');
  1603.     } else if(hostname.indexOf('millenet.pl')!=-1){            // PATCH-7, Semicolon insertion fails after do..while() conditional
  1604.         addPreprocessHandler(/;do num=Math\.ceil\(Math\.random\(\)\*maxNum\);while\(uniqueInt\.a\.hasMember\(num\)\)uniqueInt\.a\[uniqueInt\.a\.length\]=num;/, 'do num=Math.ceil(Math.random()*maxNum);while(uniqueInt.a.hasMember(num));uniqueInt.a[uniqueInt.a.length]=num;');
  1605.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Semicolon insertion fails after do..while() conditional). See browser.js for details');
  1606.     } else if(hostname.indexOf('moneta.co.kr')!=-1){            // 219041,  moneta.co.kr relies on IE quirks for CSS positioning
  1607.         addCssToDocument('#stocking{position:relative}#stocking>div{position:absolute}');
  1608.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' ( moneta.co.kr relies on IE quirks for CSS positioning). See browser.js for details');
  1609.     } else if(hostname.indexOf('monster.')!=-1){            // 315865, Monster category tree broken by their selectNodes function overwriting .text on nodes
  1610.         addPreprocessHandler( /(item|result)\.text\s*=\s*(item|result)\.textContent;\s*/g, 'if(typeof $1.text==\'undefined\')$1.text = $1.textContent;' );
  1611.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Monster category tree broken by their selectNodes function overwriting .text on nodes). See browser.js for details');
  1612.     } else if(hostname.indexOf('msdn.microsoft.com')!=-1){            // DSK-224171, MSDN menus are invisible, should appear
  1613.         HTMLBodyElement.prototype.__defineGetter__('scrollWidth', function(){ return this.document.documentElement.scrollWidth;});
  1614.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (MSDN menus are invisible, should appear). See browser.js for details');
  1615.     } else if(hostname.indexOf('msnbc.com')>-1){            // 207178, MSNBC sniffing hides Flash content
  1616.         opera.defineMagicVariable('oSniff', function(o){return o;},function(){ window['oSniff'].nn=5; });
  1617.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (MSNBC sniffing hides Flash content). See browser.js for details');
  1618.     } else if(hostname.indexOf('music.mu-mo.net')>-1){            // 256041, mu-mo.net uses SCRIPT for..event.. syntax
  1619.         scriptForEventFix();
  1620.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (mu-mo.net uses SCRIPT for..event.. syntax). See browser.js for details');
  1621.     } else if(hostname.indexOf('n-gage.com') >-1 && navigator.userAgent.indexOf('Mac')>-1){            // 181451, N-Gage plugin sniffing does not give Flash to Mac Opera
  1622.         opera.defineMagicVariable('g_plugin', function(){return navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin},null);
  1623.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (N-Gage plugin sniffing does not give Flash to Mac Opera). See browser.js for details');
  1624.     } else if(hostname.indexOf('namooya.com')>-1){            // 241286, Namooya.com main flash does not appear
  1625.         document.attachEvent=undefined;
  1626.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Namooya.com main flash does not appear). See browser.js for details');
  1627.     } else if(hostname.indexOf('news.bbc.co.uk')!=-1){            // 356736, Disabling Opera detection that prevents the BBC Olympic Map from appearing
  1628.         opera.addEventListener('BeforeExternalScript', function(e){
  1629.             indexOf.call=replace.call=addEventListener.call=call;
  1630.             var oldUA = navigator.userAgent;
  1631.             if (indexOf.call(e.element.src, 'glow.js')!=-1){
  1632.                 navigator.userAgent = replace.call(navigator.userAgent, 'Opera', '0pera (spoofing as Firefox)');
  1633.             }
  1634.             if(navigator.userAgent!=oldUA)addEventListener.call(opera,'AfterExternalScript', function(e){
  1635.                 removeEventListener.call=call;
  1636.                 navigator.userAgent=oldUA;
  1637.                 removeEventListener.call(opera,'AfterExternalScript', arguments.callee, false);
  1638.             }, false);
  1639.         }, false);
  1640.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Disabling Opera detection that prevents the BBC Olympic Map from appearing). See browser.js for details');
  1641.     } else if(hostname.indexOf('news.msn.co.kr') >-1){            // 342895, news.msn.co.kr navigation bar is offset from the page
  1642.         addCssToDocument('#home{position:relative!important}');
  1643.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (news.msn.co.kr navigation bar is offset from the page). See browser.js for details');
  1644.     } else if(hostname.indexOf('nrg.co.il')>-1){            // 244416,  NRG.co.il saving articles does not work
  1645.         addPreprocessHandler('document.getElementById("launcher").innerHTML="";', '');
  1646.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' ( NRG.co.il saving articles does not work). See browser.js for details');
  1647.     } else if(hostname.indexOf('picasaweb.google')!=-1){            // 304172, Picasaweb browser sniffing removes functionality Opera has no problems with, for example slideshow
  1648.         var oldua=navigator.userAgent;
  1649.         navigator.userAgent = {
  1650.             toString: function(){return oldua},
  1651.             toLowerCase:function(){ return oldua.replace( /Opera./, 'MSIE ' ).toLowerCase(); },
  1652.             toUpperCase:function(){ return oldua.toUpperCase(); },
  1653.             indexOf: function(s){ return oldua.indexOf(s); }
  1654.         }
  1655.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Picasaweb browser sniffing removes functionality Opera has no problems with, for example slideshow). See browser.js for details');
  1656.     } else if(hostname.indexOf('pogo.com')>-1){            // 305697,  Java detection fails on pogo.com
  1657.         if(navigator.javaEnabled()){
  1658.             var javaVersion = java.lang.System.getProperty('java.version');
  1659.             navigator.userAgent += ' Firefox';
  1660.             javaVersion=(javaVersion+'').split( '.' ).splice(0,2).join('.');
  1661.             navigator.mimeTypes[navigator.mimeTypes.length] = {type: 'application/x-java-applet;version=' + javaVersion };
  1662.             navigator.mimeTypes.length = navigator.mimeTypes.length+1;
  1663.         }
  1664.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' ( Java detection fails on pogo.com). See browser.js for details');
  1665.     } else if(hostname.indexOf('rabobank.nl')!=-1){            // 277063,  Rabobank cancels t keypress
  1666.         opera.addEventListener('AfterEvent.keypress', function(e){
  1667.             preventDefault.call=call;
  1668.             if(e.event.keyCode==116 && e.eventCancelled)preventDefault.call(e);
  1669.         },false);
  1670.         
  1671.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' ( Rabobank cancels t keypress). See browser.js for details');
  1672.     } else if(hostname.indexOf('redfin.com')!=-1){            // DSK-231794, Solve Dojo script scheduling trouble on redfin.com
  1673.         fixJQueryScriptSchedulingTrouble();
  1674.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Solve Dojo script scheduling trouble on redfin.com). See browser.js for details');
  1675.     } else if(hostname.indexOf('reviews.cnet.com') >-1){            // 179484, CNet videos: document.write adds a script that depends on variables defined later
  1676.         opera.addEventListener('BeforeScript',
  1677.         function(ev){ 
  1678.                 indexOf.call=replace.call=call;
  1679.                 var js=ev.element.text, problemstr='document.write(\'<script type="text/javascript" src="\'+skin+\'"></script>\');';
  1680.                 if(indexOf.call(js, problemstr ) > -1 ){
  1681.                     ev.element.text = replace.call(ev.element.text,  problemstr,'' )+';\n'+problemstr;
  1682.             }
  1683.         }
  1684.         ,false);
  1685.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (CNet videos: document.write adds a script that depends on variables defined later). See browser.js for details');
  1686.     } else if(hostname.indexOf('sfile.ydy.com')!= -1){            // 361539, Avoid manipulating broken Discuz! markup on sfile.ydy.com
  1687.         opera.defineMagicFunction('announcementScroll', function(){});
  1688.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Avoid manipulating broken Discuz! markup on sfile.ydy.com). See browser.js for details');
  1689.     } else if(hostname.indexOf('show.co.kr')!=-1){            // 348818, Pre-filled text as INPUT background not cleared on focus
  1690.         document.addEventListener('focus', function(e){if(e.target.tagName=='INPUT'){e.target.style.backgroundImage='none'; e.target.onfocus=null;}},true);
  1691.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Pre-filled text as INPUT background not cleared on focus). See browser.js for details');
  1692.     } else if(hostname.indexOf('shutterfly.com')!=-1){            // CORE-16706, Array splice throws on 0-length arrays, breaks Shutterfly.com
  1693.         var realsplice = Array.prototype.splice; 
  1694.         Array.prototype.splice = function () { 
  1695.         if( this.length == 0 ) { return []; } 
  1696.         return realsplice.apply(this,arguments); 
  1697.         };
  1698.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Array splice throws on 0-length arrays, breaks Shutterfly.com). See browser.js for details');
  1699.     } else if(hostname.indexOf('siren24.com')!=-1){            // SEOUL-609, ActiveX installation page redirect on siren24.com due to sniffing limitation on redirect script
  1700.         navigator.appName = 'Netscape';
  1701.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (ActiveX installation page redirect on siren24.com due to sniffing limitation on redirect script). See browser.js for details');
  1702.     } else if(hostname.indexOf('spaces.live.com')!=-1){            // 311225, Overriding spaces.live.com browser sniffing
  1703.         opera.addEventListener(
  1704.             'BeforeScript',
  1705.             function(){ window.opera=undefined; },
  1706.             false
  1707.         );
  1708.         
  1709.         opera.addEventListener(
  1710.             'AfterScript',
  1711.             function(e){
  1712.                 var ok=false;
  1713.                 if( typeof attachOperaCompatibility == 'function' ){
  1714.                     attachOperaCompatibility(window);
  1715.                     ok=true;
  1716.                 }else if( typeof $Browser !='undefined' && typeof $Browser.attachOperaCompatibility == 'function' ){
  1717.                     $Browser.attachOperaCompatibility(window);
  1718.                 }
  1719.                 if(ok){
  1720.                     opera.removeEventListener( 'AfterScript', arguments.callee, false );
  1721.                     
  1722.                 }
  1723.             },
  1724.             false
  1725.         );
  1726.         
  1727.                 // 311225, Make Range.prototype.insertNode automatically import nodes from other documents
  1728.         var rangeInsertNode = Range.prototype.insertNode;
  1729.         Range.prototype.insertNode = function(n){
  1730.             if(this.startContainer && this.startContainer.ownerDocument && n.ownerDocument != this.startContainer.ownerDocument )n=this.startContainer.ownerDocument.importNode(n, true);
  1731.             return rangeInsertNode.call(this,n);
  1732.         }
  1733.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Overriding spaces.live.com browser sniffing\nMake Range.prototype.insertNode automatically import no...). See browser.js for details');
  1734.     } else if(hostname.indexOf('spreadsheets')==0&&hostname.indexOf('.google.')>-1){            // 215770, Faking support for event object properties layerX and layerY
  1735.         opera.addEventListener( 'BeforeEventListener', function( e ){
  1736.             if(e.event.offsetX){
  1737.                 e.event.layerX=e.event.offsetX;
  1738.                 e.event.layerY=e.event.offsetY;
  1739.             }
  1740.         }, false );
  1741.         
  1742.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Faking support for event object properties layerX and layerY). See browser.js for details');
  1743.     } else if(hostname.indexOf('sytadin.fr')!=-1){            // 365351, Sytadin.fr IFRAME resize script detects Opera
  1744.         fixIFrameSSIscriptII('resizeIframeOnContent');
  1745.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Sytadin.fr IFRAME resize script detects Opera). See browser.js for details');
  1746.     } else if(hostname.indexOf('tdwaterhouse.ca')>-1&&location.protocol=='https:'){            // 147840, tdwaterhouse.ca login fails - cross-domain access on https disallows setting location
  1747.         document.domain='tdwaterhouse.ca';
  1748.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (tdwaterhouse.ca login fails - cross-domain access on https disallows setting location). See browser.js for details');
  1749.     } else if(hostname.indexOf('teletekst.nos.nl')>-1){            // 126136, Teletext focus fix
  1750.         window.focus = function () {event.preventDefault();};
  1751.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Teletext focus fix). See browser.js for details');
  1752.     } else if(hostname.indexOf('tickets.com')!=-1){            // MGTRN-2289, Scripts are not allowed to use reserved identifier "top"
  1753.         addPreprocessHandler( /top\(\)/g, '_top()' );
  1754.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Scripts are not allowed to use reserved identifier "top"). See browser.js for details');
  1755.     } else if(hostname.indexOf('tiscali.it')!=-1){            // 344935, Allows some frame nesting on web.tiscali.it
  1756.         opera.defineMagicVariable('address', function(current) {
  1757.         if (window == window.top && current == window.location) {
  1758.             return (current.search) ? current.href + '&' : current.href+'?';
  1759.         }
  1760.         return current;
  1761.         }, null);
  1762.         
  1763.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Allows some frame nesting on web.tiscali.it). See browser.js for details');
  1764.     } else if(hostname.indexOf('tistory.com')!=-1){            // 347990, two login buttons on tistory.com
  1765.         addCssToDocument('#memberbox .btn-login {text-indent:-100px;}');
  1766.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (two login buttons on tistory.com). See browser.js for details');
  1767.     } else if(hostname.indexOf('tuenti.com')!=-1){            // DSK-243723, Problems submitting messages and comments on tuenti.com
  1768.         opera.addEventListener('BeforeEventListener.load', function(e){preventDefault.call=call;
  1769.             if( e.event.target.contentWindow && e.event.target.contentWindow.location.href =='about:blank' )preventDefault.call(e);
  1770.         }, false);
  1771.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Problems submitting messages and comments on tuenti.com). See browser.js for details');
  1772.     } else if(hostname.indexOf('unicaja.es')!=-1){            // DSK-221158, unicaja.es cannot use reserved frame reference words as variables
  1773.         addPreprocessHandler(/\s+top\s*(=|\+)/g, ' _top $1')
  1774.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (unicaja.es cannot use reserved frame reference words as variables). See browser.js for details');
  1775.     } else if(hostname.indexOf('united.com')>-1 || hostname.indexOf('flyted.com')>-1 || hostname.indexOf('itn.net')>-1){            // 193907,  United.com flight search problem: hidden images do not load, so no onload event
  1776.                 document.addEventListener('load', function(){
  1777.                     var i,img;
  1778.                     var isHidden = function(el){
  1779.                         if(!el){ return false;}
  1780.                         var elmIsHidden=((el.style && el.style.display=='none') || window.getComputedStyle(el).display=='none');
  1781.                         return (elmIsHidden || isHidden( el.parentNode ));
  1782.                     }
  1783.                     for(i=document.images.length-1;img=document.images[i];i--){
  1784.                         if(img.onload){
  1785.                             if( isHidden( img ) ){
  1786.                                 img.onload();
  1787.                                 return;
  1788.                             }
  1789.                         }
  1790.                     }
  1791.                 }, false);    
  1792.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' ( United.com flight search problem: hidden images do not load, so no onload event). See browser.js for details');
  1793.     } else if(hostname.indexOf('us.etrade.com')!=-1 ){            // OTW-3340, Working around E*Trade site's security policy violation
  1794.         opera.defineMagicFunction('GoToETURL', function(oF,oT,urlPath,thirdParty){
  1795.             try{
  1796.                 oF.call(oT, urlPath, thirdParty);
  1797.             }catch(e){
  1798.                 top.postMessage(etURL.parse(urlPath,thirdParty), 'www.etrade.wallst.com');
  1799.             }
  1800.         });
  1801.         
  1802.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Working around E*Trade site\'s security policy violation). See browser.js for details');
  1803.     } else if(hostname.indexOf('usairways.com')>-1){            // 0,  USAirways is not compatible with WF2 spec required attribute
  1804.         opera.addEventListener('BeforeEvent.invalid', function(e){
  1805.             /* they specify required="True" attributes on hidden form elements. This tries to check if they are hidden
  1806.             and make sure they are temporarily "un-required" if they are */
  1807.             getAttribute.call = getComputedStyle.call = removeAttribute.call = setTimeout.call = preventDefault.call = call;
  1808.             var el=e.event.target;
  1809.             if( getAttribute.call(el, 'required')=='True' && getComputedStyle.call(window, el).visibility=='hidden' ){
  1810.                 removeAttribute.call(el,'required');
  1811.                 setTimeout.call(window, function(){setAttribute.call=call; setAttribute.call(el,'required', 'True');},0 )
  1812.                 preventDefault.call(e.event);
  1813.             }
  1814.         }, false);
  1815.         
  1816.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' ( USAirways is not compatible with WF2 spec required attribute). See browser.js for details');
  1817.     } else if(hostname.indexOf('video.nbc.com')>-1||href.indexOf('nbc.com/Video')>-1){            // 243428, NBC.com video problems
  1818.         document['all']=null;
  1819.         addCssToDocument('#flashcontent{height:550px!important}');
  1820.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (NBC.com video problems). See browser.js for details');
  1821.     } else if(hostname.indexOf('walla.co.il')!=-1){            // 184398,  Walla.co.il odd CSS styling causes display problems. Bugs 184398, 184399, 206793
  1822.         addCssToDocument(' .btn-t,.btn-r, .btn{display:inline !important;} .wp-0-b{width:auto !important}table {table-layout: auto !important}.w2b + table { width: 100%;}');
  1823.         
  1824.                 // 327825, New mail UI on Walla requires IE-style event capture
  1825.         emulateIECapturingEvents();
  1826.                 // 209477, walla.co.il custom videoplayer does not work
  1827.         opera.defineMagicFunction( 'showPlayerObject', function( origfunc, origthis, id, url ){
  1828.             document.getElementById(id).innerHTML='<object type="video/x-ms-asf" data="'+url+'"  width="100%" height="282" autostart="true"> failed to render object </object>';
  1829.             
  1830.         });
  1831.         document.addEventListener('load', function(){
  1832.             var play=document.getElementById('td_play');if(play && play.tagName=='TD'){play.parentNode.parentNode.parentNode.parentNode.style.display='none';}
  1833.         }, false);
  1834.         
  1835.                 // 205887, Walla workaround for white-space issue
  1836.         addCssToDocument('button.w2 {white-space: nowrap;}');
  1837.         
  1838.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' ( Walla.co.il odd CSS styling causes display problems. Bugs 184398, 184399, 206793\nNew mail UI on Wa...). See browser.js for details');
  1839.     } else if(hostname.indexOf('walmart.com')!=-1){            // 279084, Walmart hides "find in store" popup unintentionally
  1840.         addCssToDocument('#overlay{display: block!important}');
  1841.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Walmart hides "find in store" popup unintentionally). See browser.js for details');
  1842.     } else if(hostname.indexOf('westjet.com')>-1 ){            // 270752,  Westjet browser sniffing causes reload loop
  1843.         opera.defineMagicVariable('browser', function(o){ o.isSupported=true; return o; }, null);
  1844.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' ( Westjet browser sniffing causes reload loop). See browser.js for details');
  1845.     } else if(hostname.indexOf('worldofwarcraft.com')>-1){            // 237552, Mouseover popups do not appear due to document.all sniffing
  1846.         document.all=null;
  1847.         fakeOncontextmenu(true, 500);
  1848.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Mouseover popups do not appear due to document.all sniffing). See browser.js for details');
  1849.     } else if(hostname.indexOf('www.etrade.wallst.com')!=-1){            // OTW-3340, Working around E*Trade site's security policy violation (second part)
  1850.         addEventListener('message', function(e){
  1851.             if(e.domain=='us.etrade.com')top.location.href=e.data;
  1852.         }, false);
  1853.         
  1854.         
  1855.         
  1856.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Working around E*Trade site\'s security policy violation (second part)). See browser.js for details');
  1857.     } else if(hostname.indexOf('ynet.co.il')>-1||hostname.indexOf('ynetnews.com')>-1){            // 224708, YNet article comments display fix
  1858.         addCssToDocument('table {display:table !important}');
  1859.         
  1860.         opera.defineMagicFunction( 'showTb', function( oFunc, oThis, tbId,isShow ){ 
  1861.                     oFunc.apply(oThis, arguments.slice(2));
  1862.                     oTitle.style.display= '';
  1863.                     oTitle.style.display= ( isShow ) ? 'none !important': '';
  1864.                     oText.style.display= '';
  1865.                     oText.style.display= ( isShow ) ? '' : 'none !important' ;
  1866.                 } );
  1867.         opera.defineMagicFunction( 'loadTbData', function(oFunc, oThis, tbld, tbDataText){
  1868.                     var i1=tbDataText.indexOf('window.open('); 
  1869.                     var i2=tbDataText.indexOf(')', i1); 
  1870.                     var probl=tbDataText.substring(i1, i2);
  1871.                     probl=probl.replace(/\"/g, '"');
  1872.                     tbDataText=tbDataText.substring(0, i1 )+probl+tbDataText.substring(i2); 
  1873.                     oFunc.call(oThis, tbld, tbDataText);
  1874.                 } );    
  1875.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (YNet article comments display fix). See browser.js for details');
  1876.     } else if(hostname.indexOf('zdnet.com.com')>-1 ){            // 146580, ZDnet video site plays non-existing files if browser is Opera
  1877.         navigator.userAgent=navigator.userAgent.replace(/Opera/, 'MSIE 6.0');    
  1878.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (ZDnet video site plays non-existing files if browser is Opera). See browser.js for details');
  1879.     } else if(pathname.indexOf("Maconomy/MaconomyPortal") > -1){            // PATCH-6, Fix unload form submit behavior on Maconomy portals
  1880.         opera.addEventListener("BeforeEvent.unload", function(e){
  1881.                 var original_function = doSubmitEmptyData;
  1882.                 doSubmitEmptyData = function( command, parameter_1, parameter_2, parameter_3, formSetup ){
  1883.                     var form = viewDocument.forms["emptyForm"], node;
  1884.                     setupForm(form, formSetup);
  1885.                     form.windowSerialId.value = windowSerialId;
  1886.                     form.command.value        = command;
  1887.                     form.parameter_1.value    = parameter_1;
  1888.                     form.parameter_2.value    = parameter_2;
  1889.                     form.parameter_3.value    = parameter_3;
  1890.                     form.dataChanged.value    = (formSetup.dataChanged == null ? 0 : (formSetup.dataChanged ? 1 : 0));
  1891.                     form.componentName.value  = "";
  1892.         
  1893.                     var getstr = "";
  1894.                     for (i=0; node = form.elements[i]; i++) {
  1895.                         switch(node.type){
  1896.                             case "hidden":
  1897.                             case "text":
  1898.                             case "select-one":
  1899.                                 getstr += escape(node.name) + "=" + escape(node.value) + "&";
  1900.                                 break;
  1901.                             case "checkbox":
  1902.                                 if (node.checked) {
  1903.                                     getstr += escape(node.name) + "=" + escape(node.value) + "&";
  1904.                                 } else {
  1905.                                     getstr += escape(node.name) + "=&";
  1906.                                 }
  1907.                                 break;
  1908.                             case "radio":
  1909.                                 if (node.checked) {
  1910.                                     getstr += escape(node.name) + "=" + escape(node.value) + "&";
  1911.                                 }
  1912.                                 break;
  1913.                         }
  1914.         
  1915.                     }
  1916.                     getstr = getstr.replace(/&$/,""); //remove trailing &
  1917.                     var xhr = new XMLHttpRequest();
  1918.                     xhr.open("POST",form.action,true);
  1919.                     xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  1920.                     xhr.send(getstr);
  1921.                     resetForm(form);
  1922.                     doSubmitEmptyData = original_function;
  1923.             }
  1924.         },false);
  1925.             if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Fix unload form submit behavior on Maconomy portals). See browser.js for details');
  1926.     }
  1927. })(opera);
  1928.