// ***************************************************************************
//                          boxPhotoSet.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 boxPhotoSetMaxItems = 20;

var boxPhotoSetNumber               = Array();
var boxPhotoSetFrameBackgroundColor = Array();
var boxPhotoSetFrameSpacing         = Array();

var boxPhotoSetFontColor            = Array();
var boxPhotoSetFontHColor           = Array();
var boxPhotoSetFontFamily           = Array();
var boxPhotoSetFontSize             = Array();
var boxPhotoSetFontBold             = Array();
var boxPhotoSetFontItalic           = Array();

var boxPhotoSetHAlign               = Array();
var boxPhotoSetVAlign               = Array();

function boxPhotoSet(x, y, w, h, number, frameBackground, space, fontColor, fontHColor, fontFamily, fontSize, fontBold, fontItalic, hAlign, vAlign)
{
	if (wmWindowPageActive != 3) {
		alert(wmMessage(1704));

		return;
	}

	boxPhotoSetNumber[wmWindowIndex]               = number;
	boxPhotoSetFrameBackgroundColor[wmWindowIndex] = frameBackground;
	boxPhotoSetFrameSpacing[wmWindowIndex]         = space;

	boxPhotoSetFontColor[wmWindowIndex]            = fontColor;
	boxPhotoSetFontHColor[wmWindowIndex]           = fontHColor;
	boxPhotoSetFontFamily[wmWindowIndex]           = fontFamily;
	boxPhotoSetFontSize[wmWindowIndex]             = fontSize;
	boxPhotoSetFontBold[wmWindowIndex]             = fontBold;
	boxPhotoSetFontItalic[wmWindowIndex]           = fontItalic;

	boxPhotoSetHAlign[wmWindowIndex]               = hAlign;
	boxPhotoSetVAlign[wmWindowIndex]               = vAlign;

	var setup   = ' \
<div class="wmWindowSetupItem" id="boxPhotoSet_' + wmWindowIndex + '_SetupBox_2"> \
<b>' + wmText(3800) + '</b> \
<br /> \
<br /> \
<b>' + wmText(3801) + '</b> <br /> \
<select id="wmWindow_' + wmWindowIndex + '_Setup11" class="wmSetupSelect" onChange="javascript: boxPhotoSetSetupNumber(' + wmWindowIndex + ', this.value);" onMouseMove = "javascript: wmToolTipQuick(\'wmWindow_' + wmWindowIndex + '_Setup11\', this, wmMessage(3801));" /> \
';

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

	setup += ' \
</select> \
<br /> \
<br /> \
<b>' + wmText(3802) + '</b> <br /> \
#<input type="text" id="wmWindow_' + wmWindowIndex + '_Setup12" class="wmSetupInputColor" size="6" value="' + boxPhotoSetFrameBackgroundColor[wmWindowIndex] + '" onChange="javascript: boxPhotoSetSetupFrameBackgroundColor(' + wmWindowIndex + ', this.value);" onMouseMove = "javascript: wmToolTipQuick(\'wmWindow_' + wmWindowIndex + '_Setup12\', this, wmMessage(3802));" /> \
<a href="javascript: wmColorPicker(\'wmWindow_' + wmWindowIndex + '_Setup12\', mouse_x, mouse_y, \'boxPhotoSetSetupFrameBackgroundColor(' + 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(3803) + '</b> <br /> \
<input type="text" id="wmWindow_' + wmWindowIndex + '_Setup13" class="wmSetupInputWidth" size="2" value="' + boxPhotoSetFrameSpacing[wmWindowIndex] + '" onChange="javascript: boxPhotoSetSetupFrameSpacing(' + wmWindowIndex + ', this.value);" onMouseMove = "javascript: wmToolTipQuick(\'wmWindow_' + wmWindowIndex + '_Setup13\', this, wmMessage(3803));" /> ' + wmText(0) + ' \
<br /> \
</div> \
<div class="wmWindowSetupItem" id="boxPhotoSet_' + wmWindowIndex + '_SetupBox_3"> \
<b>' + wmText(3804) + '</b> \
<br /> \
<br /> \
<b>' + wmText(3805) + '</b> <br /> \
#<input type="text" id="wmWindow_' + wmWindowIndex + '_Setup14" class="wmSetupInputColor" size="6" value="' + boxPhotoSetFontColor[wmWindowIndex] + '" onChange="javascript: boxPhotoSetSetupFontColor(' + wmWindowIndex + ', this.value);" onMouseMove = "javascript: wmToolTipQuick(\'wmWindow_' + wmWindowIndex + '_Setup14\', this, wmMessage(3804));" /> \
<a href="javascript: wmColorPicker(\'wmWindow_' + wmWindowIndex + '_Setup14\', mouse_x, mouse_y, \'boxPhotoSetSetupFontColor(' + wmWindowIndex + ', src);\');"><img border="0" width="15" height="15" src="images/colorpicker.gif" onMouseMove = "javascript: wmToolTipQuick(\'wmWindow_' + wmWindowIndex + '_Setup14_0\', this, wmMessage(10000));" /></a> \
<br /> \
<b>' + wmText(3806) + '</b> <br /> \
#<input type="text" id="wmWindow_' + wmWindowIndex + '_Setup15" class="wmSetupInputColor" size="6" value="' + boxPhotoSetFontHColor[wmWindowIndex] + '" onChange="javascript: boxPhotoSetSetupFontHColor(' + wmWindowIndex + ', this.value);" onMouseMove = "javascript: wmToolTipQuick(\'wmWindow_' + wmWindowIndex + '_Setup15\', this, wmMessage(3805));" /> \
<a href="javascript: wmColorPicker(\'wmWindow_' + wmWindowIndex + '_Setup15\', mouse_x, mouse_y, \'boxPhotoSetSetupFontHColor(' + wmWindowIndex + ', src);\');"><img border="0" width="15" height="15" src="images/colorpicker.gif" onMouseMove = "javascript: wmToolTipQuick(\'wmWindow_' + wmWindowIndex + '_Setup15_0\', this, wmMessage(10000));" /></a> \
<br /> \
<br /> \
<b>' + wmText(3807) + '</b> <br /> \
<input type="text" id="wmWindow_' + wmWindowIndex + '_Setup16" class="wmSetupInputFont" size="12" value="' + boxPhotoSetFontFamily[wmWindowIndex] + '" onChange="javascript: boxPhotoSetSetupFontFamily(' + wmWindowIndex + ', this.value);" onMouseMove = "javascript: wmToolTipQuick(\'wmWindow_' + wmWindowIndex + '_Setup16\', this, wmMessage(3806));" /> \
<br /> \
<b>' + wmText(3808) + '</b> <br /> \
<input type="text" id="wmWindow_' + wmWindowIndex + '_Setup17" class="wmSetupInputSize" size="2" value="' + boxPhotoSetFontSize[wmWindowIndex] + '" onChange="javascript: boxPhotoSetSetupFontSize(' + wmWindowIndex + ', this.value);" onMouseMove = "javascript: wmToolTipQuick(\'wmWindow_' + wmWindowIndex + '_Setup17\', this, wmMessage(3807));" /> ' + wmText(0) + ' \
<br /> \
<b>' + wmText(3809) + '</b> <br /> \
' + wmText(1) + ' <input type="checkbox" id="wmWindow_' + wmWindowIndex + '_Setup18" ' + (boxPhotoSetFontBold[wmWindowIndex] == 1 ? 'checked' : '') + ' class="wmSetupInputCheckbox" onChange="javascript: boxPhotoSetSetupFontBold(' + wmWindowIndex + ', this.value);" onMouseMove = "javascript: wmToolTipQuick(\'wmWindow_' + wmWindowIndex + '_Setup18\', this, wmMessage(3808));" /> \
<br /> \
' + wmText(2) + ' <input type="checkbox" id="wmWindow_' + wmWindowIndex + '_Setup19" ' + (boxPhotoSetFontItalic[wmWindowIndex] == 1 ? 'checked' : '') + ' class="wmSetupInputCheckbox" onChange="javascript: boxPhotoSetSetupFontItalic(' + wmWindowIndex + ', this.value);" onMouseMove = "javascript: wmToolTipQuick(\'wmWindow_' + wmWindowIndex + '_Setup19\', this, wmMessage(3809));" /> \
<br /> \
<b>' + wmText(3810) + '</b> <br /> \
<select id="wmWindow_' + wmWindowIndex + '_Setup20" class="wmSetupSelect" onChange="javascript: boxPhotoSetSetupHAlign(' + wmWindowIndex + ', this.value);" onMouseMove = "javascript: wmToolTipQuick(\'wmWindow_' + wmWindowIndex + '_Setup20\', this, wmMessage(3810));" /> \
';

	if (boxPhotoSetHAlign[wmWindowIndex] == 'left')
		setup += '<option value="left" selected>' + wmText(3) + '</option>';
	else
		setup += '<option value="left">' + wmText(3) + '</option>';

	if (boxPhotoSetHAlign[wmWindowIndex] == 'center')
		setup += '<option value="center" selected>' + wmText(4) + '</option>';
	else
		setup += '<option value="center">' + wmText(4) + '</option>';

	if (boxPhotoSetHAlign[wmWindowIndex] == 'right')
		setup += '<option value="right" selected>' + wmText(5) + '</option>';
	else
		setup += '<option value="right">' + wmText(5) + '</option>';

	setup += ' \
</select> \
<br /> \
<b>' + wmText(3811) + '</b> <br /> \
<select id="wmWindow_' + wmWindowIndex + '_Setup21" class="wmSetupSelect" onChange="javascript: boxPhotoSetSetupVAlign(' + wmWindowIndex + ', this.value);" onMouseMove = "javascript: wmToolTipQuick(\'wmWindow_' + wmWindowIndex + '_Setup21\', this, wmMessage(3811));" /> \
';

	if (boxPhotoSetVAlign[wmWindowIndex] == 'top')
		setup += '<option value="top" selected>' + wmText(6) + '</option>';
	else
		setup += '<option value="top">' + wmText(6) + '</option>';

	if (boxPhotoSetVAlign[wmWindowIndex] == 'bottom')
		setup += '<option value="bottom" selected>' + wmText(8) + '</option>';
	else
		setup += '<option value="bottom">' + wmText(8) + '</option>';

	setup += ' \
</select> \
<br /> \
</div> \
';

	var content = '';

	var headers = Array();

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

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

	boxPhotoSetGenerate(wmWindowIndex - 1);
}

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

	if (boxPhotoSetVAlign[index] == 'top') {
		content += '<div style="text-align: ' +  boxPhotoSetHAlign[index] + ';"><a href="#" \
style="color: #' + boxPhotoSetFontColor[index] + '; font-family: ' + boxPhotoSetFontFamily[index] + '; font-size: ' + boxPhotoSetFontSize[index] + 'px; text-decoration: none;';

		if (boxPhotoSetFontBold[index] == 1)
			content += ' font-weight: bold;';
		if (boxPhotoSetFontItalic[index] == 1)
			content += ' font-style: italic;';

		content += ' \
" \
onMouseOver = "this.style.textDecoration = \'underline\'; this.style.color = \'#' + boxPhotoSetFontHColor[index] + '\';" \
onMouseOut  = "this.style.textDecoration = \'none\'; this.style.color = \'#' + boxPhotoSetFontColor[index] + '\';" \
>&lt; &lt; prev</a> <a href="#" \
style="color: #' + boxPhotoSetFontColor[index] + '; font-family: ' + boxPhotoSetFontFamily[index] + '; font-size: ' + boxPhotoSetFontSize[index] + 'px; text-decoration: none;';

		if (boxPhotoSetFontBold[index] == 1)
			content += ' font-weight: bold;';
		if (boxPhotoSetFontItalic[index] == 1)
			content += ' font-style: italic;';

		content += ' \
" \
onMouseOver = "this.style.textDecoration = \'underline\'; this.style.color = \'#' + boxPhotoSetFontHColor[index] + '\';" \
onMouseOut  = "this.style.textDecoration = \'none\'; this.style.color = \'#' + boxPhotoSetFontColor[index] + '\';" \
>next &gt; &gt;</a></div>';
	}

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

	if (boxPhotoSetVAlign[index] == 'bottom') {
		content += '<div style="clear: both;"></div><div style="text-align: ' +  boxPhotoSetHAlign[index] + ';"><a href="#" \
style="color: #' + boxPhotoSetFontColor[index] + '; font-family: ' + boxPhotoSetFontFamily[index] + '; font-size: ' + boxPhotoSetFontSize[index] + 'px; text-decoration: none;';

		if (boxPhotoSetFontBold[index] == 1)
			content += ' font-weight: bold;';
		if (boxPhotoSetFontItalic[index] == 1)
			content += ' font-style: italic;';

		content += ' \
" \
onMouseOver = "this.style.textDecoration = \'underline\'; this.style.color = \'#' + boxPhotoSetFontHColor[index] + '\';" \
onMouseOut  = "this.style.textDecoration = \'none\'; this.style.color = \'#' + boxPhotoSetFontColor[index] + '\';" \
>&lt; &lt; prev</a> <a href="#" \
style="color: #' + boxPhotoSetFontColor[index] + '; font-family: ' + boxPhotoSetFontFamily[index] + '; font-size: ' + boxPhotoSetFontSize[index] + 'px; text-decoration: none;';

		if (boxPhotoSetFontBold[index] == 1)
			content += ' font-weight: bold;';
		if (boxPhotoSetFontItalic[index] == 1)
			content += ' font-style: italic;';

		content += ' \
" \
onMouseOver = "this.style.textDecoration = \'underline\'; this.style.color = \'#' + boxPhotoSetFontHColor[index] + '\';" \
onMouseOut  = "this.style.textDecoration = \'none\'; this.style.color = \'#' + boxPhotoSetFontColor[index] + '\';" \
>next &gt; &gt;</a></div>';
	}

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

function boxPhotoSetSetupNumber(index, src)
{
	boxPhotoSetNumber[index] = src;

	wmWindowSaved = false;

	boxPhotoSetGenerate(index);
}

function boxPhotoSetSetupFrameBackgroundColor(index, src)
{
	boxPhotoSetFrameBackgroundColor[index] = src;

	wmWindowSaved = false;

	boxPhotoSetGenerate(index);
}

function boxPhotoSetSetupFrameSpacing(index, src)
{
	boxPhotoSetFrameSpacing[index] = src;

	wmWindowSaved = false;

	boxPhotoSetGenerate(index);
}

function boxPhotoSetSetupFontColor(index, src)
{
	boxPhotoSetFontColor[index] = src;

	wmWindowSaved = false;

	boxPhotoSetGenerate(index);
}

function boxPhotoSetSetupFontHColor(index, src)
{
	boxPhotoSetFontHColor[index] = src;

	wmWindowSaved = false;

	boxPhotoSetGenerate(index);
}

function boxPhotoSetSetupFontFamily(index, src)
{
	boxPhotoSetFontFamily[index] = src;

	wmWindowSaved = false;

	boxPhotoSetGenerate(index);
}

function boxPhotoSetSetupFontSize(index, src)
{
	boxPhotoSetFontSize[index] = src;

	wmWindowSaved = false;

	boxPhotoSetGenerate(index);
}

function boxPhotoSetSetupFontBold(index, src)
{
	boxPhotoSetFontBold[index] = (boxPhotoSetFontBold[index] == 0 ? 1 : 0);

	wmWindowSaved = false;

	boxPhotoSetGenerate(index);
}

function boxPhotoSetSetupFontItalic(index, src)
{
	boxPhotoSetFontItalic[index] = (boxPhotoSetFontItalic[index] == 0 ? 1 : 0);

	wmWindowSaved = false;

	boxPhotoSetGenerate(index);
}

function boxPhotoSetSetupHAlign(index, src)
{
	boxPhotoSetHAlign[index] = src;

	wmWindowSaved = false;

	boxPhotoSetGenerate(index);
}

function boxPhotoSetSetupVAlign(index, src)
{
	boxPhotoSetVAlign[index] = src;

	wmWindowSaved = false;

	boxPhotoSetGenerate(index);
}

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

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

	content += '<input type="hidden" name="box_' + index + '_fontColor"  value="' + escape(boxPhotoSetFontColor[index])  + '" />\n';
	content += '<input type="hidden" name="box_' + index + '_fontHColor" value="' + escape(boxPhotoSetFontHColor[index]) + '" />\n';
	content += '<input type="hidden" name="box_' + index + '_fontFamily" value="' + escape(boxPhotoSetFontFamily[index]) + '" />\n';
	content += '<input type="hidden" name="box_' + index + '_fontSize"   value="' + escape(boxPhotoSetFontSize[index])   + '" />\n';
	content += '<input type="hidden" name="box_' + index + '_fontBold"   value="' + escape(boxPhotoSetFontBold[index])   + '" />\n';
	content += '<input type="hidden" name="box_' + index + '_fontItalic" value="' + escape(boxPhotoSetFontItalic[index]) + '" />\n';

        content += '<input type="hidden" name="box_' + index + '_linkHAlign" value="' + escape(boxPhotoSetHAlign[index]) + '" />\n';
        content += '<input type="hidden" name="box_' + index + '_linkVAlign" value="' + escape(boxPhotoSetVAlign[index]) + '" />\n';

	return content;
}

