﻿// JScript File

function cTree() {
    this.openclass = 'open';
    this.closedclass = 'closed';
    this.toggleOnLi = true;
    this.init = function(objid)
    {
        var obj = document.getElementById(objid);
        this.root = obj;
        var objs = obj.getElementsByTagName('li');
        for(var i=0;i<objs.length;i++)
        {
            var o = objs[i];
            o.tree = this;
            if (this.toggleOnLi)
                o.onmousedown = this.clickToggle;   
        }
    }
    this.toggleLeaf = function(target)
    {
        if (target.getElementsByTagName('ul').length>0)
            target.className = (target.className.indexOf(this.openclass)==-1)?this.openclass:this.closedclass;
        else if (typeof(this.load)=='function')
            this.load(target);
    }
    this.clickToggle = function(e)
    {
        /*if (!e) var e = window.event;
        var target = (e.target)?e.target:e.srcElement;
        e.cancelBubble = true;
        e.returnValue = false;
        //alert(target);
        target.tree.toggleLeaf(target);
        return false;*/
    }
}

       var oldBorder;
        var sobj;
        
        function hideDescription(obj)
        {
            sobj = obj;
            if (obj.timer)
            {
                clearTimeout(obj.timer);
                obj.timer = null;
            }
            obj.timer = setTimeout('hideDescription2()',500);
        }
        
        function hideDescription2()
        {
            if (sobj)
            {
                obj = sobj;
                /*var o = obj.getElementsByTagName('input')[0];
                if (!o.checked)
                {*/
                    var no = getNext(obj);
                    if (no.className=='prodInfo')
                        no.style.display = 'none';
                //}
                obj.style.border = 'solid 1px #f0f0f0';
            }
        }
        
        function showDescription(obj)
        {
            if (obj.timer)
            {
                clearTimeout(obj.timer);
                obj.timer = null;
            }
            
                hideDescription2();
            
                
                obj.style.border = 'solid 1px #ccc';
                var no = getNext(obj);
                if (no.className=='prodInfo')
                {
                    if (no.style.display!='block')
                    {
                        pos = wdCore.findPos(obj);
                        //no.style.top = pos[1]+obj.offsetHeight-10+'px';
                        //no.style.left = pos[0]+10+'px';
                        no.style.display = 'block';
			no.style.top = pos[1]-no.offsetHeight+'px';
                        no.style.left = pos[0]+'px';
			
                    }
                }
            
        }
        
        function getNext(obj) { 
            var n = obj; 
            do n = n.nextSibling; 
            while (n && n.nodeType != 1); 
            return n; 
        } 
        
        function getPrev(obj) { 
            var n = obj; 
            do n = n.previousSibling; 
            while (n && n.nodeType != 1); 
            return n; 
        }
        
        function changeSrcValue (org, mtc,value)
    {
        var idx = org.indexOf(mtc+'=')+(mtc.length+1);
        if (idx!=-1)
        {
            var start = org.substring(0,idx);
            var idx_end = org.indexOf('&',idx);
            if (idx_end==-1)
            {
                return start+escape(value);
            }
            else
            {
                var end = org.substring(idx_end,org.length);
                return start+escape(value)+end;
            }
        }
        else
            return org;
    }
        
        function switchImage(cid,url,title, sub)
        {
            var img = f$(cid);
            if (img.src)
            {
				img.setAttribute('style','');
                //img.src = changeSrcValue(img.src,'url',url);
				img.src = '/gen.img?imgurl=' + url + '&mw=200&mh=400&x=png';
                img.parentNode.href = '/gen.img?imgurl=' + url + '&mw=640&mh=480&x=png';
            }
            if(title.length > 0){
                f$("imgTitle").innerHTML = title;
                f$("imgTitle").style.display = "block";
            }else
                f$("imgTitle").style.display = "none";
            if(sub.length > 0){
                f$("imgSubText").innerHTML = sub;
                f$("imgSubText").style.display = "block";
            }else
                f$("imgSubText").style.display = "none";
            
            f$("lbA").title = title + "<br /><span style='font-weight:normal;'>" + sub + "</span>";
            
        }
        
        function toggleFlipper(obj,cname)
        {
            o = obj.parentNode.parentNode.getElementsByTagName("div");
            for(i in o)
            {
                
                if (obj.checked)
                {
                    if (o[i].className=='prodInfo')
                    {
                        o[i].style.display = 'block';
                        o[i].className=cname;
                    }
                }
                else
                {
                    if (o[i].className==cname)
                    {
                        o[i].style.display = 'none';
                        o[i].className='prodInfo';
                    }
                }
            }
            o = obj.parentNode.getElementsByTagName("input");
            for(i in o)
            {
                if (o[i].style!=null && o[i]!=obj)
                {
                    o[i].style.display = (obj.checked)?'none':'block';
                    if (!obj.checked && o[i].checked) 
                        showDescription(o[i].parentNode);
                }
            }
        }
        
        function f$(i) { 
       if(document.all) { 
          return document.all[i]; 
       } else { 
          return document.getElementById(i); 
       }
} 


