
function popupImg( src )
{
	var html = { title:'Base Project', style:'', body:'' };	
	html.style = 'BODY {padding:0; margin:0;}';
	html.body = '<A HREF="/" onClick="opener.focus(); self.close(); return false;">' + 
		'<IMG SRC="'+ src +'" BORDER="0" TITLE="Закрыть" ID="resizeBy"/>' + 
		'</A>';			
	popupPro( html, null );
}

function popupPro( html, args ) 
{    	
    args = (args && args.length == 7) ? args : ['no','no','no','no','no','no','no'];	
	try	{ if ( popup ) popup.close(); } catch ( e ) {}
	var win;	
	popup = window.open( '','popup','top=0,left=0,toobar='+args[0]+',location='+args[1]+',directories='+args[2]+',status='+args[3]+',resizable='+args[4]+',scrollbars='+args[5]+',copyhistory='+args[6]+',width=1,height=1' );			
	doc = popup.document;
	var str ='<HTML><HEAD><TITLE>' + html.title + '</TITLE>' +    
	'<STYLE>'+html.style+'</STYLE><SCRIPT>function resize() {var resizeByObj = document.getElementById( "resizeBy" ); if ( resizeByObj ) { resizeTo( resizeByObj.width, resizeByObj.height ); var top = parseInt( (window.screen.height  - ( window.screen.height - window.screen.availHeight ) - resizeByObj.height) / 2); var left = parseInt( (window.screen.width - ( window.screen.width - window.screen.availWidth ) - resizeByObj.width) / 2); moveTo( left, top );}	window.focus();}</SCRIPT></HEAD>' +
	'<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1251">' + 
    '<BODY onLoad="resize(); self.focus();">' + html.body + '</BODY></HTML>';
	doc.write(str);
	doc.close();	
	self.win = popup;
}

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,
    secure: false,

    getDomain: function()
    {
        return this.domain;
    },

    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 = domain;
    },

    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 : '' ) +
                          ( ( this.domain ) ? '; domain=' + this.domain : '' ) +
                          '; 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 : '' ) +
                          ( ( this.domain ) ? '; domain=' + this.domain : '' ) +
                          ( ( this.secure ) ? '; secure' : '' );

        return true;
    }
};

function changeSearchType( elem )
{
	if( parseInt( elem.value ) == 1 )
	{
		elem.form.action = '/'+ lang +'/yandex.wbp';
		elem.form.elements[0].name = 'text';
	}
	else
	{
		elem.form.action = '/'+ lang +'/search.wbp';
		elem.form.elements[0].name = 'search.query';
	}
}
function checkType( form )
{
	if( form.choose[1].checked )
	{
		form.action = '/'+ lang +'/yandex.wbp';
		form.elements[0].name = 'text';
	}
	new FormCheckPro(form);
}