﻿var profilegenerator = true;
var html;
if (navigator.userAgent.indexOf("Firefox")!=-1) firefoxed = 1;
else firefoxed = 0;
var fstrun = 1;
var currentcolor = "000000";
var configs = new Array();

var pickx = 100;
var picky = 100;

function stopError() { return true; }
window.onerror = stopError;

 html = '<table><tr>';
 html += '<td valign="top"><div id="cp1_ColorMap"></div></td>';
 html += '<td valign="top"><div id="cp1_ColorBar"></div></td>';
 html += '<td valign="top">';
 html += '<table>';
 html += '<tr><td colspan="3"><div id="cp1_Preview" style="background-color: #fff; width: 60px; height: 60px; padding: 0; margin: 0; border: solid 1px #000;"><br /></div></td></tr>';

 html += '<tr><td><input type="radio" id="cp1_HueRadio" name="cp1_Mode" value="0" /></td>';
 html += '<td><label for="cp1_HueRadio">H:</label></td>';
 html += '<td><input type="text" id="cp1_Hue" value="0" style="width: 40px;" /> &deg;</td></tr>';

 html += '<tr><td><input type="radio" id="cp1_SaturationRadio" name="cp1_Mode" value="1" /></td>';
 html += '<td><label for="cp1_SaturationRadio">S:</label></td>';
 html += '<td><input type="text" id="cp1_Saturation" value="100" style="width: 40px;" /> %</td></tr>';

 html += '<tr><td><input type="radio" id="cp1_BrightnessRadio" name="cp1_Mode" value="2" /></td>';
 html += '<td><label for="cp1_BrightnessRadio">B:</label></td>';
 html += '<td><input type="text" id="cp1_Brightness" value="100" style="width: 40px;" /> %</td></tr>';

 html += '<tr><td colspan="3" height="5"></td></tr>';
 html += '<tr><td><input type="radio" id="cp1_RedRadio" name="cp1_Mode" value="r" /></td>';
 html += '<td><label for="cp1_RedRadio">R:</label></td>';
 html += '<td><input type="text" id="cp1_Red" value="255" style="width: 40px;" /></td></tr>';

 html += '<tr><td><input type="radio" id="cp1_GreenRadio" name="cp1_Mode" value="g" /></td>';
 html += '<td><label for="cp1_GreenRadio">G:</label></td>';
 html += '<td><input type="text" id="cp1_Green" value="0" style="width: 40px;" /></td></tr>';

 html += '<tr><td><input type="radio" id="cp1_BlueRadio" name="cp1_Mode" value="b" /></td>';
 html += '<td><label for="cp1_BlueRadio">B:</label></td>';
 html += '<td><input type="text" id="cp1_Blue" value="0" style="width: 40px;" /></td></tr>';

 html += '<tr><td>#:</td><td colspan="2"><input type="text" id="cp1_Hex" value="FF0000" style="width: 60px;" /></td></tr>';
 html += '</table></td></tr></table>';
 
 if (firefoxed == 1) html += '<p style="padding-top: 5px; width: 100%;">';

 html += ' <input type="button" value="'+colorpicker2+'" onclick="chooseColor($m(\'cp1_Hex\').value);" />';
 html += ' <input type="button" value="'+cancel+'" onclick="closeColor();" />';
 
 if (firefoxed == 1) html += '</p>';
 
function getColor(field, hdnletmewrite) {
 if (hdnletmewrite) letmewrite = true;
 var colorpicker = $m('colorpicker');
 cfield = field;
 colorpicker.innerHTML = html;
 colorpicker.style.display = "block";
 
 if (!letmewrite) {
 colorvalue = eval("document.generator_options."+ cfield +".value");
 if (!/^([0-9a-f]{1,2}){3}$/i.test (colorvalue)) colorvalue = 'FF0000';
 } else {
 colorvalue = 'FF0000';
 }
 cp1 = new Refresh.Web.ColorPicker('cp1',{startHex: colorvalue, startMode:'s'});
}
function chooseColor(color) {
 //var colorpicker = $m('colorpicker');
 if (!letmewrite) {
 choosecol = "document.generator_options."+ cfield +".value = '"+ color +"';";
 eval(choosecol);
 } else setColor(color);
 closeColor();
}
function closeColor() {
 var colorpicker = $m('colorpicker');
 colorpicker.innerHTML = "";
 colorpicker.style.display = "none";
 if (letmewrite) letmewrite = false;
}
function $m(quem) {
 return document.getElementById(quem);
}
function firstRun() {
 $m('generatelmr').style.display = "";
 fstrun = 0;
}
function saveConfigs() {
 updateRTE('letmewrite');
 createCookie("fontname", configs["fontname"], 7);
 createCookie("fontsize", configs["fontsize"], 7);
 createCookie("fontcolor", currentcolor, 7);
 $m('configssuc').style.display = "";
 setTimeout("$m('configssuc').style.display = 'none'", 1000);
}
function loadConfigs() {
 if (readCookie("fontname")) {
 fontname = readCookie("fontname");
 fontsize = readCookie("fontsize");
 fontcolor = readCookie("fontcolor");
 setRange('letmewrite');
 pgcommand = "forecolor";
 currentRTE = "letmewrite";
 $m('fontname_letmewrite').value = fontname;
 selectFont('letmewrite', 'fontname_letmewrite');
 $m('fontsize_letmewrite').value = fontsize;
 selectFont('letmewrite', 'fontsize_letmewrite');
 setColor(fontcolor);
 }
}