var host = 'dometra.ru';

function getLiveinternet()
{
	document.write('<a href="http://www.liveinternet.ru/click" '+
	'target="_blank"><img src="http://counter.yadro.ru/hit?t42.2;r'+
	escape(document.referrer)+((typeof(screen)=='undefined')?'':
	';s'+screen.width+'*'+screen.height+'*'+(screen.colorDepth?
	screen.colorDepth:screen.pixelDepth))+';u'+escape(document.URL)+
	';'+Math.random()+'" alt="" title="LiveInternet" '+'border="0" width="31" height="31" /></a>');
}

function dcounter(banids, uri, ref)
{
	document.write ('<img alt="" src="/images/stats.jpg?ids=' + banids + '&amp;uri=' + uri + '&amp;ref=' + ref + '" />');
}

function analyticsSelectSwitch(category)
{
	if (category != false)
		document.location='http://' + host + '/analytics/' + category + '/';
	else
		document.location='http://' + host + '/analytics/';
}

function activitiesSelectSwitch(category, state)
{
	if (category != false) {
		if (state != false)
			document.location='http://' + host + '/activities/' + category + '/' + state + '/';
		else
			document.location='http://' + host + '/activities/' + category + '/';
	}
	else {
		if (state != false)
			document.location='http://' + host + '/activities/' + state + '/';
		else
			document.location='http://' + host + '/activities/';
	}
}

function validatePassword()
{
	if (document.getElementById('p2').value != this.document.getElementById('p1').value)
		document.getElementById('valP2').style.background = 'url(\'/images/site/tickX.gif\') no-repeat right center';
	else
		document.getElementById('valP2').style.background = 'url(\'/images/site/tickV.gif\') no-repeat right center';
}

function passwordNotEmpty()
{
	if (document.getElementById('p1').value.length == 0)
		document.getElementById('valP1').style.background = 'url(\'/images/site/tickX.gif\') no-repeat right center';
	else
		document.getElementById('valP1').style.background = 'url(\'/images/site/tickV.gif\') no-repeat right center';
}

function validateMail()
{
	if (document.getElementById('rmail').value.length == 0)
		document.getElementById('valM').style.background = 'url(\'/images/site/tickX.gif\') no-repeat right center';
	else
	{
		if (document.getElementById('rmail').value.match(/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/gi) != null)
			document.getElementById('valM').style.background = 'url(\'/images/site/tickV.gif\') no-repeat right center';
		else
			document.getElementById('valM').style.background = 'url(\'/images/site/tickX.gif\') no-repeat right center';
	}
}

function showLogin()
{
	document.getElementById('registration').style.display = 'none';
	document.getElementById('login').style.display = '';
}

function showRegistration()
{
	document.getElementById('login').style.display = 'none';
	document.getElementById('registration').style.display = '';
}

function ecardCatSelect(id, usedIds)
{
	//document.write(usedIds);
	document.getElementById('cat_'+id).style.display="";
	aUsedIds = usedIds.split(',');
	
	for (var i = 0; i < aUsedIds.length; i++)
	{
		if (aUsedIds[i] != id)
		{
			document.getElementById('cat_'+aUsedIds[i]).style.display="none";
		}
	}
}

function textCounter(field, cntfield, maxlimit)
{
	if (field.value.length > maxlimit)
		field.value = field.value.substring(0, maxlimit);
	else
		cntfield.value = maxlimit - field.value.length;
}