/* SVN FILE: $Id: ja.js 296 2008-10-21 14:42:07Z ugoletti $ */

/**
 * JA! environment files
 * Copyright (c) 2006 Giorgio Braga <giorgio@justattributes.com>
 *
 * For the full copyright and license information, please view the COPYRIGHT.txt
 * file that was distributed with this source code.
 *
 * @copyright    Copyright (c) 2006 Giorgio Braga
 * @link         http://justattributes.com
 * @license      http://www.gnu.org/copyleft/lesser.html GNU LESSER GENERAL PUBLIC LICENSE
 * @package      ja!
 * @author       Giorgio Braga <giorgio@justattributes.com>
 * @since        JA v 0.01
 * @version      $Rev: 296 $
 * @modifiedby   $LastChangedBy: ugoletti $
 * @lastmodified $Date: 2008-10-21 16:42:07 +0200 (mar, 21 ott 2008) $
 */
 
ja = {
    document : document,
    opera : navigator.userAgent.indexOf("Opera")>0,
    safari : navigator.userAgent.indexOf("Safari")>0,
    lang: navigator.language || navigator.userLanguage.substring(0,2),
    $ : function() {
        if (arguments.length) {
            var args = arguments[0].split(" ");
            if (args.length==1 && args[0].substring(0,1)=="#") {
                return document.getElementById(args[0].substring(1));
            }
            else {
                var elements = [this==ja?document.body:this.me];
                for (var i=0;i<args.length;i++) {
                    var tmp = [];
                    var type = args[i].substring(0,1);
                    switch (type) {
                    case "#":
                        if (i==0) {
                            tmp.push(document.getElementById(args[i].substring(1)));
                            break;
                        }
                    case ".":
                        var selector = args[i].substring(1);
                        for (var j=0;j<elements.length;j++) {
                            if (elements[j]) {
                                var els = [elements[j]]; 
                                var elms = elements[j].getElementsByTagName("*");
                                for (var k=0;k<elms.length;k++) {
                                    els.push(elms[k]);
                                }
                                for (var k=0;k<els.length;k++) {
                                    var els1 = els[k][type=="#"?"id":"className"].split(" ");
                                    for (var l=0;l<els1.length;l++) {
                                        if (els1[l]==selector) {
                                            tmp.push(els[k]);
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    default:
                        for (var j=0;j<elements.length;j++) {
                            var els = elements[j].getElementsByTagName(args[i]);
                            for (var k=0;k<els.length;k++) {
                                tmp.push(els[k]);
                            }
                        }
                        break;
                    }
                    elements = tmp;
                }
                elements.setBehaviour = function(fn) {
                    for (var i=0;i<this.length;i++) {
                        this[i].ja.setBehaviour(fn);
                    }
                }
                if (type=="#") {
                    return elements[0];
                }
                else {
                    return elements;
                }
            }
        }
        else {
            return document.body;
        }
    },
    objPrototype : {
        insertElement : function(tag,attributes,before) {
            var el = document.createElement(tag);
            el.ja = {me:el};
            ja.extend(el.ja);
            for (var i in attributes) {
                el.setAttribute(i,attributes[i]);
                el[i] = attributes[i];
            }
            if (before) {
                this.me.insertBefore(el,before);
            }
            else {
                this.me.appendChild(el);
            }
            return el;
        },
        insertHTML : function(str,append) {
             if (append) str = this.me.innerHTML+str;
             this.me.innerHTML = str;
             var elements = this.me.getElementsByTagName("*");
             for (var i=0;i<elements.length;i++) {
                 elements[i].ja = {me:elements[i]};
                 ja.extend(elements[i].ja);
             }
             if (ja.onepage) ja.checkLinks(this.me);
        },
        insertRow : function(index) {
             if (this.me.tagName=="TABLE") {
                 var el = this.me.insertRow(index);
                 el.ja = {me:el};
                 ja.extend(el.ja);
                 return el;
             }
        },
        insertCell : function(index) {
             if (this.me.tagName=="TR") {
                 var el = this.me.insertCell(index);
                 el.ja = {me:el};
                 ja.extend(el.ja);
                 return el;
             }
        },
        getOuterHTML : function() {
             if (document.documentElement.outerHTML) return this.me.outerHTML;
             else {
                 var pN = this.me.parentNode;
                 var x = this.me.ownerDocument.createElement("body");
                 x.appendChild(this.me);
                 var retVal = x.innerHTML;
                 pN.appendChild(this.me);
                 return retVal;
             }
        },
        setOuterHTML : function(str) {
             var outer = document.getElementById("ja_outer") || document.body.ja.insertElement("div",{id:"ja_outer"});
             var pN = this.me.parentNode;
             var me = this.me;
             outer.style.display = "none";
             outer.ja.insertHTML(str);
             pN.insertBefore(outer.firstChild,me);
             pN.removeChild(me);
        },
        inherit : function(o,exclude) {
             exclude = exclude || {};
             for (var i in o) {
                 if (!(exclude[i] || exclude[i]+"" != "undefined")) {
                     try {this.me[i] = o[i];}
                     catch(e) {}
                 }
             }
        },
        setBehaviour : function(fn) {
             this.fn = fn;
             this.fn();
             delete this.fn;
        },
        display : function(state) {
             state = state || this.me.style.display;
             if (state=="toggle") {
                 state = this.me.style.display=="none"?"":"none";
             }
             return this.me.style.display = state;
        },
        visibility : function(state) {
             state = state || this.me.style.visibility;
             if (state=="toggle") {
                 state = this.me.style.visibility=="hidden"?"":"hidden";
             }
             return this.me.style.visibility = state;
        },
        setStyle : function(aStyles) {
             var retVal = true;
             for (var i=0;i<aStyles.length;i++) {
                 var style = aStyles[i];
                 try {
                     this.me.style[style[0]] = style[1];
                 }
                 catch(e) {}
                 if (this.me.style[style[0]]!= style[1]) {
                     try {
                         this.me.style[style[0]] = style[1]+"px";
                     }
                     catch(e) {}
                 }
                 style[2] = ((this.me.style[style[0]]== style[1]) || (this.me.style[style[0]]== style[1]+"px"));
                 retVal = retVal && style[2];
             }
             return [retVal,aStyles];
        },
        getStyle : function(style) {
             var value = this.me.style[style];
             if (!value) {
                 if (document.defaultView && document.defaultView.getComputedStyle) {
                     var css = document.defaultView.getComputedStyle(this.me, null);
                     value = style?(css?css[style]:null):css;
                 } else {
                     if (this.me.currentStyle) {
                         value = style?this.me.currentStyle[style]:this.me.currentStyle;
                     }
                 }
             }
// da verificare
//            if (window.opera && ['left', 'top', 'right', 'bottom'].include(style)) {
//                if (Element.getStyle(element, 'position') == 'static') value = 'auto';
//            }
             return value == 'auto' ? null : value;
        },
        /*
        absolutePosition : function(toDocumentBody) {
             var returnObj = {};
             var t = 0; 
             var l = 0; 
             returnObj.obj = toDocumentBody?document.body:null;
             if (ja.absAdjust) {
                 t = parseFloat(document.body.ja.getStyle("marginTop"));
                 l = parseFloat(document.body.ja.getStyle("marginLeft"));
             }
             var obj = this.me;
             while (obj && "HTML BODY".indexOf(obj.tagName)<0) {
                 switch (obj.tagName) {
                 case "TR":
                 case "TBODY":
                     if (obj!=this.me) {
                         break;
                     }
                 default:
                     t += obj.offsetTop;
                     l += obj.offsetLeft;
                 }
                 if (navigator.userAgent.indexOf("Safari")>0) {
                     var pos = obj.ja.getStyle("position");
                     if (pos=="absolute" || pos=="relative") {
                         t -= parseFloat(document.body.ja.getStyle("marginTop"));
                         l -= parseFloat(document.body.ja.getStyle("marginLeft"));
                     }
                 } 
                 if (!toDocumentBody) {
                     var pos = obj.ja.getStyle("position");
                     if (pos=="absolute" || pos=="relative") {
                         returnObj.obj = obj;
                         if (navigator.userAgent.indexOf("Safari")>0) {
                             t -= parseFloat(document.body.ja.getStyle("marginTop"));
                             l -= parseFloat(document.body.ja.getStyle("marginLeft"));
                         }
                         break;
                     }
                 }
                 if (obj.offsetParent) {
                     obj = obj.offsetParent;
                 }
                 else break;
             }
             this.absTop = t;
             this.absLeft = l;
             this.absObj = returnObj.obj;
             returnObj.top = t+"px";
             returnObj.left = l+"px";
             return returnObj;
        },
        */
        absolutePosition : function(toDocumentBody) {
             var returnObj = {obj:ja.body};
             var t = this.me.offsetTop;
             var l = this.me.offsetLeft;
             var p = this.me.offsetParent;
             var tagName, c;
             while (p!=null) {
                 if (((tagName = p.tagName.toLowerCase())!="table") && (tagName!="body")) {
                     if((c = p.clientTop)!=null) {t += c}
                     if((c = p.clientLeft)!=null) {l += c}
                 }
                 t += p.offsetTop;
                 l += p.offsetLeft;
                 if (!toDocumentBody) {
                     var pos = p.ja.getStyle("position");
                     if (pos=="absolute" || pos=="relative") {
                         returnObj.obj = p;
                         break;
                     }
                 }
                 p = p.offsetParent;
             }
             this.absTop = t;
             this.absLeft = l;
             this.absObj = returnObj.obj;
             returnObj.top = t+"px";
             returnObj.left = l+"px";
             return returnObj;
        },
        addWatch : function(prp,fn,styleHack) {
             this.me.wP = this.me.wP || {inheritsFrom:null};
             var p = prp.split(".");
             if (styleHack && p[0]=="style") {
                 var fontFamily = this.me.ja.getStyle("fontFamily");
                 this.me.id = this.me.id || ja.newId();
                 if (fontFamily.indexOf(this.me.id)<0) {
                     fontFamily += (","+this.me.id);
                     this.me.style.fontFamily = fontFamily;
                 }
             }
             this.me.wP[prp] = fn;
             var retVal = false;
             if (this.me.watch) {
                 retVal = true;
                 if (p[0]=="style") {
                     this.me.style.watch(p[1],function(id,oldV,newV){
                         var fonts = this.fontFamily.split(",");
                         var obj = document.getElementById(fonts[fonts.length-1]) || this;
                         obj.fn = obj.wP[prp];
                         return obj.fn("style."+id,oldV,newV);
                     });
                 }
                 else {
                     this.me.watch(prp,function(id,oldV,newV){
                         this.fn = this.wP[prp];
                         return this.fn(id,oldV,newV);
                     });
                 }
             }
             else {
                 if (this.me.onpropertychange || this.me.onpropertychange+""=="null") {
                     retVal = true;
                     var value = this.me;
                     for (i=0;i<p.length;i++) {
                         value = value[p[i]];
                     }
                     fn.savedValue = value;
                     this.me.onpropertychange = function() {
                         if (this.wP[event.propertyName]) {
                             var p = event.propertyName.split(".");
                             var value = this;
                             for (i=0;i<p.length;i++) {
                                 value = value[p[i]];
                             }
                             var obj = this;
                             if (p[0]=="style") {
                                 obj = this.style;
                                 p.shift();
                             }
                             obj.fn = this.wP[event.propertyName]; 
                             result = obj.fn(p[0],obj.fn.savedValue,value); 
                             var newValue = null;
                             switch (result) {
                             case value:
                                 break;
                             case undefined:
                                 newValue = fn.savedValue;
                                 break;
                             default:
                                 newValue = result;
                             }
                             if (newValue!=null) {
                                 this.wP["_"+event.propertyName] = this.wP[event.propertyName];
                                 this.wP[event.propertyName] = null;
                                 obj[p[0]] = newValue;
                                 this.wP[event.propertyName] = this.wP["_"+event.propertyName];
                                 this.wP["_"+event.propertyName] = null;
                             }
                         }
                     }
                 }
             }
             return retVal;
        },
        removeWatch : function(prp) {
             var retVal = false;
             if (this.me.watch) {
                 retVal = true;
                 var p = prp.split(".");
                 if (p[0]=="style") {
                     this.me.style.unwatch(p[1]);
                     var fonts = this.me.style.fontFamily.split(",");
                     if (document.getElementById(fonts[fonts.length-1])) {
                         fonts.pop();
                         this.me.style.fontFamily = fonts.join(",")
                     }
                 }
                 else {
                     this.me.unwatch(prp);
                 }
             }
             else {
                 if (this.me.onpropertychange || this.me.onpropertychange+""=="null") {
                     retVal = true;
                     this.me.wP[prp] = null;
                     var watch = false; 
                     for (var i in this.me.wP) {
                         if (this.me.wP[i]) {
                             watch = true;
                             break;
                         }
                     }
                     if (!watch) {
                         this.me.onpropertychange = null;
                     }
                 }
             }
             return retVal;
        },
        addEvent : function(e,fn) {
             var obj = this.document?window:this.me;
             if(window.addEventListener){
                 return obj.addEventListener(e,fn,false);
             }
             else if(window.attachEvent){
                 return obj.attachEvent("on"+e,fn);
             }
        },
        removeEvent : function(e,fn) {
             var obj = this.document?window:this.me;
             if(window.addEventListener){
                 return obj.removeEventListener(e,fn,false);
             }
             else if(window.attachEvent){
                 return obj.detachEvent("on"+e,fn);
             }
        }
    },
    extend : function(obj,prototype,exclude,clean) {
         if (clean) {
             for (var i in obj) {
                 delete obj[i];
             }
         }
         exclude = exclude || {};
         obj = obj || document.body;
         prototype = prototype || ja.objPrototype;
         for (var i in prototype) {
             if (!(exclude[i] || exclude[i]+"" != "undefined")) {
                 try {
                     obj[i] = prototype[i];
                 }
                 catch(e) {}
             }
         }
         if (prototype.$ && !obj.$) {
             obj.me.$ = prototype.$;
         }
    },
    extendC : function(obj,prototype) {
         var obj = obj || ja.$();
         if (!obj.ja) {
			obj.ja = {me:obj};
            ja.extend(obj.ja,prototype);
         }
         obj.ja.$ = ja.$;
         var elements = obj.getElementsByTagName("*");
         for (var i=0;i<elements.length;i++) {
             if (!elements[i].ja) {
                 elements[i].ja = {me:elements[i]};
                 ja.extend(elements[i].ja);
             }
         }
    },
    setBehaviour: function(behaviours) {
         for (var i in behaviours) {
             ja.$(i).setBehaviour(behaviours[i]);
         }
         return true;
    },
    addEvent : function(e,fn) {
        if(window.addEventListener){
            return this.addEventListener(e,fn,false);
        }
        else if(window.attachEvent){
            return this.attachEvent("on"+e,fn);
        }
    },
    removeEvent : function(e,fn) {
         if(window.addEventListener){
             return this.removeEventListener(e,fn,false);
         }
         else if(window.attachEvent){
             return this.detachEvent("on"+e,fn);
         }
    },
    debug : {build:function(){},exe:function(){}},
    ready : function(fn) {
         ja.loadModules("widgets");
         ja.ready = fn || function(){};
         window.addEvent("load",function() {
             ja.body = document.body;
             ja.document = document;
             var oDocElement = document.documentElement;
             var save = [oDocElement.style.marginRight,oDocElement.style.paddingRight];
             oDocElement.style.marginRight = "1px";
             oDocElement.style.paddingRight = "1px";
             var test = [oDocElement.clientWidth,document.body.clientWidth];
             oDocElement.style.marginRight = save[0];
             oDocElement.style.paddingRight = save[1];
             ja.documentBody = document.documentElement.clientWidth==test[0]?oDocElement:document.body;
             ja.getInnerWidth = function() {
                 return this.documentBody && this.documentBody.clientWidth?this.documentBody.clientWidth:window.innerWidth; 
             }
             ja.getInnerHeight = function() {
                 return this.documentBody && this.documentBody.clientHeight?this.documentBody.clientHeight:window.innerHeight; 
             }

             ja.objPrototype.$ = ja.$;
             ja.iconPath = ja.path+(ja.iconPath?(ja.iconPath+"/"):"");
             ja.extendC();
             if (ja.lightbox) ja.lightbox.init();
             if (ja.onepage) ja.checkLinks();
             ja.checkClasses();
             ja.debug.build();
             ja.ready();
         });
         return true;
    },
    absAdjust : false,
    getPath : function() {
         var tags = document.getElementsByTagName("*");
         var path;
         for (var i=0;i<tags.length;i++) {
             if (tags[i].tagName=="SCRIPT") {
                 var src = tags[i].src;
                 if (src.indexOf("ja.js")>=0) {
                     path = src.substring(0,src.indexOf("ja.js"));
                     break;
                 }
             }
         }
         return path;
    },
    counter : 0,
    setModulePath : function(module,path) {
         this.widgets[module] = this.widgets[module] || [];
         this.widgets[module][0] = path;
    },
    getModulePath : function(module,mainPath) {
         var path = this.widgets[module] ? this.widgets[module][0] : "";
         if (!(path.substring(0,1)=="/" || path.substring(0,5)=="http://")) {
             path = (mainPath || ja.path)+path;
         }
         return path;
    },
    localize : function(module) {
         return(this.widgets[module] ? this.widgets[module][1] : false)
    },
    loadModule : function(module){
        path = this.getModulePath(module);
        var src = path+"ja_"+module+".js"; 
		var css = "";
		 if ( module != "animation" && module != "widgets" )
		{
			css = path+"css/ja_"+module+".css";
		}
			
		//var skin = this.path+"skin/"+module+".css";
        var langs = this.localize(module);
        var lang = langs?((this.lang && langs.indexOf(this.lang)>=0)?this.lang:langs.split(",")[0]):"";
        if (document.body) {
            var loader = document.body.ja.insertElement("iframe");
            loader.style.display = "none";
            var params = [module];
            if (lang) params.push(lang);
            loader.src = ja.path+"ja_loader.html?"+params.join(",");
            if ( css != "" ) ja.insertHeadElement("link",{rel:"stylesheet", type:"text/css", href:css});
            //ja.insertHeadElement("link",{rel:"stylesheet", type:"text/css", href:skin});
        }
        else {
            document.write('<script type="text/javascript" src="'+src+'"><\/script>');
            if ( css != "" ) document.write('<link rel="stylesheet" href="'+css+'" type="text/css" />');
            //document.write('<link rel="stylesheet" href="'+skin+'" type="text/css" />');
            var langs = this.localize(module);
            if (lang) {
                document.write('<script type="text/javascript" src="'+path+"lang/"+lang+".js"+'"><\/script>');
            }
        }
    },
    updateTexts : function() {
        for (var i in this.localizedText) {
            this.text[i] = this.localizedText[i]
        }
    },
    modules : new Array(),
    loadModules : function() {
        for (var i=0;i<arguments.length;i++) {
            var modules = arguments[i].split(",");
            for (var k=0;k<modules.length;k++) {
                if (ja.modules.insert(modules[k])) {
                    ja.loadModule(modules[k]);
                }
            }
        }
    },
    insertHeadElement : function(tag,attributes) {
        var head = document.getElementsByTagName("head")[0];
        if (head) {
            var el = document.createElement(tag);
            el.ja = {me:el};
            ja.extend(el.ja);
            for (var i in attributes) {
                el.setAttribute(i,attributes[i]);
            }
            head.appendChild(el);
            return true;
        }
        return false;
    },
    request : function(url,method,handler,responseType,async,header,wait) {
         if(!window.XMLHttpRequest){
             window.XMLHttpRequest = function(){
                 var hR;
                 try{
                     hR = new ActiveXObject("Msxml2.XMLHTTP.4.0");
                     return hR;
                 }
                 catch(e){};
                 try{
                     hR = new ActiveXObject("Msxml2.XMLHTTP");
                     return hR;
                 }
                 catch(e){};
                 try{
                     hR = new ActiveXObject("Microsoft.XMLHTTP");
                     return hR;
                 }
                 catch(e){};
                 return null;
             }
         }
         if(XMLHttpRequest){
             method = method || "GET";
             handler = handler || "ja.nF";
             if (async!=false) {
                 async = true;
             }
             var n = ja.httpRequest.length;
             wait = wait || "ja.nF";
             var u = url.split("?");
             if (method=="GET") {
                 u[0] = url;
                 u[1] = null;
             }
             ja.httpRequest[n] = new XMLHttpRequest();
             ja.httpRequest[n].onreadystatechange = new Function('if(ja.httpRequest['+(n)+'].readyState==4&&(ja.httpRequest['+(n)+'].status<300 || ja.httpRequest['+(n)+'].response'+responseType+')){'+handler+'(ja.httpRequest['+(n)+'].response'+responseType+');'+wait+'(0)};');
             ja.httpRequest[n].open(method,u[0],async);
             if (header) {
                 for (var i=0;i<header.length;i++) {
                     ja.httpRequest[n].setRequestHeader(header[i][0],header[i][1]);
                 }
             }
             eval(wait+"(1)");
             ja.httpRequest[n].send(u[1]);
             return true;
         }
    },
    nF : function() {},
    eF : function(txt) {eval(txt)},
    httpRequest : new Array(),
    dispatch : function(fn,e,element) {
        with (window) {
            if (e) {
                if (!e.srcElement) {
                    e.srcElement = e.target;
                }
                else {
                    if (!e.target) {
                        e.target = e.srcElement;
                    }
                }
                if (e.type.substring(0,5)=="mouse") {
                    if (!e.fromElement) {
                        try {
                            e.fromElement = e.relatedTarget?(e.type=="mouseover"?e.relatedTarget:e.target):null;
                            e.toElement = e.relatedTarget?(e.type=="mouseout"?e.relatedTarget:e.target):null;
                        }
                        catch(error) {}
                    }
                    if (!e.offsetX && e.offsetX!=0) {
                        e.offsetX = e.layerX;
                        e.offsetY = e.layerY;
                    }
                    if (!e.clientX && e.clientX!=0) {
                        e.clientX = e.pageX;
                        e.clientY = e.pageY;
                    }
                    e.leftButton = (e.button==0);
                }
            }
            else {
                e = event;
                if (!e.target) {
                    e.target = e.srcElement;
                }
                e.stopPropagation = function() {e.cancelBubble = true};
                e.preventDefault = function() {e.returnValue = true};
                if (e.type.substring(0,5)=="mouse") {
                    e.relatedTarget = null;
                    if (e.fromElement && e.type=="mouseover") {
                        e.relatedTarget = e.fromElement;
                    }
                    if (e.toElement && e.type=="mouseout") {
                        e.relatedTarget = e.toElement;
                    }
                    e.layerX = e.offsetX;
                    e.layerY = e.offsetY;
                }
                if (e.type.substring(0,3)=="key") {
                    e.charCode = e.keyCode;
                }
                e.currentTarget = element || {};
                e.leftButton = (e.button==1);
                e.rightButton = (e.button==2);
            }
            return fn(e);
        }
    },
    counter : 0,
    zIndex : 0,
    moreId : String.fromCharCode(9),
    newId : function() {
        return "ja_"+(++ja.counter);          
    },
    timeouts : new Array(),
    timeoutExec : function(ndx) {
        var env = ja.timeouts[ndx];
        env[0][env[1]](ndx);
    },
    inheritFrom : function() {
        for (var i=0;i<arguments.length;i++) {
            this.tmp = arguments[i];
            this.tmp();
        }
        delete this.tmp;
    },	
    inheritFromAndClean : function() {
        for (var i=0;i<arguments.length;i++) {
            this.tmp = arguments[i];
            this.tmp();
        }
        delete this.tmp;
        for (var i in this) {
            if (this[i]==ja.inheritFromAndClean) {
                delete this[i];
            }
        }
    },
    page : {},
    stack : [],
    checkClasses : function() {
        var objToCheck = this;
        if (!objToCheck.tagName) {
            objToCheck = document.body;
            ja.cnO = document.body;
        }
        else {
            ja.cnO = this;
        }
        ja.cnO.registerO = ja.registerO;
        var all = objToCheck.ja.$("*");
        for (var i=0;i<all.length;i++) {
            var cls = all[i].getAttributeNode("class");
            if (cls) {
                var aCls = cls.value.split(" ");
                for (var c=0;c<aCls.length;c++) {
                    if (aCls[c].indexOf("ja=")==0) {
                        eval("var _"+aCls[c]);
                        aCls[c] = "";
                        for (var w in _ja) {
                            ja.loadModules(w);
                            ja.stack.push([w,all[i]]);
                            ja.extend(all[i],_ja[w]);
                        }
                    }
                }
                all[i].className = aCls.join(" ");
            }
        }
      setTimeout("ja.stackExe()",50);
    },
    stackExe : function() { 
         for (var i=0;i<ja.stack.length;i++) {
             var op = ja.stack[i];
             if (ja[op[0]]) {
                 ja[op[0]].create(op[1]);
                 ja.stack[i] = null;
             }
         }
         ja.stack.cleanup();
         if (ja.stack.length) {
             setTimeout("ja.stackExe()",50);
         }
    },
    registerO : function(o) {
         var obj = this;
         while (obj!=document.body) {
             if (obj.nO) {
                 obj.nO.push(o);
            }
            obj = obj.parentNode;
         }
    },
    saveAs : {},
    text: {}
}

if(navigator.userAgent.indexOf("MSIE 6.0")>0) {
    var doctype = document.getElementsByTagName("!");
    for(var i=0;i<doctype.length;i++){
    }
}
else{
    ja.absAdjust = true;
}

window.addEvent = ja.addEvent; 
window.removeEvent = ja.removeEvent;
document.addEvent = ja.addEvent;
document.removeEvent = ja.removeEvent;

Array.prototype.scan = function(value,index) {
    for (var i=0;i<this.length;i++) {
        if (typeof this[i]=="object" && index!=null) {
            if (this[i][index]==value) {
                return i;
            }
        }
        else {
            if (this[i]==value) {
                return i;
            }
        }
    }
    return -1;
}
Array.prototype.insert = function(value,index) {
    if (this.scan(value,index)<0) {
        this.push(value);
        return true;
    }
    return false;
}
Array.prototype.cleanup = function() {
    var newA = new Array();
    for (var i=0;i<this.length;i++) {
        newA[i] = this[i];
    }
    this.length = 0;
    for (var i=0;i<newA.length;i++) {
        if (newA[i]) {
            this.push(newA[i]);
        }
    }
}
ja.path = ja.getPath();
document.write('<script type="text/javascript" src="'+ja.path+'ja_widgets.js"><\/script>');
