      var d = document;


      function $(id, f){
        return eval('d.getElementById(id)' + (f? '.style' : ''));
        }
        function hideShow(id) {
        if(d.getElementById(id))
        d.getElementById(id).style.display =(d.getElementById(id).style.display=='')?'none':'';
        }
        function showdiv(id) {
        if (document.getElementById) {
        document.getElementById(id).style.display = 'block';
        }
        }
        function hidediv(id) {
        if (document.getElementById) {
        document.getElementById(id).style.display = 'none';
        }
        }

      function changeVal(obj, priv, pub, capId){
        obj.value = (obj.value == priv)?pub:priv;
        obj.parentNode.className = (obj.parentNode.className == 'inEdit')?'inEdit pr':'inEdit';
        $(capId).className = ($(capId).className == '')?'pr':'';
      }


      function selectTab (newTabId, oldTabId, selTabNum){
        newTab = $(newTabId);
        newTab.className += " sel";
        if (oldTabId) {
          oldTab = $(oldTabId);
          oldTab.className = oldTab.className.substring(0,oldTab.className.length-3); // ����� �� ���������� �� ��� � .sel
          hideShow (oldTabId+'Cont');
          hideShow (oldTabId+'glink');
        }
        hideShow (newTabId+'Cont');
        hideShow (newTabId+'glink');
        switch(selTabNum) {
          case 1:
            selTab1 = newTabId;
            break;
          case 2:
            selTab2 = newTabId;
            break;
          case 3:
            selTab3 = newTabId;
            break;
          case 4:
            selTab4 = newTabId;
            break;
          case 5:
            selTab5 = newTabId;
            break;
          case 6:
            selTab6 = newTabId;
            break;
          default:
            selTab = newTabId;
        }
        hideShow(oldTabId);
        showdiv(newTabId);
      }

      function pushDetails(id, vip) {
        if(document.getElementById(id).className == "pusher_plus"){
            hidediv('s'+id);
            showdiv('sd'+id);
            document.getElementById(id).className = "pusher_minus";
        }else{
            hidediv('sd'+id);
            showdiv('s'+id);
            document.getElementById(id).className = "pusher_plus";
        }
      }


      function voteForLink(idOn, idOff, lid, vote) {
        document.getElementById(idOn).style.display = 'none';
        document.getElementById(idOff).style.display = 'inline';
        sendVoteRequest(lid, vote);
      }

      function sendVoteRequest(id, vote){
            var req734 = null;
            if (window.XMLHttpRequest) {
                req734 = new XMLHttpRequest();
            } else if (window.ActiveXObject) {
                req734 = new ActiveXObject("Microsoft.XMLHTTP");
            }
            var url = "/link/vote/" + id + "/" + vote;
            req734.open("GET", url, true);
            req734.onreadystatechange = callback_sendvote( req734 );
            req734.send(null);
      }

      function callback_sendvote(req) {
        return function() {
            if (req.readyState == 4) {
                if (req.status == 200) {
                    // do nothing :)
                }
            }
        }
      }

      function addToFavorites(url, title) {
        if (document.all)  // ie
            window.external.AddFavorite(url, title)
        else if (window.sidebar) // firefox
            window.sidebar.addPanel(title, url, "");
      }

      function unsetZIndex(){
        document.getElementById('topTabs').style.zIndex = 0;
      }
      function setZIndex(){
        document.getElementById('topTabs').style.zIndex = 1000;
      }

      function getIntFromId (selObj){
        num = parseInt(selObj.substring((selObj.length - 1),selObj.length));
        return num;
      }

      /*function getTabId(type, iCount, selTab){  // type is 'prev' or 'next'
        switch(selTab) {
          case selTab4:
            objName = 'n';
            break;
          default:
            objName = 'sv';
        }
        numId = getIntFromId(selTab);
        if (type == 'next') {
          if (numId < iCount) numId += 1;
          else  numId = 1;
        } else if (type == 'prev') {
          if (numId > 1) numId -= 1;
          else numId = iCount;
        } else numId = 1;
        objId = objName + numId;
        return objId;
      }*/

      function getTabId(type, newsCount){  // type is 'prev' or 'next'
        numId = getIntFromId(selTab4);
        if (type == 'next') {
          if (numId < newsCount) numId += 1;
          else  numId = 1;
        } else if (type == 'prev') {
          if (numId > 1) numId -= 1;
          else numId = newsCount;
        } else numId = 1;
        objId = 'n' + numId;
        return objId;
      }

      function getTabIdSv(type, svCount){  // type is 'prev' or 'next'
        numId = getIntFromId(selTab6);
        if (type == 'next') {
          if (numId < svCount) numId += 1;
          else  numId = 1;
        } else if (type == 'prev') {
          if (numId > 1) numId -= 1;
          else numId = svCount;
        } else numId = 1;
        objId = 'sv' + numId;
        return objId;
      }

      function getRondomDigit(num){
        i = Math.round(num*Math.random())+1;
        return i;
      }

      function chBtn(btn){
        btn.className = (btn.className == 'sel')?'':'sel';
      }


			days = ['������', '����������','�������','�����','���������','�����','������'];
      function chWather (cat, t){

      	var d = new Date();
				var w = d.getDay();
				w = ( w + 2 ) % 7;

        html =
          '<div class="cl_wh"><div id="wh_img"><a ' +
          'href="http://b.abv.bg/app/servlet/hitb?SID=2&PID=6666&banID=33258&link=http://sinoptik.bg/?lid=' + cat[4] + '" target="_blank"><img ' +
          'src="i/w/' + cat[5] + '.jpg" alt="' + cat[1][2] + '" width="104" valign="center" title="' + cat[1][2] + '" border="0" /></a></div></div>' +
          '<div class="cr_wh"><div class="wh_city"><table cellspacing="0" cellpadding="0"><tr><td><b><a ' +
          'href="http://b.abv.bg/app/servlet/hitb?SID=2&PID=6666&banID=33258&link=http://sinoptik.bg/?lid=' + cat[4] + '" target="_blank">' + cat[0] + '</a></b></td><td>' +
          '<a id="whBtn" href="#a" onclick="hideShow (\'forecast\'); hideShow(\'cities\'); chBtn(this); hit(33256);"></a>' +
          '</td></tr></table></div>' +
          '<div class="wh_tempr"><b>' + cat[2] + '</b><br/>����� �� ����<br/>' + cat[3] + '</div></div>' +
          '<a href="http://b.abv.bg/app/servlet/hitb?SID=2&PID=6666&banID=33258&link=http://sinoptik.bg/?tid=20*oid=100*lid=' + cat[4] + '" target="_blank" class="fl forecast10">10 ������ ��������</a>';
        $('forecast').innerHTML = html;
        $('cityIn').innerHTML = '<a href="http://sinoptik.bg/" target="_blank">' + '�����'.toUpperCase() + '</a>';

        if (!t){
          hideShow ('forecast');
          hideShow('cities');
          hit(33257);
        }

        SetCookie('weatherCookieN', 'id_'+cat[4], (24*7*3600), '/', 'gbg.bg', '');
      }

      function euro2008 (){
        html =
          '<td class="euro_cont"><a href="http://adv.abv.bg/new/clickCountpro.php?banID=38392&SID=2&PID=6666&link=' + euro_1[2].replace("&","*") + '" target="_blank"><img src="i_euro/eu_1.jpg" width="65" height="65" ' +
          'border="0" alt="" align="left" hspace="8" /></a><a href="http://adv.abv.bg/new/clickCountpro.php?banID=38392&SID=2&PID=6666&link=' + euro_1[2].replace("&","*") + '" target="_blank">' + euro_1[0] + '</a></td>' +
          '<td class="euro_cont"><a href="http://adv.abv.bg/new/clickCountpro.php?banID=38392&SID=2&PID=6666&link=' + euro_2[2].replace("&","*") + '" target="_blank"><img src="i_euro/eu_2.jpg" width="65" height="65" ' +
          'border="0" alt="" align="left" hspace="8" /></a><a href="http://adv.abv.bg/new/clickCountpro.php?banID=38392&SID=2&PID=6666&link=' + euro_2[2].replace("&","*") + '" target="_blank">' + euro_2[0] + '</a></td>' +
          '<td class="euro_cont"><a href="http://adv.abv.bg/new/clickCountpro.php?banID=38392&SID=2&PID=6666&link=' + euro_3[2].replace("&","*") + '" target="_blank"><img src="i_euro/eu_3.jpg" width="65" height="65" ' +
          'border="0" alt="" align="left" hspace="8" /></a><a href="http://adv.abv.bg/new/clickCountpro.php?banID=38392&SID=2&PID=6666&link=' + euro_3[2].replace("&","*") + '" target="_blank">' + euro_3[0] + '</a></td>';

        document.write(html);
      }

      function olympics2008 (){
        html =
          '<td class="olympics_cont"><a href="http://adv.abv.bg/new/clickCountpro.php?banID=39736&SID=1&PID=6666&link=' + olympics_1[2].replace("&","*").replace("olympics","olimpiada2008") + '" target="_blank"><img src="i_olympics/olympics_1.jpg" width="65" height="65" ' +
          'border="0" alt="" align="left" hspace="8" /></a><a href="http://adv.abv.bg/new/clickCountpro.php?banID=39736&SID=1&PID=6666&link=' + olympics_1[2].replace("&","*").replace("olympics","olimpiada2008") + '" target="_blank" ' +
          'alt="' + ((olympics_1[0].length > 60) ? olympics_1[0] : "") + '" title="' + ((olympics_1[0].length > 60) ? olympics_1[0] : "") + '">' + olympics_1[0].substring(0, 60) + ((olympics_1[0].length > 60) ? " ..." : "") + '</a></td>' +
          '<td class="olympics_cont"><a href="http://adv.abv.bg/new/clickCountpro.php?banID=39736&SID=1&PID=6666&link=' + olympics_2[2].replace("&","*").replace("olympics","olimpiada2008") + '" target="_blank"><img src="i_olympics/olympics_2.jpg" width="65" height="65" ' +
          'border="0" alt="" align="left" hspace="8" /></a><a href="http://adv.abv.bg/new/clickCountpro.php?banID=39736&SID=1&PID=6666&link=' + olympics_2[2].replace("&","*").replace("olympics","olimpiada2008") + '" target="_blank" ' +
          'alt="' + ((olympics_2[0].length > 60) ? olympics_2[0] : "") + '" title="' + ((olympics_2[0].length > 60) ? olympics_2[0] : "") + '">' + olympics_2[0].substring(0, 60) + ((olympics_2[0].length > 60) ? " ..." : "") + '</a></td>' +
          '<td class="olympics_cont"><a href="http://adv.abv.bg/new/clickCountpro.php?banID=39736&SID=1&PID=6666&link=' + olympics_3[2].replace("&","*").replace("olympics","olimpiada2008") + '" target="_blank"><img src="i_olympics/olympics_3.jpg" width="65" height="65" ' +
          'border="0" alt="" align="left" hspace="8" /></a><a href="http://adv.abv.bg/new/clickCountpro.php?banID=39736&SID=1&PID=6666&link=' + olympics_3[2].replace("&","*").replace("olympics","olimpiada2008") + '" target="_blank" ' +
          'alt="' + ((olympics_3[0].length > 60) ? olympics_3[0] : "") + '" title="' + ((olympics_3[0].length > 60) ? olympics_3[0] : "") + '">' + olympics_3[0].substring(0, 60) + ((olympics_3[0].length > 60) ? " ..." : "") + '</a></td>';

        document.write(html);
      }

      function show_svejo_news (svejo_news, j){
        html = '<div id="sv' + j + 'Cont" class="svejoCont">' +
          '<a href="' + svejo_news[2] + '" alt="' + htmlspecialchars(svejo_news[0]) + '" title="' + htmlspecialchars(svejo_news[0]) + '" target="_blank"><img src="' + svejo_news[1] + '" alt="' + htmlspecialchars(svejo_news[0]) + '" title="' + htmlspecialchars(svejo_news[0]) + '" /></a>' +
          '<a href="' + svejo_news[2] + '" alt="' + ((svejo_news[0].length > 50) ? htmlspecialchars(svejo_news[0]) : "") + '" ' +
          'title="' + ((svejo_news[0].length > 50) ? htmlspecialchars(svejo_news[0]) : "") + '" target="_blank">' + svejo_news[0].substring(0, 50) + ((svejo_news[0].length > 50) ? " ..." : "") + '</a><br />' +
          svejo_news[3].substring(0, 180) + ((svejo_news[3].length > 180) ? " ..." : "") +
        '</div>';
        document.write(html);
      }

      function show_tag (tag){
        html = '&nbsp;&nbsp;<a href="' + encodeURI(strstr(tag[1], 'http://svejo.net')) + '" target="_blank">' + tag[0] + '</a>&nbsp;&nbsp; ';
        document.write(html);
      }

      function htmlspecialchars(str) {
         if (typeof(str) == "string") {
          str = str.replace(/&/g, "&amp;"); /* must do &amp; first */
          str = str.replace(/"/g, "&quot;");
          str = str.replace(/'/g, "&#039;");
          str = str.replace(/</g, "&lt;");
          str = str.replace(/>/g, "&gt;");
          }
          return str;
      }

      function strstr(_s, _k)
      {
          var _idx = _s.indexOf(_k);
          if (_idx >= 0)
          {
              return _s.substr(_idx);
          }
          else
          {
              return false;
          }
      }

      function pariteni_calc (){
        var random = Math.floor(Math.random()*5);
        var calc = Array();
        calc[0] = ['�������� ����������',
        '��������� ��������� ������ � �������, ����� �� ������ �� ������� ��� ������� �� ������.',
        'http://pariteni.bg/Calcs/2/3c59dc048e88502415.html'
        ];
        calc[1] = ['���������� ��������',
        '�������� ������,����� �� �������� � �������� �������! ��������� ����� �� �������� � ���� �� �����',
        'http://pariteni.bg/Calcs/3/c20ad4d76fe97759c.html'
        ];
        calc[2] = ['��������������� �������� �� ���� ����������',
        '��������� ��������������� ��������������� �������� �� ���� ����������',
        'http://pariteni.bg/Calcs/4/8f14e45fceea167a7.html'
        ];
        calc[3] = ['������� �� �����������',
        '��������� ������ �� �����. ����� ����� ������ �� �� ������ ����� ��������',
        'http://pariteni.bg/Calcs/5/eccbc87e4b5ce2fe3.html'
        ];
        calc[4] = ['���������� ����� ��� �������',
        '��������� ������������ � ������� ����� ��� ���������� � ���������� �� �������',
        'http://pariteni.bg/Calcs/21/4e732ced3463d06d1a.html'
        ];

        html =
          '<a href="http://adv.abv.bg/new/clickCountpro.php?banID=38888&SID=2&PID=6666&link=' + calc[random][2] + '" target="_blank">' + calc[random][0] + '</a>' +
          '<div class="contText">' + calc[random][1] + '</div>';

        document.write(html);
      }

      function pariteni_news (){
        html1 =
          '<a href="http://adv.abv.bg/new/clickCountpro.php?banID=38888&SID=2&PID=6666&link=' + pn_news[2].replace("pariteni.com","pariteni.bg") + '" target="_blank">' + pn_news[0] + '</a>' +
          '<div class="contText">' + pn_news[1] + '</div>';

        document.write(html1);
      }

      function chValuti (vCat, t){
        html = '<img src="http://spravochnik.netinfo.bg/k/c/' + vCat[1] + '" /> &nbsp; ' + vCat[0] + ' &nbsp; <span>' + vCat[2] + '</span>';
        $('valuta').innerHTML = html;
        if (!t){
          hideShow('vTypes');
          chBtn($('valBtn'));
        }
        SetCookie('valutiCookie', vCat[0], (24*7*3600), '/', 'gbg.bg', '');
      }



      // cookie functions
      function SetCookie(name,value,expires,path,domain,secure){
        var today=new Date();
        today.setTime(today.getTime());
        if(expires) expires=expires*1000*60*60*24;
        var expires_date = new Date(today.getTime()+(expires));
        document.cookie=name+"="+escape(value)+((expires)?";expires="+expires_date.toGMTString():"")+((path)?";path="+path:"")+((domain)?";domain="+domain:"")+((secure)?";secure":"");
      }

      function GetCookie(name) {
        var start=document.cookie.indexOf(name+"=");
        var len=start+name.length+1;
        if((!start)&&(name!=document.cookie.substring(0,name.length))) return null;
        if(start==-1) return null;
        var end=document.cookie.indexOf(";",len);
        if(end==-1) end=document.cookie.length;
        return unescape(document.cookie.substring(len,end));
      }

      function DeleteCookie(name,path,domain){
        var exp=new Date();
        exp.setTime(exp.getTime()-1);
        if(GetCookie(name)) document.cookie=name+"="+((path)?";path="+path:"")+
        ((domain)?";domain="+domain:"" )+";expires="+exp.toGMTString();
      }

      function checkCoockie(domain){
        if (document.cookie.length) return 1;
        else return 0;
      }


      function chUrl(aObj, url){
        if (aObj.className.indexOf('sel') != -1){
          aObj.href = "http://ukazatel.gbg.bg/" + url + "/";
          return false;
        } else aObj.href = "#1";
      }


function hit(str){
  var url="http://b.abv.bg/app/servlet/hitb?SID=2&PID=6666&banID="+str;
  document.getElementById("countFirstClick").src = url;
}

var tabs = new Array('net','gyu','pix','video','nws','know');
function changeTab (tab) {
d.getElementById('schEn').className = tab.id;
for(var x in tabs){
d.getElementById(tabs[x]).className = tab.id != tabs[x]? '' : 'sel';
if(tab.id != tabs[x])
hidediv('mid'+tabs[x]);
else
showdiv('mid'+tabs[x]);
}
}
function submitTab (n) {
  d.forms[n].submit();
}
function _(o, _e, id){
return eval('o.getElementsByTagName("' + _e + '")[' + (id? id : 0) + ']');
}

function showDetails(id) {
	if(document.getElementById(id).className == "pusher_plus"){
       //showdiv('er'+id);
       //showdiv('i'+id);
       document.getElementById('s'+id).innerHtml = '��������� ������ �� �����-����� �������, ������ ���������� � ���� ����������, ��������� ���� 1999 ������. ��������� ������ �� �����-����� �������, ������ ���������� � ���� ����������, ��������� ���� 1999 ������. ��������� ������ �� �����-����� �������, ������ ���������� � ���� ����������, ��������� ���� 1999 ������.';
       document.getElementById(id).className = "pusher_minus";
    }else{
       //hidediv('er'+id);
       //hidediv('i'+id);
       document.getElementById('s'+id).innerHtml = '��������� ������ �� �����-����� �������, ������ ���������� � ���� ����������, ��������� ���� 1999 ������.';
       document.getElementById(id).className = "pusher_plus";
    }
}
