﻿function init()
{
    isIE = (navigator.appName == "Microsoft Internet Explorer")?true:false;    
    ShowCode();
}
function ShowCode()
{
    document.getElementById("FriendshipCalculatorCode").value = '<script type="text/javascript">\nvar FC_BGColor="#'+Settings[0]+'";\nvar FC_TextColor="#'+Settings[1]+'";\nvar FC_TopbarBGColor="#'+Settings[2]+'";\nvar FC_TopbarTextColor="#'+Settings[3]+'";\n</script>\n<script type="text/javascript" src="http://e-infotainment.com/applications/friendship-calculator/v1/js/fcv1.js" ></script>';
}
function TestColorCode(id,value,i)
{
    var status;
    var test = value.toString().match(/[^0-9A-F]/gi) ;
    var length = value.length;
    if( test || length !=6)
    {
         value = Settings[i];         
         document.getElementById(id).value = value;
    } 
    else
        Settings[i] = value;
                   
    return value;
}
function HexColorCodeGenerator(id)
{
    var TrixCGId=(isIE)?"ColorCodeGenerator_IE":"ColorCodeGenerator";
    try
    {
        var value = document.getElementById(id).value;
        document.getElementById(TrixCGId).GenerateColorsAndCodes(value,id);
    }
    catch(err){}    
}
function PreviewSelectedColor(value,id)
{
    document.getElementById(id).value = value;
    document.getElementById(id).onchange();
}
function PreviewAndDisplayCode()
{
    document.getElementById("FC_Outer").style.backgroundColor = "#"+TestColorCode('BGColor',document.getElementById("BGColor").value,0);
    document.getElementById("FC_Outer").style.color = "#"+TestColorCode('TextColor',document.getElementById("TextColor").value,1);
    document.getElementById("FC_Header").style.backgroundColor = "#"+TestColorCode('TopbarBGColor',document.getElementById("TopbarBGColor").value,2);
    document.getElementById("FC_Header").style.color = "#"+TestColorCode('TopbarTextColor',document.getElementById("TopbarTextColor").value,3);
    ShowCode();
}
var isIE;
var Settings = new Array("000000","FFFFFF","CCCCCC","000000");
window.onload = init;