﻿/// <reference path="glogal.js" />
/// <reference path="engine.js" />
var $m = {
    checkInputs: {
        checkMail: function(input) {
            var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
            if (filter.test(input.value))
                return true;
            else
                return false;
        },
        checkPhone: function(input) {
            var phonefilter = /^[+][0-9]{1,3} [0-9]{3,3} [0-9]{3} [0-9]{4}$/;
            if (phonefilter.test(input.value))
                return true;
            else
                return false;
        },
        checkIsEmpty: function(input) {
            if (input.value == null || input.value == "")
                return true;
            else
                return false;
        },
        checkIsDigit: function(obj, keycode) {
            var buf = obj.value;
            var digitFilter = /^([1-9]|[1-9]\d|100)$/;
            if (digitFilter.test(String.fromCharCode(keycode)))
                obj.value += String.fromCharCode(keycode);
            else
                obj.value = "";
        },
        valid: function(o, w) {
            var r = {
                'special': /[\W]/g,
                'quotes': /['\''&'\"']/g,
                'notnumbers': /[^\d]/g
            }
            o.value = o.value.replace(r[w], '');
        }

    },
    hideshowObjs: function(oper) {
        var objs = $G.Get.ByTag(document.body, "object", true);
        for (var i = 0; i < objs.length; i++) {
            if (oper == "hide") {
                $G.Display.Hide(objs[i]);
            }
            else if (oper == "show") {
                $G.Display.Block(objs[i]);
            }
        }
    },
    menu: {
        setClassNames: function(menu_id, QueryStringName, parentclass, childclass) {
            var menu = $global.Get.ById(menu_id);
            var currQuery = $m.menu.getQueryStringValue(QueryStringName);
            var div = $G.Get.ByTag(menu, 'div', null);
            if (currQuery == null) {
                for (var i = 0; i < div.length; i++) {
                    var divchildrens = div[i].childNodes;
                    for (var i_ = 0; i_ < divchildrens.length; i_++) {
                        if (divchildrens[i_].tagName) {
                            switch (divchildrens[i_].tagName.toLowerCase()) {
                                case 'a':
                                    divchildrens[i_].className = parentclass;
                                    break;
                                case 'div':
                                    var inputs = $G.Get.ByTag(divchildrens[i_], 'a', null);
                                    for (var i__ = 0; i__ < inputs.length; i__++) {
                                        inputs[i__].className = childclass;
                                    }
                                    break;
                                default:
                            }
                        }
                    }
                }
            }
            else {
                for (var i = 0; i < div.length; i++) {
                    var divchildrens = div[i].childNodes;
                    var parentmenu;
                    var showblock = false;
                    for (var i_ = 0; i_ < divchildrens.length; i_++) {
                        if (divchildrens[i_].tagName) {
                            switch (divchildrens[i_].tagName.toLowerCase()) {
                                case 'a':
                                    parentmenu = divchildrens[i_];
                                    parentmenu.className = parentclass;
                                    showblock = showblock == true ? true : (parentmenu.id == '_' + currQuery ? true : false);
                                    break;
                                case 'div':
                                    var inputs = $G.Get.ByTag(divchildrens[i_], 'a', null);
                                    for (var i__ = 0; i__ < inputs.length; i__++) {
                                        showblock = showblock == true ? true : (inputs[i__].id == '_' + currQuery ? true : false);
                                        if (inputs[i__].id == '_' + currQuery)
                                            inputs[i__].className = childclass + 'A';
                                        else
                                            inputs[i__].className = childclass;
                                    }
                                    if (showblock) {
                                        parentmenu.className = parentclass + 'A';
                                        $G.Display.Block(divchildrens[i_]);
                                    }
                                    break;
                                default:
                            }
                            if (showblock) {
                                parentmenu.className = parentclass + 'A';
                                $G.Display.Block(divchildrens[i_]);
                            }
                        }
                    }
                }
            }
        },
        getQueryStringValue: function(name) {
            var RawUrl = document.location.href;
            var QueryStrings = RawUrl.split('&');
            for (var i = 0; i < QueryStrings.length; i++) {
                if (QueryStrings[i].indexOf(name) != -1) {
                    return QueryStrings[i].split('=')[1];
                }
            }
            return null;
        }
    },
    mmh: {
        open: function(obj) {
            var objs = $G.Get.ByTag($G.GET(obj, "up:2"), "div");
            for (var i = 0; i < objs.length; i++) {
                var _curr = $G.GET(objs[i], "div:0");
                if (_curr)
                    _curr.style.display = "none";
            }
            var subm = $G.GET(obj, "up:1,div:0");
            if (subm)
                subm.style.display = "block"
        },
        arr: {},
        over: function(obj, id) {
            if (obj) {
                $m.mmh.arr[id] = true;
                var menu = $G.Next(obj, 1);
                $G.Display.Block(menu);
                menu.onmouseover = function() {
                    $m.mmh.arr[this.id] = true;
                } .bind({ obj: obj, id: id, menu: menu });
                menu.onmouseout = function() {
                    $m.mmh.arr[this.id] = false;
                    setTimeout(function() {
                        $m.mmh.out(this.id);
                    } .bind(this), 100);
                } .bind({ obj: obj, id: id, menu: menu });
                obj.onmouseout = function() {
                    $m.mmh.arr[this.id] = false;
                    setTimeout(function() {
                        $m.mmh.out(this.id);
                    } .bind(this), 100);
                } .bind({ obj: obj, id: id, menu: menu });
            }
        },
        out: function(id) {
            if (!$m.mmh.arr[id]) {
                var obj = $G.Get.ById(id);
                $G.Display.Hide(obj);
            }
        }
    },
    pm: {
        open: function(obj) {
            //debugger;
            var objs = $G.Get.ByTag($G.GET(obj, "up:2"), "div");
            for (var i = 0; i < objs.length; i++) {
                var _div = $G.GET(objs[i], "div:0");
                if (_div)
                    _div.style.display = "none";
                $G.GET(obj, "up:1,div:0").style.display = "block";
            }
        }
    },
    pc: {
        Close: function() {
            $G.Display.Hide($G.Get.ById('PhotoContainer'));
        },
        OpenGallery: function(obj,id) {
            var obj = document.getElementById('imgs');
            obj.innerHTML = "";
            var url = "/ajax.ashx?action=getProductImg_G&itemId=" + id + "&rnd=" + Math.random();
            var request = new Request();
            request.Send(url, function callback(req) {
                var block = $G.Tag("div", "", "PhotoContainer");
                block.innerHTML = req.responseText;              
                $G.Append(obj, block); Gallery.Show(obj.getElementsByTagName('img')[0]);
            } .bind(request), function() { } .bind(request)
        );
        },
        OpenArticleGallery: function(id) {                 
            var url = "/ajax.ashx?action=getProductArticleImg_G&itemId=" + id + "&rnd=" + Math.random();
            var request = new Request();
            request.Send(url, function callback(req) {
                var block = $G.Tag("div", "", "PhotoContainer") 
                //  block have req.responseText        
                block.innerHTML = req.responseText;                
                GalleryArticle.Show(block);
                //GalleryArticle.Show(req.responseText);
            } .bind(request), function() { } .bind(request)
        );
        },
        Open: function(obj, id) {
            var url = "/ajax.ashx?action=getProductImg&itemId=" + id + "&rnd=" + Math.random();
            var request = new Request();
            request.Send(url, function callback(req) {
                var block = $G.Tag("div", "PhotoContainer", "PhotoContainer");
                block.width = "300px";
                block.height = "400px";
                block.style.display = 'none';
                $G.Append($G.Get.ById('PI_Img'), block);
                block.innerHTML = req.responseText;
                $G.ShowInPageCenter(block);
            } .bind(request), function() { } .bind(request)
        );
        },
        HideAllPages: function(ContentBlockId, ContentObjType, NavigationBlockId, NavigationObjType, NavigationClearCssClass) {
            var _container = $G.Get.ById(ContentBlockId);
            if (_container) {
                var _arr = $global.GetElementsByTagName(_container, ContentObjType);
                for (var i = 0; i < _arr.length; i++)
                    $global.Display.Hide(_arr[i]);
            }
            var _cont = $G.Get.ById(NavigationBlockId);
            if (_cont) {
                var _arr = $G.Get.ByTag(_cont, NavigationObjType);
                for (var i = 0; i < _arr.length; i++)
                    _arr[i].className = NavigationClearCssClass;
            }
        },
        Pager: function(link, DisplayedId) {
            $m.pc.HideAllPages($G.GET(link, 'up:2,div:1').id, 'div', 'NavigationLinks', 'a', 'pager_all_def');
            $G.Display.Block($G.Get.ById(DisplayedId));
            link.className = "pager_all";
        },
        Desc: function(lnk, page) {
            var arr = $G.Get.ByTag($G.GET(lnk, "up:1"), "div");
            for (var i = 0; i < arr.length; i++)
                $G.Display.Hide(arr[i]);

            arr = $G.Get.ByTag($G.Get.ById("PI_Desc"), "span");
            for (var i = 0; i < arr.length; i++)
                arr[i].className = "PI_descTitle";

            $G.Display.Block($G.Get.ById("PI_Desc_" + page));
            lnk.className = "PI_descTitleA";
        },
        ChangePicture: function(obj) {
             var cont = $G.Get.ById('main_img');             
              cont.src=obj.src;              
              cont.setAttribute('attrid',obj.getAttribute('attrid').toString());              
              var article = $G.Get.ById('article');
              article.innerHTML='Артикул: '+obj.alt;
        },
        ChangeArticleGalleryPicture: function(obj) {
              var cont = $G.Get.ById('main_img'); 
              var attrid = cont.getAttribute('attrid');             
              cont.src=obj.src;              
              cont.setAttribute('attrid',obj.getAttribute('attrid').toString());   
              var article = $G.Get.ById('article');
              article.innerHTML='Артикул: '+obj.alt;              
              var defaultborder=obj.style.border;
              var defaultpadding = obj.style.padding;
              obj.style.padding="0px";
              obj.style.margin="5px";
              obj.style.border="solid #ddeedd 5px";                               
              if(attrid!=cont.getAttribute('attrid'))
              {
                var borderarticle =  $G.Get.ById('img_'+attrid);
                borderarticle.style.margin="0px";
                borderarticle.style.padding=defaultpadding; borderarticle.style.border=defaultborder; 
              }
        }                                
    },
    im: {/*
        currency: "",
        showalert: function() {
            alert("sdfsf");
        },*/
        Buy: function(link, askCount, itemId, price) {
            if (price == 0)
                alert("Товар без цены не может быть добавлен в корзину.");
            else {
                var forCancel = $G.Get.ById("recycleContainer").innerHTML;
                $G.Get.ById("recycleContainer").innerHTML = "<img class='recycleLoader' src='/resource/img/im_loader.gif' alt='Добавление товара' title='Добавление товара' />";
                var itemCount = 1;
                if (askCount == "1") {
                    var container = $G.Get.ById("recycleCount");

                    if (container)
                        container.parentNode.removeChild(container);

                    var form = $G.Tag("div", null, "recycleCount");
                    form.width = "80px";
                    form.height = "40px";
                    form.style.display = 'none';

                    var _count = $G.Append(form, $G.Tag("input"));
                    _count.onkeyup = new Function("$m.checkInputs.valid(this,'notnumbers')");
                    _count.onblur = new Function("$m.checkInputs.valid(this,'notnumbers')");
                    _count.value = 1;

                    var imgUp = $G.Tag("img", "recycleBtnUp");
                    imgUp.src = "/resource/img/im_upCountBlue.gif";
                    var imgDown = $G.Tag("img", "recycleBtnDown");
                    imgDown.src = "/resource/img/im_downCountBlue.gif";
                    var imgOk = $G.Tag("img", "recycleBtnOk");
                    imgOk.src = "/resource/img/im_okCount.gif";
                    var imgCancel = $G.Tag("img", "recycleBtnCancel");
                    imgCancel.src = "/resource/img/im_cancelCount.gif";

                    var part = $G.Append(form, $G.Tag("div", "recycleBtnBlock"));

                    var btnUp = $G.Append(part, imgUp);
                    $G.Event.Add(btnUp, "click", function() {
                        _count.value = parseInt(_count.value) + 1;
                    } .bind(this), null, null, null, true);

                    var btnDown = $G.Append(part, imgDown);
                    $G.Event.Add(btnDown, "click", function() {
                        if (parseInt(_count.value) > 1)
                            _count.value = parseInt(_count.value) - 1;
                    } .bind(this), null, null, null, true);

                    var btnOk = $G.Append(form, imgOk);
                    $G.Event.Add(btnOk, "click", function() {
                        var bgcol = $G.GET(link, "up:0");
                        bgcol.style.backgroundColor = "#ddeedd";
                        var req = new Request();
                        req.Send("/ajax.ashx?action=im.Buy&itemId=" + itemId + "&itemPrice=" + price + "&itemCount=" + this._count.value + "&rnd=" + Math.random(), function(req) {
                            $G.Get.ById("recycleContainer").innerHTML = req.responseText;
                            setTimeout(function() { bgcol.style.backgroundColor = "#fff"; }, 300);
                        } .bind({link:link, bgcol:bgcol}), null, null, null, true);
                    } .bind({ _count: _count, btnOk: btnOk, form: form, win: win, btnUp: btnUp, btnDown: btnDown }));

                    var btnCancel = $G.Append(form, imgCancel);
                    $G.Event.Add(btnCancel, "click", function() {
                        var container = $G.Get.ById("recycleCount");
                        if (container)
                            container.parentNode.removeChild(container);
                        $G.Get.ById("recycleContainer").innerHTML = forCancel;
                    } .bind(this), null, null, null, true);

                    $G.Append($G.Get.ById("recycleContainer"), form);
                    var win = $G.ShowUnderObject(form, link);

                }
                else {
                    var bgcol = $G.GET(link, "up:0");
                    bgcol.style.backgroundColor = "#ddeedd";
                    var req = new Request();
                    req.Send("/ajax.ashx?action=im.Buy&itemId=" + itemId + "&itemPrice=" + price + "&itemCount=1&rnd=" + Math.random(), function(req) {
                        $G.Get.ById("recycleContainer").innerHTML = req.responseText;
                        setTimeout(function() { bgcol.style.backgroundColor = "#fff"; }, 300);
                    } .bind(this), null, null, null, true);
                }
            }
        },
        BuyInArticleGallery: function(link, askCount, itemId, price) {
            if (price == 0)
                alert("Товар без цены не может быть добавлен в корзину.");
            else {
                var forCancel = $G.Get.ById("recycleContainer").innerHTML;
                $G.Get.ById("recycleContainer").innerHTML = "<img class='recycleLoader' src='/resource/img/im_loader.gif' alt='Добавление товара' title='Добавление товара' />";
                var itemCount = 1;
                if (askCount == "1") {
                    var container = $G.Get.ById("recycleCount");

                    if (container)
                        container.parentNode.removeChild(container);

                    var form = $G.Tag("div", null, "recycleCount");
                    form.width = "80px";
                    form.height = "40px";
                    form.style.display = 'none';

                    var _count = $G.Append(form, $G.Tag("input"));
                    _count.onkeyup = new Function("$m.checkInputs.valid(this,'notnumbers')");
                    _count.onblur = new Function("$m.checkInputs.valid(this,'notnumbers')");
                    _count.value = 1;

                    var imgUp = $G.Tag("img", "recycleBtnUp");
                    imgUp.src = "/resource/img/im_upCountBlue.gif";
                    var imgDown = $G.Tag("img", "recycleBtnDown");
                    imgDown.src = "/resource/img/im_downCountBlue.gif";
                    var imgOk = $G.Tag("img", "recycleBtnOk");
                    imgOk.src = "/resource/img/im_okCount.gif";
                    var imgCancel = $G.Tag("img", "recycleBtnCancel");
                    imgCancel.src = "/resource/img/im_cancelCount.gif";

                    var part = $G.Append(form, $G.Tag("div", "recycleBtnBlock"));

                    var btnUp = $G.Append(part, imgUp);
                    $G.Event.Add(btnUp, "click", function() {
                        _count.value = parseInt(_count.value) + 1;
                    } .bind(this), null, null, null, true);

                    var btnDown = $G.Append(part, imgDown);
                    $G.Event.Add(btnDown, "click", function() {
                        if (parseInt(_count.value) > 1)
                            _count.value = parseInt(_count.value) - 1;
                    } .bind(this), null, null, null, true);

                    var btnOk = $G.Append(form, imgOk);
                    $G.Event.Add(btnOk, "click", function() {
                        var bgcol = $G.GET(link, "up:0");
                        bgcol.style.backgroundColor = "#ddeedd";
                        var req = new Request();
                        req.Send("/ajax.ashx?action=im.Buy&itemId=" + itemId + "&itemPrice=" + price + "&itemCount=" + this._count.value + "&rnd=" + Math.random(), function(req) {
                            $G.Get.ById("recycleContainer").innerHTML = req.responseText;
                            setTimeout(function() { bgcol.style.backgroundColor = "#fff"; }, 300);
                        } .bind({link:link, bgcol:bgcol}), null, null, null, true);
                    } .bind({ _count: _count, btnOk: btnOk, form: form, win: win, btnUp: btnUp, btnDown: btnDown }));

                    var btnCancel = $G.Append(form, imgCancel);
                    $G.Event.Add(btnCancel, "click", function() {
                        var container = $G.Get.ById("recycleCount");
                        if (container)
                            container.parentNode.removeChild(container);
                        $G.Get.ById("recycleContainer").innerHTML = forCancel;
                    } .bind(this), null, null, null, true);

                    $G.Append($G.Get.ById("recycleContainer"), form);
                    var win = $G.ShowUnderObject(form, link);

                }
                else {
                    var bgcol = $G.Get.ById("BuyLink");                            
                    bgcol.style.backgroundColor = "#ddeedd";   
                    var req = new Request();
                    req.Send("/ajax.ashx?action=im.Buy&itemId=" + itemId + "&itemPrice=" + price + "&itemCount=1&rnd=" + Math.random(), function(req) {
                        $G.Get.ById("recycleContainer").innerHTML = req.responseText;
                        setTimeout(function() { GalleryArticle.Close(); }, 300);
                    } .bind(this), null, null, null, true);
                }
            }
        },        
        Clear: function() {
            var req = new Request();
            req.Send("/ajax.ashx?action=im.Clear&rnd=" + Math.random(), function(req) {
                $m.im.Show();
            } .bind(this), null, null, null, true);
        },
        inOrder: function() {
            document.location.href = '/Recycle.aspx';
        },
        doOrder: function() {
            if ($m.im.Sum() > 0)
                document.location.href = '/Order.aspx';
            else
                alert("Сумма вашего заказа равна 0, измените состояние заказа перед его формированием.");
        },
        Show: function() {
            var req = new Request();
            req.Send("/ajax.ashx?action=im.Show&rnd=" + Math.random(), function(req) {
                $G.Get.ById("recycleContainer").innerHTML = req.responseText;
            } .bind(this), null, null, null, true);
        },
        Count: function(oper, itemId, currency, articleId) {
            var inpt = $G.Get.ById('inp_' + itemId+'_'+articleId);
            if (oper == "del")
                inpt.value = 0;
            else {
                var precount = parseInt(inpt.value) + (oper == "up" ? 1 : -1);
                if (precount == 0) {
                    inpt.value = 1;
                    return;
                }
                else { inpt.value = precount; }
            }
            $m.im.ChangeCount(itemId, inpt.value,articleId);
            $m.im.Sum(currency);
            if (parseInt(inpt.value) == 0) {
                var tr = $G.GET(inpt, "up:2");
                var tbl = $G.GET(tr, "up:1");
                tr.parentNode.removeChild(tr);
            }
            if ($m.im.Sum() == 0) {
                tbl.parentNode.removeChild(tbl);
                alert("В корзине не осталось товаров.");
                document.location.href = "/";
            }
        },
        Sum: function(curency) {
            var sum = 0;
            var cont = $G.GET($G.Get.ById('recycleTbl'), "tbody:0");
            var firstLvl = $G.Get.ByTag(cont, 'tr');
            for (var i = 0; i < firstLvl.length; i++) {
                var secondLvl = $G.Get.ByTag(firstLvl[i], 'td');
                sum = sum + (parseInt($G.GET(secondLvl[1], 'input').value) * parseInt(secondLvl[2].innerHTML.replace(" " + curency, "").trim()));
            }
            $m.im.Show();

            if (curency != null) {
                var bin1 = $G.Get.ById("recycleSumUp");
                if (bin1)
                    bin1.innerHTML = sum + " " + curency;
                var bin2 = $G.Get.ById("recycleSumDown");
                if (bin2)
                    bin2.innerHTML = sum + " " + curency;
            }
            else
                return sum;
        },
        ChangeCount: function(itemId, count,articleId) {
            var req = new Request();            
            req.Send("/ajax.ashx?action=im.ChangeCount&itemId=" + itemId+"$"+articleId + "&itemCount=" + count + "&rnd=" + Math.random(), function(req) {
                // some code                
            } .bind(this), null, null, null, true);
        }
    },
    fb: {
        CheckFields: function() {
            var _form = document.getElementById('defaultForm');
            var objs = _form.getElementsByTagName("input");
            var result = true;
            for (var i = 0; i < objs.length; i++) {
                if (objs[i].name.indexOf("aqu_") > -1) {
                    if (objs[i].name.indexOf("_1x") > -1 && objs[i].value == "") {
                        alert("Одно или несколько обязательных полей незаполненны. Рассчет данных невозможен.");
                        result = false;
                        break;
                    }

                }
            }
            if (result) {
                var a = $G.GET($G.Get.ById("FB_hidenLink"), "a:0");
                __doPostBack(a.id.toString().replace("_", "$"), "");
            }
        },
        calculate: function() {
            var arrea = document.getElementById("checks_list");
            if (arrea) {
                var inputs = arrea.getElementsByTagName("input");
                var result = 0;
                var summ = document.getElementById("CountBox");
                for (var i = 0; i < inputs.length; i++) {
                    var input = inputs[i];
                    if (input.type == "radio" || input.type == "checkbox")
                        if (input.value != "")
                        if (input.checked)
                        result += parseInt(input.value);
                }
                if (summ)
                    summ.value = result.toString() + " руб.";
            }
        },
        _clear: function() {
            var arrea = document.getElementById("checks_list");
            if (arrea) {
                var inputs = arrea.getElementsByTagName("input");
                var summ = document.getElementById("CountBox");
                for (var i = 0; i < inputs.length; i++) {
                    var input = inputs[i];
                    if (input.type == "radio" || input.type == "checkbox")
                        input.checked = false;
                }
                if (summ)
                    summ.value = "0 руб.";
            }
        }
    },
    SetHiddenValuesForSearch: function() {
        var hiddenSearchValue = null;
        var txtSearchValue = null;

        for (var i = 0; i < document.all.length; i++) {
            var obj = document.all.item(i);
            if (obj.id != "") {
                if (obj.id.indexOf("hiddenSearchValue") > -1)
                    hiddenSearchValue = obj;

                if (obj.id.indexOf("txtSearchValue") > -1)
                    txtSearchValue = obj;
            }
        }
        if (hiddenSearchValue != null && txtSearchValue != null)
            hiddenSearchValue.value = txtSearchValue.value;
    }
}
var $M = $m;


// Скопировано из base.js
// Модуль, исправляющий ошибку, связаную с некорректным отображением PNG файлов в IE 6 и ниже
// и содержащий в себе все дополнения к конкретному сайту
function fixPNG() {
    for (var i = 0; i < document.images.length; i++) {
        var img = document.images[i];
        imgSrc = img.src;
        if (imgSrc.substr(imgSrc.length - 3).toLowerCase() == "png") {
            var w, h;
            w = img.width, h = img.height;
            img.src = "/res/img/px.gif";
            img.width = w, img.height = h;
            img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'" + imgSrc + "\', SizingMethod='scale');";
        }
    }
}
function fixPNGBackground(id, src) {
    var obj = document.getElementById(id);
    if (obj) {
        obj.style.background = "url(/res/img/px.gif) repeat left top";
        obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'" + src + "\', SizingMethod='scale');";
        obj.parentNode.style.background = "url(/res/img/px.gif) repeat left top";
    }
}
function isIE() {
    return ((navigator.userAgent.indexOf("IE") != -1) && (navigator.userAgent.indexOf("Opera") == -1));
}
if (isIE()) {
    window.attachEvent("onload", fixPNG);
}
function isIE6() {
    return isIE() && (navigator.userAgent.indexOf("IE 6") != -1);
}
function isFirefox() {
    return (navigator.userAgent.indexOf("Firefox") != -1);
}

function GetArticle() {
            var article= $G.Get.ById('main_img');                            
            if(article.getAttribute('attrid').toString()=='')                           
             return '6';  
            else            
             return article.getAttribute('attrid').toString();
}
function collapsElement(div, a)
{
 var txt = document.getElementById(div);
 var a = document.getElementById(a);
 txt.className = txt.className == "show" ? "no_show" : "show";
 a.className = a.className == "show" ? "no_show" : "show";
}
