function Cookie_remove( key ) {

	var cookie  = this.prefix_ + key + "=" ;
	    cookie += "; expires=Fri, 02-Jan-1970 00:00:00 GMT" ;

	if( this.path_ )   cookie += "; path="   + this.path_ ;
	if( this.domain_ ) cookie += "; domain=" + this.domain_ ;
	if( this.secure_ ) cookie += "; secure=" + this.secure_ ;

	this.document_.cookie = cookie ;

}

function Cookie_get( key ) {

	var tmp1, tmp2, xx1, xx2, xx3, len ;
	tmp1 = " " + this.document_.cookie + ";" ;
	xx1 = xx2 = 0 ;
	len = tmp1.length ;
	while( xx1 < len ) {
		xx2  = tmp1.indexOf( ";", xx1 ) ;
		tmp2 = tmp1.substring( xx1 + 1, xx2 ) ;
		xx3  = tmp2.indexOf( "=" ) ;
		if( tmp2.substring( 0, xx3 ) == ( this.prefix_ + key ) ) {
			return( unescape( tmp2.substring( xx3 + 1, xx2 - xx1 - 1 ) ) ) ;
		}
		xx1 = xx2 + 1 ;
	}
	return( "" ) ;

}

function Cookie_set( key, value ) {

	var cookie = this.prefix_ + key + "=" + escape( value ) ;

	if( this.expiration_ ) cookie += "; expires=" + this.expiration_.toGMTString( ) ;
	if( this.path_ )       cookie += "; path="    + this.path_ ;
	if( this.domain_ )     cookie += "; domain="  + this.domain_ ;
	if( this.secure_ )     cookie += "; secure="  + this.secure_ ;

	this.document_.cookie = cookie ;

}

function Cookie( ) {

	var a = arguments ;
	this.prefix_     = ( a[0] ? a[0] + "_" : "" ) ;
	this.expiration_ = ( a[1] ? new Date( new Date( ).getTime( ) + a[1]*24*60*60*1000 )
	                                       : null ) ;
	this.path_       = ( a[2] ? a[2]       : null ) ;
	this.domain_     = ( a[3] ? a[3]       : null ) ;
	this.secure_     = ( a[4] ? a[4]       : false ) ;
	this.document_   = ( a[5] ? a[5]       : document ) ;

	this.set       = Cookie_set ;
	this.get       = Cookie_get ;
	this.remove    = Cookie_remove ;

}
