<?php
$script = '';
for ($side = 1; $side <= 2; $side++) {
  $adverts = @blogStore::$moduleConfig['adverts']['float'.$side];
  if (!isset($adverts)) continue;
  $pos = ($side==1? 'left':'right');
  $posy = 0;
  foreach ($adverts as $key => $value) {
    if (@$value['visible']===0) continue;
    echo '<div id="'.$key.$pos.'" class="banner" style="position: absolute; display: none;">';
    if (isset($value['imgUrl'])) {
      echo link_to(myUtility::global_image_tag($value['imgUrl'], $value['width'], $value['height']), $value['link'],
      array('title'=>$value['title'], 'target'=>'_blank'));
    } else {
      echo $value['embed'];
    }
    echo "</div>\n";
    $script .= "setPosition({element:'$key$pos', top:$posy, $pos:3, minWidth:1000});";
    $posy += $value['height'];
    $posy += @$value['gap'];
  }
}
$sf_context->getResponse()->addJavascriptCommand($script);
