// ***************************************************************************
//                          boxPictures.js  -  description
//                             -------------------
//    begin                : Fri Dec 9 2005
//    copyright            : (C) 2005 by Andrei Gavrila
//    email                : andrei.gavrila@gmail.com
// ***************************************************************************
//
// ***************************************************************************
// *                                                                         *
// *   This program is free software; you can redistribute it and/or modify  *
// *   it under the terms of the GNU General Public License as published by  *
// *   the Free Software Foundation; either version 2 of the License, or     *
// *   (at your option) any later version.                                   *
// *                                                                         *
// ***************************************************************************

var boxPicturesMaxItems = 15;

var boxPicturesType                 = Array();
var boxPicturesNumber               = Array();
var boxPicturesFrameBackgroundColor = Array();
var boxPicturesFrameSpacing         = Array();

function boxPictures(x, y, w, h, type, number, frameBackground, space)
{
	boxPicturesType[wmWindowIndex]                 = type;
	boxPicturesNumber[wmWindowIndex]               = number;
	boxPicturesFrameBackgroundColor[wmWindowIndex] = frameBackground;
	boxPicturesFrameSpacing[wmWindowIndex]         = space;

	var setup   = ' \
<div class="wmWindowSetupItem" id="boxPictures_' + wmWindowIndex + '_SetupBox_2"> \
<b>' + wmText(3200) + '</b> \
<br /> \
<br /> \
<b>' + wmText(3201) + '</b> <br /> \
<select id="wmWindow_' + wmWindowIndex + '_Setup10" class="wmSetupSelect" onChange="javascript: boxPicturesSetupType(' + wmWindowIndex + ', this.value);" onMouseMove = "javascript: wmToolTipQuick(\'wmWindow_' + wmWindowIndex + '_Setup10\', this, wmMessage(3200));" /> \
<option value="1" \
';

	if (type == 1)
		setup += ' selected';

	setup += ' \
>' + wmText(3202) + '</option> \
<option value="2" \
';

	if (type == 2)
		setup += ' selected';

	setup += ' \
>' + wmText(3203) + '</option> \
</select> \
<br /> \
<b>' + wmText(3204) + '</b> <br /> \
<select id="wmWindow_' + wmWindowIndex + '_Setup11" class="wmSetupSelect" onChange="javascript: boxPicturesSetupNumber(' + wmWindowIndex + ', this.value);" onMouseMove = "javascript: wmToolTipQuick(\'wmWindow_' + wmWindowIndex + '_Setup11\', this, wmMessage(3201));" /> \
';

	for (i = 1 ; i <= boxPicturesMaxItems; i++) {
		setup += '<option value="' + i + '"';
		if (i == number)
			setup += ' selected';
		setup += '>' + i + '</option>';
	}

	setup += ' \
</select> \
<br /> \
</div> \
<div class="wmWindowSetupItem" id="boxPictures_' + wmWindowIndex + '_SetupBox_3"> \
<b>' + wmText(3205) + '</b> \
<br /> \
<br /> \
<b>' + wmText(3206) + '</b> <br /> \
#<input type="text" id="wmWindow_' + wmWindowIndex + '_Setup12" class="wmSetupInputColor" size="6" value="' + boxPicturesFrameBackgroundColor[wmWindowIndex] + '" onChange="javascript: boxPicturesSetupFrameBackgroundColor(' + wmWindowIndex + ', this.value);" onMouseMove = "javascript: wmToolTipQuick(\'wmWindow_' + wmWindowIndex + '_Setup12\', this, wmMessage(3202));" /> \
<a href="javascript: wmColorPicker(\'wmWindow_' + wmWindowIndex + '_Setup12\', mouse_x, mouse_y, \'boxPicturesSetupFrameBackgroundColor(' + wmWindowIndex + ', src);\');"><img border="0" width="15" height="15" src="images/colorpicker.gif" onMouseMove = "javascript: wmToolTipQuick(\'wmWindow_' + wmWindowIndex + '_Setup12_0\', this, wmMessage(10000));" /></a> \
<br /> \
<b>' + wmText(3207) + '</b> <br /> \
<input type="text" id="wmWindow_' + wmWindowIndex + '_Setup13" class="wmSetupInputWidth" size="2" value="' + boxPicturesFrameSpacing[wmWindowIndex] + '" onChange="javascript: boxPicturesSetupFrameSpacing(' + wmWindowIndex + ', this.value);" onMouseMove = "javascript: wmToolTipQuick(\'wmWindow_' + wmWindowIndex + '_Setup13\', this, wmMessage(3203));" /> ' + wmText(0) + ' \
<br /> \
</div> \
';
	var content = '';

	var headers = Array();

	headers[0] = '';
	headers[1] = 'boxPictures_' + wmWindowIndex + '_SetupBox_2';
	headers[2] = 'boxPictures_' + wmWindowIndex + '_SetupBox_3';

	wmWindow(x, y, w, h, 'pictures', setup, content, headers);

	boxPicturesGenerate(wmWindowIndex - 1);
}

function boxPicturesGenerate(index)
{
	var content = '';

	for (i = 0; i < boxPicturesNumber[index]; i++)
		content += ' \
<div class="boxPictures_Picture" style="margin: ' + boxPicturesFrameSpacing[index] + 'px;"> \
<table width="100" height="100" cellspacing="0" cellpadding="0" border="0"> \
<tr> \
<td valign="middle" align="center" bgcolor="#' + boxPicturesFrameBackgroundColor[index] + '"> \
<img src="images/pictures/' + boxPicturesType[index] + '/' + i + '.jpg" /> \
</td> \
</tr> \
</table> \
</div> \
';

	wmGetElementById('wmWindow_' + index + '_Content').innerHTML = content;
}

function boxPicturesSetupType(index, src)
{
	boxPicturesType[index] = src;

	wmWindowSaved = false;

	boxPicturesGenerate(index);
}

function boxPicturesSetupNumber(index, src)
{
	boxPicturesNumber[index] = src;

	wmWindowSaved = false;

	boxPicturesGenerate(index);
}

function boxPicturesSetupFrameBackgroundColor(index, src)
{
	boxPicturesFrameBackgroundColor[index] = src;

	wmWindowSaved = false;

	boxPicturesGenerate(index);
}

function boxPicturesSetupFrameSpacing(index, src)
{
	boxPicturesFrameSpacing[index] = src;

	wmWindowSaved = false;

	boxPicturesGenerate(index);
}

function boxPicturesSave(index)
{
	var content = '';

	content += '<input type="hidden" name="box_' + index + '_picturesType"                   value="' + escape(boxPicturesType[index])                 + '" />\n';
	content += '<input type="hidden" name="box_' + index + '_picturesNumber"                 value="' + escape(boxPicturesNumber[index])               + '" />\n';

	content += '<input type="hidden" name="box_' + index + '_picturesFrameBackgroundColor"   value="' + escape(boxPicturesFrameBackgroundColor[index]) + '" />\n';
	content += '<input type="hidden" name="box_' + index + '_picturesFrameSpacing"           value="' + escape(boxPicturesFrameSpacing[index])         + '" />\n';

	return content;
}

