/* ws/_global/static/imgplayer/vkajtaz_1/player.js */


function	imgplayer_vkajtaz_1(baseImagePath, paramsXml)
{
	/************************************************/
	/* PROPERTIES */

	this.baseImagePath = null;

	// Params (defaults)

	this.loading = {
		'bgColor'	:	'FFFFFF',
		'bgImage'	:	
		{
			'url'		:	null,
			'object'	:	null
		}
	};

	this.imageZone = {
		'clickable'			:	true
	};

	this.infoZone = {
		'position'			:	'top',
		'showImageName'		:	true,
		'showImageSeq'		:	false,
		'bgColor'			:	'000000',
		'bgAlpha'			:	70,
		'fontFamily'		:	'Verdana',
		'fontSize'			:	10,
		'fontColor'			:	'FFFFFF'
	};

	/*

	23/03/2009
	IE's image onload bug : PNG image size was always reported to be 32x32
	Therefore, we had to replace .png images by .gif images
	*/

	this.nav = {
		'alpha'	:	100,

		'prev'	:	
		{
			'tooltip'		:	'',
			'inactive'		:
			{
				'url'			:	'http://static.kigo.net/shared/players/vkajtaz_1/previous.gif',
				'object'		:	null,
				'done'			:	false
			},

			'active'		:
			{
				'url'			:	'http://static.kigo.net/shared/players/vkajtaz_1/previous_hover.gif',
				'object'		:	null,
				'done'			:	false
			},
			'left'			:	0,
			'right'			:	null,
			'top'			:	null,
			'bottom'		:	0
		},

		'next'	:	
		{
			'tooltip'		:	'',
			'inactive'		:
			{
				'url'			:	'http://static.kigo.net/shared/players/vkajtaz_1/next.gif',
				'object'		:	null,
				'done'			:	false
			},

			'active'		:
			{
				'url'			:	'http://static.kigo.net/shared/players/vkajtaz_1/next_hover.gif',
				'object'		:	null,
				'done'			:	false
			},
			'left'			:	null,
			'right'			:	0,
			'top'			:	null,
			'bottom'		:	0
		}
	};

	// Runtime

	this.navReady = false;
	this.players = [];


	// Initialize
	var	params;

	// On parse error, use defaults...
	if(params = this.parseXml(paramsXml))
		this.parseParams(params);

	this.baseImagePath = baseImagePath;

	// Preload navigation images
	this.preloadNavImages();
}


/************************************************/
/* PUBLIC */

imgplayer_vkajtaz_1.prototype.reset = function()
{
	// Resets all players
	this.players = [];
}

imgplayer_vkajtaz_1.prototype.create = function(container, width, height, imgList)
{
	var	idx;

	this.players[idx = this.players.length] = {
		'container'		:	container,
		'images'		:	[],
		'nav'			:	null,
		'infoZone'		:	null,
		'seqInfoZone'	:	null,
		'nameInfoZone'	:	null,
		'width'			:	width,
		'height'		:	height,
		'currentImage'	:	0,
		'imgList'		:	imgList,
		'url'			:	(this.imageZone.clickable && arguments.length > 4 && typeof(arguments[4]) == 'string') ? arguments[4] : null,
		'urlTitle'		:	(this.imageZone.clickable && arguments.length > 5 && typeof(arguments[4]) == 'string' && typeof(arguments[5]) == 'string') ? arguments[5] : null
	};

	for(var i = 0; i < this.players[idx].imgList.length; i++)
		this.players[idx].images[i] = null;

	if(vkDom.el(container))	// Create player immediately
		this.createContent(idx);
	else
	{
		var	self = this;

		// Defer player create
		vkDom.onLoad(
			function()
			{
				self.createContent(idx);
			}
		);
	}
}


/************************************************/
/* PRIVATE */


imgplayer_vkajtaz_1.prototype.setAlpha = function(object, alpha)
{
	if(isNaN(alpha = parseInt(alpha)))
		alpha = 0;
	else if(alpha < 0)
		alpha = 0;
	else if(alpha > 100)
		alpha = 100;

	if(typeof(object.style.opacity) != 'undefined')
		object.style.opacity = alpha / 100;
	else if(typeof(object.style.MozOpacity) != 'undefined')
		object.style.MozOpacity = alpha / 100;
	else if(typeof(object.style.KhtmlOpacity) != 'undefined')
		object.style.KhtmlOpacity = alpha / 100;
	else if(typeof(object.style.filter) == 'string')
		object.style.filter = 'alpha(opacity='+alpha+')';
}



imgplayer_vkajtaz_1.prototype.createContent = function(idx)
{
	var	player, container, newContainer;
	
	player = this.players[idx];

	if(!(container = vkDom.el(player.container)))
		return;

	/*
	vkDom.clean(container);

	container.style.position = 'relative';
	container.style.top = '0px';
	container.style.left = '0px';

	container.style.width = player.width+'px';
	container.style.height = player.height+'px';
	container.style.overflow = 'hidden';
	container.style.clip = 'rect(0px '+player.width+'px '+player.height+'px 0px)';

	// Create the first image, request load
	container.appendChild(
		player.images[0] = this.createPhotoImage(player, 0)
	);
	*/

	// 06/03/2009 - Okay, we're now replacing the container, exactly as swfobject does,
	// so that we have unique HTML layout for both javascript and flash players

	newContainer = document.createElement('div');

	newContainer.style.position = 'relative';
	newContainer.style.top = '0px';
	newContainer.style.left = '0px';

	newContainer.style.width = player.width+'px';
	newContainer.style.height = player.height+'px';
	newContainer.style.overflow = 'hidden';
	newContainer.style.clip = 'rect(0px '+player.width+'px '+player.height+'px 0px)';

	container.parentNode.replaceChild(newContainer, container);

	if(typeof(container.id) == 'string' && container.id.length)
		newContainer.id = container.id;
	
	player.container = newContainer;

	// Create the first image, request load
	player.container.appendChild(
		player.images[0] = this.createPhotoImage(player, 0)
	);


	// Create image info zone, if required
	if(
		this.infoZone.showImageName ||
		this.infoZone.showImageSeq
	)
	{
		var	self = this;
		var	onover = function() { self.photoMouseOver(player) };
		var	onout = function() { self.photoMouseOut(player) };
		var	seqText, nameText;

		player.infoZone = document.createElement('div');
		
		player.infoZone.style.zIndex = 2;

		player.infoZone.style.textAlign = 'left';
		player.infoZone.style.fontFamily = this.infoZone.fontFamily;
		player.infoZone.style.fontSize = this.infoZone.fontSize+'px';
		player.infoZone.style.color = '#'+this.infoZone.fontColor;
		player.infoZone.style.backgroundColor = '#'+this.infoZone.bgColor;
		player.infoZone.style.cursor = 'default';

		player.infoZone.style.visibility = 'hidden';			
		player.infoZone.style.padding = '0px 0px 0px 0px';
		player.infoZone.style.margin = '0px 0px 0px 0px';
		player.infoZone.style.position = 'absolute';
		player.infoZone.style.left = '0px';

		if(this.infoZone.position == 'top')
			player.infoZone.style.top = '0px';
		else
			player.infoZone.style.bottom = '0px';

		player.infoZone.style.width = player.width+'px';

		player.infoZone.style.overflow = 'hidden';
		player.infoZone.style.height = '2em';

		if(this.infoZone.bgAlpha != 100)
			this.setAlpha(player.infoZone, this.infoZone.bgAlpha);


		if(window.addEventListener)
		{
			player.infoZone.addEventListener('mouseover', onover, false);
			player.infoZone.addEventListener('mouseout', onout, false);
		}
		else if(window.attachEvent)
		{
			player.infoZone.attachEvent('onmouseover', onover);
			player.infoZone.attachEvent('onmouseout', onout);
		}
		else
		{
			player.infoZone.onmouseover = onover;
			player.infoZone.onmouseout = onout;
		}



	// Sequence text

		if(this.infoZone.showImageSeq)
		{
			player.seqInfoZone = document.createElement('div');
			player.seqInfoZone.style.cursor = 'default';
			player.seqInfoZone.style.lineHeight = '2em';
			player.seqInfoZone.style.padding = '0px 1em 0px 1em';
			player.seqInfoZone.style.margin = '0px 0px 0px 0px';


			if(typeof(player.seqInfoZone.style.cssFloat) == 'string')
				player.seqInfoZone.style.cssFloat = 'right';
			else if(typeof(player.seqInfoZone.style.styleFloat) == 'string')
				player.seqInfoZone.style.styleFloat = 'right';

			player.infoZone.appendChild(player.seqInfoZone);
		}			

	// Name text

		if(this.infoZone.showImageName)
		{
			player.nameInfoZone = document.createElement('div');
			player.nameInfoZone.style.cursor = 'default';
			player.nameInfoZone.style.lineHeight = '2em';
			player.nameInfoZone.style.padding = '0px 1em 0px 1em';
			player.nameInfoZone.style.margin = '0px 0px 0px 0px';

			player.infoZone.appendChild(player.nameInfoZone);
		}

		player.container.appendChild(player.infoZone);
	}


	if(this.navReady)
		this.setupPlayerNav(player.container, player);
}



imgplayer_vkajtaz_1.prototype.createPhotoImage = function(player, imgIdx)
{
	var	img;

	img = document.createElement('img');

	img.setAttribute('title', player.urlTitle != null ? player.urlTitle : '');
	img.setAttribute('alt', player.urlTitle != null ? player.urlTitle : '');
	img.setAttribute('src', this.baseImagePath+'/FILLRECT-'+player.width+'-'+player.height+'-'+player.imgList[imgIdx].FILENAME);

	img.style.backgroundColor = '#'+this.loading.bgColor;
	if(typeof(this.loading.bgImage.url) == 'string' && this.loading.bgImage.url.length)
	{
		img.style.backgroundImage = 'url('+this.loading.bgImage.url+')';
		img.style.backgroundPosition = 'center center';
		img.style.backgroundRepeat = 'no-repeat';
	}

	img.style.zIndex = 1;
	img.style.width = player.width+'px';
	img.style.height = player.height+'px';
	img.style.position = 'absolute';
	img.style.left = '0px';
	img.style.top = '0px';
	img.style.padding = '0px 0px 0px 0px';
	img.style.margin = '0px 0px 0px 0px';

	if(player.url != null)
		img.style.cursor = 'pointer';


	var	self = this;

	var	onover = function() { self.photoMouseOver(player) };
	var	onout = function() { self.photoMouseOut(player) };
	var	onclick = null;

	if(player.url != null)
		onclick = function() { window.location = player.url; };
		
	if(window.addEventListener)
	{
		img.addEventListener('mouseover', onover, false);
		img.addEventListener('mouseout', onout, false);
		
		if(onclick)
			img.addEventListener('click', onclick, false);
	}
	else if(window.attachEvent)
	{
		img.attachEvent('onmouseover', onover);
		img.attachEvent('onmouseout', onout);
		
		if(onclick)
			img.attachEvent('onclick', onclick);
	}
	else
	{
		img.onmouseover = onover;
		img.onmouseout = onout;
		if(onclick)
			img.onclick = onclick;
	}

	return img;
}


imgplayer_vkajtaz_1.prototype.photoMouseOver = function(player)
{
	if(
		player.infoZone &&
		(
			player.seqInfoZone ||
			(
				player.nameInfoZone &&
				player.imgList[player.currentImage].NAME.length
			)
		)
	)
		player.infoZone.style.visibility = 'visible';
}

imgplayer_vkajtaz_1.prototype.photoMouseOut = function(player)
{
	if(player.infoZone)
		player.infoZone.style.visibility = 'hidden';
}


imgplayer_vkajtaz_1.prototype.updatePlayerNav = function(player)
{
	// Loads the current image, shows the navigation images appropriately
	
	if(player.currentImage < 0)
		player.currentImage = 0;
	else if(player.currentImage >= player.imgList.length)
		player.currentImage = player.imgList.length-1;

	if(player.images[player.currentImage] == null)
	{
		vkDom.el(player.container).appendChild(
			player.images[player.currentImage] = this.createPhotoImage(player, player.currentImage)
		);
	}

	for(var i = 0; i < player.images.length; i++)
	{
		if(player.images[i] != null)
			player.images[i].style.visibility = (i == player.currentImage ? 'visible' : 'hidden');
	}

	if(player.infoZone)
	{
		if(player.seqInfoZone)
			vkDom.setText(player.seqInfoZone, (player.currentImage+1)+'/'+player.images.length);

		if(player.nameInfoZone)
			vkDom.setText(player.nameInfoZone, player.imgList[player.currentImage].NAME);
	}

	if(this.nav != null)
	{
		player.nav.prev.style.visibility = player.currentImage ? 'visible' : 'hidden';
		player.nav.next.style.visibility = player.currentImage < player.imgList.length - 1 ? 'visible' : 'hidden';
	}
}


imgplayer_vkajtaz_1.prototype.setupPlayerNav = function(container, player)
{
	//player.nav = {};

	// Nav might have been disabled..	
	if(this.nav != null)
	{
		player.nav = {
			'prev'	:	document.createElement('img'),
			'next'	:	document.createElement('img')
		};

		this.setupPlayerNavPart(player, false);
		this.setupPlayerNavPart(player, true);

		container.appendChild(player.nav.prev);
		container.appendChild(player.nav.next);
	}

	this.updatePlayerNav(player);
}

imgplayer_vkajtaz_1.prototype.setupPlayerNavPart = function(player, next)
{
	var	self = this;
	var	image = next ? player.nav.next : player.nav.prev;
	var	settings = next ? this.nav.next : this.nav.prev;

	// We could not use "this" because of IE!
	//var	onover = function() { if(image.src != settings.active.object.src) { image.src = settings.active.object.src; } };
	//var	onout = function() { if(image.src != settings.inactive.object.src) { image.src = settings.inactive.object.src; } };

	var	onover = function() { if(image.src != settings.active.object.src) { image.src = settings.active.object.src; }; self.photoMouseOver(player); };
	var	onout = function() { if(image.src != settings.inactive.object.src) { image.src = settings.inactive.object.src; self.photoMouseOut(player); } };

	var	onclick = function() { player.currentImage += next ? 1 : -1; self.updatePlayerNav(player); self.photoMouseOut(player); self.photoMouseOver(player); }


	image.setAttribute('src', settings.inactive.url);
	image.setAttribute('title', settings.tooltip);
	image.setAttribute('alt', settings.tooltip);

	image.style.zIndex = 3;
	image.style.width = settings.inactive.object.width+'px';
	image.style.height = settings.inactive.object.height+'px';
	image.style.position = 'absolute';
	image.style.cursor = 'pointer';
	image.style.visibility = 'hidden';
	image.style.padding = '0px 0px 0px 0px';
	image.style.margin = '0px 0px 0px 0px';


	if(settings.left != null)
		image.style.left = settings.left+'px';
	else
		image.style.right = settings.right+'px';

	if(settings.top != null)
		image.style.top = settings.top+'px';
	else
		image.style.bottom = settings.bottom+'px';

	
	if(this.nav.alpha != 100)
		this.setAlpha(image, this.nav.alpha);
	
	if(window.addEventListener)
	{
		image.addEventListener('mouseover', onover, false);
		image.addEventListener('mouseout', onout, false);
		image.addEventListener('click', onclick, false);
		//image.addEventListener('dblclick', onclick, false);
	}
	else if(window.attachEvent)
	{
		image.attachEvent('onmouseover', onover);
		image.attachEvent('onmouseout', onout);
		image.attachEvent('onclick', onclick);
		//image.attachEvent('ondblclick', onclick);
	}
	else
	{
		image.onmouseover = onover;
		image.onmouseout = onout;
		image.onclick = onclick;
		//image.ondblclick = onclick;
	}
}


imgplayer_vkajtaz_1.prototype.preloadNavImages = function()
{
	// Step 0 - Preload the "loading" image if any - don't assign any listeners, we don't care to know when its loaded...
	if(typeof(this.loading.bgImage.url) == 'string' && this.loading.bgImage.url.length)
	{
		this.loading.bgImage.object = new Image();
		this.loading.bgImage.object.src = this.loading.bgImage.url;
	}

	// Two steps: 
	// Step 1: Create image objects
	// Step 2: register handlers

	// This way, we're sure than on handlers activation, *all* objects were created

	// Step 1
	this.nav.prev.inactive.object = new Image();
	this.nav.prev.active.object = new Image();
	this.nav.next.inactive.object = new Image();
	this.nav.next.active.object = new Image();

	// Step 2
	this.preloadNavImage(this.nav.prev.inactive);
	this.preloadNavImage(this.nav.prev.active);
	this.preloadNavImage(this.nav.next.inactive);
	this.preloadNavImage(this.nav.next.active);
}


imgplayer_vkajtaz_1.prototype.preloadNavImage = function(image)
{
	var	self = this;

	var	onload = function() { self.onNavImageLoad(image) };
	var	onerror = function() { self.onNavImageError(image) };


	if(window.addEventListener)
	{
		image.object.addEventListener('load', onload, false);
		image.object.addEventListener('error', onerror, false);
		image.object.addEventListener('abort', onerror, false);
	}
	else if(window.attachEvent)
	{
		image.object.attachEvent('onload', onload);
		image.object.attachEvent('onerror', onerror);
		image.object.attachEvent('onabort', onerror);
	}
	else
	{
		image.object.onload = onload;
		image.object.onerror = onerror;
		image.object.onabort = onerror;
	}

	image.object.src = image.url;
}

imgplayer_vkajtaz_1.prototype.onNavImageLoad = function(image)
{
	image.done = true;
	
	this.onNavImageEvent();
}

imgplayer_vkajtaz_1.prototype.onNavImageError = function(image)
{
	image.object = null;
	image.done = true;
	
	this.onNavImageEvent();
}

imgplayer_vkajtaz_1.prototype.onNavImageEvent = function()
{
	// Is nav ready?

	if(
		this.nav.prev.inactive.done &&
		this.nav.prev.active.done &&
		this.nav.next.inactive.done &&
		this.nav.next.active.done
	)
	{
		// All navigation images are loaded

		if(
			// If any of the "inactive" images failed, the whole navigation is disabled!
			this.nav.prev.inactive.object == null ||
			this.nav.next.inactive.object == null
		)
			this.nav = null;
		else if(

			// If any of the "active" images failed...
			this.nav.prev.active.object == null ||
			this.nav.next.active.object == null ||

			// Or if their sizes don't match the "inactive" sizes...
			this.nav.prev.active.object.width != this.nav.prev.inactive.object.width ||
			this.nav.prev.active.object.height != this.nav.prev.inactive.object.height ||
			this.nav.next.active.object.width != this.nav.next.inactive.object.width ||
			this.nav.next.active.object.height != this.nav.next.inactive.object.height
		)
		{
			// ... then (all) active images default to inactive images
			this.nav.prev.active.object = this.nav.prev.inactive.object;
			this.nav.next.active.object = this.nav.next.inactive.object;
		}

		this.navReady = true;

		// Okay, setup navigation for players that are already loaded...
		for(var i = 0; i < this.players.length; i++)
		{
			if(this.players[i].nav == null)
				this.setupPlayerNav(vkDom.el(this.players[i].container), this.players[i]);
		}
	}
}


imgplayer_vkajtaz_1.prototype.parseXml = function(string)
{
	var	parser, result;

	/* 
	Note from 
		https://developer.mozilla.org/en/DOMParser

	Error handling

	Note that if the parsing process failed, DOMParser currently does not throw an exception, but instead returns an error document (see bug 45566):

	<parsererror xmlns="http://www.mozilla.org/newlayout/xml/parsererror.xml">
	(error description)
	<sourcetext>(a snipper of the source XML)</sourcetext>
	</parsererror>

	HOWEVER, if bad value (ie not a string) is provided to parseFromString(), then an error is thrown

	MOREOVER, Chrome embeds <parsererror> element in <html><body> structure

	*/

	// Try native DOMParser support

	if(
		typeof(DOMParser) == 'function' ||
		typeof(DOMParser) == 'object'		// Safari
		
	)
	{
		parser = new DOMParser();

		try
		{
			result = parser.parseFromString(string, 'text/xml');
		}
		catch (e)
		{
			return null;
		}
			
		return result && result.firstChild ? this.parseXmlRoot(result) : null;
	}
	

	// Try IE's native support
	if(window.ActiveXObject)
	{
		try
		{
			parser = new ActiveXObject('MSXML.DomDocument');
		}
		catch (e0)
		{
			try
			{
				parser = new ActiveXObject('Microsoft.XMLDOM');
			}
			catch (e1)
			{
				return null;
			}
		}
		
		parser.async = false;

		try
		{
			parser.loadXML(string);
		}
		catch (e)
		{
			return null;
		}

		return parser && parser.firstChild ? this.parseXmlRoot(parser) : null;
	}


	// Fall-back to XMLHttpRequest
	// This works in Opera only AFAIK (other browser throw access-denied error) and Opera supports DOMParser..
	// Therefore, this is probably a bit useless
	if(window.XMLHttpRequest)
	{
		parser = new XMLHttpRequest();

		try
		{
			parser.open('GET', 'data:text/xml;charset=utf-8,'+encodeURIComponent(string), false);

			if(parser.overrideMimeType)
				parser.overrideMimeType('text/xml');
			
			parser.send(null);
		}
		catch (e)
		{
			return null;
		}


		return typeof(parser.responseXML) == 'object' ? this.parseXmlRoot(parser.responseXML) : null;
	}


	// No parser was found...
	return null;
}

imgplayer_vkajtaz_1.prototype.parseXmlRoot = function(node)
{
	// Some browsers embed the response in document nodes, others consider <?xml...?> as a PI
	// Therefore, clean-it up before returning the real document to the application...
	// -> return on first element node (1)


	if(node.nodeType == 1)
		return node;

	if(node.hasChildNodes())
	{
		var	i, tmp;

		for(i = 0; i < node.childNodes.length; i++)
		{
			if( (tmp = this.parseXmlRoot(node.childNodes[i])) != null)
				return tmp;
		}
	}

	return null;
}


imgplayer_vkajtaz_1.prototype.getIntParam = function(node, path, defaultValue)
{
	var	value, minValue, maxValue;

	if(arguments.length > 3)
		minValue = parseInt(arguments[3]);
	else
		minValue = null;
	
	if(arguments.length > 4)
		maxValue = parseInt(arguments[4]);
	else
		maxValue = null;

	if(isNaN(value = parseInt(this.getParam(node, path, defaultValue))))
		value = defaultValue;

	if(minValue != null && value != defaultValue && value < minValue)
		value = minValue;

	if(maxValue != null && value != defaultValue && value > maxValue)
		value = maxValue;

	return value;
}

imgplayer_vkajtaz_1.prototype.getColorParam = function(node, path, defaultValue)
{
	var	tmp, color, c;

	tmp = this.getParam(node, path, defaultValue).toUpperCase();
	color = '';

	// Kill characters other than 0-9 A-F

	for(i = 0; i < tmp.length; i++)
	{
		if(
			((c = tmp.substr(i, 1)) >= '0' && c <= '9') ||
			(c >= 'A' && c <= 'F')
		)
			color += c;
	}

	if(color.length == 3)
	{
		return ''+
			color.substr(0, 1) + 
			color.substr(0, 1) + 
			color.substr(1, 1) + 
			color.substr(1, 1) + 
			color.substr(2, 1) + 
			color.substr(2, 1)
		;
	}
	else if(color.length == 6)
		return color;
	else
		return defaultValue;
}


imgplayer_vkajtaz_1.prototype.getBoolParam = function(node, path, defaultValue)
{
	return this.getParam(node, path, defaultValue ? '1' : '0', [ '0', '1' ]) == '1' ? true : false;
}

imgplayer_vkajtaz_1.prototype.getParam = function(node, path)
{
	var	defaultValue;

	if(arguments.length > 2)
		defaultValue = arguments[2];
	else
		defaultValue = null;

	if(arguments.length > 3)
		allowedChoices = arguments[3];
	else
		allowedChoices = null;

	tmp = this._getParam(node, path, defaultValue);

	if(
		allowedChoices != null &&
		typeof(allowedChoices) == 'object' &&
		allowedChoices.length
	)
	{
		// Limited choices are always case-insensitive

		tmp = tmp.toLowerCase();

		for(var i = 0; i < allowedChoices.length; i++)
		{
			if(tmp == allowedChoices[i].toLowerCase())
				return tmp;
		}

		return defaultValue.toLowerCase();
	}

	return tmp;
}


imgplayer_vkajtaz_1.prototype._getParam = function(node, path, defaultValue)
{
	var	i, search;

	if(!node.hasChildNodes())
		return defaultValue;

	search = path.shift().toLowerCase();

	for(i = 0; i < node.childNodes.length; i++)
	{
		if(node.childNodes[i].nodeType != 1)
			continue;

		if(search == node.childNodes[i].tagName.toLowerCase())
		{
			if(!path.length)	// We got it
				return this._getNodeText(node.childNodes[i], defaultValue);

			// Must go deeper
			return this._getParam(node.childNodes[i], path, defaultValue);
		}
	}

	// Not found!
	return defaultValue;
}


imgplayer_vkajtaz_1.prototype._getNodeText = function(node, defaultValue)
{
	// Concatenate all text nodes..
	// No other nodes than text nodes may be present. If found, return defaultValue

	var	i, value;

	if(!node.hasChildNodes())
		return defaultValue;

	value = '';

	for(i = 0; i < node.childNodes.length; i++)
	{
		if(node.childNodes[i].nodeType != 3)	// TEXT_NODE
			return defaultValue;

		value += node.childNodes[i].nodeValue;
	}

	return value;
}


imgplayer_vkajtaz_1.prototype.parseParams = function(root)
{
	var	tmpLeft, tmpRight, tmpTop, tmpBottom;


	if(root.tagName != 'params')
		return false;

	// Okay, except in the root element, which has a "version" attribute, all information is stored in CDATA

// loading

	this.loading.bgColor = this.getColorParam(root, ['loading', 'backgroundColor' ], 'FFFFFF');
	this.loading.bgImage.url = this.getParam(root, ['loading', 'backgroundImage' ], null);

// imageZone

	this.imageZone.clickable = this.getBoolParam(root, ['imageZone', 'clickable' ], true);


// infoZone

	this.infoZone.position = this.getParam(root, ['imageInfoZone', 'position' ], 'top', ['top', 'bottom'] );
	this.infoZone.showImageName = this.getBoolParam(root, ['imageInfoZone', 'showImageName' ], true);
	this.infoZone.showImageSeq = this.getBoolParam(root, ['imageInfoZone', 'showImageSeq' ], false);

	if(this.infoZone.showImageName || this.infoZone.showImageSeq)
	{
		// Save a couple of CPU cycles if this feature is disabled
		this.infoZone.bgColor = this.getColorParam(root, ['imageInfoZone', 'backgroundColor' ], '000000');
		this.infoZone.bgAlpha = this.getIntParam(root, ['imageInfoZone', 'backgroundAlpha' ], 100, 0, 100);
		this.infoZone.fontFamily = this.getParam(root, ['imageInfoZone', 'fontFamily' ], 'Verdana');
		this.infoZone.fontSize = this.getIntParam(root, ['imageInfoZone', 'fontSize' ], 9, 1, 20);
		this.infoZone.fontColor = this.getColorParam(root, ['imageInfoZone', 'fontColor' ], 'FFFFFF');
	}

// nav alpha
	this.nav.alpha = this.getIntParam(root, ['navElements', 'alpha' ], 100, 0, 100);

// previous nav


	this.nav.prev.tooltip = this.getParam(root, [ 'navElements', 'previous', 'tooltip' ], '');
	this.nav.prev.inactive.url = this.getParam(root, [ 'navElements', 'previous', 'image' ], this.nav.prev.inactive.url);
	this.nav.prev.active.url = this.getParam(root, [ 'navElements', 'previous', 'activeImage' ], this.nav.prev.active.url);

	// Okay lookup (left|right) and (top|bottom)

	tmpLeft = this.getIntParam(root, [ 'navElements', 'previous', 'left' ], -1, 0, 10000);
	tmpRight = this.getIntParam(root, [ 'navElements', 'previous', 'right' ], -1, 0, 10000);
	tmpTop = this.getIntParam(root, [ 'navElements', 'previous', 'top' ], -1, 0, 10000);
	tmpBottom = this.getIntParam(root, [ 'navElements', 'previous', 'bottom' ], -1, 0, 10000);


	if(tmpLeft != -1)
	{
		this.nav.prev.left = tmpLeft;
		this.nav.prev.right = null;
	}
	else if(tmpRight != -1)
	{
		this.nav.prev.left = null;
		this.nav.prev.right = tmpRight;
	}

	if(tmpTop != -1)
	{
		this.nav.prev.top = tmpTop;
		this.nav.prev.bottom = null;
	}
	else if(tmpBottom != -1)
	{
		this.nav.prev.top = null;
		this.nav.prev.bottom = tmpBottom;
	}

// next nav

	this.nav.next.tooltip = this.getParam(root, [ 'navElements', 'next', 'tooltip' ], '');
	this.nav.next.inactive.url = this.getParam(root, [ 'navElements', 'next', 'image' ], this.nav.next.inactive.url);
	this.nav.next.active.url = this.getParam(root, [ 'navElements', 'next', 'activeImage' ], this.nav.next.active.url);

	// Okay lookup (left|right) and (top|bottom)

	tmpLeft = this.getIntParam(root, [ 'navElements', 'next', 'left' ], -1, 0, 10000);
	tmpRight = this.getIntParam(root, [ 'navElements', 'next', 'right' ], -1, 0, 10000);
	tmpTop = this.getIntParam(root, [ 'navElements', 'next', 'top' ], -1, 0, 10000);
	tmpBottom = this.getIntParam(root, [ 'navElements', 'next', 'bottom' ], -1, 0, 10000);


	if(tmpLeft != -1)
	{
		this.nav.next.left = tmpLeft;
		this.nav.next.right = null;
	}
	else if(tmpRight != -1)
	{
		this.nav.next.left = null;
		this.nav.next.right = tmpRight;
	}

	if(tmpTop != -1)
	{
		this.nav.next.top = tmpTop;
		this.nav.next.bottom = null;
	}
	else if(tmpBottom != -1)
	{
		this.nav.next.top = null;
		this.nav.next.bottom = tmpBottom;
	}


	// That's all folks!
}


