
function add_rule(myselector, rule)
{
  document.styleSheets["cmpg_empty_css"].addRule(myselector, rule);
}

function fix_bugs()
{
 if(is_ie5up)
 {
    add_rule(".LOGOSUB", "vertical-align: sub");
    add_rule(".LOGOSUP", "vertical-align: super");

    add_rule("TABLE .LOGOSUB", "vertical-align: sub");
    add_rule("TABLE .LOGOSUP", "vertical-align: super");

    add_rule("TABLE.NAVABTEILUNG TD.HSPACER", "padding-left:  0px;");
    add_rule("TABLE.NAVABTEILUNG TD.HSPACER", "padding-right: 0px;");
    add_rule("TABLE.NAVABTEILUNG TD.HSPACER", "border-top:    solid 6px #000099;");
    add_rule("TABLE.NAVABTEILUNG TD.HSPACER", "border-bottom: solid 6px #000099;");

    add_rule("TD.PUBSSUBMENULEFT",  "width: 49%;");
    add_rule("TD.PUBSSUBMENURIGHT", "width: 50%;");
 }

 
 if(is_ie5up && ! is_ie6up)
 {
   add_rule("TABLE.NAVABTEILUNG TD.HSPACER", "border-left:   solid 2px #000099;");
   add_rule("TABLE.NAVABTEILUNG TD.HSPACER", "border-right:  solid 2px #000099;");
 }

 if(is_ie5_5up)
 {
    add_rule(".LOGOSUB", "vertical-align: -1%");
    add_rule(".LOGOSUP", "vertical-align: +1%");

    add_rule("TABLE .LOGOSUB", "vertical-align: -1%");
    add_rule("TABLE .LOGOSUP", "vertical-align: +1%");
 }
 
 if(is_ie6up)
 {
   var iframe = document.getElementById("myIframe");
   if(iframe)
   {
     var new_width = "95%";
     iframe.setAttribute("width", new_width);
   }
 }
 
 if(is_ns4)
 {
   document.contextual(document.tags.TABLE, document.classes.LOGOSUB).verticalAlign = "sub";
   document.contextual(document.tags.TABLE, document.classes.LOGOSUP).verticalAlign = "super";
 }
}

function correct_buffer() 
{
 if(is_ie6up)
 {
   // this correct an apparent bug involving the persistence of the right scroll bar
   // hiding part of the content
 
   var iframe = document.getElementById("myIframe");
   var c = document.getElementById("myContent");
   var b = document.getElementById("buffer");

   if(!iframe && c && b)
   {
     if(get_window_width() < 1000)
       var correction_content_width = 5; // in percent
     else 
       var correction_content_width = 3; // in percent

     var s = "10%";
     var width_menu = parseInt(s.substring(0, s.length - 1)) ;
     var width_news_box = 0;
     
     n = document.getElementById("myNewsBox");
     if(n)
     {
       var s = "20%";
       width_news_box = parseInt(s.substring(0, s.length - 1)) ;
     }  

     var new_width = (100 - width_menu - width_news_box - correction_content_width) + "%";
     var buffer_width = correction_content_width + "%";

     my_alert("set content width to " + new_width + " and buffer to " + buffer_width);
     c.setAttribute("width", new_width);
     b.setAttribute("width", buffer_width);
   }
 }   
}
   
function correct_iframe_content()
{
  // there seems to be no way to remove the h-scrollbar, but at least the following allows
  // the user to read the content
  
 if(is_ie5up)
 {
   var correction_iframe_content_width = 30;
   
   var iframe_content = document.getElementById("cmpg_website_is_iframe");
   if (iframe_content)
   {
     c = iframe_content.childNodes;
     
     for(var i=0; i<c.length; i++)
     {
       if(c[i].className = "IFRAMECONTENT")
       {
//         my_alert("padding iframe content of " + correction_iframe_content_width);
         c[i].style.width = iframe_content.clientWidth - correction_iframe_content_width;
       }
     }
   }
 }
}


function get_correction_ie_width(obj)
{
  return 20;
}

function set_width(obj, newwidth)
{
  obj.setAttribute("width", "" + newwidth);
}

function get_width(obj)
{
// IE6 is buggy concerning the compatibility mode and reading the width,
// IE5 is ok (I don't know for IE5.5)

  var correction_ie_width = 0;
  if(is_ie6up)
    correction_ie_width = get_correction_ie_width(obj);

  return parseInt(obj.getAttribute("width")) - correction_ie_width;
}

