<!--

/************************************************
 * JavaScript Helper Functions v.0.1.0
 * (c) 2006 Oliver Hader <oh@inpublica.de>
 * Last modification: 2006-12-09
 * All rights reserved.
 ************************************************/

var ohHelper = {
	objects: {
		'image': {}
	},

	/**************************************************************************************************************
	 * Processing of images & files.
	 **************************************************************************************************************/ 

	image: function(object, value) {
		var src = '';

		if (value) {
			if (this.objects.image[object.id] == null) this.objects.image[object.id] = object.src;
			object.src = object.src.replace(/(\/|\\)(.+_)(.+)(\.(gif|jpg|png))$/i, '$1$2'+value+'$4');
		} else {
			if (this.objects.image[object.id] != null) object.src = this.objects.image[object.id];
		}
	},

	getFilePath: function(string) {
		var backSlash = path.lastIndexOf('\\');
		var normalSlash = path.lastIndexOf('/');
		
		if (backSlash > 0)
			path = path.substring(0,backSlash+1);
		else if (normalSlash > 0)
			path = path.substring(0,normalSlash+1);
		else
			path = '';
			
		return path;
	},

	/**************************************************************************************************************
	 * Handling of layers according to CSS-classes
	 **************************************************************************************************************/ 

	ssl: function(element) {
		this._singleSelectLayer(element);
	},

	scl: function(element) {
		this._singleCloseLayer(element);
	},

	cal: function(className) {
		this._closeAllLayers(className, null);
	},

	nothing: function(element) {
		// do nothing
	},

	_singleSelectLayer: function(element) {
		var stdClassName;
		element = $(element);
		if (element) {
			if (element.className) this._closeAllLayers(element.className, element);
			element.style.visibility = 'visible';
		} else if (stdClassName = ohSlider.getStdClassName()) {
			this._closeAllLayers(stdClassName, null);
		}
	},

	_singleCloseLayer: function(element) {
		element = $(element);
		element.style.visibility = 'hidden';
	},

	_closeAllLayers: function(className, skipElement) {
		var i, max;
		var elements = document.getElementsByClassName(className);
		if (elements.length) {
			for (i=0, max=elements.length; i<max; i++) {
				if (!skipElement || skipElement !== elements[i]) elements[i].style.visibility = 'hidden';
			}
		}
	},

	/**************************************************************************************************************
	 * Handling of input fields
	 **************************************************************************************************************/ 

	inputFocus: function(obj) {
		if (obj && obj.value == obj.defaultValue) obj.value = '';
	},
	inputBlur: function(obj) {
		if (obj && !obj.value) obj.value = obj.defaultValue;
	}
};

// -->