function checkElementExists(checkMe) {
  var oElement, oId;
  if (document.getElementById
      && (oElement = document.getElementById(checkMe))
      && (oId = oElement.id)) {
      return true;
  } else {
    return false;
  }
}


function adjustAds() {
    if( document.getElementById('banner_sky') ) {
  /*     document.getElementById('banner_sky').style.display = "block";*/
    }
    /* Sets background color of body    */
    if( typeof(ads_background_color) == 'string' ) {
      if( ads_background_color.charAt(0) != '#' ) {
        ads_background_color = '#' + ads_background_color;
      }
      document.getElementsByTagName('body')[0].background = '';
      document.getElementsByTagName('body')[0].style.backgroundColor = ads_background_color;
      document.getElementById('banner_sky').style.backgroundColor = ads_background_color;
      document.getElementById('banner_big').style.backgroundColor = ads_background_color;

    }
    
    /* Sets background image of body    */
    if( typeof(ads_background_image) == 'string' ) {
      document.getElementsByTagName('body')[0].background = '';
      document.getElementsByTagName('body')[0].style.backgroundImage = 'url(' + ads_background_image + ')';
    }
    
    if( typeof(ads_background_image_norepeat) == 'string' ) {
      document.getElementsByTagName('body')[0].style.backgroundRepeat = ads_background_image_norepeat;
    }
    
    if( typeof(ads_background_image_position) == 'string' ) {
      document.getElementsByTagName('body')[0].style.backgroundPosition = ads_background_image_position;
    }
    
    
    /* BIGSIZE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  */
    if( checkElementExists('banner_big') ) {
    
      /* Sets Background to BIGSIZE   */
      if( typeof(ads_trackinglink_bigsize) == 'string' ) {
        document.getElementById('banner_big').onclick = function(){ window.open(ads_trackinglink_bigsize) };
      }
            
      /* Sets Alignment to BIGSIZE    Header_change in abhängigkeit anpassen*/
      if( typeof(ads_align_bigsize) == 'string' ) {
        document.getElementById('banner_big').style.textAlign = ads_align_bigsize;
        document.getElementById('header_change').style.top = '100px';
                document.getElementById('banner_big').style.top = '0px';

      }
        
    }

    /* banner_sky ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  */
    if( checkElementExists('banner_sky') ) {
      
      /* Sets Link to SKY    */
      /*if( typeof(ads_trackinglink_sky) == 'string' ) {
        document.getElementById('banner_sky').onclick = function(){ window.open(ads_trackinglink_sky) };
      }*/
      
      /* Top margin to SKY    */
      if( typeof(ads_offset_top_sky) == 'string' ) {
        var set_absolute_sky = true;
        document.getElementById('banner_sky').style.top = ads_offset_top_sky;
      } 
      
      
       if( typeof(ads_align_sky) == 'string' ) {
        document.getElementById('banner_sky').style.textAlign = ads_align_sky;
      }
      /* Left margin to SKY    */
      
      if( typeof(ads_offset_left_sky) == 'string' ) {
        document.getElementById('banner_sky').style.marginLeft  = ads_offset_left_sky;
        document.getElementById('banner_sky').style.left        = '0px';
      }
      
      if( set_absolute_sky ) {
        document.getElementById('banner_sky').style.zIndex = 999;
        document.getElementById('banner_sky').style.position = 'absolute';
      }
      
      if( typeof(Prototype) == 'object' ) {               
        
        var divs_a    = $$("#banner_sky div a");
        
        if( divs_a.length > 0) {
          //divs_a[0].style.display = 'none';
        }
      }
      
   }
   
}

var resizeSkyWorkerInterval;

function resizeSky() {
    
    /* Resizes the banner DIV on the right side */  
    if( window.innerHeight && window.scrollMaxY )  {  
      pageWidth   = window.innerWidth;  
      pageHeight  = window.innerHeight + window.scrollMaxY;  
    }  else if( document.body.scrollHeight > document.body.offsetHeight ) {
      pageWidth   = document.body.offsetWidth;  
      pageHeight  = document.body.scrollHeight;  
    } else {
      pageWidth   = document.body.offsetWidth; 
      pageHeight  = document.body.offsetHeight + document.body.offsetTop; 
    }

    var set_absolute_sky = false;   
    restWidth = pageWidth - 819;
    
    resizeSkyWorkerInterval = setInterval( 'resizeSkyWorker(' + restWidth + ',' + pageHeight + ');', 200 );
}

function resizeSkyWorker( restWidth, pageHeight ) {

    if( document.getElementById('banner_background_adition') ) {
      document.getElementById('banner_background_adition').style.width          = restWidth + 'px';
      document.getElementById('banner_background_adition').style.height         = pageHeight + 'px';
      //document.getElementById('banner_background_adition').style.backgroundColor = '#fff';
      clearInterval(resizeSkyWorkerInterval);
      //alert( document.getElementById('banner_sky').style.width + ' x ' + document.getElementById('banner_sky').style.height );
    }
    
}

