function CheckEmailForm()
	{
		var frm = document.getElementById( 'emailform' );
		msg = '';
		err = '';
		if ( frm.email.value == 'e-mail получателя' )
			msg += 'E-mail\n';
		else
		{
			reg = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;

			if (!frm.email.value.match(reg))				
				err += '\nПожалуйста, введите правильный e-mail\n';
		}		
		if ( msg != '' )
		{
			alert( 'Должны быть заполнены следующие поля: \n'+msg );
			return false;
		}
		else
			if(err != '')
			{
				alert( err );
				return false;
			}
		do_emailform_Action( 'send-url-form' );
		return true;
	}



function SetSiteCookie( cookie_name, value )
{
	//document.cookie = cookie_name+"=" + escape( value ) + ";path=/";
	//window.location.reload();
	var item = document.getElementById( 'cook' );        
        item.value = value;        
	do_setcookie_Action('setcookie');
}

function SetSiteSortOrderCookie( cookie_name, value, orderval )
{
	document.cookie = cookie_name+"=" + escape( value ) + ";";
	var cval = getCookie('sort_order');
	if(cval == null)
		orderval = 0;
	else
		if(cval == 0)
			orderval = 1;
		else
			orderval = 0;

	document.cookie = "sort_order=" + escape(orderval)+";";	
	window.location.reload();	
}

function getCookie(name) {
        var prefix = name + "="
        var cookieStartIndex = document.cookie.indexOf(prefix)
        if (cookieStartIndex == -1)
                return null
        var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
        if (cookieEndIndex == -1)
                cookieEndIndex = document.cookie.length
        return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}

function SetSiteSortCookie( cookie_name, value )
{
	document.cookie = cookie_name+"=" + escape( value ) + ";path=/";
	window.location.reload();	
}

var setSelect = function( name, value )
{
	var el = document.getElementById( name );
	for ( var i=0; i < el.options.length; i++ )
	{
		if ( el.options[ i ].value == value )
		{
			el.selectedIndex = i;
			break;
		}
	}
}

