﻿/// <reference path="jquery-1.2.6-vsdoc.js" />


function SetModuleHeaderColors(m_header_bgcolor, m_header_color) {

    var module_header = $("div.module h6");
    module_header.css("background-color", m_header_bgcolor);
    module_header.css("background-image", "none");
    module_header.css("color", m_header_color);
}

function GetModuleHeaderBgColor() {
    var module_header = $("div.module h6");

    var color = module_header.css("background-color");

    if (color.substring(0, 3) == "rgb") { 
        
        var triplet = rgb2triplet(color);

        var color = rgb2hex(triplet);

    }
    

    return color;
}

function GetModuleHeaderColor() {

    var module_header = $("div.module h6");

    var color = module_header.css("color")
    
    if (color.substring(0, 3) == "rgb") {

        var triplet = rgb2triplet(color);

        var color = rgb2hex(triplet);
    }

    return color;
}

function rgb2triplet(rgb) {
    var triplet = "";
    triplet = rgb.substring(3);
    
    triplet = triplet.replace("(", "");
    triplet = triplet.replace(")", "");

    var array = triplet.split(",");
    
    return array;
}

//Function to get hex format a rgb colour
function rgb2hex(rgb) {

    //alert(rgb.toString());
    
    //generates the hex-digits for a colour. 
    function hex(x) {
        hexDigits = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8",
"9", "A", "B", "C", "D", "E", "F");
        return isNaN(x) ? "00" : hexDigits[(x - x % 16) / 16] + hexDigits[x % 16];
    }

    //alert(rgb[0]);
    
    var hex = "#" + hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]);

    //alert(hex);
    
    return hex;
} 




