
function getRequestBody(oForm) {
    var aParams = new Array();
    for(var i = 0; i < oForm.elements.length; i++) {
        var sParam = encodeURIComponent(oForm.elements[i].name);
        sParam += "=";
        sParam += encodeURIComponent(oForm.elements[i].value);
        aParams.push(sParam);
    };
    return aParams.join("&");
};





    function changeTab(tabBox,tab,totalTabs)
{
    var box = $('#tab_box_' + tabBox);
    var parent_box = box.closest('.tab_box');
    var tabs = box.find('td');
    tabs.removeClass('selected');
    box.find('#tab_' + tabBox + '_' + tab).addClass('selected');
    parent_box.find('.tab_content > div').hide();
    parent_box.find('#tab_content_' + tabBox + '_' + tab).show();

	return false;
}

function open_win(addr)
{
 pipupWin = window.open(addr,'newwin','width=300,height=200,toolbar=0') ;
 pipupWin.focus();
}



function changeLogin(select){
  var selectVal = select.options[select.selectedIndex].value;
     if(selectVal == 0 || selectVal == 1 || selectVal ==2 || selectVal==3 || selectVal==4) {


       if(selectVal == 0){
 document.getElementById('zz_openidlogin').style.display = 'none';
 document.getElementById('zz_anonim').style.display = '';
  document.getElementById('zz_tab_box').style.display = 'none';

       }

           if(selectVal == 1){
 document.getElementById('zz_openidlogin').style.display = 'none';
 document.getElementById('zz_anonim').style.display = 'none';
 document.getElementById('zz_tab_box').style.display = '';
       }

        if(selectVal == 2){
 document.getElementById('zz_openidlogin').style.display = '';
 document.getElementById('zz_anonim').style.display = 'none';
 document.getElementById('zz_openid_server').value    =   'lj';
  document.getElementById('zz_tab_box').style.display = 'none';
 document.getElementById('zz_openid_val').className="zz-input-openid zz-livejournal";
       }

          if(selectVal == 3){
 document.getElementById('zz_openidlogin').style.display = '';
 document.getElementById('zz_anonim').style.display = 'none';
   document.getElementById('zz_tab_box').style.display = 'none';
 document.getElementById('zz_openid_server').value    =   'rambler';
  document.getElementById('zz_openid_val').className="zz-input-openid zz-rambler";
       }

               if(selectVal == 4){
 document.getElementById('zz_openidlogin').style.display = '';
 document.getElementById('zz_anonim').style.display = 'none';
   document.getElementById('zz_tab_box').style.display = 'none';
 document.getElementById('zz_openid_server').value    =   '';
  document.getElementById('zz_openid_val').className="zz-input-openid zz-openid";
       }




 function closeOpenId(){
      document.getElementById('zz_openidlogin').style.display = 'none';
document.getElementById('zz_openid_server').value    =   '';
  document.getElementById('zz_tab_box').style.display = 'none';
 }

function goEnter(){
var openidVal =  document.getElementById("zz_openid_val").value;
if(openidVal == ''){alert("Введите логин!"); return false;};
   document.location.href = document.getElementById("zz_gotolink").value + "&login=" + openidVal + "&server="+document.getElementById('zz_openid_server').value;
}

/*

   $("#zz_openid_enter").click(function(){

  });

*/



       return false;

     }

			location.href = select.options[select.selectedIndex].value;

}


function ctrlEnter(event, formElem)
{
    if((event.ctrlKey) && ((event.keyCode == 0xA)||(event.keyCode == 0xD)))
    {
	document.getElementById('zzSendText').value='Подождите...';
        sendData(formElem);
    };
};

function quickreply(tree) {

var commentForm =  document.getElementById('zz_addComment');



 var replyToField = document.getElementById('replyto');


     if(tree==0){
     document.getElementById('zz_showMain').style.display = 'none';
document.getElementById('zz_butt_answer'+replyToField.value).style.display = '';
     var currentComment = document.getElementById('zz_showForm');
         }else{

         document.getElementById('zz_butt_answer'+tree).style.display = 'none';

          document.getElementById('zz_showMain').style.display = '';
          var currentComment = document.getElementById('zz_usercomment_'+tree);
         };


replyToField.value = tree;


    currentComment.parentNode.insertBefore(commentForm, currentComment.nextSibling);
   document.getElementById('zz_qcom').focus();





    return false;
};

function goTo(link){
    window.location.href = link;
};


var Url = {


    encode : function (string) {
        return escape(this._utf8_encode(string));
    },


    decode : function (string) {
        return this._utf8_decode(unescape(string));
    },


    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            };
        };

        return utftext;
    },


    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            };

        };

        return string;
    }

};



function notice(text){
    alert(text);
    return false;
}





function voteComment(u,vote){
    var data = new Object();
    if(!eluserID){notice("Необходимо войти  на сайт или зарегистрироваться!"); return false;}
    if(vote){

        HttpRequest.post("http://deita.ru/users/voteup/"+u, data,

			 function(responseg) {
            if(responseg.result == 'ok')
                document.getElementById('rateid'+u).innerHTML= (responseg.rating>0)?"+"+responseg.rating:responseg.rating;

        });
    } else{

        HttpRequest.post("http://deita.ru/users/votedown/"+u, data,

			 function(responseg) {
            if(responseg.result == 'ok')
                document.getElementById('rateid'+u).innerHTML= (responseg.rating>0)?"+"+responseg.rating:responseg.rating;

        });
    };

}










