function Blacksmith() {
	this.onload_f 		= new Array();
	this.onmouseover_f 	= new Array();
	this.control_hdler 	= new Array();
	this.mouseX			= 0;
	this.mouseY			= 0;
	this.controlOpen	= false;
	
	this.onmouseover_f.push([function (params, hdl, e) {
		if (Blacksmith) {
			if (!e) e = window.event;	
			Blacksmith.mouseX = e.clientX;
			Blacksmith.mouseY = e.clientY;
			}
		}, null]);
	
	document.onmousemove = function (e) {
		if (Blacksmith) for (i=0; i<Blacksmith.onmouseover_f.length; i++) { 
			Blacksmith.onmouseover_f[i][0](Blacksmith.onmouseover_f[i][1], i, e);
			}
		}
	}
	
Blacksmith.prototype.objPos = function(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
			}
		}
	return [curleft,curtop];
	}

Blacksmith.prototype.mouseXY = function (e) {
	this.mouseX = event.clientX;
	this.mouseY = event.clientY;
	return [this.mouseX, this.mouseY];
	}

Blacksmith.prototype.disableMouseOver = function (f_hdl) {
	this.onmouseover_f[f_hdl] = [function () {}, null, this.onmouseover_f[f_hdl][0], this.onmouseover_f[f_hdl][1]];
	}

Blacksmith.prototype.enableMouseOver = function (f_hdl) {
	this.onmouseover_f[f_hdl] = [this.onmouseover_f[f_hdl][2], this.onmouseover_f[f_hdl][3]];
	}

Blacksmith.prototype.onMouseOver = function (n_hdl, params) {
	ret_hdl = this.onmouseover_f.length;
	this.onmouseover_f[this.onmouseover_f.length] = [n_hdl, params];
	return ret_hdl;
	}
	
Blacksmith.prototype.doNothing = function () {}
	
Blacksmith.prototype.validateControl = function (hid, params) {
	window.close();
	window.opener.Blacksmith.control_hdler[hid](params);
	}
	
Blacksmith.prototype.setControlOpen = function (ctrlopen) {
	window.opener.Blacksmith.controlOpen = ctrlopen;
	}
	
Blacksmith.prototype.openControl = function (moduleName, moduleAction, str_extraGetParams, handler, w, h) {
	this.controlOpen = true;
	if (!w) w=600; if (!h) h=450;
	var top = (screen.height-h)/2;
	var left = (screen.width-w)/2;
	var IUUrl = BS_CONFIG['RESOURCES']['SITE'] + "controllers/action.controller.php?m=" + moduleName + "&a=" + moduleAction;
	if (handler) 
	{
		this.control_hdler.push(handler);
		IUUrl = IUUrl + "&h=1&hid=" + (this.control_hdler.length-1);
	}
	else IUUrl = IUUrl + "&h=0";
	if (str_extraGetParams) IUUrl = IUUrl + '&' + str_extraGetParams;
	window.open(IUUrl,"GsControl_"+moduleName+"_"+moduleAction,"top="+top+",left="+left+",width="+w+",height="+h+", toolbar=no, status=yes, scrollbars=no, resizable=yes, directories=no, menubar=no, location=no"); 
	}
	
Blacksmith.prototype.resizeControl = function()
{
	var hv = document.getElementById('ffThCtnr');
	var th = document.getElementById('thumbnails');
	var op = Blacksmith.objPos(th);
	hv.style.left = op[0] + 'px';
	hv.style.top = op[1] + 'px';
	hv.style.width = th.offsetWidth + 'px';
	hv.style.height = th.offsetHeight + 'px';
	hv.style.zIndex = 999;
}
	
Blacksmith.prototype.hidePanel = function (panelName) {
	var pnl = document.getElementById(panelName);
	if (pnl) {
		if (BsCtrl_C == panelName) BsCtrl_C = null; 
		pnl.style.display = 'none';
		}
	}
	
Blacksmith.prototype.showPanel = function (panelName) {
	var pnl = document.getElementById(panelName);
	if (pnl) {
		BsCtrl_C = panelName;
		pnl.style.display = 'block';
		}
	}
	
Blacksmith.prototype.switchPanel = function (panelName) {
	var pnl = document.getElementById(panelName);
	if (pnl) {
		if (BsCtrl_C) Blacksmith.hidePanel(BsCtrl_C);
		pnl.style.display = 'block';
		BsCtrl_C = panelName;
		}
	}
	
Blacksmith.prototype.getBrowser = function () {
	browser = '';
	version = 0;
	var strChUserAgent = navigator.userAgent;
	if ((agPos = strChUserAgent.indexOf('MSIE')) != -1) {
		browser = 'MSIE';
		vPos = strChUserAgent.indexOf(';', agPos+5);
		version = parseFloat(strChUserAgent.substring(agPos+5, vPos));
		}
	else if ((agPos = strChUserAgent.indexOf('Firefox')) != -1) {
		browser = 'Firefox';
		vPos = strChUserAgent.indexOf(' ', agPos+8);
		version = parseFloat(strChUserAgent.substring(agPos+8, vPos));
		}
	return [browser, version];
	}
	
Blacksmith = new Blacksmith();
