function Str(_Str)
{
	return g_Strings[_Str];
}

function CheckForm()
{
	if (_$('name').value == '' || _$('name').value == 'Имя*')
	{
		alert(Str('no_user_name'));
		return false;
	}
	
	if (_$('mail').value == '' || _$('mail').value == 'E-mail*')
	{
		alert(Str('no_mail'));
		return;
	}
	else
	{
		if (_$('mail').value.search(/^[0-9a-zA-Z_\-\.]+@[0-9a-zA-Z_\-\.]+\.[a-z]{2,5}$/) == -1)
		{
			alert(Str('no_correct_mail'));
			return false;
		}
	}
	
	if (_$('message').value == '' || _$('message').value == 'Сообщение*')
	{
		alert(Str('no_message'));
		return false;
	}

	return true;
}

function SendMail()
{
	if (!CheckForm()) return;
	
	var l_Post = '&name='+_$('name').value+'&tel='+_$('tel').value+'&mail='+_$('mail').value+'&message='+_$('message').value;
	SendRequest('sendmail', '', 1, l_Post);
	
	alert(Str('message_send'));
}


//////////////////////////////////////////////////////////////////////

var l_ActiveProjLink = null;
var l_ActivePageLink = null;
function ChangeImages(_LinkDom)
{
	if (_LinkDom == l_ActivePageLink) return;
	if (l_ActivePageLink != null)
	{
		l_ActivePageLink.className = '';
	}
	
	_LinkDom.className = 'selekta';
	l_ActivePageLink = _LinkDom;

	SendRequest(_LinkDom.getAttribute('request'), 'image_preview');
	
	var l_ContDiv = _$('mediaspace');
	if (l_ContDiv)
	{
		if (l_ContDiv.getAttribute('video') != '')
		{
			var so = new SWFObject('/file?name=flash/player.swf','single','425','344','0','#333333');
			so.addVariable('fullscreen','true');
		    so.addParam('allowfullscreen','true');
		    so.addParam('wmode','opaque');
		    so.addVariable('file', l_ContDiv.getAttribute('video'));
		    so.addVariable('image', l_ContDiv.getAttribute('preview'));
		    so.addVariable('skin', '/file?name=flash/nacht.swf');
		    so.write('mediaspace');
		}
		else if (l_ContDiv.getAttribute('flash') != '')
		{
			var so = new SWFObject(l_ContDiv.getAttribute('flash'),'single','425','344','0','#333333');
			so.addVariable('fullscreen','true');
			so.addParam('allowfullscreen','true');
			so.addParam('wmode','opaque');							
			so.write('mediaspace');
		}
	}
}

function ShowImages(_LinkDom)
{
	if (_LinkDom == l_ActiveProjLink) return;
	l_ActivePageLink = null;

	if (l_ActiveProjLink != null)
	{
		l_ActiveProjLink.className = '';
	}
	
	_LinkDom.className = 'selekta';
	
	SendRequest(_LinkDom.getAttribute('request'), 'PrevIuBlok');
	
	var l_Links = _$('zifri').getElementsByTagName('a');
	
	_$('zifri').style.display = l_Links.length > 1 ? '' : 'none';
	if (l_Links.length > 0) ChangeImages(l_Links[0]);
	
	l_ActiveProjLink = _LinkDom;
	
	InitEvents();
}