<?xml version="1.0"?>
<!--
 * this file is a part of Check4Change 
 *
 * Copyright 2010 Ronen Zilberman
 * See license.txt for details.
 *-->

<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<dialog id="c4c_AdvancedDialog" title="Custom Configuration"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        onload="loadParams();"
        ondialogaccept="return doOK();"
        ondialogcancel="return doCancel();">

<script type="application/x-javascript"  src="chrome://c4c/content/c4cUti.js" />
<script type="application/x-javascript"  src="chrome://c4c/content/c4cMenu.js" />
<script type="application/x-javascript"  src="chrome://c4c/content/c4cSystem.js" />

<vbox align="center" id="c4c_vipbox" style="display:none;">
    <hbox align="center">
        <image src="vip.png" />
        <vbox align="center">
            <label id="c4c_vipname" value="Thank you %NAME% :)" />
        </vbox>
        <image src="vip.png" />
    </hbox>
    <label value="" />
</vbox>
<groupbox orient="horizontal">
    <caption label="Check Interval" />
    <vbox>
        <hbox>
            <hbox align="center">
                <label value="Reload and check every" tooltiptext="How often should this page be reloaded and checked for change in the selected text." />
            </hbox>
            <textbox class="option number" id="duration" size="3" oninput="this.value=parseInt(this.value);if (this.value=='NaN') this.value=''; " />
            <menulist class="option" id="units">
                <menupopup>
                    <menuitem label="seconds" />
                    <menuitem label="minutes" />
                    <menuitem label="hours" />
                </menupopup>
            </menulist>
        </hbox>
    </vbox>
</groupbox>
<groupbox orient="horizontal">
    <caption label="Modes of Operation" />
    <vbox>
        <checkbox class="option" id="doContinue" label="Continue monitoring after first change" tooltiptext="When checked, the tab will remain c4c-enabled after the first change has been detected. Subsequent reloads will be tested against the new content and changes will continue to be notified." />
        <checkbox class="option" id="doStopWhenViewing" label="Pause reloading while tab in view" tooltiptext="When checked, c4c will not reload the tab while it is in focus." />
        <checkbox class="option" id="dontReload" label="Monitor without actually reloading" tooltiptext="Useful for pages that update themselves automatically with javascript/AJAX like Gmail." />
    </vbox>
</groupbox>
<vbox>
    <groupbox orient="horizontal">
        <caption label="Notifications" />
        <vbox>
            <checkbox class="option" id="notifyAnim" label="Tab animation" tooltiptext="Dancing C4C letters in the tab." />
            <checkbox class="option" id="notifyTaskBar" label="Flash Task Bar button" tooltiptext="OS dependant behavior. In Windows, it flashes the browser's button in the taskbar." />
            <checkbox class="option" id="notifyPopup" label="Pop-up alert" tooltiptext="Like the one used to indicate 'Download Complete'. Clicking it will bring up the page." />
            <checkbox class="option" id="notifyFocus" label="Bring tab to front" tooltiptext="Bring tab to the foreground and restore window if it is minimized." />
            <hbox>
                <checkbox class="option" id="notifySound" oncommand="updateSound();" label="Play sound" tooltiptext="Play a sound notification. Sound can be changed in the Options window." />
                <checkbox class="option" id="notifySoundContinuous" label="Continuously" tooltiptext="Replay sound notification until tab is clicked." />
            </hbox>
            <checkbox class="option" id="notifyLog" label="Log changes to log file" tooltiptext="Log changes to log file. File location is set in the Options window. " />
            <hbox align="center">
                <checkbox class="option" id="notifyEmail" label="Send Email Notification" tooltiptext="Send an email when a change is found." disabled="true" />
                <label id="notifyEmailActivate" class="text-link" value="Activate..." onclick="becomeVIP(3);" />
                <label id="notifyEmailConfigure" class="text-link" value="" onclick="openProfile();" />
            </hbox>
        </vbox>
    </groupbox>
    <groupbox orient="horizontal">
        <caption label="Special Modes" />
        <vbox>
            <hbox>
                <checkbox class="option" id="doAbsPos" label="Use absolute positioning (for forums etc)" tooltiptext="Compare new reloads at the exact position of the marked text overriding c4c's smart location search. For example if you wish to monitor when a new message is posted on a forum, you might select the topic of the 1st entry. However when a new entry is posted, C4C might recognize the selected text in the 2nd entry and not show a notification. Use this option to fix this issue. " />
            </hbox>
        </vbox>
    </groupbox>
</vbox>
<label value="" />
<vbox align="center">
    <hbox>
        <button dlgtype="accept" />
        <button dlgtype="cancel" />
    </hbox>
</vbox>
<label value="" />
<label value="To change system defaults, use extension options." tooltiptext="Available from the Tools menu under Add-ons. Find Check4Change and press Options." />
<label value="For Help, hold the mouse over desired option." tooltiptext="Yes. Just like that..." />



<script>
<![CDATA[

function updateSound() {
  var state = document.getElementById("notifySound").checked;
  document.getElementById("notifySoundContinuous").disabled = !state;
}

function becomeVIP(code) {
    var win = c4cUti_getRecentBrowser();	
	win.c4cSystem_goBecomeVIP(code);
}

function openProfile() {
    var win = c4cUti_getRecentBrowser();	
	win.c4cSystem_goVIPProfile();
}

function loadParams() {

	//vip
	if (c4cVIP_isVIP()) {
		document.getElementById("notifyEmail").disabled = false;	
		document.getElementById("notifyEmailActivate").value = '';
		document.getElementById("notifyEmailConfigure").value = 'Configure..';		
		document.getElementById("c4c_vipbox").style.display = "";
		document.getElementById("c4c_vipname").value = document.getElementById("c4c_vipname").value.replace('%NAME%', c4cVIP_getName());
	}

	c4cParams_setupDialog(window.arguments[0].params);

	updateSound();

}

function doOK()
{
try {
  // validation
  if (document.getElementById("duration").value == "") {
    c4cUti_alert(window, "Missing data", "Please enter a time duration.");
    document.getElementById("duration").focus();
    return false;
  }
  
  // save params  
  var params = c4cParams_getFromDialog(window.arguments[0].params);
  window.arguments[0].params = params;
  
  return true;
  
} catch (e) {c4cUti_assert(false, e); return true;}
}

function doCancel()
{
  window.arguments[0].params.cancel = true;
  return true;
}

]]>

</script>


</dialog>