﻿//http://bytes.com/groups/javascript/152679-getting-css-property-value
//javascript:alert(getcss(".schoolfgcolor","color"));
function getcss(selector, property) {
  if (document.styleSheets && document.styleSheets[0]) {
    var si = document.styleSheets.length;
    while (si--) {
      var s = document.styleSheets[si];
      var r = s.rules ? s.rules : s.cssRules;
      if (r) {
        var i = r.length;
        while (i--) {
          if (r[i].selectorText && r[i].selectorText.toLowerCase() === selector.toLowerCase()) {
            return (r[i].style[property]);
          }
        }
      }
    }
  }
  return null;
}

function getRGB(color) {
  var result;

  // Check if we're already dealing with an array of colors
  if (color && color.constructor == Array && color.length == 3)
    return color;

  // Look for rgb(num,num,num)
  if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
    return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];

  // Look for rgb(num%,num%,num%)
  if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
    return [parseFloat(result[1]) * 2.55, parseFloat(result[2]) * 2.55, parseFloat(result[3]) * 2.55];

  // Look for #a0b1c2
  if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
    return [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)];

  // Look for #fff
  if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
    return [parseInt(result[1] + result[1], 16), parseInt(result[2] + result[2], 16), parseInt(result[3] + result[3], 16)];

  // Otherwise, we're most likely dealing with a named color
  return colors[jQuery.trim(color).toLowerCase()];
}

jQuery.noConflict();



jQuery(document).ready(function() {
  /* RBP20090109 - Wrapping in try/catch block because it was causing problems when trying to work w/ password strength script */
  try {
    var c = getRGB(getcss(".schoolfgcolor", "color"));
    c = "rgb(" + [
				Math.max(Math.min(parseInt(255 - (.2 * (255 - c[0]))), 255), 0),
				Math.max(Math.min(parseInt(255 - (.2 * (255 - c[1]))), 255), 0),
				Math.max(Math.min(parseInt(255 - (.2 * (255 - c[2]))), 255), 0)
			].join(",") + ")";

    jQuery(".main_dnnmenu_rootitem,.main_dnnmenu_rootitem_selected").css("background-color", "white").mouseover(function() {
      jQuery(this).stop().animate({ backgroundColor: c }, 200);
    }).mouseout(function() {
      jQuery(this).stop().animate({ backgroundColor: "white" }, 400);
    });
    var e = jQuery("div.center_bg")[0]; if (e.clientHeight < 500) e.height = 500;
    e = jQuery("table.gradbox");
    for (var i = 0; i < e.length; i++) {
      var a = jQuery(e[i]).find("a.buttonaction");
      var f = jQuery(e[i]).find("a.gradbox2_button").text(a.text()).attr("href", a.attr("href"));
      if (a.attr("onclick")) f.bind("click", eval(a.attr("onclick")));
    }
  } catch (err) {
    document.write("<div style='display:none;'>");
    document.write("There are some errors on this page while loading...<br>");
    document.write("Error is : " + err.description + " <br>Error number is " + err.number);
    document.write("<\/div>");
  }
});
