<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin/"?>
<?xml-stylesheet type="text/css" href="chrome://kmprefs/skin/"?>
<?xul-overlay href="chrome://kmprefs/content/kmprefs/ovrl-history.xul"?>
<?xul-overlay href="chrome://kmprefs/content/kmprefs/ovrl-cache.xul"?>
<?xul-overlay href="chrome://kmprefs/content/kmprefs/ovrl-prefetch.xul"?>
<?xul-overlay href="chrome://kmprefs/content/kmprefs/ovrl-donottrack.xul"?>
<?xul-overlay href="chrome://kmprefs/content/kmprefs/ovrl-referrer.xul"?>
<!DOCTYPE page SYSTEM "chrome://kmprefs/locale/pref-privacy.dtd">
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="prefPrivacy" onload="init()">
	<stringbundle id="pref_bundle" src="chrome://kmprefs/locale/pref.properties"/>
	<script type="application/x-javascript" src="chrome://kmprefs/content/pref.js"/>
	<script type="application/x-javascript" src="chrome://kmprefs/content/kplugins/jsbridge.js"/>
	<script type="application/x-javascript">
<![CDATA[
function init() {
	initCheckbox("signon.rememberSignons"); // setInterval("initCheckbox('signon.rememberSignons')",100);
	if (JSB.load)
		document.getElementById("signonsView").removeAttribute("hidden");
	Cookies.init(); // setInterval("Cookies.init()",100);
	//   History.init();
	//   DiskCache.init();
	//   UserAgent.init();
	Referrer.init();
	initCheckbox("network.prefetch-next");
	donottrack();
}
var Cookies = {
	init : function () {
		initCheckbox("network.cookie.alwaysAcceptSessionCookies");
		initTextbox("network.cookie.lifetime.days", false);
		initRadiogroup("network.cookie.cookieBehavior");
		initRadiogroup("network.cookie.lifetimePolicy");
		this.initAcceptance();
	},
	initAcceptance : function () {
		if ("@mozilla.org/cookie-consent;1" in Components.classes)
			document.getElementById("p3p").removeAttribute("hidden");
		if (JSB.load) {
			document.getElementById("cookiePerm").removeAttribute("hidden");
			document.getElementById("cookieView").removeAttribute("hidden");
		}
		var elem = document.getElementById("network.cookie.cookieBehavior");
		document.getElementById("network.cookie.lifetimePolicy").disabled = (elem.value == 2);
		document.getElementById("network.cookie.lifetime.days").nextSibling.disabled = (elem.value == 2);
		document.getElementById("cookieP3P").disabled = (elem.value != 3);
		this.initLifetime();
	},
	initLifetime : function () {
		var elem = document.getElementById("network.cookie.lifetimePolicy");
		document.getElementById("network.cookie.alwaysAcceptSessionCookies").disabled = (elem.value != 1);
		document.getElementById("network.cookie.lifetime.days").disabled = (elem.value != 3);
	},
	toggleAcceptance : function () {
		toggleRadiogroup("network.cookie.cookieBehavior");
		this.initAcceptance();
	},
	toggleLifetime : function () {
		toggleRadiogroup("network.cookie.lifetimePolicy");
		this.initLifetime();
		if (document.getElementById("network.cookie.lifetimePolicy").value == 3)
			document.getElementById("network.cookie.lifetime.days").focus();
	}
};
var UserAgent = {
	_agnt : null,
	_box : null,
	_nam : null,
	_str : null,
	elem : null,
	bndl : null,
	pref : "general.useragent.override",
	base : "kmeleon.privacy.useragent",
	init : function () {
		this.elem = document.getElementById(this.pref);
		this.bndl = document.getElementById("pref_bundle");
		this._box = document.getElementById("UserAgentString");
		this._nam = new Array();
		this._nam[0] = this.bndl.getString("default");
		this._str = new Array();
		this._str[0] = "";
		for (var j = 1; getPrefValue(this.base + j + ".name"); j++) {
			this._nam[this._nam.length] = getPrefValue(this.base + j + ".name");
			this._str[this._str.length] = getPrefValue(this.base + j + ".string");
		}
		this.elem.appendChild(document.createElement("menupopup"));
		for (var j = 0, item = document.createElement("menuitem"); j < this._nam.length; j++) {
			item.setAttribute("label", this._nam[j]);
			item.setAttribute("value", j);
			this.elem.firstChild.appendChild(item.cloneNode(true));
			if (!j)
				this.elem.firstChild.appendChild(document.createElement("menuseparator"));
		}
		if (j > 1)
			this.elem.firstChild.appendChild(document.createElement("menuseparator"));
		item.setAttribute("label", this.bndl.getString("custom"));
		item.setAttribute("value", "custom");
		this.elem.firstChild.appendChild(item.cloneNode(true));
		this._initMenulist();
	},
	_initMenulist : function () {
		this._agnt = getPrefValue(this.pref);
		if (!this._agnt) {
			this._agnt = "";
			this.elem.selectedIndex = 0;
			this._box.value = this._str[0];
			this._box.setAttribute("readonly", true);
			return;
		}
		for (var j = 1; j < this._str.length; j++)
			if (this._agnt == this._str[j]) {
				this.elem.selectedIndex = j + 1;
				this._box.value = this._str[j];
				this._box.setAttribute("readonly", true);
				return;
			}
		this.elem.selectedItem = this.elem.firstChild.lastChild;
		this._box.value = this._agnt;
		this._box.removeAttribute("readonly");
	},
	select : function (val) {
		val = parseInt(val);
		if (isNaN(val)) {
			this._box.value = this._agnt;
			this._box.removeAttribute("readonly");
			this._box.focus();
		} else {
			if (val)
				pref.setCharPref(this.pref, this._str[val]);
			else
				restoreDefault(this.pref);
			this._initMenulist();
		}
	}
};
]]>
	</script>
	<vbox flex="1" style="overflow:auto">
		<dialogheader title="&privacy.header;"/>
		<separator class="thin"/>
		<tabcontrol flex="1">
			<tabbox flex="1">
				<tabs>
					<tab label="&general;"/>
		<!--        <tab label="&history.label;"/>
					<tab label="&cache.label;"/>	-->
					<tab label="&privacy.paranoia;"/>
				</tabs>
				<tabpanels flex="1">
					<tabpanel flex="1" orient="vertical" style="overflow:auto">
						<!-- General -->
						<separator class="thin"/>
						<checkbox oncommand="toggleCheckbox(this.id)" id="signon.rememberSignons" label="&privacy.signons;"/>
						<hbox id="signonsView" hidden="true">
							<button label="&privacy.signons.view;" oncommand="JSB.id('ID_PASSWORDS_VIEWER')" style="margin-left:2.25em"/>
							<hbox flex="1"/>
						</hbox>
						<separator class="thin"/>
						<description>&privacy.protect;</description>
						<separator class="thick"/>
						<hbox>
							<groupbox flex="1">
								<caption>
									<label>&cookies.accept;</label>
								</caption>
								<radiogroup oncommand="Cookies.toggleAcceptance()" id="network.cookie.cookieBehavior">
									<radio value="2" label="&cookies.accept.never;"/>
									<radio value="0" label="&cookies.accept.always;"/>
									<radio value="1" label="&cookies.accept.noForeign;"/>
									<vbox id="p3p" hidden="true">
										<radio value="3" label="&cookies.accept.p3p;"/>
										<hbox>
											<button id="cookieP3P" label="&cookies.view.p3p;" oncommand="window.openDialog('chrome://communicator/content/permissions/cookieP3P.xul','_blank','modal,centerscreen')" style="margin-left:2.25em"/>
										</hbox>
									</vbox>
								</radiogroup>
								<vbox id="cookiePerm" hidden="true" flex="1">
									<separator class="thin"/>
									<vbox flex="1"/>
									<hbox>
										<button label="&exceptions;" oncommand="JSB.id('ID_COOKIE_PERM')"/>
										<hbox flex="1"/>
									</hbox>
								</vbox>
							</groupbox>
							<groupbox flex="1">
								<caption>
									<label>&cookies.keep;</label>
								</caption>
								<radiogroup oncommand="Cookies.toggleLifetime()" id="network.cookie.lifetimePolicy">
									<radio value="0" label="&cookies.keep.normally;"/>
									<radio value="2" label="&cookies.keep.session;"/>
									<hbox align="center">
										<radio value="3" label="&cookies.keep.daysBefore;"/>
										<textbox id="network.cookie.lifetime.days" size="4" class="uri-element" oninput="setIntPref(this.id,this.value)"/>
										<label value="&cookies.keep.daysAfter;"/>
									</hbox>
									<radio value="1" label="&cookies.keep.ask;"/>
									<checkbox oncommand="toggleCheckbox(this.id)" id="network.cookie.alwaysAcceptSessionCookies" label="&cookies.keep.ask.notForSession;" style="margin-left:2em"/>
								</radiogroup>
								<vbox id="cookieView" hidden="true" flex="1">
									<separator class="thin"/>
									<vbox flex="1"/>
									<hbox>
										<button label="&cookies.view;" oncommand="JSB.id('ID_COOKIES_VIEWER')"/>
										<hbox flex="1"/>
									</hbox>
								</vbox>
							</groupbox>
						</hbox>
						<!-- General -->
					</tabpanel>
	<!--			<tabpanel flex="1" orient="vertical" style="overflow:auto">
						<separator class="thin"/>
						<vbox id="history"/>
					</tabpanel>
					<tabpanel flex="1" orient="vertical" style="overflow:auto">
						<separator class="thin"/>
						<groupbox id="diskcache"/>
					</tabpanel>	-->
					<tabpanel flex="1" orient="vertical" style="overflow:auto">
						<!-- Paranoia -->
						<separator class="thin"/>
<!--
						<groupbox>
							<caption><label>&useragent.label;</label></caption>
							<description>&useragent.select;</description>
							<separator class="thin"/>
							<vbox>
								<menulist id="general.useragent.override" oncommand="UserAgent.select(this.value)"/>
								<textbox id="UserAgentString" flex="1" class="uri-element" oninput="setCharPref(this.previousSibling.id,this.value)" readonly="true"/>
							</vbox>
							<separator class="thin"/>
							<description>&useragent.note;</description>
						</groupbox>
						<separator class="thin"/>
-->
						<groupbox id="referrer"/>
						<separator class="thin"/>
						<groupbox id="prefetch"/>
						<separator class="thin"/>
						<groupbox id="donottrack"/>
						<!-- Paranoia -->
					</tabpanel>
				</tabpanels>
			</tabbox>
		</tabcontrol>
	</vbox>
</page>