function select_region( city )
{  
   
   document.location.href="?city="+city;
}

function save_result( game_result )
{  
   document.getElementById('win_score').value = game_result;
   document.forms.form_game_result.submit();
}

fon0 = '#fff';
fon1 = '#eee';
fon_err = '#f90';
fon_good = '#E8E9F4';

// зададим первоначальные флаги ошибок
err = new Array();
for(f=1; f<=3; f++){
	err[f] = 2;
}

function set_e(id){ 
// функция проверки e-mail
	mail = document.getElementById(id).value;
	lan = mail.length;

if(id == "3"){ if(mail.indexOf(",")>1) {mail = mail.substring(0, mail.indexOf(","));}}

	fon = fon_err;
	err[id]=1;
	
	if(mail.length >= 7) {
		if(mail.indexOf("@") > 0 && mail.lastIndexOf("@") < (lan-5) && mail.indexOf("@") == mail.lastIndexOf("@")){
			if(mail.lastIndexOf(".") > (mail.lastIndexOf("@") + 2) && mail.lastIndexOf(".") < (lan - 2)){
				fon = fon_good;
				err[id]=0;
			}		
		}
	}
	document.getElementById(id).style.background = fon;
}
function set(id, min){
	// функция проверки и смены фона
	if(document.getElementById(id).value.length < min) {
		fon = fon_err;
		err[id]=1;
	} else {
		fon = fon_good;
		err[id]=0;
	}
	document.getElementById(id).style.background = fon;
}

function sendform(){
	set('1','1'); // проверим заполнение имени
	if(err[1] != 0){
		alert("Укажите ваше имя или ник");
		document.getElementById('1').focus();
		return false;
	}
// 1 проверим - вызвать ли на дуэль - и если да - тогда проверим поля адресов
if(document.getElementById('email_duel').value!=""){
	set_e('3'); // проверим правильность заполнения адресов дуэлянтов
	if(err[3] != 0){
		alert("Не верно указан e-mail для вызова на дуэль");
		document.getElementById('3').focus();
		return false;
	}
	set_e('2'); // проверим правильность заполнения адреса игрока
	if(err[2] != 0){
		alert("Не верно указан ваш e-mail");
		document.getElementById('2').focus();
		return false;
	}
}
document.winner.submit();
}

function select_metro(page) {
	mmm = document.getElementById('id_metro_select_list').value;
	if(mmm !== "any"){
		document.location.href = "/index"+page+".php?metr="+mmm;
		} else {document.location.href = "/index"+page+".php";}
}

var Http =
{
    cookies: document.cookie.split('; '),

    getCookies: function()
    {
        var result = new Array();
        for( i in this.cookies )
        {
            var cookie = this.cookies[i].split('=');
            result[i] = new Http.Cookie( cookie[0], ( cookie[1] ) ? cookie[1] : '' );
        }
        return result;
    },

    getCookieByName: function( name )
    {
        for( i in this.cookies )
        {		
            var cookie = this.cookies[i].split('=');			
            if( cookie[0].toUpperCase() === name.toUpperCase() )
            {
                return new Http.Cookie( cookie[0], ( cookie[1] ) ? cookie[1] : '' );
            }
        }

        return null;
    }
};

Http.Cookie = function( name, value, maxAge, path, domain, secure )
{
    if ( name )
    {
        this.setName( name );
    }
    if ( value )
    {
        this.setValue( value );
    }
    if ( maxAge instanceof Date )
    {
        this.setMaxAge( maxAge );
    }
    if ( path )
    {
        this.setPath( path );
    }
    if ( domain )
    {
        this.setDomain( domain );
    }

    if ( secure instanceof Boolean )
    {
        this.setSecure( secure );
    }
};
Http.Cookie.prototype =
{
    name: '',
    value: '',
    maxAge: null,
    path: '/',
    // domain: location.hostname,
	domain: 'binbank.ru',
    secure: false,

    getDomain: function()
    {
        return 'binbank.ru';
    },

    getMaxAge: function()
    {
        return this.maxAge;
    },

    getName: function()
    {
        return this.name;
    },

    getPath: function()
    {
        return this.path;
    },

    getSecure: function()
    {
        return this.secure;
    },

    getValue: function()
    {
        return unescape( this.value );
    },

    setMaxAge: function( maxAge )
    {
        this.maxAge = new Date( maxAge );
    },

    setDomain: function( domain )
    {
        this.domain = 'binbank.ru';
    },

    setName: function( name )
    {
        this.name = name;
    },

    setPath: function( path )
    {
        this.path = path;
    },

    setSecure: function( secure )
    {
        this.secure = secure;
    },

    setValue: function( value )
    {
        this.value = escape( value );
    },

    destroy: function()
    {
        document.cookie = this.name + "=" +
                          ( ( this.path ) ? '; path=' + this.path : '' ) +
                          ('; domain=binbank.ru') +
                          '; expires=' + ( new Date(1970, 00, 01) ).toGMTString();
    },

    save: function()
    {
        document.cookie = this.name + "=" +
                          ( ( this.value ) ? this.value : '' ) +
                          ( ( this.expires ) ? '; expires=' + this.expires.toGMTString() : '' ) +
                          ( ( this.path ) ? '; path=' + this.path : '' ) +
                          ('; domain=binbank.ru') +
                          ( ( this.secure ) ? '; secure' : '' );

        return true;
    }
};