function SeeMe(id, st)
{
var hover = document.getElementById(id);
hover.style.display=st;
}

function SeeMeVis(id, st) {
    var hover = document.getElementById(id);
    hover.style.visibility = st;
}

function isPrinciple(CurrentId) {
    var PrincipleDiv = document.getElementById("PrinciplesDiv");
    var Current = document.getElementById(CurrentId);
    if (PrincipleDiv.innerHTML == Current.innerHTML) {
        return true;
    }
    else {
        return false;
    }
}

function AllClassChange(CurrentId) {
    var client = document.getElementById("P_client").className = "principles";
    var prices = document.getElementById("P_prices").className = "principles";
    var design = document.getElementById("P_design").className = "principles";
    var easy = document.getElementById("P_easy").className = "principles";
    var tech = document.getElementById("P_tech").className = "principles";
    var custom = document.getElementById("P_custom").className = "principles";
    var Current = document.getElementById(CurrentId).className = "principles_H";
}

function ClassChange(id, cl)
{
var hover = document.getElementById(id);
hover.className=cl;
}

function InsertInfo(info, container) {
    var info = document.getElementById(info).innerHTML;
    var cont = document.getElementById(container);
    cont.innerHTML = info;
}

function ScrollPrinciples(dir) {
    var P_Array = new Array("client", "prices", "design", "easy", "tech", "custom");
    for (i = 0; i < P_Array.length; i++) {
        var CurrentId = P_Array[i];
        var ChangeId;
        if (i == 0 && dir == -1) {
            ChangeId = P_Array[5];
        }
        else if (i == 5 && dir == 1) {
        ChangeId = P_Array[0];
        }
        else {
             ChangeId = P_Array[i + dir];
        }
        if (isPrinciple(CurrentId)) {
            AllClassChange("P_" + ChangeId); InsertInfo(ChangeId, 'PrinciplesDiv');
            break;
        }
    }
}

function isNumberKey(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 96 || charCode > 105))
        return false;

    return true;
}

function isHexKey(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode;
    if (charCode == 86 || charCode == 17) {
        return true;
    }
    else if (charCode == 13) {
    goColor('#' + document.getElementById('CustomColorTxt').value);
    }
    else if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 96 || charCode > 105) && (charCode < 65 || charCode > 70)) {
        return false;
    }
    else {
        return true;
    }
}

function ChangeGlobalColor(NewColor) {
    var OppositeColor = ColorInverter(NewColor);
    ChangeSiteColor('a', 'color', OppositeColor);
    ChangeSiteColor('.Header_div', 'background-color', NewColor);
    ChangeSiteColor('.sub_header', 'color', NewColor);
    ChangeSiteColor('.Nav_div', 'background-color', NewColor);
    ChangeSiteColor('.nav_link:hover', 'border', 'solid 2px ' + NewColor);
    ChangeSiteColor('.nav_link:hover', 'color', NewColor);
    ChangeSiteColor('.nav_link:hover', 'background-color', '#FFF');
    ChangeSiteColor('p:first-letter', 'color', NewColor);
    ChangeSiteColor('b', 'color', OppositeColor);
    ChangeSiteColor('.header', 'color', NewColor);
    ChangeSiteColor('.subheading', 'color', OppositeColor);
    ChangeSiteColor('.Footer_div', 'background-color', NewColor);
    ChangeSiteColor('.principles', 'background-color', NewColor);
    ChangeSiteColor('.principles', 'border-color', NewColor);
    ChangeSiteColor('.principles_H', 'background-color', OppositeColor);
    ChangeSiteColor('.principles_H', 'border-color', OppositeColor);
    ChangeSiteColor('.News_title', 'color', NewColor);
    ChangeSiteColor('.News_head', 'background-color', OppositeColor);
    ChangeSiteColor('.News_div', 'border-color', OppositeColor);
    ChangeSiteColor('.News_div', 'background-color', OppositeColor);
    ChangeSiteColor('.port_link:hover', 'border-color', OppositeColor);
    ChangeSiteColor('.port_link:hover', 'background-color', OppositeColor);
    ChangeSiteColor('.port_link:hover', 'color', NewColor);
    ChangeSiteColor('.port_link img', 'border-color', OppositeColor);
    ChangeSiteColor('.port_link img:hover', 'border-color', NewColor);
    ChangeSiteColor('.add_img', 'background-color', OppositeColor);
    ChangeSiteColor('.data_table', 'border-color', NewColor);
    ChangeSiteColor('.data_head', 'background-color', NewColor);
    ChangeSiteColor('.data_body', 'border-color', NewColor);
    ChangeSiteColor('.data_body_A', 'border-color', NewColor);
    ChangeSiteColor('.data_body_A', 'background-color', NewColor);
    ChangeSiteColor('.arrow_link', 'background-color', NewColor);
    ChangeSiteColor('.arrow_link:hover', 'background-color', OppositeColor);
    ChangeSiteColor('.arrow', 'background-color', OppositeColor);
    ChangeSiteColor('.service_link_C', 'background-color', NewColor);
    ChangeSiteColor('.service_link', 'background-color', OppositeColor);
}

function ChangeSiteColor(ClassN, StyleTag, NewColor) {
    var StylesNum = (document.styleSheets.length) - 1;

    if (document.styleSheets[0].addRule) {
        document.styleSheets[StylesNum].addRule(ClassN, StyleTag + ":" + NewColor);
    }
    else {
        var rulelength = document.styleSheets[StylesNum].cssRules.length;
        document.styleSheets[StylesNum].insertRule(ClassN + "{" + StyleTag + ":" + NewColor + "}", rulelength - 1);
    }
}

function ColorInverter(NewColor) {
    NewColor = NewColor.toUpperCase();
    var Color = NewColor.replace("#", "");
    var patt1 = /\w{1}/;

    var R1 = Color.match(patt1);
    var Two = Color.replace(patt1, "");
    var R2 = Two.match(patt1);
    var Three = Two.replace(patt1, "");
    var G1 = Three.match(patt1);
    var Four = Three.replace(patt1, "");
    var G2 = Four.match(patt1);
    var Five = Four.replace(patt1, "");
    var B1 = Five.match(patt1);
    var Six = Five.replace(patt1, "");
    var B2 = Six.match(patt1);
    if (R1 == "A") { R1 = 10 }
    if (R1 == "B") { R1 = 11 }
    if (R1 == "C") { R1 = 12 }
    if (R1 == "D") { R1 = 13 }
    if (R1 == "E") { R1 = 14 }
    if (R1 == "F") { R1 = 15 }
    if (R2 == "A") { R2 = 10 }
    if (R2 == "B") { R2 = 11 }
    if (R2 == "C") { R2 = 12 }
    if (R2 == "D") { R2 = 13 }
    if (R2 == "E") { R2 = 14 }
    if (R2 == "F") { R2 = 15 }
    if (B1 == "A") { B1 = 10 }
    if (B1 == "B") { B1 = 11 }
    if (B1 == "C") { B1 = 12 }
    if (B1 == "D") { B1 = 13 }
    if (B1 == "E") { B1 = 14 }
    if (B1 == "F") { B1 = 15 }
    if (B2 == "A") { B2 = 10 }
    if (B2 == "B") { B2 = 11 }
    if (B2 == "C") { B2 = 12 }
    if (B2 == "D") { B2 = 13 }
    if (B2 == "E") { B2 = 14 }
    if (B2 == "F") { B2 = 15 }
    if (G1 == "A") { G1 = 10 }
    if (G1 == "B") { G1 = 11 }
    if (G1 == "C") { G1 = 12 }
    if (G1 == "D") { G1 = 13 }
    if (G1 == "E") { G1 = 14 }
    if (G1 == "F") { G1 = 15 }
    if (G2 == "A") { G2 = 10 }
    if (G2 == "B") { G2 = 11 }
    if (G2 == "C") { G2 = 12 }
    if (G2 == "D") { G2 = 13 }
    if (G2 == "E") { G2 = 14 }
    if (G2 == "F") { G2 = 15 }
    R = 0;
    G = 0;
    B = 0;
    R1 = R1 * 16;
    R2 = R2 * 1;
    R = R1 + R2;

    G1 = G1 * 16;
    G2 = G2 * 1;
    G = G1 + G2;

    B1 = B1 * 16;
    B2 = B2 * 1;
    B = B1 + B2;
    
    var PR = 1 - (R / 255);
    var PG = 1 - (G / 255);
    var PB = 1 - (B / 255);
    
    var OR = 255 * PR;
    var OG = 255 * PG;
    var OB = 255 * PB;
 
    if ((OR + OG + OB) > 323) {
        var Diff = ((OR + OG + OB) - 323) / 3;
        OR = OR - Diff;
        OG = OG - Diff;
        OB = OB - Diff;
    }

    if (OR < 0) { OR = 0 }
    if (OG < 0) { OG = 0 }
    if (OB < 0) { OB = 0 }
    if (OR > 255) { OR = 255 }
    if (OG > 255) { OG = 255 }
    if (OB > 255) { OB = 255 }
    
    return "rgb(" + Math.round(OR) + "," + Math.round(OG) + "," + Math.round(OB) + ")";
}

function goColor(NewColor) {
    ChangeGlobalColor(NewColor);
    Set_Cookie("CustomColor", NewColor, 1, '', '', '');
}

function AcceptsCookies(divId) {
    Set_Cookie('test', 'none', '', '/', '', '');
    if (Get_Cookie('test')) {       
        Delete_Cookie('test', '/', '');
    }
    else {
        document.getElementById(divId).style.display = "block";
    }
}

function Set_Cookie(name, value, expires, path, domain, secure) {
    // set time, it's in milliseconds
    var today = new Date();
    today.setTime(today.getTime());

    /*
    if the expires variable is set, make the correct
    expires time, the current script below will set
    it for x number of days, to make it for hours,
    delete * 24, for minutes, delete * 60 * 24
    */
    if (expires) {
        expires = expires * 1000 * 60 * 60 * 24;
    }
    var expires_date = new Date(today.getTime() + (expires));

    document.cookie = name + "=" + escape(value) +
((expires) ? ";expires=" + expires_date.toGMTString() : "") +
((path) ? ";path=" + path : "") +
((domain) ? ";domain=" + domain : "") +
((secure) ? ";secure" : "");
}

function Get_Cookie(check_name) {
    // first we'll split this cookie up into name/value pairs
    // note: document.cookie only returns name=value, not the other components
    var a_all_cookies = document.cookie.split(';');
    var a_temp_cookie = '';
    var cookie_name = '';
    var cookie_value = '';
    var b_cookie_found = false; // set boolean t/f default f

    for (i = 0; i < a_all_cookies.length; i++) {
        // now we'll split apart each name=value pair
        a_temp_cookie = a_all_cookies[i].split('=');


        // and trim left/right whitespace while we're at it
        cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

        // if the extracted name matches passed check_name
        if (cookie_name == check_name) {
            b_cookie_found = true;
            // we need to handle case where cookie has no value but exists (no = sign, that is):
            if (a_temp_cookie.length > 1) {
                cookie_value = unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g, ''));
            }
            // note that in cases where cookie is initialized but no value, null is returned
            return cookie_value;
            break;
        }
        a_temp_cookie = null;
        cookie_name = '';
    }
    if (!b_cookie_found) {
        return null;
    }
}

function Delete_Cookie(name, path, domain) {
    if (Get_Cookie(name)) document.cookie = name + "=" +
((path) ? ";path=" + path : "") +
((domain) ? ";domain=" + domain : "") +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}