// JavaScript Document
function getStyleObject (styleSheetIndex, ruleIndex)
{
/*
 * Funkce slouzi pro vraceni objektu CSSStyleSheet pro dany index CSS souboru a index CSS pravidla
 */
  
  if (document.styleSheets)
  {
    var styleSheet = document.styleSheets[styleSheetIndex];
  
    if (styleSheet)
    {
      var rule;
  
      if (styleSheet.cssRules)
      {
        rule = styleSheet.cssRules[ruleIndex];
      }
      else if (styleSheet.rules) 
      {
        rule = styleSheet.rules[ruleIndex];
      }
      
      if (rule && rule.style)
      {
        return rule.style;
      }
      else
      {
        return null;
      }
    }
    else
    {
      return null;
    }
  }
  else 
  {
    return null;
  }
}
// ** End of getStyleObject function ***********************************

function getStyleObjectFromSelector (selectorText)
{
/*
 * Funkce slouzi pro vraceni objektu CSSStyleSheet pro dany nazev CSS pravidla
 */
  if (document.styleSheets)
  {
    for (var i = document.styleSheets.length - 1; i >= 0; i--)
    {
      var styleSheet = document.styleSheets[i];
      var rules;

      if (styleSheet.cssRules)
      {
        rules = styleSheet.cssRules;
      }
      else if (styleSheet.rules) 
      {
        rules = styleSheet.rules;
      }

      if (rules) 
      {
        for (var j = rules.length - 1; j >= 0; j--) 
        {
          if (rules[j].selectorText == selectorText) 
          {
            return rules[j].style;
          }
        }
      }
    }
    return null;
  }
  else 
  {
    return null;
  }
}
// ** End of getStyleObjectFromSelector function ***********************************

function getComputedStyleForElement (element, cssPropertyName) 
{
/*
 * Funkce slouzi pro vraceni stylu pro dany HTML element(podle jmena) a jmeno vlastnosti
 */
  if (element) 
  {
    if (window.getComputedStyle) 
    {
      return window.getComputedStyle(element,'').getPropertyValue(cssPropertyName.replace(/([A-Z])/g,"-$1").toLowerCase());
    }
    else if (element.currentStyle) 
    {
      return element.currentStyle[cssPropertyName];
    }
    else 
    {
      return null;
    }
  }
  else 
  {
    return null;
  }
}
// ** End of getComputedStyleForElement function ***********************************

function getComputedStyleForId (elementId, cssPropertyName) 
{
/*
 * Funkce slouzi pro vraceni stylu pro dany HTML element(podle ID) a jmeno vlastnosti
 */
  if (document.getElementById) 
  {
    return getComputedStyleForElement(document.getElementById (elementId), cssPropertyName);
  }
  else 
  {
    return null;
  }
}
// ** End of getComputedStyleForId function ***********************************

