var dmtempInd = new Array();
function find(elem) {
    var f = true;
    for (var i = 0; i < dmtempInd.length; i++) {
        if (elem == dmtempInd[i])f = false;
    }
    if (!f) {
        elem = find(Math.floor(Math.random() * (arImg.length)))
    } else {
        dmtempInd[dmtempInd.length] = elem;
    }
    return elem;

}
var fid = "";
if(dmparams.carousel){
    var w = parseInt(dmparams.fwidth)+200;
    var countCell = parseInt(dmparams.fwidth/(dmparams.pwidth*1+dmparams.bwidth*2+dmparams.fcellspacing*2));
    var fw = dmparams.pwidth*1+dmparams.bwidth*2+dmparams.fcellspacing*1;
    if (countCell>1){
         fw = countCell*dmparams.pwidth+countCell*(dmparams.bwidth*2)+(parseInt(countCell)+2)*(dmparams.fcellspacing);
    }
    var h = 10 + parseInt(dmparams.pwidth*1.4)+parseInt(dmparams.tsize*3);
    fid +='<style type="text/css">'+
    '.DirCashflashdiv{position:relative;width:100%;height:'+h+'px;padding-top: 5px;float:left;background:'+dmparams.fbgcolor+';}'+
    '.DirCashleftButton{width:41px;height:41px;float:left;background:url("http://dirkino-traff.ru/fid/img/strButton.png") no-repeat left top;cursor:pointer;position:absolute;left:5px;top:40%;z-index: 99;}'+
    '.DirCashrightButton{width:41px;height:41px;float:left;background:url("http://dirkino-traff.ru/fid/img/strButton.png") no-repeat right top;cursor:pointer;position:absolute;top:40%;right:5px;z-index: 99;}'+
    '.DirCashrightButtonA{width:41px;height:41px;float:left;background:url("http://dirkino-traff.ru/fid/img/strButton.png") no-repeat right bottom;cursor:pointer;position:absolute;top:40%;right:5px;z-index: 99;}'+
    '.DirCashleftButtonA{width:41px;height:41px;float:left;background:url("http://dirkino-traff.ru/fid/img/strButton.png") no-repeat left bottom;cursor:pointer;position:absolute;left:5px;top:40%;z-index: 99;}'+
    '.DirCashcentrLogo{width:1000000px;:'+h+'px;position:absolute;left:0;}'+
    '.DirCashscroll{height:'+h+'px;width:'+fw+'px;margin:0 auto;position:relative;overflow:hidden;}'+
    '</style>';

    fid+='<script type="text/javascript" src="createFeedCarousel.js"> <\/script>';

    fid += '<div class="DirCashflashdiv">'+
             '<div onmouseout="this.className=\'DirCashleftButton\'" onmouseover="this.className=\'DirCashleftButtonA\'" onclick="DirCashscrollImg(1)" onmousedown="DirCashstopClick(event)" class="DirCashleftButton" id="ba"></div>'+
                '<div class="DirCashscroll">'+
                '<div onmousedown="DirCashstopClick(event)" class="DirCashcentrLogo" id="scroll" style="left: 0;">'+
                     '<div style="float: left" id="carouselContent">';

}
    fid += '\<table cellspacing="' + dmparams.fcellspacing + '" style="width:' + dmparams.fwidth + 'px;background:' + dmparams.fbgcolor + ';font-size:' + dmparams.tsize + 'px;color:' + dmparams.tcolor + '">';
    for (var i = 0; i < dmparams.rows; i++) {
        fid += '\<tr>';
        for (var j = 0; j < dmparams.cols; j++) {
            if (arImg.length==dmtempInd.length){
                dmtempInd = new Array();
            }
            var ind = find(Math.floor(Math.random() * (arImg.length)));
            var h = dmparams.tsize*1+2;
            if (dmparams.traf===undefined||!dmparams.traf){
                fid += '\<td>' +
                       '\<a target="'+(dmparams.nwin ? '_blank'  : '')+'" style="text-decoration:none;color:' + dmparams.tcolor + '" href="' + (dmparams.main ? 'http://'+dmparams.url+'/'+dmparams.userId+'/' : 'http://'+dmparams.url+'/'+dmparams.userId+'/download/' + arImg[ind].id + '/') + '"><img style="border:' + dmparams.bwidth + 'px solid ' + dmparams.bcolor + '" src="http://dirkino-pic.ru/' + arImg[ind].id + '.jpg" alt="' + arImg[ind].name + '" width="' + dmparams.pwidth + 'px" height="'+dmparams.pwidth*1.4+'px"\>'+
                       '\<br>'+(!dmparams.desc ?'<div style="width:'+ dmparams.pwidth+'px;overflow:hidden;height:'+h+'px">' +arImg[ind].name+'\</div>':'')+'\</a>'+
                       '\</td>';
            }else{
                fid += '\<td>' +
                       '\<a target="'+(dmparams.nwin ? '_blank'  : '')+'" style="text-decoration:none;color:' + dmparams.tcolor + '" href="http://dirkino-traff.ru/in/?idd=' + dmparams.userId + '"><img style="border:' + dmparams.bwidth + 'px solid ' + dmparams.bcolor + '" src="http://dirkino-pic.ru/' + arImg[ind].id + '.jpg" alt="' + arImg[ind].name + '" width="' + dmparams.pwidth + 'px" height="'+dmparams.pwidth*1.4+'px"\>'+
                       '\<br>'+(!dmparams.desc ?'<div style="width:'+ dmparams.pwidth+'px;overflow:hidden;height:'+h+'px">' +arImg[ind].name+'\</div>':'')+'\</a>'+
                       '\</td>';
            }
        }
        fid += '\</tr>';
    }
    fid += '\</table>';
if(dmparams.carousel){

    fid += '</div></div></div>'+
             '<div onmouseout="this.className=\'DirCashrightButton\'" onmouseover="this.className=\'DirCashrightButtonA\'" onclick="DirCashscrollImg(0)" onmousedown="DirCashstopClick(event)" class="DirCashrightButton" id="nx"></div>'+
             '<script>DirCashscrollImg(0);<\/script>'
          '</div>';

}
document.write(fid);