function createCSSClass(selector, style)
{
 // using information found at: http://www.quirksmode.org/dom/w3c_css.html
 // doesn't work in older versions of Opera (< 9) due to lack of styleSheets support
 if(!document.styleSheets) return;
 if(document.getElementsByTagName("head").length == 0) return;
 var stylesheet;
 var mediaType;
 if(document.styleSheets.length > 0)
 {
  for(i = 0; i<document.styleSheets.length; i++)
  {
   if(document.styleSheets[i].disabled) continue;
   var media = document.styleSheets[i].media;
   mediaType = typeof media;
   // IE
   if(mediaType == "string")
   {
    if(media == "" || media.indexOf("screen") != -1)
    {
     styleSheet = document.styleSheets[i];
    }
   }
   else if(mediaType == "object")
   {
    if(media.mediaText == "" || media.mediaText.indexOf("screen") != -1)
    {
     styleSheet = document.styleSheets[i];
    }
   }
   // stylesheet found, so break out of loop
   if(typeof styleSheet != "undefined") break;
  }
 }
 // if no style sheet is found
 if(typeof styleSheet == "undefined")
 {
  // create a new style sheet
  var styleSheetElement = document.createElement("style");
  styleSheetElement.type = "text/css";
  // add to <head>
  document.getElementsByTagName("head")[0].appendChild(styleSheetElement);
  // select it
  for(i = 0; i<document.styleSheets.length; i++)
  {
   if(document.styleSheets[i].disabled) continue;
   styleSheet = document.styleSheets[i];
  }
  // get media type
  var media = styleSheet.media;
  mediaType = typeof media;
 }
 // IE
 if(mediaType == "string")
 {
  for(i = 0;i<styleSheet.rules.length;i++)
  {
   // if there is an existing rule set up, replace it
   if(styleSheet.rules[i].selectorText.toLowerCase() == selector.toLowerCase())
   {
    styleSheet.rules[i].style.cssText = style;
    return;
   }
  }
  // or add a new rule
  styleSheet.addRule(selector,style);
 }
 else if(mediaType == "object")
 {
  for(i = 0;i<styleSheet.cssRules.length;i++)
  {
   // if there is an existing rule set up, replace it
   if(styleSheet.cssRules[i].selectorText.toLowerCase() == selector.toLowerCase())
   {
    styleSheet.cssRules[i].style.cssText = style;
    return;
   }
  }
  // or insert new rule
  styleSheet.insertRule(selector + "{" + style + "}", styleSheet.cssRules.length);
 }
}


/* http://javathoughts.capesugarbird.com/2008/03/ajax-button-with-overlay-div-and-wait.html */
/**
 Inspired by the Veil component by Igor Vaynberg in wicketstuff-minis
 http://wicketstuff.org/confluence/display/STUFFWIKI/wicketstuff-minis
 wicketstuff-minis is released under the Apache 2 License
 http://apache.org/licenses/LICENSE-2.0.html 
*/
Mask = { };
 
/**
 Shows a mask and a spinner over the element with the specified id
*/
Mask.show = function(onoff)
{
  if (Mask.mask == null) {
    var spinner = document.createElement("img");
    spinner.src = "/images/30-1.gif";
    spinner.style.position = "absolute";
    spinner.style.left = (document.body.clientWidth - spinner.width) / 2 + "px";
    spinner.style.top = (document.body.clientHeight - spinner.height) / 2 + "px";
    Mask.mask=document.createElement("div");
    Mask.mask.className="wicket-mask";
    Mask.mask.style.zIndex="5000";
    Mask.mask.appendChild(spinner);
  } else {
    //Mask.mask.style.display="";
  }
  document.body.appendChild(Mask.mask);
}

/**
 Hides the mask and spinner
*/
Mask.hide = function()
{
  if (Mask.mask!=null) {
    //Mask.mask.style.display="none";
    document.body.removeChild(Mask.mask);
  }
}

// cookie functions, http://www.quirksmode.org/js/cookies.html
function createCookie(name,value,days) {
        if (days) {
                var date = new Date();
                date.setTime(date.getTime()+(days*24*60*60*1000));
                var expires = "; expires="+date.toGMTString();
        }
        else var expires = "";
        document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for(var i=0;i < ca.length;i++) {
                var c = ca[i];
                while (c.charAt(0)==' ') c = c.substring(1,c.length);
                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
        }
        return null;
}

function eraseCookie(name) {
        createCookie(name,"",-1);
}

