if( !console ) { var console = { 'log': function( _a ) { } } } var maxzoom = 10; var eInterface = { Main:0, Edit:1 }; function wTimestamp( _utc, _offset, _z ) { var d = new Date(); this.loffset = - ( d.getTimezoneOffset() * 60 ); this.utc = parseInt( _utc, 10 ); this.offset = parseInt( _offset, 10 ); this.z = parseInt( _z, 10 ); this.ldate = new Date(); this.ldate.setTime( this.getLocal() * 1000 ); } wTimestamp.prototype = { getUTC: function(){ return this.utc; }, getLocal: function() { return this.utc + this.offset - this.loffset; }, getLocalTime: function() { return { d: this.ldate.getDate(), m: this.ldate.getMonth(), y: this.ldate.getFullYear(), h: this.ldate.getHours(), i: this.ldate.getMinutes(), s:this.ldate.getSeconds() }; } } function convertTimestamp( _timestamp ){ var t = _timestamp; var nd = new Date(); var off = nd.getTimezoneOffset(); t = _timestamp - off; var d = new Date( t ); var v = new Array(); v.d = d.getDate(); v.m = d.getMonth() + 1; v.y = d.getFullYear(); v.h = d.getHours(); v.i = d.getMinutes(); v.s = v.d + '/' + v.m + '/' + v.y + ' ' + ( ( v.h < 10 )?'0':'' ) + v.h + ':' + ( ( v.i < 10 )?'0':'' ) + v.i; return v; } function getTimestamp( _day, _month, _year, _hour, _minute, _second, _millisecond ){ var d = new Date(); d.setDate( _day ); d.setMonth( _month - 1 ); d.setFullYear( _year ); d.setHours( _hour ); d.setMinutes( _minute ); d.setSeconds( _second ); d.setMilliseconds( _millisecond ); var v = d.getTime(); delete d; return v; } function showSectorCallback( _obj ){ var response = _obj.http_request.responseXML.documentElement; var vv = gds( response, 'sector' ); var s = ''; if( vv.length > 0 ){ s = ga( vv[ 0 ], 'id' ); } re( ge( 'sector' ), s ); } var eTagType = { User: 0, Group: 1, All: 2, Contact: 3 }; var eEditMode = { UserTags: 0, GroupTags: 1, AllTags: 3, planStay: 4, planEvent: 5, Newbie: 6 }; function tagData( _id, _name, _type ) { this.id = _id; this.name = _name; this.type = _type; } function tagManagerObject2() { this.obj = new ajaxobject2(); this.data = []; this.size = 20; this.page = 0; this.filter = ''; } tagManagerObject2.prototype = { create: function( _id, _sel, _mode, _type ) { this.id = _id; this.sel = _sel; this.mode = _mode; this.type = _type; this.obj.create( this, this.processRequest, eAjaxModes.Get, 'wheriz.php?get=tags', '' ); if( this.mode == eEditMode.Newbie ) { re( this.id, '
' + loc_js.direct_vis1 + '' + loc_js.direct_vis2 + '
' + loc_js.direct_vis3 + '
| ';
head_code += ' ' + loc_js.legend + ': ' + loc_js.my_tags + ' ' + loc_js.my_contacts + ' ' + loc_js.my_groups + ''; head_code += ' | ';
}
head_code += ' |
';
else if( t.type == eTagType.Group ) icon = '
';
else if( t.type == eTagType.User ) icon = '
';
else icon = '';
var code = '' + icon + t.name;
if( t.type == eTagType.Group ) code += ' [' + loc_js.group + ']';
if( t.vis ) code += ' [' + loc_js.pub_tag + ']';
code += '';
e.innerHTML = code;
e.onclick = bargs( this.onItemClick, this, t.id );
l.appendChild( e );
}
var l = ge( this.id + '.pager' );
if( !l ) return;
while( l.hasChildNodes() )
l.removeChild( gfc( l ) );
var c = 3;
var mp = 10;
if( tpp > 1 ) {
if( this.page != 0 && tpp > mp ) {
l.appendChild( this.createLink( 'Previous', this.page - 1 ) );
l.appendChild( this.createLink( 'First', 0 ) );
}
var dots = true;
for( var j = 0; j < tpp; j++ ) {
if( ( tpp <= mp ) ||
( Math.abs( this.page - j ) < c ) ||
( Math.abs( ( tpp / 2 ) - j ) < c ) ||
( j < 2 * c ) ||
( j > ( tpp - 2 * c ) )
) {
if( this.page == j ) {
var e = document.createElement( 'li' );
e.className = 'current';
e.innerHTML = j + 1;
l.appendChild( e );
} else l.appendChild( this.createLink( j + 1 , j ) );
dots = false;
} else {
if( !dots ) {
var p = document.createElement( 'li' );
p.innerHTML = '...';
p.className = 'static';
l.appendChild( p );
dots = true;
}
}
}
if( this.page != ( tpp - 1 ) && tpp > mp ) {
l.appendChild( this.createLink( 'Last', tpp - 1 ) );
l.appendChild( this.createLink( 'Next', this.page + 1 ) );
}
}
this.onUpdated( this );
},
moveTo: function( _this, _page ) {
_this.page = _page;
_this.updateList();
return false;
},
getText: function() {
var str = '';
if( this.sel ) {
for( var j = 0; j < this.sel.length; j++ ) {
var found = false;
for( var k = 0; k < this.data.length && !found; k++ ) {
if( this.data[ k ].id == this.sel[ j ] ) { str += this.data[ k ].name; found = true; }
}
if( j < ( this.sel.length - 1 ) ) str += ', ';
}
}
return str;
},
getTags: function() {
var str = '';
if( this.sel ) {
for( var j = 0; j < this.sel.length; j++ ) {
str += this.sel[ j ];
if( j < ( this.sel.length - 1 ) ) str += ',';
}
}
return str;
},
getVisibility: function() {
var str = '';
var contacts = [];
if( this.sel ) {
for( var j = 0; j < this.sel.length; j++ ) {
var found = false;
for( var k = 0; k < this.data.length && !found; k++ ) {
if( this.data[ k ].id == this.sel[ j ] ) {
for( var i = 0; i < this.data[ k ].contacts.length; i++ )
//contacts[ this.data[ k ].contacts[ i ] ] = true;
contacts[ this.data[ k ].contacts[ i ].id ] = this.data[ k ].contacts[ i ].name;
found = true;
}
}
}
}
var names = [];
for( var j in contacts )
if( typeof( contacts[ j ] ) != 'function' )
names.push( contacts[ j ] );
for( var j = 0; j < names.length; j++ ) {
//str += usrMgr.getUserByID( names[ j ] ).name;
str += names[ j ];
if( j < names.length - 1 ) str += ', ';
}
return str;
}
}
function calCtrl( _id, _div ) {
var el = ge( _div );
if( !el ) return;
this.id = _id;
this.name = _div;
this.box = _div + '.box';
this.cal = _div + '.cal';
this.txt = _div + '.txt';
var e = document.createElement( 'div' );
e.id = this.box;
e.className = 'calbox';
e.innerHTML = '' + loc_js.clicktoseldate +'
'; var thisPtr = this; e.onclick = function( evt ) { toggleCalendars( evt, thisPtr ); }; el.appendChild( e ); var e = document.createElement( 'div' ); e.id = this.cal; e.className = 'c_div'; el.appendChild( e ); this.calendar = new myCal( this.id + '.calendar', this.cal, this ); toggle( this.cal ); this.calendar.setDateCallback( this.update ); } calCtrl.prototype = { update: function(){ re( ge( this.parent.txt ), this.sday + ' ' + this.monthNames[ this.smonth ] + ', ' + this.syear ); }, destroy: function() { return null; } } function lbox(){ } lbox.prototype = { create: function( ) { var body = window.document.body; var objOverlay = document.createElement( 'div' ); objOverlay.setAttribute( 'id', 'overlay' ); objOverlay.onclick = bargs( this.hide, this ); objOverlay.style.position = 'absolute'; objOverlay.style.top = '0'; objOverlay.style.left = '0'; objOverlay.style.zindex = '100'; objOverlay.style.zIndex = '90'; objOverlay.style.width = '100%'; objOverlay.style.height = '100%'; objOverlay.style.display = 'block'; objOverlay.style.display = 'none'; body.appendChild( objOverlay ); var newdiv = document.createElement( 'div' ); newdiv.setAttribute( 'id', 'ovr_panel' ); newdiv.setAttribute( 'class', 'border shadow' ); newdiv.setAttribute( 'className', 'border shadow' ); newdiv.style.position = 'absolute'; newdiv.style.top = '0'; newdiv.style.left = '0'; newdiv.style.bottom = '0'; newdiv.style.right = '0'; newdiv.style.marginTop = '40px'; newdiv.style.marginLeft = '100px'; newdiv.style.marginBottom = '40px'; newdiv.style.marginRight = '100px'; newdiv.style.zIndex = '90'; var code = ''; code += ''+loc_js.checking+'
' ); return newdiv; }, addContent: function( _id, _code ) { var d = document.createElement( 'div' ); d.innerHTML = _code; d.id = 'lbc' + _id; this.base.appendChild( d ); }, show: function( _this, _id ) { _this = _this || this; _this.onShow(); for( var j = 0; j < _this.base.childNodes.length; j++ ) show( _this.base.childNodes[ j ], false ); show( 'lbc' + _id, true ); show( 'ovr_panel', true ); show( 'overlay', true ); _this.onShown(); }, onHide: function() { return false; }, onHidden: function() { }, onShow: function() { }, onShown: function() { }, hide: function( _this ) { _this = _this || this; _this.onHide(); show( 'ovr_panel', false ); show( 'overlay', false ); _this.onHidden(); return false; }, destroy: function( _this ) { _this.hide(); var node = ge( 'ovr_panel' ); if ( node ) node.parentNode.removeChild( node ); var node = ge( 'overlay' ); if ( node ) node.parentNode.removeChild( node ); } } function wStatus() {} wStatus.prototype = { create: function( _link, _text ){ this.link = _link; this.text = _text; this.o = new ajaxobject2(); this.o.create( this, this.onData, eAjaxModes.Get, 'wheriz.php?communications', '' ); }, load: function(){ re( ge( 'wstatus' ), '' + loc_js.checking + '
' ); this.o.request(); }, onData: function( _obj ) { var response = _obj.http_request.responseXML.documentElement; var txt = []; if( parseInt( ga( response, 'warning' ), 10 ) > 0 ) txt.push( 'warning' ); var ft = ''; if( txt.length > 0 ) { ft = ''; } if( ft == '' ) ft = '' + _obj.thisPtr.text + '
'; re( ge( 'wstatus' ), ft ); } } function collapseEl( _id ) { var el = ge( _id ); toggle( el ); ge( _id + '.click' ).style.backgroundPosition = ( el.style.display == 'none' )?'-12px':'0'; } function cityObject () { } cityObject.prototype = { create: function() { this.g = .1; this.mw = Math.floor( 360.0 / this.g ); this.ogc = new ajaxobject2(); this.os = null; this.sovr = null; this.citylist = []; this.sorted = []; this.pos = null; this.tzones = []; }, setPosition: function( _p ) { if( _p == this.pos ) return; this.pos = _p; var y = Math.floor( ( _p.lat() + 90.0 ) / this.g ); var x = Math.floor( ( _p.lng() + 180.0 ) / this.g ); var s = y * this.mw + x; if( s != this.os ) { this.ogc.create( this, this.onLoadCities, eAjaxModes.Get, 'wheriz.php?get=cities§or=' + s, '' ); this.ogc.request(); this.os = s; } else this.updateCitiesList(); }, getCities: function() { /*re( 'cityinfo', 'Retrieving...' ); show( 'citylist', false ); show( 'cityinfo', true );*/ /*console.log( 'sector: ' + s + ' (' + os + ')' ); var lat = Math.floor( cpoint.lat() / g ) * g; var lng = Math.floor( cpoint.lng() / g ) * g;*/ /*if( sovr ) { map.removeOverlay( sovr ); sovr = null; } var pts = [ new GLatLng( lat - g, lng - g ), new GLatLng( lat - g, lng + 2 * g ), new GLatLng( lat + 2 * g, lng + 2 * g ), new GLatLng( lat + 2 * g, lng - g ), new GLatLng( lat - g, lng - g ) ]; sovr = new GPolyline( pts, '#ff0000', 2, 0.2 ); map.addOverlay( sovr );*/ /*console.log( 'load' ); this.ogc.create( this, this.onLoadCities, eAjaxModes.Get, 'wheriz.php?get=cities§or=' + s, '' ); this.ogc.request(); this.os = s;*/ //} else this.updateCitiesList(); }, onLoadCities: function( _obj ) { var _this = _obj.thisPtr; _this.citylist.clear(); var response = _obj.http_request.responseXML.documentElement; var ca = gds( response, 'city' ); for( var j = 0; j < ca.length; j++ ) { var i = ca[ j ]; _this.citylist.push( { 'id': ga( i, 'id' ), 'name': ga( i, 'name' ), 'pos': new GLatLng( parseFloat( ga( i, 'lat' ) ), parseFloat( ga( i, 'lng' ) ) ), 'tz': parseInt( ga( i, 'tz' ) ) } ); } _this.updateCitiesList(); }, updateCitiesList: function() { this.sorted.clear(); this.tzones.clear(); for( var j = 0; j < this.citylist.length; j++ ) { var found = false; for( var i = 0; i < this.tzones.length && !found; i++ ) { if( this.tzones[ i ].id == this.citylist[ j ].tz ) { this.tzones[ i ].total++; found = true; } } if( !found ) this.tzones.push( { 'id': this.citylist[ j ].tz, 'total': 0 } ); var d = this.pos.distanceFrom( this.citylist[ j ].pos ); var e = { 'id': j, 'd': d }; var added = false; if( this.sorted.length == 0 ) { this.sorted.push( e ); added = true; } else { for( k = 0; k < this.sorted.length && !added; k++ ){ if( this.sorted[ k ].d > d ) { this.sorted.splice( k, 0, e ); added = true; } } if( !added ) { this.sorted.push( e ); added = true; } } } this.onChanged(); }, onChanged: function() { }, getNearest: function() { if( this.citylist.length > 0 ) return this.citylist[ this.sorted[ 0 ].id ].name; return null; } } function sortAsc( _a, _b ) { return _a.total < _b.total; } function tzList() { } tzList.prototype = { create: function( _id ) { this.divId = _id; this.tzId = null; this.zoneName = ''; re( ge( this.divId ), ''+loc_js.checking+'
' + loc_js.use_controls + '
'; code += '';
code += '' + loc_js.choose_by_search + ''; code += ''; //code += ''; code += ''; code += ''; code += ''; code += ' | '; code += ''; code += ' | ';
code += '' + loc_js.type_location + ''; code += ''; //code += '' + loc_js.type_hint + ' '; code += ' |

'+ loc_js.uploading + '' );
show( _this.id + '.progress', true );
},
onLoad: function( _this, _id ) {
var el = ge( _id );
if( !el ) return;
if( el.readyState && el.readyState != 'complete' ) return;
_this.updateImage();
var txt = 'Completed.';
var doc = null;
if( el.contentDocument ) // Firefox, Opera
doc = el.contentDocument;
else if( el.contentWindow ) // Internet Explorer
doc = el.contentWindow.document;
else if( el.document ) // Others?
doc = el.document;
if( doc ) if( document.all ) txt = doc.body.innerText; else txt = doc.body.textContent;
re( _this.id + '.progress', txt );
if( _this.onLoaded ) _this.onLoaded();
return false;
},
updateImage: function() {
var d = new Date();
ge( this.id + '.img' ).src = 'image.php?' + ( ( this.mode == 'user' )?( 'id=' + this.iid ):( 'gid=' + this.iid ) ) + '&size=64' + '&' + d.getFullYear() + d.getMonth() + d.getDate();
}
}
var months = [ 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec' ];
var days = [ 'sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday' ];
Date.prototype.getWeekDay = function() {
return loc_js[ days[ this.getDay() ] ] + '. ' + this.getDate();
}
function getHumanDate( _timestamp ) {
if( typeof( _timestamp ) != 'object' ) {
var a = 2;
}
var d = new Date();
d.setTime( _timestamp.getLocal() * 1000 );
return sprintf( '%s %s %s %s %s', d.getWeekDay(), loc_js[ 'of_dates' ],loc_js[ months[ d.getMonth() ] ], loc_js[ 'of_dates' ], d.getFullYear() )
}
function getHumanTime( _date ) {
var m = _date.getMinutes();
return _date.getHours() + ':' + ( ( m < 10 )?'0':'' ) + m;
}
function getCompleteDateRange( _from, _to, _remote ) {
if( typeof( _from ) != 'object' || typeof( _to ) != 'object') {
var a = 2;
}
var df = new Date();
var dt = new Date();
if( _remote ) {
df.setTime( _from.getUTC() * 1000 );
dt.setTime( _to.getUTC() * 1000 + 1000 );
} else {
df.setTime( _from.getLocal() * 1000 );
dt.setTime( _to.getLocal() * 1000 + 1000 );
}
var str = '';
if( df.getFullYear() == dt.getFullYear() && df.getMonth() == dt.getMonth() && df.getDate() == dt.getDate() ) {
str = sprintf( loc_js.hr1, df.getWeekDay(), loc_js[ months[ df.getMonth() ] ], df.getFullYear(), getHumanTime( df ), getHumanTime( dt ) );
} else {
str = sprintf( loc_js.hr6,
df.getWeekDay(), loc_js[ months[ df.getMonth() ] ], df.getFullYear(), getHumanTime( df ),
dt.getWeekDay(), loc_js[ months[ dt.getMonth() ] ], dt.getFullYear(), getHumanTime( dt )
);
}
if( _remote ) str += ' (hora local)';
return str;
}
function getHumanDateRange( _from, _to ) {
if( typeof( _from ) != 'object' || typeof( _to ) != 'object') {
var a = 2;
}
var df = new Date();
df.setTime( _from.getLocal() * 1000 );
var dt = new Date();
dt.setTime( _to.getLocal() * 1000 + 1000 );
if( df.getFullYear() == dt.getFullYear() ) {
if( df.getMonth() == dt.getMonth() ) {
if( df.getDate() == dt.getDate() ) {
return sprintf( loc_js.hr1,
df.getWeekDay(), loc_js[ months[ df.getMonth() ] ], df.getFullYear(), getHumanTime( df ), getHumanTime( dt ) );
} else {
return sprintf( loc_js.hr2, df.getWeekDay(), dt.getWeekDay(), loc_js[ months[ df.getMonth() ] ], df.getFullYear() )
}
} else {
return sprintf( loc_js.hr3, df.getWeekDay(), loc_js[ months[ df.getMonth() ] ], dt.getWeekDay(), loc_js[ months[ dt.getMonth() ] ], dt.getFullYear() )
}
} else {
return sprintf( loc_js.hr4, df.getWeekDay(), loc_js[ months[ df.getMonth() ] ], df.getFullYear(), dt.getWeekDay(), loc_js[ months[ dt.getMonth() ] ], dt.getFullYear() )
}
}
function wTabs() {
}
wTabs.prototype = {
create: function( _id, _div ) {
this.id = _id;
this.divId = _div;
this.ul = document.createElement( 'ul' );
this.ul.className = 'wtabs';
this.div = document.createElement( 'div' );
this.div.style.clear = 'both';
this.lis = document.createElement( 'li' );
this.lis.className = 's';
this.lie = document.createElement( 'li' );
this.lie.className = 'e';
var el = ge( _div );
this.ul.appendChild( this.lis );
this.ul.appendChild( this.lie );
el.appendChild( this.ul );
el.appendChild( this.div );
this.tabs = [];
},
addTab: function( _id, _text, _callback ) {
var li = document.createElement( 'li' );
var a = document.createElement( 'a' );
a.onclick = bargs( this.switchTab, this, _id );
a.innerHTML = '' + _text + '
';
var tip = _text;
div.onmouseover = function( _event ) { helper.show( _event, tip ); }
div.onmousemove = function( _event ) { helper.move( _event ); }
div.onmouseout = function() { helper.hide(); }
return div;
}
function tZs( _val ) {
var res = '';
if( _val < 10 ) res += '0';
res += _val;
return res;
}
var eTooltipMode = { Standard: 0, Info: 1 }
function tooltipObject() {
this.ttip = null;
}
tooltipObject.prototype = {
create: function( _id, _mode, _parent ) {
this.id = _id;
this.parent = _parent;
if( !_mode ) _mode = eTooltipMode.Standard;
this.mode = _mode;
this.ttip = document.createElement( 'div' );
this.ttip.className = 'ttip';
this.ttip.id = 'tooltip_' + this.id;
this.ttip.style.display = 'none';
this.ttip.style.position = 'absolute';
this.content = document.createElement( 'div' );
this.content.id = 'tip_content_' + this.id;
this.ttip.appendChild( this.content );
if( this.mode == eTooltipMode.Info ) {
this.tip = document.createElement( 'div' );
this.tip.className = 'arrow';
this.tip.style.display = 'none';
document.body.appendChild( this.tip );
}
document.body.appendChild( this.ttip );
},
show: function( _event, _text ) {
if( !_event ) var _event = window.event;
this.ttip.style.width = 'auto';
this.ttip.style.height = 'auto';
this.ttip.style.overflow = 'hidden';
this.content.innerHTML = _text;
this.ttip.style.display = 'block';
this.move( _event );
},
hide: function() {
show( this.tip, false );
show( this.ttip, false );
return false;
},
move: function( _event ) {
if( !_event ) var _event = window.event;
var h = 0;
if( window.innerHeight ) h = window.innerHeight;
else h = document.documentElement.clientHeight;
var w = 0;
if( window.innerWidth ) w = window.innerWidth;
else w = document.documentElement.clientWidth;
if( this.ttip.clientWidth > ( w / 3 ) ) this.ttip.style.width = ( w / 3 ) + 'px';
//if( this.ttip.clientHeight > ( h / 3 ) ) this.ttip.style.height = ( h / 3 ) + 'px';
var x = 0;
var y = 0;
var tx = 0;
var ty = 0;
switch( this.mode ) {
case eTooltipMode.Standard: {
x = _event.clientX + 20;
y = _event.clientY + 20;
if( x > .5 * w ) x = _event.clientX - this.ttip.clientWidth - 10;
if( y > .5 * h ) y = _event.clientY - this.ttip.clientHeight - 10;
break;
}
case eTooltipMode.Info: {
var el = _event.currentTarget;
if( !el ) el = _event.srcElement;
var p = gp( el );
x = p.x + .5 * ( el.clientWidth - this.ttip.clientWidth );
tx = p.x + 2;
y = p.y - this.ttip.clientHeight - 10;
ty = p.y - 10;
if( this.parent ) {
y -= ge( this.parent ).scrollTop;
ty -= ge( this.parent ).scrollTop;
}
break;
}
}
if( y < 2 ) y = 2;
if( x < 2 ) x = 2;
this.ttip.style.left = x + 'px';
this.ttip.style.top = y + 'px';
show( this.ttip, true );
if( this.tip ) {
this.tip.style.left = tx + 'px';
this.tip.style.top = ty + 'px';
show( this.tip, true );
}
}
}
function genHex( _value ){
var colors = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' ];
var digit = new Array( 5 );
var color = '';
for( var i = 0; i < 6; i++ ){
digit[ i ] = colors[ Math.round( Math.random() * 14 ) ]
color = color + digit[ i ]
}
return color;
}
function RGBtoHex( _r, _g, _b ) {
return toHex( _r ) + toHex( _g ) + toHex( _b );
}
function toHex( _n ) {
if( _n == null ) return '00';
_n = parseInt( _n, 10 );
if( _n == 0 || isNaN( _n ) ) return '00';
_n = Math.max( 0, _n );
_n = Math.min( _n , 255 );
_n = Math.round( _n );
return '0123456789ABCDEF'.charAt( ( _n - _n % 16 ) / 16 )
+ '0123456789ABCDEF'.charAt( _n % 16 );
}
function getHumanTimeDistance( _timestamp, _timestamp_end ) {
var d = new Date();
var now = d.getTime();
var distance = ( _timestamp - now ) / ( 60 * 1000 );
var days = Math.floor( distance / ( 24 * 60 ) );
var hours = Math.floor( ( distance % ( 24 * 60 ) ) / 60 );
var minutes = Math.floor( distance % ( 60 ) );
var distance2 = ( _timestamp_end - now ) / ( 60 * 1000 );
var days2 = Math.floor( distance2 / ( 24 * 60 ) );
var hours2 = Math.floor( ( distance2 % ( 24 * 60 ) ) / 60 );
var minutes2 = Math.floor( distance2 % ( 60 ) );
var d = new Date();
d.setTime( _timestamp );
d.setHours( 0 );
d.setMinutes( 0 );
d.setSeconds( 0 );
var nowd = new Date();
nowd.setHours( 0 );
nowd.setMinutes( 0 );
nowd.setSeconds( 0 );
var distance = parseInt( Math.round( ( d.getTime() - nowd.getTime() ) / ( 1000 * 60 * 60 * 24 ) ), 10 );
var span = null;
var type = null;
if( _timestamp > now )
type = 'upcoming';
else {
if( _timestamp_end ) {
span = _timestamp_end - _timestamp;
if( _timestamp_end < now ) type = 'over';
else type = 'ongoing';
} else
type = 'ongoing';
}
var timespan = '';
switch( type ) {
case 'over': {
timespan = loc_js.finished + ' ';
switch( distance ) {
case 0: timespan += loc_js.for_time + tZs( Math.abs( hours2 ) ) + ':' + tZs( Math.abs( minutes2 ) ); break;
case -1: timespan += loc_js.m_yesterday; break;
case -2: timespan += loc_js.m_day_before_yesterday; break;
default: timespan += sprintf(loc_js.m_for_n_days, Math.abs( distance )); break; }
break;
}
case 'ongoing': {
timespan = loc_js.ongoing + ' ';
switch( distance ) {
case 0: timespan += loc_js.m_since_today; break;
case -1: timespan += loc_js.m_since_yesterday; break;
case -2: timespan += loc_js.m_since_day_before_yesterday; break;
default: timespan += sprintf(loc_js.m_since_n_days, Math.abs( distance )); break;
}
break;
}
case 'upcoming': {
timespan = '';
switch( distance ) {
case 0: timespan += loc_js.m_today_in + tZs( Math.abs( hours ) ) + ':' + tZs( Math.abs( minutes ) ); break;
case 1: timespan += loc_js.m_tomorrow_in + tZs( distance * 24 + hours ) + ':' + tZs( Math.abs( minutes ) ); break;
case 2: timespan += loc_js.m_day_after_tomorrow; break;
default: timespan += sprintf(loc_js.m_in_n_days, distance); break;
break;
}
}
}
return { 'd': distance, 'h': hours, 'm': minutes, 'inTime': timespan };
}
function getAnchorPosition( _parent, _anchor ) {
if( !_anchor ) return { x: 0, y: 0 };
if( document.layers ) {
return { x: anchor.x, y: anchor.y };
} else if ( document.getElementById ) {
var coords = { x: 0, y: 0 };
while( _anchor ) {
coords.x += _anchor.offsetLeft;
coords.y += _anchor.offsetTop;
_anchor = _anchor.offsetParent;
if( _anchor == _parent ) _anchor = null;
}
return coords;
}
}
function ensureVisible( _container, _link ) {
if( !_container ) return;
var coords = getAnchorPosition( _container, _link );
_container.scrollTop = coords.y;
return true;
}
function switchTagMode() {
show( 'tag_switcher', false );
show( 'tag_switcher_progress', true );
var o = new ajaxobject2();
o.create( this, onTagModeSwitched, eAjaxModes.Get, 'wheriz.php?settagmode&action=' + nextTagMode, '' );
o.request();
}
function onTagModeSwitched( _obj ) {
document.location.reload()
}
function gjson( _string ) {
var json = '';
try{
json = eval( '(' + _string + ')' );
} catch( e ) {
}
return json;
}
function ellipse( _string, _limit ) {
if( _string.length > _limit && ( _string.length - _limit ) > 4 )
return _string.substr( 0, _limit ) + '[...]';
return _string;
}
var eExtraManagerMode = { 'Profile': 1, 'Group': 2, 'Event': 3 };
function extraManager() {
this.request = new ajaxobject2();
this.userReq = new ajaxobject2();
this.applyReq = new ajaxobject2();
this.data = [];
this.current = null;
this.items = [];
this.lastId = 0;
}
extraManager.prototype = {
create: function( _id, _mode, _reference, _offline ) {
this.id = _id;
this.mode = _mode;
this.offline = _offline;
this.reference = _reference;
re( this.id, '
'+ loc_js.processing +'