function count( mixed_var, mode ) {    // Count elements in an array, or properties in an object
    //
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: _argos

    var key, cnt = 0;

    if( mode == 'COUNT_RECURSIVE' ) mode = 1;
    if( mode != 1 ) mode = 0;

    for (key in mixed_var){
        cnt++;
        if( mode==1 && mixed_var[key] && (mixed_var[key].constructor === Array || mixed_var[key].constructor === Object) ){
            cnt += count(mixed_var[key], 1);
        }
    }

    return cnt;
}
function execute(id, img_id, url, while_loading) {
        var inner_id=document.getElementById(id);
        var img_id=document.getElementById(img_id);
        if (!id){
                return false;
        }
        if (!while_loading){
                img_id.innerHTML="<img src='loader.gif' width='16' height=16>";
        }else if(while_loading!='__empty__'){
                img_id.innerHTML=while_loading;
        }
        var request   = false;
        var msxmlhttp = new Array('Msxml2.XMLHTTP.5.0','Msxml2.XMLHTTP.4.0','Msxml2.XMLHTTP.3.0','Msxml2.XMLHTTP','Microsoft.XMLHTTP' );

        if ( window.XMLHttpRequest ) {
                request = new XMLHttpRequest;
        } else if ( window.ActiveXObject ) {
                for ( var i = 0; i < msxmlhttp.length; i ++ ) {
                        try {
                                request = new ActiveXObject( msxmlhttp[i] );
                        } catch ( e ) {
                                request = false;
                        }
                }
        }
        if ( !request ) {
                alert( 'Can\'t create XMLHTTP instance' );
                return false;
        }
        request.onreadystatechange = function() {
                if ( request.readyState == 4 ) {
                        if ( request.status == 200 ) {
                                inner_id.innerHTML="";
                                arr=request.responseText.split('<br>');
                                var n = 1;//min
                                var m = 1;//max рандома
                                for (i in arr){
                                     var r=Math.floor(Math.random( ) * (n - m + 1)) + m;
                                     window.setTimeout('document.getElementById("res").innerHTML += "'+arr[i]+'<br>"',(i*1000*r));
                                     if((count(arr)-1)==i)
                                         window.setTimeout('document.getElementById("img").innerHTML = ""',(count(arr)*1000*r));
                                }
                        } else {
                                alert( 'There was a problem with the request :(' );
                        }
                }
        }
        var q_data="site="+document.site.url.value;
        request.open( 'POST', url, true );
        request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        request.send(q_data);
};
function execute_with_hiding(id,url,table_id,img_id){
        var resObj=document.getElementById(id);
        var table=document.getElementById(table_id);
        var img=document.getElementById(img_id);
        if (resObj){
                if (resObj.style.display=='none'){
                        table.style.display='';
                        resObj.style.display='';
                        img.style.display='';
                        execute(id,img_id,url);
                }else{
                        resObj.style.display='none';
                        table.style.display='none';
                }
        }
}