﻿<!--
// Copyright © Dmitry Kukushkin <codecity@gmail.com> 2007

    //***** textBlock *****//
    function textBlock(header, content, html)
    {
        this.header = header;
        this.content = content;
        this.html = html;
        this.isClosed = true;
        
        this.header.style.display = "block";
        
        var _this = this;
        
        this.close();
        this.header.onclick = function() { _this.switchState(); };
    }
    
    textBlock.prototype.switchState = function()
    {
        if(this.isClosed)
        {
            this.open();
        }
        else
        {
            this.close();
        }
    }
    
    textBlock.prototype.open = function()
    {
        this.content.style.display = "block";
        this.header.innerHTML = '<a style="text-decoration: none; color: #030303; cursor: hand;" href="javascript:void(0);"><table border="0"><tr><td><img border="0" alt="Open" src="http://resources.cardstore.com.ua/pic/minus.gif" /></td><td>' + this.html + '</td></tr></table></a>';
        this.isClosed = false;
    }
    
    textBlock.prototype.close = function()
    {
        this.content.style.display = "none";
        this.header.innerHTML = '<a href="javascript:void(0);" style="text-decoration: none; color: #030303; cursor: hand;"><table border="0"><tr><td><img border="0" alt="Open" src="http://resources.cardstore.com.ua/pic/plus.gif" /></td><td>' + this.html + '</td></tr></table></a>';
        this.isClosed = true;
    }
    
    //***** Hider *****//
    function Hider()
    {
        var switchClassRExp = new RegExp("hswitch", "i");
        var headerClassRExp = new RegExp("hheader", "i");
        var contentClassRExp = new RegExp("hcontent", "i");

        this.containers = new Array();
        
        var allElements = document.getElementsByTagName("div");
        
        if ("undefinite" == allElements || null == allElements || 0 >= allElements.length)
            return;
            
        var divTagName = allElements[0].tagName;

        for (var i = 0; i < allElements.length; i++)
        {
            if (-1 == allElements[i].className.search(switchClassRExp))
                continue;
                
            var header = null;
            var content = null;

            for (var ii = 0; ii < allElements[i].childNodes.length; ii++)
            {
                if (allElements[i].childNodes[ii].tagName != divTagName)
                    continue;

                if (null == header)
                    header = allElements[i].childNodes[ii];
                
                if (null != header)
                    content = allElements[i].childNodes[ii];
            }

            if (null == header || null == content)
                continue;

            var tBlock = new textBlock(header, content, header.innerHTML);

            this.containers[this.containers.length] = tBlock;
        }
    }
    
// -->