var Xinha = {}; // Auto detect _editor_url if it's not set. if (!window._editor_url) { (function() // wrap this in an ad-hoc function to avoid unecessary pollution of global namespace { // Because of the way the DOM is loaded, this is guaranteed to always pull our script tag. var scripts = document.getElementsByTagName('script'); var this_script = scripts[scripts.length - 1]; // We'll allow two ways to specify arguments. We'll accept them in the // argument of the script, or we'll accept them embedded into our script tag. var args = this_script.src.split('?'); args = args.length == 2 ? args[1].split('&') : ''; for (var index = 0; index < args.length; ++index) { var arg = args[index].split('='); if (arg.length == 2) { switch (arg[0]) { case 'lang': case 'icons': case 'skin': case 'url': window['_editor_' + arg[0]] = arg[1]; break; } } } // We can grab the script innerHTML and execute that to cut down on script // tags. Thanks John Resig! // http://ejohn.org/blog/degrading-script-tags/ if (this_script.innerHTML.replace(/\s+/, '')) { eval(this_script.innerHTML); } // Default values _editor_lang = window._editor_lang || 'en'; // Chop off any query string. Chop the filename off of the URL. _editor_url = window._editor_url || this_script.src.split('?')[0].split('/').slice(0, -1).join('/'); })() } _editor_url = _editor_url.replace(/\x2f*$/, '/'); Xinha.agt = navigator.userAgent.toLowerCase(); Xinha.is_ie = ((Xinha.agt.indexOf("msie") != -1) && (Xinha.agt.indexOf("opera") == -1)); Xinha.ie_version= parseFloat(Xinha.agt.substring(Xinha.agt.indexOf("msie")+5)); Xinha.is_opera = (Xinha.agt.indexOf("opera") != -1); Xinha.is_khtml = (Xinha.agt.indexOf("khtml") != -1); Xinha.is_webkit = (Xinha.agt.indexOf("applewebkit") != -1); Xinha.is_safari = (Xinha.agt.indexOf("safari") != -1); Xinha.opera_version = navigator.appVersion.substring(0, navigator.appVersion.indexOf(" "))*1; Xinha.is_mac = (Xinha.agt.indexOf("mac") != -1); Xinha.is_mac_ie = (Xinha.is_ie && Xinha.is_mac); Xinha.is_win_ie = (Xinha.is_ie && !Xinha.is_mac); Xinha.is_gecko = (navigator.product == "Gecko" && !Xinha.is_safari); // Safari lies! Xinha.isRunLocally = document.URL.toLowerCase().search(/^file:/) != -1; Xinha.is_designMode = (typeof document.designMode != 'undefined' && !Xinha.is_ie); // IE has designMode, but we're not using it Xinha.isSupportedBrowser = Xinha.is_gecko || (Xinha.is_opera && Xinha.opera_version >= 9.1) || Xinha.ie_version >= 5.5 || Xinha.is_safari; Xinha.loadPlugins = function(plugins, callbackIfNotReady) { if ( !Xinha.isSupportedBrowser ) return; Xinha.loadStyle(typeof _editor_css == "string" ? _editor_css : "Xinha.css","XinhaCoreDesign"); Xinha.createLoadingMessages(xinha_editors); var loadingMessages = Xinha.loadingMessages; Xinha._loadback(_editor_url + "XinhaCore.js",function () { Xinha.removeLoadingMessages(xinha_editors); Xinha.createLoadingMessages(xinha_editors); callbackIfNotReady() }); return false; } Xinha._loadback = function(Url, Callback, Scope, Bonus) { var T = !Xinha.is_ie ? "onload" : 'onreadystatechange'; var S = document.createElement("script"); S.type = "text/javascript"; S.src = Url; if ( Callback ) { S[T] = function() { if ( Xinha.is_ie && ( ! ( /loaded|complete/.test(window.event.srcElement.readyState) ) ) ) { return; } Callback.call(Scope ? Scope : this, Bonus); S[T] = null; }; } document.getElementsByTagName("head")[0].appendChild(S); }; Xinha.getElementTopLeft = function(element) { var curleft = 0; var curtop = 0; if (element.offsetParent) { curleft = element.offsetLeft curtop = element.offsetTop while (element = element.offsetParent) { curleft += element.offsetLeft curtop += element.offsetTop } } return { top:curtop, left:curleft }; } // find X position of an element Xinha.findPosX = function(obj) { var curleft = 0; if ( obj.offsetParent ) { return Xinha.getElementTopLeft(obj).left; } else if ( obj.x ) { curleft += obj.x; } return curleft; }; // find Y position of an element Xinha.findPosY = function(obj) { var curtop = 0; if ( obj.offsetParent ) { return Xinha.getElementTopLeft(obj).top; } else if ( obj.y ) { curtop += obj.y; } return curtop; }; Xinha.createLoadingMessages = function(xinha_editors) { if ( Xinha.loadingMessages || !Xinha.isSupportedBrowser ) { return; } Xinha.loadingMessages = []; for (var i=0;i