function DrawMainLinks(Language)
{
    var Lang = Language ? Language.toUpperCase() : "EN"
   
    //document.write('<scr'  + 'ipt src="http://www.penki.lt/images/Banners/2006/NewYearBanner.asp?lang=' + Lang + '" type="text/javascript"></scr' + 'ipt>')
    
    var iconGroups = new PenkiLT_IconGroups()
    var mygroup 
    switch (Lang)
    {
        case 'LT':
        {
            mygroup = iconGroups.AddGroup("100")
            mygroup.Add(1,'<font color="#CC0000">Ypatingi pasiūlymai</font>',"http://www.penki.lt/Images/Icons/akcija3.gif",52,"http://miestas.penki.lt/city.aspx?Lang=LT&Element=ViewArticles&TopicID=59","_top");
            
            mygroup = iconGroups.AddGroup("200")
            mygroup.Add(10,'Skynet',"http://www.penki.lt/Images/Icons/skynet.gif",43,"http://miestas.penki.lt/city.aspx?Lang=" + Lang,"_top");
            mygroup.Add(11,'Miestas',"http://www.penki.lt/Images/Icons/miestas.gif",41,"http://miestas.penki.lt/City.aspx?Element=VilniusNews&TopicID=232&Lang=LT","_top");
            mygroup.Add(25,'Smart House',"http://www.penki.lt/Images/Icons/smarthouse.gif",51,"http://smarthouse.penki.lt/Default.aspx?Lang=LT","_top");
            
            mygroup = iconGroups.AddGroup("300")
            mygroup.Add(12,'Sužinok',"http://www.penki.lt/Images/Icons/suzinok.gif",45,"http://news.penki.lt/default.aspx?Lang=" + Lang,"_top");
            mygroup.Add(13,'Gyvūnai',"http://www.penki.lt/Images/Icons/gyvunai.gif",45,"http://gyvunai.penki.lt/default.aspx?Lang=" + Lang,"_top");            

            mygroup = iconGroups.AddGroup("400")
            mygroup.Add(26,'Penki TV',"http://www.penki.lt/Images/Icons/TV.gif",39,"http://www.penki.tv","_top");            
            mygroup.Add(14,'Medijos centras',"http://www.penki.lt/Images/Icons/media.gif",52,"http://mediacentras.penki.lt/default.aspx?Lang=" + Lang,"_top");
            

            mygroup = iconGroups.AddGroup("500")
            mygroup.Add(15,'Renginių centras',"http://www.penki.lt/Images/Icons/renginiai.gif",43,"http://renginiai.penki.lt/default.aspx?Lang=" + Lang,"_top");
            
            mygroup = iconGroups.AddGroup("600")
            mygroup.Add(16,'Ieškok',"http://www.penki.lt/Images/Icons/ieskok.gif",34,"http://ieskok.penki.lt/default.aspx?Lang=" + Lang,"_top");
            mygroup.Add(17,'Google',"http://www.penki.lt/Images/Icons/Google.gif",41,"http://www.googlesyndicatedsearch.com/u/penki?hl=lt&sitesearch=penki.lt","_top");
            
            mygroup = iconGroups.AddGroup("700")
            mygroup.Add(18,'El. paštas',"http://www.penki.lt/Images/Icons/mail.gif",41,"http://webmail.penki.lt","_top");

            mygroup = iconGroups.AddGroup("800")
            mygroup.Add(19,'Forumai',"http://www.penki.lt/Images/Icons/forum.gif",35,"http://forum.penki.lt","_top");
            mygroup.Add(20,'Pramogauk',"http://www.penki.lt/Images/Icons/pramogauk.gif",35,"http://pramogos.penki.lt/default.aspx?Lang=" + Lang,"_top");
            mygroup.Add(21,'Pažintys',"http://www.penki.lt/Images/Icons/pazintys.gif",40,"http://pazintys.penki.lt/index.php?lg=lt","_top");
            
            mygroup = iconGroups.AddGroup("900")
            mygroup.Add(22,'Top100',"http://www.penki.lt/Images/Icons/top100.gif",50,"http://top100.penki.lt/default.aspx?Lang=" + Lang,"_top");
            mygroup.Add(23,'Pirk',"http://www.penki.lt/Images/Icons/pirk.gif",40,"http://pirk.penki.lt/default.aspx?Lang=" + Lang,"_top");
            
            mygroup = iconGroups.AddGroup("1000")
            mygroup.Add(24,'Pasas',"http://www.penki.lt/Images/Icons/pasas.gif",52,"https://pasas.penki.lt/default.aspx?Lang=" + Lang,"_new");

            break;
        }
        case 'RU':
        {
            mygroup = iconGroups.AddGroup("200")
            mygroup.Add(10,'Skynet',"http://www.penki.lt/Images/Icons/skynet.gif",43,"http://miestas.penki.lt/city.aspx?Lang=" + Lang,"_top");
            mygroup.Add(11,'Город',"http://www.penki.lt/Images/Icons/miestas.gif",41,"http://miestas.penki.lt/city.aspx?Lang=" + Lang + "&Element=RegionInfo&TopicID=485","_top");
            
            mygroup = iconGroups.AddGroup("300")
            mygroup.Add(12,'Новости',"http://www.penki.lt/Images/Icons/suzinok.gif",45,"http://www.penki.lt/default.aspx?Lang=" + Lang,"_top");
            mygroup.Add(13,'Животные',"http://www.penki.lt/Images/Icons/gyvunai.gif",45,"http://gyvunai.penki.lt/default.aspx?Lang=" + Lang,"_top")
            
            mygroup = iconGroups.AddGroup("400")
            mygroup.Add(26,'Penki TV',"http://www.penki.lt/Images/Icons/TV.gif",39,"http://www.penki.tv","_top");            
            mygroup.Add(14,'Медиа-<br />центр',"http://www.penki.lt/Images/Icons/media.gif",52,"http://mediacentras.penki.lt/default.aspx?Lang=" + Lang,"_top");

            
            mygroup = iconGroups.AddGroup("500")
            mygroup.Add(15,'Конференц-<br />центр',"http://www.penki.lt/Images/Icons/renginiai.gif",43,"http://renginiai.penki.lt/default.aspx?Lang=" + Lang,"_top");
                        
            mygroup = iconGroups.AddGroup("600")
            mygroup.Add(16,'Поиск',"http://www.penki.lt/Images/Icons/ieskok.gif",34,"http://ieskok.penki.lt/default.aspx?Lang=" + Lang,"_top");
            mygroup.Add(17,'Google',"http://www.penki.lt/Images/Icons/Google.gif",41,"http://www.googlesyndicatedsearch.com/u/penki?hl=ru&sitesearch=penki.lt","_top");
            
            mygroup = iconGroups.AddGroup("700")
            mygroup.Add(18,'Эл. почта',"http://www.penki.lt/Images/Icons/mail.gif",41,"http://webmail.penki.lt","_top");
            
            mygroup = iconGroups.AddGroup("800")
            mygroup.Add(19,'Форумы',"http://www.penki.lt/Images/Icons/forum.gif",35,"http://forum.penki.lt","_top");
            mygroup.Add(20,'Развлечения',"http://www.penki.lt/Images/Icons/pramogauk.gif",35,"http://pramogos.penki.lt/default.aspx?Lang=" + Lang,"_top");
            mygroup.Add(21,'Знакомства',"http://www.penki.lt/Images/Icons/pazintys.gif",40,"http://pazintys.penki.lt/index.php?lg=ru","_top");
            
            mygroup = iconGroups.AddGroup("900")
            mygroup.Add(22,'Топ100',"http://www.penki.lt/Images/Icons/top100.gif",50,"http://top100.penki.lt/default.aspx?Lang=" + Lang,"_top");
            mygroup.Add(23,'Магазин',"http://www.penki.lt/Images/Icons/pirk.gif",40,"http://pirk.penki.lt/default.aspx?Lang=" + Lang,"_top");            

            mygroup = iconGroups.AddGroup("1000")
            mygroup.Add(24,'Паспорт',"http://www.penki.lt/Images/Icons/pasas.gif",52,"https://pasas.penki.lt/default.aspx?Lang=" + Lang,"_new");
            
            break;
        }
        default :
        {
            mygroup = iconGroups.AddGroup("200")
            mygroup.Add(11,'City',"http://www.penki.lt/Images/Icons/miestas.gif",41,"http://miestas.penki.lt/city.aspx?Lang=" + Lang,"_top");
            mygroup.Add(25,'Smart House',"http://www.penki.lt/Images/Icons/smarthouse.gif",51,"http://smarthouse.penki.lt/Default.aspx?Lang=EN","_top");
            
            
            mygroup = iconGroups.AddGroup("300")
            mygroup.Add(12,'News',"http://www.penki.lt/Images/Icons/suzinok.gif",45,"http://www.penki.lt/default.aspx?Lang=" + Lang,"_top");
            mygroup.Add(13,'Animals',"http://www.penki.lt/Images/Icons/gyvunai.gif",45,"http://gyvunai.penki.lt/default.aspx?Lang=" + Lang,"_top");
            
            mygroup = iconGroups.AddGroup("400")
            mygroup.Add(26,'Penki TV',"http://www.penki.lt/Images/Icons/TV.gif",39,"http://www.penki.tv","_top");                        
            mygroup.Add(14,'Media center',"http://www.penki.lt/Images/Icons/media.gif",52,"http://mediacentras.penki.lt/default.aspx?Lang=" + Lang,"_top");
            
            mygroup = iconGroups.AddGroup("500")
            mygroup.Add(15,'Events centre',"http://www.penki.lt/Images/Icons/renginiai.gif",43,"http://renginiai.penki.lt/default.aspx?Lang=" + Lang,"_top");
            
            mygroup = iconGroups.AddGroup("600")            
            mygroup.Add(16,'Search',"http://www.penki.lt/Images/Icons/ieskok.gif",34,"http://ieskok.penki.lt/default.aspx?Lang=" + Lang,"_top");
            mygroup.Add(17,'Google',"http://www.penki.lt/Images/Icons/Google.gif",41,"http://www.googlesyndicatedsearch.com/u/penki?hl=en&sitesearch=penki.lt","_top");

            mygroup = iconGroups.AddGroup("700")
            mygroup.Add(18,'Web mail',"http://www.penki.lt/Images/Icons/mail.gif",41,"http://webmail.penki.lt","_top");

            mygroup = iconGroups.AddGroup("800")
            mygroup.Add(19,'Forum',"http://www.penki.lt/Images/Icons/forum.gif",35,"http://forum.penki.lt","_top");
            mygroup.Add(20,'Have fun',"http://www.penki.lt/Images/Icons/pramogauk.gif",35,"http://pramogos.penki.lt/default.aspx?Lang=" + Lang,"_top");
            mygroup.Add(21,'Dating',"http://www.penki.lt/Images/Icons/pazintys.gif",40,"http://pazintys.penki.lt/index.php?lg=en","_top");
            
            mygroup = iconGroups.AddGroup("900");
            mygroup.Add(22,'Top100',"http://www.penki.lt/Images/Icons/top100.gif",50,"http://top100.penki.lt/default.aspx?Lang=" + Lang,"_top");
            mygroup.Add(23,'Shopping',"http://www.penki.lt/Images/Icons/pirk.gif",40,"http://pirk.penki.lt/default.aspx?Lang=" + Lang,"_top");
            
            
            mygroup = iconGroups.AddGroup("1000")
            mygroup.Add(24,'Passport',"http://www.penki.lt/Images/Icons/pasas.gif",52,"https://pasas.penki.lt/default.aspx?Lang=" + Lang,"_new");
            
            break; 
        }
    }
    var html=iconGroups.GetHTML();
    document.write(html);
}    


function PenkiLT_Icon(id,title ,iconURL,iconW,iconH,linkURL,linkTarget,fontColor)
{
    this.spacerURL = "";
    this.dropDownArrowURL = "";
    this.dropDownArrowWidth = 0;
    this.dropDownArrowHeight = 0;
    this.DivWidth = 0;
    this.FontColor = "#000000" ;
    
    
    this.ID = id;
    this.Title = title;
    this.IconURL = iconURL;
    this.IsMain = false;
    this.Group = null;
    this.IconWidth = iconW;
    this.IconHeight = iconH;
    this.URL = linkURL;
    this.Target = linkTarget;
    this.TitleStripped = this.Title.replace(/(<([^>]+)>)/ig,"");
    
        
    this.StrStyle = 'color:'+this.FontColor+';text-decoration:none;font-weight:bold;font-size:10px;font-family:Verdana;'
    this.AddToGlobal()
}
PenkiLT_Icon.prototype.AddToGlobal = function ()
{
    var AllIcons = document.All_PenkiLT_Icons
    if (!AllIcons)
    {
        AllIcons = new Object()
        document.All_PenkiLT_Icons = AllIcons
    }
    AllIcons[this.ID]=this
}

PenkiLT_Icon.prototype.GetHTML = function ()
{
    var html = '';
    if ( this.IsMain||(this.Group==null|| !(this.Group.Icons.length>1) ) )
    {
        html += '<div style="width:' + this.DivWidth + 'px;border:solid 0px #CCCCCC" align="center">';
    }
    else
    {
        html += '<div style="width:' + this.DivWidth + 'px;border:solid 0px #CCCCCC;padding-bottom:10px;" align="center">';
    }    

    html += this.FirstRow()
    html += this.SecondRow()
    html += '</div>'
    return html;
}

PenkiLT_Icon.prototype.OnClick = function ()
{
    if (this.Group!=null)
    {
        this.Group.SetAsMain(this)
    }
    return true;
}
PenkiLT_Icon.prototype.OnDropDown = function (SetOldEvent)
{
    if (this.Group!=null)
    {
        this.Group.DropDownToggle(SetOldEvent);
    }
    return false;
}

PenkiLT_Icon.prototype.FirstRow=function ()
{
    var html = '';
    html += '<div style="width:' + this.DivWidth + 'px;">';
    if (this.IsMain&&this.Group!=null&&this.Group.Icons.length>1)
    {
        var item
        var w = this.DivWidth
        html += '<table cellpadding="0" cellspacing="0" border="0" style="height:' + this.IconHeight + 'px;width:' + w + 'px;background-position:center;background-repeat:no-repeat;" background="' + this.IconURL + '">';
        html += '<tr>'
        html += '<td rowspan="2">'
            item = '<img name="PenkiLT_Icon_Img_' + this.ID + '" src="' + this.spacerURL + '" width="' + ( w- this.dropDownArrowWidth ) + '" height="' + this.IconHeight + '"  style="border:solid 0px #000000;" alt="' + this.TitleStripped +  '" />';
        html += this.setLink(item)
        html += '</td>'
        html += '<td>'
            item = '<img src="' + this.spacerURL + '" width="' + (this.dropDownArrowWidth ) + '" height="' + (this.IconHeight -  this.dropDownArrowHeight) + '"  style="border:solid 0px #000000;" alt="' + this.TitleStripped +  '" />';
        html += this.setLink(item)
        html += '</td>'
        html += '</tr>'        
        html += '<tr>'
        html += '<td>'
            
            item = '<a href="#" onclick="return document.All_PenkiLT_Icons[\'' + this.ID + '\'].OnDropDown(false);" HIDEFOCUS="true" >'
            item += '<img src="' + this.dropDownArrowURL + '" width="' + (this.dropDownArrowWidth - 0) + '" height="' + (this.dropDownArrowHeight - 0) + '"  style="border:solid 0px #000000;" alt="" HIDEFOCUS="true" />';
            item += '</a>'
            html += item            
        html += '</td>'
        html += '</td>'
        
        html += '</tr>'
        html += '</table>'
    }
    else
    {
        var item = '';
        item += '<img name="PenkiLT_Icon_Img_' + this.ID + '" src="' + this.IconURL + '" width="' + this.IconWidth + '" height="' + this.IconHeight + '"  style="border:solid 0px #000000;" alt="' + this.TitleStripped +  '" />';
        html += this.setLink(item)
    }
    
    html += '</div>';
    return html;
}
PenkiLT_Icon.prototype.SecondRow=function ()
{
    var html = '';
    html += '<div style="width:' + this.DivWidth + 'px;">';
    html += this.setLink(this.Title);  
    html += '</div>';
    return html;
}
PenkiLT_Icon.prototype.setLink=function (item)
{
    var html = '';
    var ownerString = "document";
    if (this.IsMain!=true&&this.Group!=null&&this.Group.Icons.length>1)
    {
        ownerString="window.parent.document"
    }
    html += '<a style="' +  this.StrStyle   + '" href="' + this.URL + '" target="' + this.Target + '" title="' + this.TitleStripped + '" onclick="return ' + ownerString + '.All_PenkiLT_Icons[\'' + this.ID + '\'].OnClick();">';  
    html +=item
    html +='</a>'
    return html;
}


function PenkiLT_IconGroup(id)
{
    this.dropDownArrowWidth = 15;
    this.dropDownArrowHeight = 10;
    this.DivWidth = 68;
    this.IconHeight = 47;
    this.DropDownBackgroundColor = "#FFFFFF"
    this.DropDownTextColor = "#000000"    
    this.spacerURL = "http://www.penki.lt/images/spacer.gif";
    this.dropDownArrowURL = "http://www.penki.lt/images/spacer.gif"; 
    this.Owner = null;
    this.DefaultIconID = null
    

    this.ID = id;
    this.Icons = new Array();
    this.MainIcon = null;
    this.DropDown = null;
    this.DropDownDocument = null;

    this.DivHeight = this.IconHeight + 14;
    this.MaxDropDownHeight = this.DivHeight * 4
    
    this.UserScrollBarWidth = 19
    
    this.writenToDropDown=false
    
}
PenkiLT_IconGroup.prototype.Add = function(id,title ,iconURL,iconW,linkURL,linkTarget)
{
    var _icon = new PenkiLT_Icon(id,title ,iconURL,iconW,this.IconHeight,linkURL,linkTarget,this.DropDownTextColor)
    _icon.Group=this
    _icon.spacerURL = this.spacerURL;
    _icon.dropDownArrowURL = this.dropDownArrowURL;
    _icon.dropDownArrowWidth = this.dropDownArrowWidth;
    _icon.dropDownArrowHeight = this.dropDownArrowHeight;
    _icon.DivWidth = this.DivWidth;
    _icon.FontColor = this.FontColor
    if (this.DefaultIconID == id&&this.MainIcon==null)
    {
            _icon.IsMain=true;
            this.MainIcon = _icon;
    }
    this.Icons.push(_icon)
    if (this.Icons.length==2)
    {
        this.createDropDown()
    }
}
PenkiLT_IconGroup.prototype.DropDownToggle = function(SetOldEvent)
{
    var dd=this.DropDown
    if (dd!=null)
    {
        if (dd.style.display=="none"||this.writenToDropDown==false)
        {
            this.Expand(SetOldEvent)
        }
        else
        {
            this.Collapse(SetOldEvent)
        }
    }
}

PenkiLT_IconGroup.prototype.Expand = function(SetOldEvent)
{
    var dd=this.DropDown
    var _this = this;
    _this.ClickCount = 0;
    var currentOnClick = document.onclick;
    if (currentOnClick&&currentOnClick.Name)
    {
        if (currentOnClick.Name == "DocOnClickNew_Expand")
        {
            currentOnClick(true)
        }
    }
    if (dd!=null)
    {
        this.writeToDropDown()
        var imgParent=document.images['PenkiLT_Icon_Img_' + this.MainIcon.ID ]
        var coords = new Object()
        coords.x=0;
        coords.y=0;
        if (imgParent)
        {
            coords=getXY(imgParent)
            coords.y += imgParent.offsetHeight + 1
        }
        dd.style.position = "absolute"
        dd.style.top = coords.y + "px";
        dd.style.left = coords.x + "px";
        dd.style.display="block";
        this.DropDownCheckScroll()
        currentOnClick = document.onclick;
        document.onclickOld = currentOnClick;
        document.onclick=DocOnClickNew
        
    }
    function DocOnClickNew()
    {
        if (_this.ClickCount==0)
        {
            _this.ClickCount = 1;
            return
        }
        else
        {
            _this.ClickCount = 0;
            document.All_PenkiLT_Icons[_this.MainIcon.ID].OnDropDown(true)
        }
    }
    DocOnClickNew.Name="DocOnClickNew_Expand"
    function getXY( oElement )
    {
        var iReturnValue = new Object();
        iReturnValue.x=0;
        iReturnValue.y=0;
        while( oElement != null )
        {
            iReturnValue.y += oElement.offsetTop;
            iReturnValue.x += oElement.offsetLeft;
            oElement = oElement.offsetParent;
        }
        return iReturnValue;
    }

}
PenkiLT_IconGroup.prototype.Collapse = function(SetOldEvent)
{
    var dd=this.DropDown
    if (dd!=null)
    {
        if (SetOldEvent)
        {
            var oldOnClick = document.onclickOld;
            document.onclick = oldOnClick;
        }
        else
        {
            var _this=this;
            _this.ClickCount = 0;
            document.onclick = DocOnClickNew;
        }
        dd.style.display="none";
    }
    
    function DocOnClickNew()
    {
        if (_this.ClickCount==0)
        {
            _this.ClickCount = 1;
            return
        }
        else
        {
            _this.ClickCount = 0;
            var oldOnClick = document.onclickOld;
            document.onclick = oldOnClick;
        }
    }
    DocOnClickNew.Name="DocOnClickNew_Collapse"
    
}
PenkiLT_IconGroup.prototype.GetHTML = function()
{
    this.getAutoMainIcon()
    if (this.MainIcon!=null)
    {
        return this.MainIcon.GetHTML()
    }
    else
    {
        return ""
    }
}
PenkiLT_IconGroup.prototype.getAutoMainIcon = function()
{
    if (this.MainIcon==null)
    {
        if (this.Icons.length>0)
        {
            this.Icons[0].IsMain=true;
            this.MainIcon = this.Icons[0];
        }
    
    }
}
PenkiLT_IconGroup.prototype.SetAsMain = function (ico)
{
    if (ico&&ico.Group!=null&&ico.Group==this)
    {
        if (this.MainIcon!=ico&&this.Owner!=null)
        {
            this.Owner.SaveMainIcon(this,ico)
        }
    }
}
PenkiLT_IconGroup.prototype.createDropDown = function()
{
    var html = '';
    html += '<iframe id="PenkiLT_IconGroup_' + this.ID  + '_IFRAME" style="width:' + (this.DivWidth + this.UserScrollBarWidth) + 'px;background-color' + this.DropDownBackgroundColor + ';border:solid 1px #CCCCCC;position:absolute;left:-1000px;top:-1000px;" border = "0" frameBorder = "0" marginWidth = "0" marginHeight = "0" scrolling="auto" ></iframe>'
    document.write(html)    
    
    var dd
    dd= document.getElementById('PenkiLT_IconGroup_' + this.ID  + '_IFRAME')

    if (dd)
    {
        this.DropDown=dd;
    }
    else
    {
        //alert('no DropDown')
    }
    
    //var documentBody;
    //documentBody = document.body ? document.body : document.body ? document.documentElement : document.getElementsByTagName('body').length>0 ? document.getElementsByTagName('body')[0] : null
    //if (documentBody)
    //{
        //documentBody.appendChild(dd)
    //}
    //document.appendChild(dd)
    //this.DropDown=dd;
}
PenkiLT_IconGroup.prototype.writeToDropDown = function()
{
    if (this.DropDown!=null&&this.Icons.length>1&&!this.writenToDropDown)
    {
        var ddDocument = null
        var dd= this.DropDown
        var ddh;
        ddh = Math.min(this.MaxDropDownHeight, (this.DivHeight + 10) * (this.Icons.length- 1))
        dd.style.height = ddh + "px"
    
        try
        {
            if (dd.contentDocument) { // For NS6 and opera
                ddDocument = dd.contentDocument;
            } else if(dd.contentWindow) { // For IE5.5 and IE6
                ddDocument = dd.contentWindow.document;
            } else if(dd.document) {// For IE5
                ddDocument = dd.document;
            }
        }
        catch(e)
        {
            //alert(e)
            this.DropDown = null;
            return
        }
        this.DropDownDocument = ddDocument
        if (ddDocument)
        {
            var ddIconsHML = '';
            var i;
            for (i=0;i<this.Icons.length;i++)
            {
                if (this.Icons[i]!=this.MainIcon)
                {
                    ddIconsHML += this.Icons[i].GetHTML()
                }
            }
            ddIconsHML = '<html><head><style>A{' + this.MainIcon.StrStyle + '}</style></head><body bgcolor="' + this.DropDownBackgroundColor + '"><div id="Group_Icons" style="width:' + this.DivWidth + 'px;" align="right">' + ddIconsHML + '</div></body></html>'
            //ddDocument.clear()
            ddDocument.open()            
            ddDocument.write(ddIconsHML)
            ddDocument.close()
            dd.style.display="none"
            this.writenToDropDown=true
        }
    }
}
PenkiLT_IconGroup.prototype.DropDownCheckScroll = function()
{
    if (this.DropDown!=null&&this.Icons.length>1&&this.writenToDropDown)
    {
        var ddDocument = this.DropDownDocument;
        var dd= this.DropDown
        var ddh;
        ddh = Math.min(this.MaxDropDownHeight, (this.DivHeight + 10) * (this.Icons.length- 1))
        try
        {
            if (ddDocument)
            {            
                var _ic = ddDocument.getElementById('Group_Icons')
                if (_ic)
                {
                    var newWidth = this.DivWidth
                    if (_ic.offsetWidth>this.DivWidth)
                    {
                        newWidth=_ic.offsetWidth
                    }
                    
                    if(_ic.offsetHeight<=ddh)
                    {
                        dd.scrolling="no"
                        dd.style.width = newWidth + "px"
                    }
                    else
                    {
                        dd.style.width = (newWidth + this.UserScrollBarWidth) + "px"
                        dd.scrolling="auto"
                    }
                }    
            }
        }
        catch (e)
        {
            //alert(e)
        }
    }
}
function PenkiLT_IconGroups()
{
    this.dropDownArrowWidth = 20;
    this.dropDownArrowHeight = 20;
    this.DivWidth = 68;
    this.IconHeight = 47;
    this.DropDownBackgroundColor = "#FFFFFF"
    this.DropDownTextColor = "#000000"    
    this.spacerURL = "http://www.penki.lt/images/spacer.gif";
    this.dropDownArrowURL = "http://www.penki.lt/images/icons/DownArrow2.gif";
    this.Domain = "delfi.lt"
    this.Groups = new Array();
    this.StateArray = this.LoadState();
    //alert(this.StateArray)
}
PenkiLT_IconGroups.prototype.AddGroup = function (id)
{
    var g=new PenkiLT_IconGroup(id)
    g.dropDownArrowWidth = this.dropDownArrowWidth;
    g.dropDownArrowHeight = this.dropDownArrowHeight;
    g.DivWidth = this.DivWidth;
    g.IconHeight = this.IconHeight;
    g.DropDownBackgroundColor = this.DropDownBackgroundColor
    g.DropDownTextColor = this.DropDownTextColor
    g.spacerURL = this.spacerURL;
    g.dropDownArrowURL = this.dropDownArrowURL;
    g.Owner = this;
    var i
    var strID='' + id
    for(i=0;i<this.StateArray.length;i++)
    {
        if (this.StateArray[i])
        {
            if (this.StateArray[i].substr(0,strID.length + 1) == id + "-")
            {
                
                //alert("found" + this.StateArray[i].substr(strID.length + 1))
                g.DefaultIconID = this.StateArray[i].substr(strID.length + 1)
            }
        }
    }
    //this.DefaultIconID = null
    this.Groups.push(g);
    return g
}
PenkiLT_IconGroups.prototype.GetHTML = function()
{
    var html = '';
    if (this.Groups.length>0)
    {
        html += '<table width="100%" cellpadding="0" cellspacing="0">' 
        html += '<tr>' 
        var i
        for (i=0;i<this.Groups.length;i++)
        {
            html += '<td align="center" valign="top">';
            html += this.Groups[i].GetHTML();
            html += '</td>';
        }
        html += '</tr>' 
        html += '</table>' 
    }
    return html;
}
PenkiLT_IconGroups.prototype.SaveMainIcon = function (g,ico)
{
    if (g&&g.Owner!=null&&g.Owner==this)
    {
        g.MainIcon = ico;
        this.SaveState()
    }
}
PenkiLT_IconGroups.prototype.SaveState = function ()
{
    var state="";
    var i;
    for (i=0;i<this.Groups.length;i++)
    {
        var g = this.Groups[i]
        if (g.Icons.length>1&&g.MainIcon!=null)
        {
            state += g.ID + "-" + g.MainIcon.ID + ",";
        }
    }
    try
    {
        setCookie("PenkiLT_IconGroups",state,"penki.lt","");
    }
    catch(e)
    {
        //alert(e)
    }
    function setCookie(name, value, domain, path, expires, secure)
    {
        var d=new Date();
        if (!expires) expires=new Date(d.getFullYear() + 1, d.getMonth(), d.getDate())
        document.cookie= name + "=" + escape(value) +
            ((expires) ? "; expires=" + expires.toGMTString() : "") +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            ((secure) ? "; secure" : "");
    }
}
PenkiLT_IconGroups.prototype.LoadState = function ()
{
    var i;
    var state= ""
    try
    {
        state=getCookie("PenkiLT_IconGroups")
    }
    catch(e)
    {
        //alert(e)
    }
    stateArray = new Array()
    if (state)
    {
        stateArray = state.split(',')
    }
    return stateArray
    function getCookie(name)
    {
        var dc = document.cookie;
        var prefix = name + "=";
        var begin = dc.indexOf("; " + prefix);
        if (begin == -1)
        {
            begin = dc.indexOf(prefix);
            if (begin != 0) return null;
        }
        else
        {
            begin += 2;
        }
        var end = document.cookie.indexOf(";", begin);
        if (end == -1)
        {
            end = dc.length;
        }
        return unescape(dc.substring(begin + prefix.length, end));
    }
}
