/*
	javascript framework

	(c) 2008 Jiří Lýsek
	jlx@seznam.cz
*/

//------------------------------------------------------------------------------

//useful functions
function fLib() {

	this.getElementById = getElementById;
	this.deleteElementById = deleteElementById;
	this.getElementsByClassName = getElementsByClassName;
	this.appendElem = appendElem;
	this.swapElemetnts = swapElemetnts;
	this.clone = clone;
	this.roundNumber = roundNumber;
	this.formatNumber = formatNumber;
	this.getNumVal = getNumVal;
	this.isNumeric = isNumeric;
	this.setValue = setValue;
	this.postData = postData;
	this.parseJSON = parseJSON;
	this.setOpacity = setOpacity;
	this.fadeElement = fadeElement;
	this.getDocumentHeight = getDocumentHeight;
	this.getDocumentWidth = getDocumentWidth;
	this.getTopScroll = getTopScroll;
	this.getWindowHeight = getWindowHeight;
	this.findPos = findPos;
	this.addMyEvent = addMyEvent;
	this.removeMyEvent = removeMyEvent;
	this.getMousePositionX = getMousePositionX;
	this.getMousePositionY = getMousePositionY;
	this.getEventTarget = getEventTarget;

	//vyhledavani elementu podle ruznych kriterii
	function getElementById(aID) {
		var elem = document.getElementById(aID);
		if(elem !== null) {
			return elem;
		} else {
			alert("Element of id: " + aID + " not found");
			return null;
		}
	}
	
	function deleteElementById(aID) {
		var remElem = fLib.getElementById(aID);
		var parElem = remElem.parentNode;
		
		if(remElem !== null && parElem !== null) {
			parElem.removeChild(remElem);
		}
	}
	
	function getElementsByClassName(findClass) {
		var elems = document.body.getElementsByTagName("*");
		var ret = new Array();
		for(var i = 0; i < elems.length; i++) {
			if(elems[i].className.indexOf(findClass) != -1) {
				ret.push(elems[i]);
			}
		}
		return ret;
	}
	
	//--------------------------------------------------------------------------
	
	function appendElem(aElem, aElemName) {
		var child = document.createElement(aElemName);
		aElem.appendChild(child);
		return child;
	}
	
	function swapElemetnts(aNew, aOld) {
		var parElem = aOld.parentNode;
		if(parElem !== null) {
			parElem.replaceChild(aNew, aOld);
			return aNew;
		} else {
			alert("Element requested to be replaced has no parent!");
		}
	}
	
	function clone(cloneID, insertID) {
		var cloneNode = document.getElementById(cloneID);
		var insertNode = document.getElementById(insertID);
		
		insertNode.appendChild(cloneNode.cloneNode(true));
	}

	//--------------------------------------------------------------------------
	
	//round to certain number of decimal numbers
	function roundNumber(num, dec) {
		var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
		return result;
	}
	
	//insert spaces afrer 3 nums
	function formatNumber(nStr) {
		nStr += "";
		var rgx = /(\d+)(\d{3})/;
		while(rgx.test(nStr)) {
			nStr = nStr.replace(rgx, "$1" + " " + "$2");
		}
		return nStr;
	}
	
	/* TODO: dodelat max */
	function getNumVal(aId, aMin) {
		var obj = document.getElementById(aId);
		var val = obj.value;
			
		if(fLib.isNumeric(val)) {
			if(obj.value >= aMin) {
				return obj.value;
			} else {
				obj.value = aMin;
				return aMin;
			}
		} else {
			obj.value = aMin;
			return aMin;
		}			
	}
	
	function isNumeric(v) {
		return typeof v != "boolean" && v !== null && !isNaN(+ v);
	}
	
	function setValue(aID, aVal) {
		var elem = fLib.getElementById(aID);
		if(elem.value !== null) {
			elem.value = aVal;
		}
	}
	
	//--------------------------------------------------------------------------

	function postData(client, url, data, StateChange) {
		client.open('POST', url);
		client.onreadystatechange = StateChange;

		client.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		client.setRequestHeader("Content-length", data.length);
		client.send(data);
	}
	
	function parseJSON(data) {
		return eval('(' + data + ')');
	}
	
	//--------------------------------------------------------------------------
	
	function setOpacity(opac, elem) {
		if(browser.isIE) {
			elem.style.filter = "alpha(opacity=" + opac + ")";
		} else {
			elem.style.opacity = opac / 100;
		}
	}
	
	function fadeElement(aElem, aOpacityStart, aOpacityEnd, aStep, aTimeStep, aCallback) {
		function doStep(aStart, aEnd, aStep) {
			if(aStart == aEnd) {
				return false;
			}
			return (aStart > aEnd) ? aStart - aStep : aStart + aStep;
		}
		
		function opacityStep() {
			if((newOpacity = doStep(current, aOpacityEnd, aStep)) !== false) {
				fLib.setOpacity(newOpacity, aElem);
				//alert(newOpacity)
				current = newOpacity;
				setTimeout(opacityStep, aTimeStep);
			} else {
				//uz je konec prechodu
				if(aCallback !== undefined) {
					aCallback();
				}
			}
		}
		
		setTimeout(opacityStep, aTimeStep);
		var current = aOpacityStart;
	}
	
	//--------------------------------------------------------------------------
	
	//height of document
	function getDocumentHeight() {
		return document.documentElement.scrollHeight;
	}

	//width of document
	function getDocumentWidth() {
		return document.documentElement.scrollWidth;
	}
	
	//return scroll position
	function getTopScroll() {
		return document.documentElement.scrollTop;
	}
	
	//height of viewport
	function getWindowHeight() {
		if(window.innerHeight) {
			return window.innerHeight;
		} else {
			return document.documentElement.clientHeight;
		}
	}
	
	function findPos(obj) {
		var curleft = curtop = 0;
		if (obj.offsetParent) {
			do {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
			} while (obj = obj.offsetParent);
		}
		return [curleft,curtop];
	}
	
	//--------------------------------------------------------------------------
	
	//adds event to element
	function addMyEvent(eventName, handler, object) {
		if(object.addEventListener) {
			object.addEventListener(eventName, handler, false);
		} else {
			object.attachEvent("on" + eventName, handler);
		}
	}
	
	//removes event from element
	function removeMyEvent(eventName, handler, object) {
		if(object.removeEventListener) {
			object.removeEventListener(eventName, handler, false);
		} else {
			object.detachEvent("on" + eventName, handler);
		}
	}
	
	//mouse position
	function getMousePositionX(e) {
		return e.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
	}
	
	function getMousePositionY(e) {
		return e.clientY + document.documentElement.scrollTop + document.body.scrollTop;
	}
	
	function getEventTarget(e) {
		if(!e)
			var e = window.event;
	
		if(e.target) {
			var elem = e.target;
		} else if(e.srcElement) {
			var elem = e.srcElement;
		}
		return elem;
	}

}

//==============================================================================

function browser() {
	this.isIE = false;
	this.isNS = false;

	var agent = navigator.userAgent;
	var s = "MSIE";

	if(agent.indexOf(s) >= 0) {
		this.isIE = true;
		return;
	} else {
		this.isNS = true;
		return;
	}
}

//==============================================================================

function MovableModalWindow(Title) {

	this.Show = Show;
	this.StartDrag = StartDrag;
	this.EndDrag = EndDrag;
	this.MoveFunction = MoveFunction;
	this.RemoveWindow = RemoveWindow;
	this.SetWH = SetWH;

	var ID = "modalBox";
	var Title = Title;

	var Width = 300;
	var Height = 100;

	var Drag = false;
	var DragX = 0;
	var DragY = 0;

	var ModalObj = null;
	var ModalObj2 = null;

	function StartDrag(e) {

		var LeftClick = false;

		if(!e) e = window.event;

		if (e.which) {
			LeftClick = (e.which == 1);
		}  else if(e.button) {
			LeftClick = (e.button == 1);
		}

		if(LeftClick) {

			DragX = fLib.getMousePositionX(e);
			DragY = fLib.getMousePositionY(e);

			Drag = true;
		}
	}

	function EndDrag() {
		Drag = false;
	}

	function MoveFunction(e) {
		if(Drag) {
			if(!e) e = window.event;

			diffX = fLib.getMousePositionX(e) - DragX;
			diffY = fLib.getMousePositionY(e) - DragY;

			DragX = fLib.getMousePositionX(e);
			DragY = fLib.getMousePositionY(e);

			ModalWindow.style.left = parseInt(ModalWindow.style.left, 10) + diffX + 'px';
			ModalWindow.style.top = parseInt(ModalWindow.style.top, 10) + diffY + 'px';

			if(!browser.isIE) {
				e.cancelBubble = true;
				e.returnValue = false;
			} else {
				e.preventDefault();
			}
		}
	}

	//---------------------------------------------------------------------------

	function RemoveWindow() {
		var docBody = document.getElementsByTagName("body")[0];
		fLib.removeMyEvent("mousemove", this.MoveFunction, document);
		docBody.removeChild(ModalObj);
		//docBody.removeChild(ModalObj2);
	}
	
	function SetWH(aW, aH) {
		Width = aW;
		Height = aH;
	}

	function Show() {
		var docBody = document.getElementsByTagName("body")[0];

		//pokud uz existuje
		if(document.getElementById(ID)) {
			return false;
		}
		
		/*ModalObj2 = docBody.appendChild(document.createElement("div"));
		ModalObj2.style.width = fLib.getDocumentWidth() + "px";
		ModalObj2.style.height = fLib.getDocumentHeight() + "px";
		fLib.setOpacity(20, ModalObj2);
		ModalObj2.id = ID;
		ModalObj2.style.backgroundColor = "#000000";*/

		ModalObj = docBody.appendChild(document.createElement("div"));
		ModalObj.id = ID;
		ModalObj.style.width = fLib.getDocumentWidth() + "px";
		ModalObj.style.height = fLib.getDocumentHeight() + "px";
		
		// okynko
		ModalWindow = document.createElement("div");
		ModalWindow.id = "messageBox";
		ModalWindow.style.width = Width + 'px';

		// centrovani
		var posTop = Math.round(((fLib.getWindowHeight() - Height) / 2) + fLib.getTopScroll());
		if(posTop < 0) {
			posTop = 10;
		}
		ModalWindow.style.top = posTop + "px";
		ModalWindow.style.left = Math.round((fLib.getDocumentWidth() - Width)/2) + "px";

		// header
		Header = document.createElement("div");
		Header.appendChild(document.createTextNode(Title));
		Header.className = "header";
		Header.onmousedown = this.StartDrag;
		Header.onmouseup = this.EndDrag;
		ModalWindow.appendChild(Header);

		fLib.addMyEvent("mousemove", this.MoveFunction, document);

		ModalObj.appendChild(ModalWindow);

		this.ModalObj = ModalObj;
		this.ModalWindow = ModalWindow;
	}
}

//==============================================================================

function ConfirmationDialog(s) {

	var ID = "customConfirm";
	var Title = appMessages.get(25);
	var Message = appMessages.get(20);
	var YesAction = s;
	var Parent = new MovableModalWindow(Title);

	this.Show = Show;
	this.OKFunction = OKFunction;
	this.CancelFunction = CancelFunction;

	function CancelFunction() {
		Parent.RemoveWindow();
		return true;
	}

	function OKFunction() {
		Parent.RemoveWindow();
		window.location.replace(YesAction);
		return true;
	}

	function Show() {

		Parent.Show();

		// text
		msg = Parent.ModalWindow.appendChild(document.createElement("p"));
		msg.appendChild(document.createTextNode(Message));

		// tlacitka
		div = Parent.ModalWindow.appendChild(document.createElement("div"));
		div.id = "btnContainer";

		btn1 = div.appendChild(document.createElement("button"));
		btn1.id = "btn";
		btn1.appendChild(document.createTextNode(appMessages.get(50)));
		btn1.onclick = this.OKFunction;
		btn1.focus();

		btn3 = div.appendChild(document.createElement("button"));
		btn3.id = "btn";
		btn3.appendChild(document.createTextNode(appMessages.get(45)));
		btn3.onclick = this.CancelFunction;

	}
}

function ConfirmationDialogForm(text, callBackOK, callbackCancel) {

	var ID = "customConfirm";
	var Title = appMessages.get(25);
	var Message = text;
	var Parent = new MovableModalWindow(Title);
	var CallBackOk = callBackOK;
	var CallBackCancel = callbackCancel;

	this.Show = Show;
	this.OKFunction = OKFunction;
	this.CancelFunction = CancelFunction;

	function CancelFunction() {
		Parent.RemoveWindow();
		CallBackCancel();
		return true;
	}

	function OKFunction() {
		Parent.RemoveWindow();
		CallBackOk();
		return true;
	}

	function Show() {

		Parent.Show();

		// text
		msg = Parent.ModalWindow.appendChild(document.createElement("p"));
		msg.appendChild(document.createTextNode(Message));

		// tlacitka
		div = Parent.ModalWindow.appendChild(document.createElement("div"));
		div.id = "btnContainer";

		btn1 = div.appendChild(document.createElement("button"));
		btn1.id = "btn";
		btn1.appendChild(document.createTextNode(appMessages.get(50)));
		btn1.onclick = this.OKFunction;
		btn1.focus();

		btn3 = div.appendChild(document.createElement("button"));
		btn3.id = "btn";
		btn3.appendChild(document.createTextNode(appMessages.get(45)));
		btn3.onclick = this.CancelFunction;

	}
}

//==============================================================================

function QuestionDialog(s, text) {

	var ID = "customConfirm";
	var Title = appMessages.get(15);
	var Message = text;
	var YesAction = s;
	var Parent = new MovableModalWindow(Title);

	this.Show = Show;
	this.OKFunction = OKFunction;
	this.CancelFunction = CancelFunction;
	this.BackFunction = BackFunction;

	function CancelFunction() {
		Parent.RemoveWindow();
		return true;
	}

	function OKFunction() {
		Parent.RemoveWindow();
		window.location.replace(YesAction);
		return true;
	}

	function BackFunction() {
		Parent.RemoveWindow();
		return true;
	}

	function Show() {

		Parent.Show();

		// text
		msg = Parent.ModalWindow.appendChild(document.createElement("p"));
		//msg.innerHTML = Message;
		msg.appendChild(document.createTextNode(Message));

		// tlacitka
		div = Parent.ModalWindow.appendChild(document.createElement("div"));
		div.id = "btnContainer";

		btn1 = div.appendChild(document.createElement("button"));
		btn1.id = "btn";
		btn1.appendChild(document.createTextNode(appMessages.get(30)));
		btn1.onclick = this.OKFunction;
		btn1.focus();

		btn2 = div.appendChild(document.createElement("button"));
		btn2.id = "btn";
		btn2.appendChild(document.createTextNode(appMessages.get(35)));
		btn2.onclick = this.BackFunction;

		btn3 = div.appendChild(document.createElement("button"));
		btn3.id = "btn";
		btn3.appendChild(document.createTextNode(appMessages.get(45)));
		btn3.onclick = this.CancelFunction;

	}
}

//==============================================================================

function AlertDialog(text) {

	var ID = "customAlert";
	var Title = appMessages.get(10);
	var Message = text;
	var Parent = new MovableModalWindow(Title);

	this.Show = Show;
	this.OKFunction = OKFunction;

	function OKFunction() {
		Parent.RemoveWindow();
		return true;
	}

	function Show() {

		Parent.Show();

		// text
		msg = Parent.ModalWindow.appendChild(document.createElement("p"));
		msg.innerHTML = Message;

		// tlacitka
		div = Parent.ModalWindow.appendChild(document.createElement("div"));
		div.id = "btnContainer";

		btn1 = div.appendChild(document.createElement("button"));
		btn1.id = "btn";
		btn1.appendChild(document.createTextNode(appMessages.get(50)));
		btn1.onclick = this.OKFunction;
		btn1.focus();
	}
}

//==============================================================================

function QueryDialog(message, callBack, initVal) {

	var ID = "customQuery";
	var Title = appMessages.get(60);
	var Message = message;
	var CallBack = callBack;
	var InitVal = initVal;
	var Parent = new MovableModalWindow(Title);

	this.Show = Show;
	this.OKFunction = OKFunction;
	this.CancelFunction = CancelFunction;

	function CancelFunction() {
		Parent.RemoveWindow();
		return true;
	}

	function OKFunction() {
		Parent.RemoveWindow();
		CallBack(inp.value);
		return true;
	}

	function Show() {

		Parent.Show();

		// text
		msg = Parent.ModalWindow.appendChild(document.createElement("p"));
		msg.appendChild(document.createTextNode(Message));

		// tlacitka
		div = Parent.ModalWindow.appendChild(document.createElement("div"));
		div.id = "btnContainer";

		frm = msg.appendChild(document.createElement("form"));
		inp = frm.appendChild(document.createElement("input"));
		inp.id = "inp";
		frm.onsubmit = this.OKFunction;

		inp.value = InitVal;
		inp.focus();
		inp.select();

		btn1 = div.appendChild(document.createElement("button"));
		btn1.id = "btn";
		btn1.appendChild(document.createTextNode(appMessages.get(50)));
		btn1.onclick = this.OKFunction;

		btn3 = div.appendChild(document.createElement("button"));
		btn3.id = "btn";
		btn3.appendChild(document.createTextNode(appMessages.get(45)));
		btn3.onclick = this.CancelFunction;

	}
}

//==============================================================================

function EditorDialog(text, callBack) {
	var ID = "customEdit";
	var Title = "Edit HTML";
	var Parent = new MovableModalWindow(Title);
	var CallBack = callBack;
	var Text = text;
	var area;
	
	this.Show = Show;
	this.OKFunction = OKFunction;
	this.CancelFunction = CancelFunction;
	
	function OKFunction() {
		Parent.RemoveWindow();
		CallBack(area.value);
		return true;
	}
	
	function CancelFunction() {
		Parent.RemoveWindow();
		return true;
	}
			
	function Show() {
		Parent.SetWH(800, 600);
		Parent.Show();
		
		// textarea
		area = Parent.ModalWindow.appendChild(document.createElement("textarea"));
		//Parent.ModalWindow.style.width = "550px";
		area.value = Text;
		area.style.width = "750px";
		area.style.height = "550px";
		area.style.marginLeft = "auto";
		area.style.marginRight = "auto";
		if(browser.isIE) {
			area.style.styleFloat = "none";
		} else {
			area.style.cssFloat = "none";
		}
		 
		// tlacitka
		var div = Parent.ModalWindow.appendChild(document.createElement("div"));
		div.id = "btnContainer";
		div.style.clear = "both";
		
		var btn1 = div.appendChild(document.createElement("button"));
		btn1.id = "btn";
		btn1.appendChild(document.createTextNode(appMessages.get(50)));
		btn1.onclick = this.OKFunction;

		var btn3 = div.appendChild(document.createElement("button"));
		btn3.id = "btn";
		btn3.appendChild(document.createTextNode(appMessages.get(45)));
		btn3.onclick = this.CancelFunction;
		
	}
}


//==============================================================================

function application() {

	this.Alert = Alert;
	this.Confirm = Confirm;
	this.ConfirmForm = ConfirmForm;
	this.Question = Question;
	this.Query = Query;
	this.Editor = Editor;
	this.wysiwygEdit = wysiwygEdit;
	
	this.calendar = new calendar;
	
	//--------------------------- dialogs --------------------------------------

	function Confirm(s, text) {
		Dialog = new ConfirmationDialog(s);
		Dialog.Show();
		Dialog = null;
	}
	
	function ConfirmForm(text, callBackOK, callBackCancel) {
		Dialog = new ConfirmationDialogForm(text, callBackOK, callBackCancel);
		Dialog.Show();
		Dialog = null;
	}

	function Question(s, text) {
		Dialog = new QuestionDialog(s, text);
		Dialog.Show();
		Dialog = null;
	}

	function Alert(text) {
		Dialog = new AlertDialog(text);
		Dialog.Show();
		Dialog = null;
	}

	function Query(message, callBack, initVal) {
		Dialog = new QueryDialog(message, callBack, initVal);
		Dialog.Show();
		Dialog = null;
	}
	
	function Editor(text, callback) {
		Dialog = new EditorDialog(text, callback);
		Dialog.Show();
		Dialog = null;
	}
	
	//--------------------------- wysiwyg editor -------------------------------	

	function wysiwygEdit() {
	
		this.init = init;
		this.formatText = formatText;
		this.createURL = createURL;
		this.selectColor = selectColor;
		this.getText = getText;
		this.email = email;
		this.image = image;
		this.editHTML = editHTML;
		this.removeFormat = removeFormat;
		this.setForm = setForm;
	
		var editorElem = null;
		var formElem = null;
		var submitElem = null;
		var editor = null;
		var output = null;
		
		function init(aEditorID, aOutputID, aContent) {
			if((editorElem = document.getElementById(aEditorID)) !== null) {
				editor = editorElem.contentWindow.document;
				output = document.getElementById(aOutputID);
				editor.designMode = "On";
				editor.write("<html><head></head><body>");
				editor.write(aContent);
				editor.write("</body></html>");
				editor.body.style.margin = "0px";
				editor.body.style.padding = "5px";
				editor.body.style.fontFamily = "Verdana, Arial, Helvetica, sans-serif";
				editor.body.style.fontSize = "12px";
				editor.close();
			}
		}
		
		function editHTML() {
			var data = getText();
			data = data.replace("<br>", "<br />\r\n");
			Editor(data, putText);
		}
		
		function setForm(aFormID, aDataID) {
			formElem = fLib.getElementById(aFormID);
			submitElem = fLib.getElementById(aDataID);
			fLib.addMyEvent("submit", returnText, formElem);
		}
		
		function returnText() {
			submitElem.value = getText();
		}
		
		//ziskani textu
		function getText() {
			return editor.body.innerHTML;
		}
		
		function putText(aText) {
			//alert(aText);
			editor.body.innerHTML = aText;
		}
		
		//formatovaci funkce
		function formatText(aStyle, aParam) {
			editor.execCommand(aStyle, false, aParam);
		}
		
		function removeFormat() {
			editor.execCommand("RemoveFormat", false, null);
			editor.execCommand("formatblock", false, "<p>");
		}
		
		//URL
		function createURL() {
			app.Query("URL:", placeURL, "http://");
		}
		
		function placeURL(aURL) {
			if ((aURL != null) && (aURL != "")) {
				editor.execCommand("CreateLink", false, aURL);
			}
		}
		
		//email
		function email() {
			app.Query("email:", placeMail, "");
		}
		
		function placeMail(aMail) {
			placeURL("mailto:" + aMail);
		}
		
		//img
		function image() {
			app.Query("URL:", placeImage, "http://");
		}
		
		function placeImage(aURL) {
			editor.execCommand("InsertImage", false, aURL);
		}
		
		//barva
		function selectColor() {
			app.Query("Color:", setColor, "#000000");
		}
		
		function setColor(color) {
			editor.execCommand("forecolor", false, color);
		}
		
	}
	
	//-------------------------------- calendar --------------------------------
	
	function calendar() {
	
		this.showCalendar = showCalendar;
		this.hideCalendar = hideCalendar;
		this.setDate = setDate;
		this.getMonth = getMonth;
		
		var calendarElem;
		var calendarHook;
		var targetElemD = null;
		var targetElemM = null;
		var targetElemY = null;
		var calendarOpened = false;
		
		var client = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP.3.0");
				
		function getCalendar() {
			if(client.readyState == 4) {
				if(client.status == 200) {
					calendarElem.innerHTML = client.responseText;
				} else {
					alert('There was a problem with the request.');
				}
			}
		}
		
		function getMonth(aMon, aYr) {
			fLib.postData(client, 'index.php', 'act=calendar&mon=' + aMon + '&yr=' + aYr, getCalendar);
		}

		function showCalendar(aObj, aTargetD, aTargetM, aTargetY) {
		
			if(calendarOpened) {
				hideCalendar();
			}
		
			calendarHook = aObj;
			calendarElem = document.createElement("div");
			targetElemD = document.getElementById(aTargetD);
			targetElemM = document.getElementById(aTargetM);
			targetElemY = document.getElementById(aTargetY);
			
			var pos = fLib.findPos(calendarHook);
			
			calendarElem.style.position = "absolute";
			
			calendarElem.style.left = (pos[0] + 20) + "px";
			calendarElem.style.top = pos[1] + "px";
			
			fLib.postData(client, 'index.php', 'act=calendar', getCalendar);
			
			calendarHook.parentNode.appendChild(calendarElem);
			
			calendarOpened = true;
		}
		
		function hideCalendar() {
			calendarHook.parentNode.removeChild(calendarElem);
			calendarOpened = false;
		}
		
		function setDate(aD, aM, aY) {
			targetElemD.value = aD;
			targetElemM.value = aM;
			targetElemY.value = aY;
			hideCalendar();
		}
	}

}

//==============================================================================

var browser = new browser();
var fLib = new fLib();
var app = new application();