// requires Dom v1.7
// initialisation of library objects

function init() {
	var i; // iterator
	try {
		var imgRootElement = document.getElementById("img_root");
		var img_root = imgRootElement.content;
		
//		var linkMenuIcon = img_root + "arrow01_right.gif";
//		var linkBackIcon = img_root + "arrow01_left.gif";
		var newWindowIcon = img_root + "icons/url.gif";
		var detailLinkIcon = img_root + "icons/arrow.gif";
	} catch(ex) { exceptionWarning(ex, "init images"); };
	
	var quotes=new Array();
	quotes[0]='"';
	quotes[1]='"';
	
	try {
		var quoteTags = document.getElementsByTagName("q");
		for (i = 0; i < quoteTags.length; i++) {
			if (document.getElementsByTagName && document.all && !window.opera) {
				addContent(quoteTags[i], quotes[0], "before");
				addContent(quoteTags[i], quotes[1], "after");
			}
		}
	} catch(ex) { exceptionWarning(ex, "init quotes"); };
	
	var anchors = document.getElementsByTagName("a");
	for (i = 0; i < anchors.length; i++) {
		setTarget(anchors[i]);
		if((anchors[i].target == "_blank") && !cls.has(anchors[i], "noIcon"))
			addIcon(anchors[i], newWindowIcon, "after");
		if(cls.has(anchors[i], "detailLink"))
			addIcon(anchors[i], detailLinkIcon, "after");
	}

	// init input fields
	var inputs = elm.getByTag("input"); // input fields - HTML collection
	var button;
	for (i = 0; i < inputs.length; i++) {
		// init calendar
		if ((cls.has(inputs[i], "date"))) {
			try {
				button = document.createElement('img');
				button.className = "BTNcalendar";
				button.id = inputs[i].id+"_calendar";
				button.src = img_root+"calendar.gif";
				button.alt = "Calendar";
				button.title = "Open Calendar";
				if (inputs[i].nextSibling)
					inputs[i].parentNode.insertBefore(button, inputs[i].nextSibling);
				else
					inputs[i].parentNode.appendChild(button);
				Calendar.setup( {
					inputField  : inputs[i],      // input field
					button      : button,       // button
					ifFormat    : dateFormat,   // the date format is defined in local-specific variables
					step        : 1,            // step of the years in drop-down boxes
					firstDay    : dateFirstDay, // first day of week is defined in local-specific variables
					align       : "Bl"
				} );
			} catch(ex) {exceptionError(ex, "init calendar");}
		}
	}

/*
	// init forms
	var formulars = elm.getByTag("form");
	var frm;
	for (i = 0; i < formulars.length; i++) {
		// init checkForm
		try {
			frm = new SimpleForm();
			frm.init(formulars[i]);
			frm.addCheckArray(checkFunctions);
			frm.addCheckRegExpArray(checkRegExps);
		} catch(ex) {exceptionError(ex, "init checkForm");}
	}
*/

	// init gallery
	if (typeof gallery != "undefined")
		gallery.init();

	// init newsTicker
	if (typeof newsTicker != "undefined")
		newsTicker.init(document.getElementById("newsTicker"), 2, 25, 5000);


	return true;
};


evt.add(window, "load", init);

