//////////////////////////////////////////////////////////////////////////ToKreci.pl//////////////////////////////////////////////////////////////////////////
//Zabrania się wykorzystywania niniejszych skryptów. Wszelkie prawa zasttrzeżone

function okno(adres,w,h){
    window.open('http://www.tokreci.pl/'+adres,'tokreci','scrollbars=yes, resizable=yes, height='+h+', width='+w+', left='+ (window.top.screen.width / 2 - (w/2) ) +', top='+ (window.top.screen.height / 2 - (h/2) ));
    return false;
}

function wstaw(nick,id){
    f = window.opener.document.forms["friend"];
    f.user.value=id;
    f.nick.value=nick;
    window.close();
}
function max(obj,max){
    if (obj.value.length>max)
         obj.value=obj.value.substring(0,max)
}

//opis do mini menu
function des(oGet, hide){
    oDes = document.getElementById('label');
    oDes.innerHTML = (hide) ? oGet.title : '';
}

//show/hide
function visable(obj){
    var obj = document.getElementById(obj).style;
    obj.display = (obj.display!=='block') ? 'block' : 'none';
    return false;
}
//Pozdrowienia

function greeting(){
       //setTimeout( function(){ alphaDown(100) }, 5000);
       var greatings = '';
       for(i=0; i<=gLength; i++){
           greatings += '\n<div style="height:25px;"><a href="http://' + greating[i][1] + '.tokreci.pl" style="font-weight:bold;color:#fff">' + greating[i][0] + ':</a> ' + greating[i][2] + '</div>\n';
       }
       document.getElementById('greeting').innerHTML = greatings;
       window.setInterval("alphaDown(100)", 5000);

}
gTop = 0;
function greeting_go(){
    var obj = document.getElementById('greeting').style;
    if(gTop>gLength)gTop = 0;
    var top = gTop * (-25);
    gTop += 1;
    obj.marginTop = top + 'px';
}
    gGo = 0;
function alphaUp(ile){
    if(gGo>0)greeting_go();
    gGo = 0;
    if(ile<101)
              setTimeout( function(){ alphaUp(ile+=10) }, 100);
    alpha(ile);
}
function alphaDown(ile){
    gGo = 1;
    if(ile>0)
             setTimeout( function(){ alphaDown(ile-=10) }, 100);
    else
             setTimeout( function(){ alphaUp(ile) }, 100);
    alpha(ile);
}
function alpha(ile){
    if(ile>101)
        return false;

    var obj = document.getElementById('greeting');

    if(navigator.appName==='Microsoft Internet Explorer')
        obj.filters.alpha.opacity = ile;
    else
        obj.style.MozOpacity = ile/100;
}


//BBCode form

function bbInsertMore(str, end, pole, window, def){
         var plus = prompt(window, def);
         if(plus!=='null' && plus.lastIndexOf("http://")==0 && plus!==def){
             var co = str + plus + end;
             bbInsert(co, pole);
         }
}

function bbInsert(co, pole){
         var txtarea = document.forms["bb"].elements[pole];
         if(navigator.appName!=='Microsoft Internet Explorer'){
                  var selStart = txtarea.selectionStart;
                  var selEnd   = txtarea.selectionEnd;

                  var start = txtarea.value.substring(0, selStart);
                  var quote = txtarea.value.substring(selStart, selEnd);
                  var end   = txtarea.value.substring(selEnd, txtarea.value.length);

                  var re = /\]\[/;
                  if(co.search(re)>=0){
                           var bb = co.split("][");
                           txtarea.value = start+bb[0]+']' + quote + '['+bb[1]+end;
                  }else{
                           txtarea.value=start + quote + co + end;
                  }
         }else{
                  txtarea.value = txtarea.value + co;
         }
         txtarea.focus();
}

//Zaznaczenie wiadomsoci w Prywatne wiadomosci

function select_mail(id,ch){
    document.getElementById('mail_' + id).className = (ch) ? 'hl' : '';
}

function select_del(act){

    var fr = document.forms['mails'].elements;
    for (i=0;i<fr.length;i++) {
      if(fr[i].type==='checkbox')
        if(act==='all'){
          fr[i].checked = true;
          select_mail(fr[i].value, true);
        }else if(act==='delall'){
          fr[i].checked = false;
          select_mail(fr[i].value, false);
        }else if(act==='change'){
          var a = (fr[i].checked) ? false : true;
          fr[i].checked = a;
          select_mail(fr[i].value, a);
        }else{
          fr[i].checked = false;
          select_mail(fr[i].value,false);
          if(fr[i].alt===act){
             fr[i].checked=true;
             select_mail(fr[i].value,true);
          }
        }
    }
    return false;
}

//menu
function moreData(id){
    var dis = document.getElementById(id).style;
    dis.display = ( dis.display === 'none' ) ? 'block' : 'none';

}
function moreBBcode(id, obj){
    var dis = document.getElementById(id).style;
    dis.display = ( dis.display === 'block' ) ? 'none' : 'block';
    dis.left = obj.offsetLeft + 'px';
    dis.top  = ( obj.offsetTop + obj.clientHeight - 3 ) + 'px';
}
function moreBBcode2(id){
    var dis = document.getElementById(id).style;
    dis.display = ( dis.display === 'block' ) ? 'none' : 'block';
}

//Czy faktycznie....
function DoYouWant(text){
    result = confirm(text);
    return result;
}
