function wrapText(id, mw, mh, s, mask, maskSide, site, direction) {
    obj = document.getElementById(id);
    $('#'+id+' img').each(function () {
        //opakowanie grafik w relatywne boxy
        tmpImgHeight = $(this).attr('height');
//        console.log(tmpHeight);
        if (site == 'index' ) {
            $(this).wrap('<div class="imgRelativeBoxRight" style="height:' + tmpImgHeight + 'px;"></div>');
        } else {
            $(this).wrap('<div class="imgRelativeBox" style="height:' + tmpImgHeight + 'px;"></div>');
        }
    })
	var tmpContent = obj.innerHTML;
	obj.innerHTML = '';
	var tmpWidth = 0;
	var tmpWidthIndex = 0;
	var tmpHeight = 0;
	var tmpHeightIndex = 0;
	var lastWidth = 0;
	var lastWidthIndex = 0;
	for(i = 0, steps = Math.round((mw-mh)/s); i <steps; i++){
		tmpHeight++;
		tmpHeightIndex++;

	    var div = document.createElement('div');
		if ( maskSide == 'left' ) {
		    div.className = 'blockMaskLeft';
		    tmpWidth = Math.round((mw - s * (steps  - i)));
		    if (direction == 'RightToLeft') {
		        tmpWidth = mw - tmpWidth;

		    }
		} else {
		    div.className = 'blockMaskRight';
		    tmpWidth = Math.round(mw - s * i);
		}

		if (lastWidth != tmpWidth) {
		    lastWidth = lastWidth == 0 ? tmpWidth : lastWidth;
    		div.innerHTML = (mask) ? '<div class="blockMaskFill" style="width:' +lastWidth+ 'px; height:' + tmpHeight+ 'px">&nbsp;</div>' : '&nbsp;';
    		div.style.width = lastWidth+"px";
    		div.style.height = tmpHeight+"px";
    		obj.appendChild(div);
    		lastWidth = tmpWidth;
    		tmpHeight = 0;
		}


		if (site == 'index') {
		    //sciecie na glownej
		    tmpWidthIndex = Math.round(-115 + mw - 0.07 * i);
		    if (lastWidthIndex != tmpWidth) {
    		    var div = document.createElement('div');
    		    div.className = 'blockMaskRight';
    		    div.innerHTML = '<div class="blockMaskFill" style="width:' +lastWidthIndex+ 'px; height:' + tmpHeightIndex+ 'px;">';
    		    div.style.width = lastWidthIndex+"px";
    		    div.style.height = tmpHeightIndex+"px";
    		    obj.appendChild(div);
        		lastWidthIndex = tmpWidthIndex;
        		tmpHeightIndex = 0;
    		}


		}
	}

	obj.innerHTML += tmpContent;
}
