﻿/*Created By: Chris D'Aoust*/
var xmlR = window.xml.Resource;
var path = siteDomain;
function closeInput() 
{
	d = window.document;
	if (d.getElementById("jsEventContainer"))
	    d.getElementsByTagName("body")[0].removeChild(d.getElementById("jsEventContainer"));
	if (d.getElementById("layerControl"))
	    d.getElementsByTagName("body")[0].removeChild(d.getElementById("layerControl"));
	if (d.getElementById("field")) {
		d.getElementsByTagName("body")[0].removeChild(d.getElementById("field"));
	}
	return false;
}
if(document.getElementById) 
{
    window.debugAlert = window.alert;
	window.alert = function(txt, var1, obj) 
	{
		return alertUser(txt, var1, obj);
	}
}

var trk = false;
var ox = 0;
var oy = 0;
document.onmousemove = mtrk;
document.onkeypress = keyStroke;
var obj = null;
if (!ie) 
{
	window.onmousemove = mtrk;
    window.onkeypress = keyStroke;
}
function keyStroke(e) 
{
	d = window.document;
	var key = (ie)? event.keyCode : e.which;
	if (d.getElementById("jsEventContainer")) {
		if (key==13) {
			d.getElementById("jsBtn").onclick();
		}
		if (key==27 || (key==0 && e.DOM_VK_ESCAPE==27)) {
			if (d.getElementById("jsBtn")) {
				d.getElementById("jsBtn").onclick();
			} else {
				d.getElementById("jsBtn").onclick();
			}
		}
	}
}
function mtrk(e) 
{
	if (trk && obj) {
		obj.style.left = (((ie)?event.x:e.pageX)-ox) + "px";
		obj.style.top = (((ie)?event.y:e.pageY)-oy) + "px";
	}
}
function setOffset(e) 
{
	ox = ((ie)?event.x:e.pageX) - parseInt(obj.style.left.replace("px",""));
	oy = ((ie)?event.y:e.pageY) - parseInt(obj.style.top.replace("px",""));
}
function remFocus(height) 
{
	d = window.document;
	field = d.getElementsByTagName("body")[0].appendChild(d.createElement("input"));
	field.id = "field";
	field.style.width = 1;
	field.style.height = 1;
	field.style.position = "absolute";
	field.style.top = height;
	field.style.right = 0;	
	field.focus();
	field.style.display = "none";
	
}
function alertUser(msgField, var1, obj) {
	var d = window.document;
	if (d.getElementById("jsEventContainer")) { return false; }	
	bdy = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
	bdy.id = "layerControl";
	frameControl = d.createElement("iframe");
	frameControl.src = path+"blank.htm";
	frameControl.id = "iframeLayer";
	frameControl.setAttribute("frameborder", "0");
	frameControl.style.height = d.documentElement.scrollHeight + "px";
	bdy.appendChild(frameControl);
	bdy = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
	bdy.onselectstart = function() { return false; }
	bdy.id = "jsEventContainer";
	bdy.style.height = d.documentElement.scrollHeight + "px";
	confirmObj = bdy.appendChild(d.createElement("div"));
	confirmObj.id = "jsEventBox";
	confirmObj.style.top = (d.documentElement.scrollTop+30) + "px";
	confirmObj.style.left = (d.documentElement.scrollWidth - confirmObj.offsetWidth)/2 + "px";
	header = confirmObj.appendChild(d.createElement("div"));
	header.id = "jsEventHdr";
	header.onmousedown = function(e) {
		window.parent.obj = d.getElementById('jsEventBox');
		window.parent.setOffset(e);
		window.parent.trk = true;
	}
	header.onmouseup = function() {
		window.parent.trk = false;		
	}
	header.appendChild(d.createTextNode(xmlR.alert));
	msgDiv = confirmObj.appendChild(d.createElement("div"));
	msgDiv.id = "jsEventMsgDiv";
	regEx = "\\r\\n";
	msgDiv.innerHTML = eval('xmlR.'+msgField).replace(regEx, "<br>").replace("VARIABLE", var1);	
	btnDiv = confirmObj.appendChild(d.createElement("div"));	
	btnDiv.id = "jsEventBtnBox";
	if (ie) {
	btnDiv.style.left = 0 + "px";
	}
	btnTable = btnDiv.appendChild(d.createElement("table"));
	btnTable.border = 0;
	btnTable.align = "center";
	btnTable.setAttribute("cellPadding", "0");
	btnTable.setAttribute("cellSpacing", "0");
	btnTbody = btnTable.appendChild(d.createElement("TBODY"));
	btnTr = btnTbody.appendChild(d.createElement("tr"));
	btnTr.obj = obj;
	btnTr.onclick = function() {
		if (obj) {
			obj.focus();
		}
		return closeInput();
	}
	btnTr.id = "jsBtn";
	btnTd = btnTr.appendChild(d.createElement("td"));
	btnImg = btnTd.appendChild(d.createElement("img"));
	btnImg.src = path+"images/buttonBackgroundLeft.gif";
	btnTd = btnTr.appendChild(d.createElement("td"));	
	btnTd.appendChild(d.createTextNode(xmlR.ok));
	btnTd.id = "jsBtnTxt";
	btnTd = btnTr.appendChild(d.createElement("td"));
	btnImg = btnTd.appendChild(d.createElement("img"));
	btnImg.src = path+"images/buttonBackgroundRight.gif";
	remFocus(confirmObj.style.top);
	return false;
}
function confirmUser(msgField, func, var1, var2, var3) {
	d = window.document;
	if (d.getElementById("jsEventContainer")) { return false; }
	bdy = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
	bdy.id = "layerControl";
	frameControl = d.createElement("iframe");
	frameControl.src = path+"blank.htm";
	frameControl.id = "iframeLayer";
	frameControl.style.height = d.documentElement.scrollHeight + "px";
	bdy.appendChild(frameControl);
	bdy = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
	bdy.onselectstart = function() { return false; }
	bdy.id = "jsEventContainer";
	bdy.style.height = d.documentElement.scrollHeight + "px";
	confirmObj = bdy.appendChild(d.createElement("div"));
	confirmObj.id = "jsEventBox";
	confirmObj.style.top = (d.documentElement.scrollTop+30) + "px";
	confirmObj.style.left = (d.documentElement.scrollWidth - confirmObj.offsetWidth)/2 + "px";
	header = confirmObj.appendChild(d.createElement("div"));
	header.id = "jsEventHdr";
	header.onmousedown = function(e) {
		window.top.obj = d.getElementById('jsEventBox');
		window.top.setOffset(e);
		window.top.trk = true;
	}
	header.onmouseup = function() {
		window.top.trk = false;		
	}
	header.appendChild(d.createTextNode(xmlR.confirm));
	msgDiv = confirmObj.appendChild(d.createElement("div"));
	msgDiv.id = "jsEventMsgDiv";
	regEx = "\\r\\n";
	msgDiv.innerHTML = eval('xmlR.'+msgField).replace(regEx, "<br>").replace("VARIABLE", var1);	
	btnDiv = confirmObj.appendChild(d.createElement("div"));
	btnDiv.id = "jsEventBtnBox";
	if (ie) {
	btnDiv.style.left = 0 + "px";
	}
	btnDiv.align = "center";
	
	
	
	btnDiv1 = btnDiv.appendChild(d.createElement("div"));
	btnDiv1.className = "btnLeftAlign";
	btnTable = btnDiv1.appendChild(d.createElement("table"));
	btnTable.border = 0;
	btnTable.style.display = "inline";
	btnTable.setAttribute("cellPadding", "0");
	btnTable.setAttribute("cellSpacing", "0");
	btnTbody = btnTable.appendChild(d.createElement("TBODY"));
	btnTr = btnTbody.appendChild(d.createElement("tr"));	
	btnTr.func = func;
	btnTr.var1 = var1;
	btnTr.var2 = var2;
	btnTr.onclick = function() {  
	    func(var1, var2);
	    return closeInput();
	}
	btnTr.id = "jsBtn";
	btnTd = btnTr.appendChild(d.createElement("td"));
	btnImg = btnTd.appendChild(d.createElement("img"));
	btnImg.src = path+"images/buttonBackgroundLeft.gif";
	btnTd = btnTr.appendChild(d.createElement("td"));	
	btnTd.appendChild(d.createTextNode(xmlR.yes));
	btnTd.id = "jsBtnTxt";
	btnTd = btnTr.appendChild(d.createElement("td"));
	btnImg = btnTd.appendChild(d.createElement("img"));
	btnImg.src = path+"images/buttonBackgroundRight.gif";
	btnDiv2 = btnDiv.appendChild(d.createElement("div"));
	btnDiv2.className = "btnRightAlign";
	btnTable = btnDiv2.appendChild(d.createElement("table"));
	btnTable.border = 0;
	btnTable.style.display = "inline";
	btnTable.setAttribute("cellPadding", "0");
	btnTable.setAttribute("cellSpacing", "0");
	btnTbody = btnTable.appendChild(d.createElement("TBODY"));
	btnTr = btnTbody.appendChild(d.createElement("tr"));
	btnTr.onclick = function() {
		return closeInput();
	}
	btnTr.id = "jsBtn";
	btnTd = btnTr.appendChild(d.createElement("td"));
	btnImg = btnTd.appendChild(d.createElement("img"));
	btnImg.src = path+"images/buttonBackgroundLeft.gif";
	btnTd = btnTr.appendChild(d.createElement("td"));	
	btnTd.appendChild(d.createTextNode(xmlR.no));
	btnTd.id = "jsBtnTxt";
	btnTd = btnTr.appendChild(d.createElement("td"));
	btnImg = btnTd.appendChild(d.createElement("img"));
	btnImg.src = path+"images/buttonBackgroundRight.gif";
	remFocus(confirmObj.style.top);
	return false;
}
function promptUser(msgField, defaultField, func, var1) {
	d = window.top.document;
	if (d.getElementById("jsEventContainer")) { return false; }
	bdy = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
	bdy.id = "layerControl";	
	frameControl = d.createElement("iframe");
	frameControl.style.height = d.documentElement.scrollHeight + "px";
	frameControl.src = path+"blank.htm";
	frameControl.id = "iframeLayer";
	bdy.appendChild(frameControl);
	bdy = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
	bdy.id = "jsEventContainer";
	bdy.style.height = d.documentElement.scrollHeight + "px";
	promptObj = bdy.appendChild(d.createElement("div"));
	promptObj.id = "jsEventBox";
	promptObj.style.top = (d.documentElement.scrollTop+80) + "px";
	promptObj.style.left = (d.documentElement.scrollWidth - promptObj.offsetWidth)/2 + "px";
	header = promptObj.appendChild(d.createElement("div"));
	header.onselectstart = function() { return false; }
	header.id = "jsEventHdr";
	header.onmousedown = function(e) {
		window.top.obj = d.getElementById('jsEventBox');
		window.top.setOffset(e);
		window.top.trk = true;
	}
	header.onmouseup = function() {
		window.top.trk = false;		
	}
	hdrImg = header.appendChild(d.createElement("img"));
	hdrImg.src = path+"images/jsEvents/p.gif";
	hdrImg.align = "absmiddle";
	header.appendChild(d.createTextNode(xmlR.system_prompt));
	table = promptObj.appendChild(d.createElement("table"));
	tbody = table.appendChild(d.createElement("TBODY"));
	table.id = "tbl";
	table.border = 0;
	table.setAttribute("cellPadding", "5");
	table.setAttribute("cellSpacing", "0");
	tr = tbody.appendChild(d.createElement("tr"));
	tr.setAttribute("style", "-moz-user-select: none;");
	tr.onselectstart = function() { return false; }
	td = tr.appendChild(d.createElement("td"));
	td.style.width = 385;
	td.appendChild(d.createTextNode(eval('xmlR.'+msgField)));
	td = tr.appendChild(d.createElement("td"));
	btnTable = td.appendChild(d.createElement("table"));
	btnTable.border = 0;
	btnTable.align = "center";
	btnTable.setAttribute("cellPadding", "0");
	btnTable.setAttribute("cellSpacing", "0");
	btnTbody = btnTable.appendChild(d.createElement("TBODY"));
	btnTr = btnTbody.appendChild(d.createElement("tr"));
	btnTr.func = func;
	btnTr.var1 = var1;
	btnTr.onclick = function() {
		if (d.getElementById('inputField').value!="") {
			func(d.getElementById('inputField').value, var1);
		}
		return closeInput();
	}
	btnTr.id = "jsBtn";
	btnTd = btnTr.appendChild(d.createElement("td"));
	btnImg = btnTd.appendChild(d.createElement("img"));
	btnImg.src = path+"images/jsEvents/btnLeft.gif";
	btnTd = btnTr.appendChild(d.createElement("td"));	
	btnTd.appendChild(d.createTextNode(xmlR.ok));
	btnTd.id = "jsBtnTxt";
	btnTd = btnTr.appendChild(d.createElement("td"));
	btnImg = btnTd.appendChild(d.createElement("img"));
	btnImg.src = path+"images/jsEvents/btnRight.gif";	
	btnTr = btnTbody.appendChild(d.createElement("tr"));
	td.appendChild(d.createTextNode(spacer(1)));
	btnTable = td.appendChild(d.createElement("table"));
	btnTable.border = 0;
	btnTable.align = "center";
	btnTable.setAttribute("cellPadding", "0");
	btnTable.setAttribute("cellSpacing", "0");
	btnTbody = btnTable.appendChild(d.createElement("TBODY"));
	btnTr = btnTbody.appendChild(d.createElement("tr"));
	btnTr.onclick = function() {
		return closeInput();
	}
	btnTr.id = "jsBtn";
	btnTd = btnTr.appendChild(d.createElement("td"));
	btnImg = btnTd.appendChild(d.createElement("img"));
	btnImg.src = path+"images/jsEvents/btnLeft.gif";
	btnTd = btnTr.appendChild(d.createElement("td"));
	btnTd.appendChild(d.createTextNode(xmlR.cancel));
	btnTd.id = "jsBtnTxt";
	btnTd = btnTr.appendChild(d.createElement("td"));
	btnImg = btnTd.appendChild(d.createElement("img"));
	btnImg.align = "absmiddle";
	btnImg.src = path+"images/jsEvents/btnRight.gif";
	tr = tbody.appendChild(d.createElement("tr"));
	td = tr.appendChild(d.createElement("td"));
	td.colSpan = 2;
	inputField = td.appendChild(d.createElement("input"));
	inputField.id = "inputField";
	inputField.style.width = "85%";
	inputField.setAttribute("type", "text");
	inputField.value = (defaultField.substring(0,3)=="js_")?eval('xmlR.'+defaultField):defaultField;
	inputField.select();
	return false;
}