

/**
* Sorts the output display of a module
*
* @param Object obj
* @param String module
*/
function sort( obj, module )
{
var	url = location.href,
reg = new RegExp( module + '/.*?/|' + module + '/.*$', 'gi' );
url = url.replace( reg, '' ) + '/';
url = url.replace( /\/+$/, '/' );
if ( obj.type == 'checkbox' )
if ( obj.checked )
location.href = url + module + '/' + obj.value;
else
location.href = url;
else if ( obj.value )
location.href = url + module + '/' + obj.options[obj.selectedIndex].value;
else
location.href = url;
}

/**
*
*/
var	NOT_ANIMATED		= 0,
FADE				= 1,
SLIDE_LEFT			= 2,
SLIDE_RIGHT			= 3,
SLIDE_TOP			= 4,
SLIDE_BOTTOM		= 5,
SCROLL_LEFT			= 6,
SCROLL_RIGHT		= 7,
BLOCKS_SLIDE_TOP	= 8,
BLOCKS_SLIDE_BOTTOM	= 9,
BLOCKS_SLIDE_LEFT	= 10,
BLOCKS_SLIDE_RIGHT	= 11,
BLOCKS_SWIRL		= 12,
BLOCKS_RANDOM		= 13;
function Advert( name )
{
this.name		= name;
this.list		= new Array;
this.index		= -1;
this.currentAd	= null;
this.nextAd		= null;
this.prevAd		= null;
this.timer		= null;
this.tiles		= null;
this.zindex		= 100;
this.createTiles = function( obj )
{
var	obj		= $('#' + obj),
width	= obj.width(),
height	= obj.height(),
tilesX	= parseInt( width / 10 ),
tilesY	= parseInt( height / 7 );
this.tiles	= new Array;
this.sizeX	= tilesX;
this.sizeY	= tilesY;
for( var y = 0; y < 8; y++ )
{
this.tiles[y] = new Array;
for( var x = 0; x < 11; x++ )
{
this.tiles[y][x] = 0;
obj.parent().append( '<div id="tilein_' + this.name + '-' + x + '-' + y + '" style="margin:0;padding:0;left:' + (x*tilesX) + ';top:' + (y*tilesY) + ';width:' + tilesX + 'px;height:' + tilesY + 'px;float:left;position:absolute;z-index:' + this.zindex + '"></div>' );
obj.parent().append( '<div id="tileout_' + this.name + '-' + x + '-' + y + '" style="margin:0;padding:0;left:' + (x*tilesX) + ';top:' + (y*tilesY) + ';width:' + tilesX + 'px;height:' + tilesY + 'px;float:left;position:absolute;z-index:' + this.zindex + '"></div>' );
}
}
}
/**
*
*/
this.add = function( obj )
{
switch( obj.type )
{
case NOT_ANIMATED:
obj.transition = this.notAnimated;
obj.opposite = this.notAnimated;
break;
case FADE:
obj.transition = this.fade;
obj.opposite = this.fade;
break;
case SLIDE_LEFT:
obj.transition = this.slideLeft;
obj.opposite = this.slideRight;
break;
case SLIDE_RIGHT:
obj.transition = this.slideRight;
obj.opposite = this.slideLeft;
break;
case SLIDE_TOP:
obj.transition = this.slideTop;
obj.opposite = this.slideBottom;
break;
case SLIDE_BOTTOM:
obj.transition = this.slideBottom;
obj.opposite = this.slideTop;
break;
case SCROLL_LEFT:
obj.transition = this.scrollLeft;
obj.opposite = this.scrollRight;
break;
case SCROLL_RIGHT:
obj.transition = this.scrollRight;
obj.opposite = this.scrollLeft;
break;
case BLOCKS_SLIDE_TOP:
obj.transition = this.blocksSlideTop;
obj.opposite = this.blocksSlideBottom;
break;
case BLOCKS_SLIDE_BOTTOM:
obj.transition = this.blocksSlideBottom;
obj.opposite = this.blocksSlideTop;
break;
case BLOCKS_SLIDE_LEFT:
obj.transition = this.blocksSlideLeft;
obj.opposite = this.blocksSlideRight;
break;
case BLOCKS_SLIDE_RIGHT:
obj.transition = this.blocksSlideRight;
obj.opposite = this.blocksSlideLeft;
break;
case BLOCKS_SWIRL:
obj.transition = this.blocksSwirl;
obj.opposite = this.blocksSwirl;
break;
case BLOCKS_RANDOM:
obj.transition = this.blocksRandom;
obj.opposite = this.blocksRandom;
break;
}
obj.parent	= this;
obj.zindex	= this.zindex;
this.list.push( obj );
this.zindex++;
if ( (obj.type == BLOCKS_SLIDE_TOP || obj.type == BLOCKS_SLIDE_BOTTOM || obj.type == BLOCKS_SLIDE_LEFT || obj.type == BLOCKS_SLIDE_RIGHT || obj.type == BLOCKS_SWIRL || obj.type == BLOCKS_RANDOM) && ! this.tiles )
this.createTiles( obj.object );
}
/**
*
*/
this.exec = function()
{
clearTimeout( this.timer );
if ( ! this.currentAd && this.list[ 0 ].type != SCROLL_LEFT && this.list[ 0 ].type != SCROLL_RIGHT && this.list[ 0 ].type != NOT_ANIMATED )
{
this.index++;
this.currentAd = this.list[ this.index ];
this.currentAd.fade = this.fade;
this.currentAd.duration /= 3;
this.currentAd.fade( 1 );
this.currentAd.duration *= 3;
}
else if ( ! this.currentAd )
this.doNext();
this.timer = setTimeout( this.name + '.doNext()', (this.currentAd.type == SCROLL_LEFT || this.currentAd.type == SCROLL_RIGHT ? this.currentAd.duration : this.currentAd.delay) );
}
/**
*
*/
this.pause = function()
{
if ( this.currentAd.type != SCROLL_LEFT && this.currentAd.type != SCROLL_RIGHT )
clearTimeout( this.timer );
}
/**
*
*/
this.resume = function()
{
if ( this.currentAd.type != SCROLL_LEFT && this.currentAd.type != SCROLL_RIGHT )
this.timer = setTimeout( this.name + '.doNext()', (this.currentAd.type == SCROLL_LEFT || this.currentAd.type == SCROLL_RIGHT ? this.currentAd.duration : this.currentAd.delay) );
}
/**
*
*/
this.doNext = function()
{
if ( ! this.currentAd || this.currentAd.type == SCROLL_LEFT || this.currentAd.type == SCROLL_RIGHT || this.currentAd && $('#'+this.currentAd.object).queue().length == 0 )
{
clearTimeout( this.timer );
this.index++;
this.next();
this.exec();
}
}
/**
*
*/
this.doPrevious = function()
{
if ( ! this.currentAd || this.currentAd.type == SCROLL_LEFT || this.currentAd.type == SCROLL_RIGHT || this.currentAd && $('#'+this.currentAd.object).queue().length == 0 )
{
clearTimeout( this.timer );
this.currentAd = this.list[ this.index ];
this.index--;
this.previous();
this.exec();
}
}
/**
*
*/
this.next = function()
{
if ( this.index >= this.list.length )
this.index = 0;
this.nextAd = this.list[ this.index ];
if ( this.currentAd && this.list.length > 1 && this.currentAd.opposite )
this.nextAd.transition( null, this.currentAd );
this.currentAd = this.list[ this.index ];
this.currentAd.transition( 1 );
//	if ( this.currentAd.type != SCROLL_LEFT && this.currentAd.type != SCROLL_RIGHT )
//		$.post( '/library/ajax/advert-impression.php', 'id=' + this.currentAd.id );
}
/**
*
*/
this.previous = function()
{
if ( this.index == -1 )
this.index = this.list.length - 1;
this.nextAd = this.list[ this.index ];
if ( this.currentAd && this.list.length > 1 && this.currentAd.opposite )
this.nextAd.opposite( null, this.currentAd );
this.currentAd = this.list[ this.index ];
this.currentAd.opposite( 1 );
//	if ( this.currentAd.type != SCROLL_LEFT && this.currentAd.type != SCROLL_RIGHT )
//		$.post( '/library/ajax/advert-impression.php', 'id=' + this.currentAd.id );
}
/**
*
*/
this.notAnimated = function( start, obj )
{
var	obj = $( '#' + (obj ? obj.object : this.object) );
obj.css( 'left', 0 );
obj.css( 'top', 0 );
if ( start )
obj.show();
else
obj.hide();
}
/**
*
*/
this.fade = function( start, obj )
{
var	obj = $( '#' + (obj ? obj.object : this.object) );
obj.css( 'left', 0 );
obj.css( 'top', 0 );
if ( start )
obj.fadeIn( this.duration );
else
obj.fadeOut( this.duration );
}
/**
*
*/
this.scrollLeft = function()
{
var	obj = $('#'+this.object);
obj.stop();
obj.show();
obj.css( 'left', 0 );
obj.animate( {left:'-=' + (obj.width() / 2)}, this.duration, 'linear' );
}
/**
*
*/
this.scrollRight = function()
{
var	obj = $('#'+this.object);
obj.stop();
obj.show();
obj.css( 'left', -(obj.width() / 2) );
obj.animate( {left:'+=' + (obj.width() / 2)}, this.duration, 'linear' );
}
/**
*
*/
this.slideLeft = function( start, obj )
{
var	obj = $( '#' + (obj ? obj.object : this.object) );
obj.css( 'top', 0 );
if ( start )
{
obj.css( 'left', obj.width() );
obj.show();
obj.animate( {left:'-=' + obj.width()}, this.duration );
}
else
{
obj.css( 'left', 0);
obj.animate( {left:'-=' + obj.width()}, this.duration, function() {obj.hide()} );
}
}
/**
*
*/
this.slideRight = function( start, obj )
{
var	obj = $( '#' + (obj ? obj.object : this.object) );
obj.css( 'top', 0 );
if ( start )
{
obj.css( 'left', -obj.width() );
obj.show();
obj.animate( {left:'+=' + obj.width()}, this.duration );
}
else
{
obj.css( 'left', 0);
obj.animate( {left:'+=' + obj.width()}, this.duration, function() {obj.hide()} );
}
}
/**
*
*/
this.slideTop = function( start, obj )
{
var	obj = $( '#' + (obj ? obj.object : this.object) );
obj.css( 'left', 0 );
if ( start )
{
obj.css( 'top', obj.height() );
obj.show();
obj.animate( {top:'-=' + obj.height()}, this.duration );
}
else
{
obj.css( 'top', 0 );
obj.animate( {top:'-=' + obj.height()}, this.duration, function() {obj.hide()} );
}
}
/**
*
*/
this.slideBottom = function( start, obj )
{
var	obj = $( '#' + (obj ? obj.object : this.object) );
obj.css( 'left', 0 );
if ( start )
{
obj.css( 'top', 0 - obj.height() );
obj.show();
obj.animate( {top:'+=' + obj.height()}, this.duration );
}
else
{
obj.css( 'top', 0 );
obj.animate( {top:'+=' + obj.height()}, this.duration, function() {obj.hide()} );
}
}
/**
*
*/
this.setBlock = function( name, x, y, url )
{
$('#' + name + this.name + '-' + x + '-' + y ).css( {
'top'					: y * this.sizeY,
'left'					: x * this.sizeX,
'background-image'		: 'url(' + url + ')',
'background-position'	: -(x * this.sizeX) + 'px ' + (-(y * this.sizeY) + 'px'),
'background-repeat'		: 'no-repeat',
'z-index'				: this.zindex
} );
}
/**
*
*/
this.blocksSlideTop = function( start, obj )
{
var	name	= ( obj ? obj.object : this.object ),
obj		= $( '#' + name );
obj.css( 'left', 0 );
obj.css( 'top', 0 );
if ( start )
{
for( var y = this.parent.tiles.length - 1, n = 0; y >= 0 ; y--, n++ )
for( var x = 0; x < this.parent.tiles[y].length; x++ )
{
this.parent.setBlock( 'tilein_', x, y, obj.find('img').attr('src') );
$('#tilein_' + this.parent.name + '-' + x + '-' + y ).hide();
$('#tilein_' + this.parent.name + '-' + x + '-' + y ).fadeIn( n * (this.duration / 10) );
}
setTimeout( "$('#" + name + "').show();$(\"div[id*='tilein']\").hide();", this.duration );
}
else
{
for( var y = this.parent.tiles.length - 1, n = 0; y >= 0 ; y--, n++ )
for( var x = 0; x < this.parent.tiles[y].length; x++ )
{
this.parent.setBlock( 'tileout_', x, y, obj.find('img').attr('src') );
$('#tileout_' + this.parent.name + '-' + x + '-' + y ).show();
$('#tileout_' + this.parent.name + '-' + x + '-' + y ).fadeOut( n * (this.duration / 10) );
}
setTimeout( "$('#" + name + "').hide();", this.duration );
}
}
/**
*
*/
this.blocksSlideBottom = function( start, obj )
{
var	name	= ( obj ? obj.object : this.object ),
obj		= $( '#' + name );
obj.css( 'left', 0 );
obj.css( 'top', 0 );
if ( start )
{
for( var y = 0; y < this.parent.tiles.length; y++ )
for( var x = 0; x < this.parent.tiles[y].length; x++ )
{
this.parent.setBlock( 'tilein_', x, y, obj.find('img').attr('src') );
$('#tilein_' + this.parent.name + '-' + x + '-' + y ).hide();
$('#tilein_' + this.parent.name + '-' + x + '-' + y ).fadeIn( y * (this.duration / 10) );
}
setTimeout( "$('#" + name + "').show();$(\"div[id*='tilein']\").hide();", this.duration );
}
else
{
for( var y = 0; y < this.parent.tiles.length; y++ )
for( var x = 0; x < this.parent.tiles[y].length; x++ )
{
this.parent.setBlock( 'tileout_', x, y, obj.find('img').attr('src') );
$('#tileout_' + this.parent.name + '-' + x + '-' + y ).show();
$('#tileout_' + this.parent.name + '-' + x + '-' + y ).fadeOut( y * (this.duration / 10) );
}
setTimeout( "$('#" + name + "').hide();", this.duration );
}
}
/**
*
*/
this.blocksSlideLeft = function( start, obj )
{
var	name	= ( obj ? obj.object : this.object ),
obj		= $( '#' + name );
obj.css( 'left', 0 );
obj.css( 'top', 0 );
if ( start )
{
for( var y = 0; y < this.parent.tiles.length; y++ )
for( var x = this.parent.tiles[y].length - 1, n = 0; x >= 0 ; x--, n++ )
{
this.parent.setBlock( 'tilein_', x, y, obj.find('img').attr('src') );
$('#tilein_' + this.parent.name + '-' + x + '-' + y ).hide();
$('#tilein_' + this.parent.name + '-' + x + '-' + y ).fadeIn( n * (this.duration / 10) );
}
setTimeout( "$('#" + name + "').show();$(\"div[id*='tilein']\").hide();", this.duration );
}
else
{
for( var y = 0; y < this.parent.tiles.length; y++ )
for( var x = this.parent.tiles[y].length - 1, n = 0; x >= 0 ; x--, n++ )
{
this.parent.setBlock( 'tileout_', x, y, obj.find('img').attr('src') );
$('#tileout_' + this.parent.name + '-' + x + '-' + y ).show();
$('#tileout_' + this.parent.name + '-' + x + '-' + y ).fadeOut( n * (this.duration / 10) );
}
setTimeout( "$('#" + name + "').hide();", this.duration );
}
}
/**
*
*/
this.blocksSlideRight = function( start, obj )
{
var	name	= ( obj ? obj.object : this.object ),
obj		= $( '#' + name );
obj.css( 'left', 0 );
obj.css( 'top', 0 );
if ( start )
{
for( var y = 0; y < this.parent.tiles.length; y++ )
for( var x = 0; x < this.parent.tiles[y].length; x++ )
{
this.parent.setBlock( 'tilein_', x, y, obj.find('img').attr('src') );
$('#tilein_' + this.parent.name + '-' + x + '-' + y ).hide();
$('#tilein_' + this.parent.name + '-' + x + '-' + y ).fadeIn( x * (this.duration / 10) );
}
setTimeout( "$('#" + name + "').show();$(\"div[id*='tilein']\").hide();", this.duration );
}
else
{
for( var y = 0; y < this.parent.tiles.length; y++ )
for( var x = 0; x < this.parent.tiles[y].length; x++ )
{
this.parent.setBlock( 'tileout_', x, y, obj.find('img').attr('src') );
$('#tileout_' + this.parent.name + '-' + x + '-' + y ).show();
$('#tileout_' + this.parent.name + '-' + x + '-' + y ).fadeOut( x * (this.duration / 10) );
}
setTimeout( "$('#" + name + "').hide();", this.duration );
}
}
/**
*
*/
this.blocksSwirl = function( start, obj )
{
var	name	= ( obj ? obj.object : this.object ),
obj		= $( '#' + name );
obj.css( 'left', 0 );
obj.css( 'top', 0 );
if ( start )
{
xstart	= 0;
xfinish	= this.parent.tiles[0].length - 1;
ystart	= 0;
yfinish	= this.parent.tiles.length - 1;
nn		= 1;
for( var n = 0; n < 4; n++ )
{
for( var x = xstart; x <= xfinish; x++ )
{
this.parent.setBlock( 'tilein_', x, ystart, obj.find('img').attr('src') );
$('#tilein_' + this.parent.name + '-' + x + '-' + ystart ).hide();
$('#tilein_' + this.parent.name + '-' + x + '-' + ystart ).fadeIn( ++nn * (this.duration / 100) );
}
ystart++;
for( var y = ystart; y <= yfinish; y++ )
{
this.parent.setBlock( 'tilein_', xfinish, y, obj.find('img').attr('src') );
$('#tilein_' + this.parent.name + '-' + xfinish + '-' + y ).hide();
$('#tilein_' + this.parent.name + '-' + xfinish + '-' + y ).fadeIn( ++nn * (this.duration / 100) );
}
xfinish--;
for( var x = xfinish; x >= xstart; x-- )
{
this.parent.setBlock( 'tilein_', x, yfinish, obj.find('img').attr('src') );
$('#tilein_' + this.parent.name + '-' + x + '-' + yfinish ).hide();
$('#tilein_' + this.parent.name + '-' + x + '-' + yfinish ).fadeIn( ++nn * (this.duration / 100) );
}
yfinish--;
for( var y = yfinish; y >= ystart; y-- )
{
this.parent.setBlock( 'tilein_', xstart, y, obj.find('img').attr('src') );
$('#tilein_' + this.parent.name + '-' + xstart + '-' + y ).hide();
$('#tilein_' + this.parent.name + '-' + xstart + '-' + y ).fadeIn( ++nn * (this.duration / 100) );
}
xstart++;
}
setTimeout( "$('#" + name + "').show();$(\"div[id*='tilein']\").hide();", this.duration );
}
else
{
xstart	= 0;
xfinish	= this.parent.tiles[0].length - 1;
ystart	= 0;
yfinish	= this.parent.tiles.length - 1;
nn		= 1;
for( var n = 0; n < 4; n++ )
{
for( var x = xstart; x <= xfinish; x++ )
{
this.parent.setBlock( 'tileout_', x, ystart, obj.find('img').attr('src') );
$('#tileout_' + this.parent.name + '-' + x + '-' + ystart ).show();
$('#tileout_' + this.parent.name + '-' + x + '-' + ystart ).fadeOut( ++nn * (this.duration / 100) );
}
ystart++;
for( var y = ystart; y <= yfinish; y++ )
{
this.parent.setBlock( 'tileout_', xfinish, y, obj.find('img').attr('src') );
$('#tileout_' + this.parent.name + '-' + xfinish + '-' + y ).show();
$('#tileout_' + this.parent.name + '-' + xfinish + '-' + y ).fadeOut( ++nn * (this.duration / 100) );
}
xfinish--;
for( var x = xfinish; x >= xstart; x-- )
{
this.parent.setBlock( 'tileout_', x, yfinish, obj.find('img').attr('src') );
$('#tileout_' + this.parent.name + '-' + x + '-' + yfinish ).show();
$('#tileout_' + this.parent.name + '-' + x + '-' + yfinish ).fadeOut( ++nn * (this.duration / 100) );
}
yfinish--;
for( var y = yfinish; y >= ystart; y-- )
{
this.parent.setBlock( 'tileout_', xstart, y, obj.find('img').attr('src') );
$('#tileout_' + this.parent.name + '-' + xstart + '-' + y ).show();
$('#tileout_' + this.parent.name + '-' + xstart + '-' + y ).fadeOut( ++nn * (this.duration / 100) );
}
xstart++;
}
setTimeout( "$('#" + name + "').hide();", this.duration );
}
}
/**
*
*/
this.blocksRandom = function( start, obj )
{
var	name	= ( obj ? obj.object : this.object ),
obj		= $( '#' + name );
obj.css( 'left', 0 );
obj.css( 'top', 0 );
if ( start )
{
for( var y = 0; y < this.parent.tiles.length; y++ )
for( var x = 0; x < this.parent.tiles[y].length; x++ )
{
this.parent.setBlock( 'tilein_', x, y, obj.find('img').attr('src') );
$('#tilein_' + this.parent.name + '-' + x + '-' + y ).hide();
$('#tilein_' + this.parent.name + '-' + x + '-' + y ).fadeIn( Math.floor( Math.random() * (this.duration / 2) ) );
}
setTimeout( "$('#" + name + "').show();$(\"div[id*='tilein']\").hide();", this.duration );
}
else
{
for( var y = 0; y < this.parent.tiles.length; y++ )
for( var x = 0; x < this.parent.tiles[y].length; x++ )
{
this.parent.setBlock( 'tileout_', x, y, obj.find('img').attr('src') );
$('#tileout_' + this.parent.name + '-' + x + '-' + y ).show();
$('#tileout_' + this.parent.name + '-' + x + '-' + y ).fadeOut( Math.floor( Math.random() * (this.duration / 2) ) );
}
setTimeout( "$('#" + name + "').hide();", this.duration );
}
}
}

/*---------------------------------------------------------------------------------------------------
* File:		animation.js
* Author:		Peter Quinn
* Copyright:	(C)Copyright 2007.  All rights reserved.
* Version:		1.00
* Date:
*
* Description:
*
* Methods:
*
*-------------------------------------------------------------------------------------------------*/
var	LEFT				= 0,
RIGHT				= 1,
UP					= 2,
DOWN				= 3,
ALPHA				= 4,
WIDTH				= 5,
HEIGHT				= 6,
WIDTH_LEFT			= 7,
HEIGHT_UP			= 8,
SCROLL_LEFT			= 9,
SCROLL_RIGHT		= 10,
SCROLL_UP			= 11,
SCROLL_DOWN			= 12,
WIDTH_CENTER		= 13,
HEIGHT_CENTER		= 14,
HEIGHT_CENTER_CLOSE	= 15,
SLIDE_LEFT			= 16,
SLIDE_RIGHT			= 17;
/*---------------------------------------------------------------------------------------------------
*
* Animation Class
*
*/
function Animation( name, object )
{
this.name			= name || "unnamed";
this.parent			= parent || null;
this.object			= object || null;
this.timer			= null;
this.waitingTimer	= null;
this.delay			= 6;
this.duration		= null;
this.destination	= 0;
this.init			= 0;
this.distance		= 0;
this.time			= 0;
this.formula		= null;
this.action			= null;
this.step			= 0;
this.startTime		= 0;
this.startPos		= 0;
this.onstart		= null;
this.onfinish		= null;
this.onexecute		= null;
this.active			= false;
this.paused			= false;
this.pos			= 0;
/**
* starts the animation
*/
this.start = function()
{
clearTimeout( this.timer );
if ( this.onstart )
this.onstart( this );
this.time		= 0;
this.init		= this.getStart();
this.distance	= this.destination - this.init;
this.step		= this.distance / this.duration / this.duration;
this.startTime	= new Date().getTime();
this.active		= true;
this.exec();
}
/**
* Calculates the initial parameters
*
* @return int
*/
this.getStart = function()
{
if ( this.action == HEIGHT_UP || this.action == HEIGHT_CENTER || this.action == HEIGHT_CENTER_CLOSE )
this.startPos = this.object.getY();
else if ( this.action == WIDTH_LEFT || this.action == WIDTH_CENTER || this.action == HEIGHT_CENTER_CLOSE )
this.startPos = this.object.getX();
switch( this.action )
{
case SCROLL_UP:
case SCROLL_DOWN:
return this.object.getScrollY();
case SCROLL_LEFT:
case SCROLL_RIGHT:
return this.object.getScrollX();
case UP:
case DOWN:
return this.object.getY();
case LEFT:
case RIGHT:
return this.object.getX();
case SLIDE_LEFT:
case SLIDE_RIGHT:
return this.pos;
case WIDTH:
case WIDTH_LEFT:
return this.object.getWidth();
case HEIGHT:
case HEIGHT_UP:
return ie ? this.object.getHeight() : this.object.getHeight() - 2;
case WIDTH_CENTER:
return this.object.getWidth();
case HEIGHT_CENTER:
return this.object.getHeight();
case HEIGHT_CENTER_CLOSE:
return ie ? this.object.getHeight() : this.object.getHeight() - 2;
case ALPHA:
return this.object.getAlpha();
}
}
/**
* Main animation execution
*/
this.exec = function()
{
clearTimeout( this.timer );
this.time = new Date().getTime() - this.startTime;
if ( ! this.duration || this.time < this.duration )
{
if ( ! this.paused )
{
switch( this.action )
{
case UP:
this.object.moveY( this.formula() );
break;
case DOWN:
this.object.moveY( this.formula() );
break;
case SLIDE_LEFT:
this.object.moveX( this.pos-- );
break;
case SLIDE_RIGHT:
this.object.moveX( this.pos++ );
break;
case LEFT:
this.object.moveX( this.formula( this.object.getX() ) );
break;
case RIGHT:
this.object.moveX( this.formula( this.object.getX() ) );
break;
case WIDTH:
this.object.resizeX( this.formula() );
break;
case SCROLL_LEFT:
case SCROLL_RIGHT:
this.object.scrollX( this.formula( this.object.getScrollX() ) );
break;
case SCROLL_UP:
case SCROLL_DOWN:
this.object.scrollY( this.formula( this.object.getScrollY() ) );
break;
case WIDTH_LEFT:
n = this.formula();
this.object.resizeX( n );
this.object.moveX( this.init + this.startPos - n );
break;
case HEIGHT:
this.object.resizeY( this.formula() );
break;
case HEIGHT_UP:
n = this.formula();
this.object.resizeY( n );
this.object.moveY( this.init + this.startPos - n );
break;
case WIDTH_CENTER:
n = this.formula();
this.object.resizeX( n );
this.object.moveX( this.init + this.startPos - (n / 2) );
break;
case HEIGHT_CENTER:
n = this.formula();
this.object.resizeY( n );
this.object.moveY( this.init + this.startPos - (n / 2) );
break;
case HEIGHT_CENTER_CLOSE:
n = this.formula();
this.object.resizeY( n );
this.object.moveY( this.init - this.startPos - (n / 2) );
break;
case ALPHA:
this.object.alpha( this.formula() );
break;
}
if ( this.onexecute )
this.onexecute( this );
}
this.timer = setTimeout( this.name + ".exec()", this.delay );
}
else
{
this.active = false;
switch( this.action )
{
case UP:
this.object.moveY( this.destination );
break;
case DOWN:
this.object.moveY( this.destination );
break;
case LEFT:
this.object.moveX( this.destination );
break;
case RIGHT:
this.object.moveX( this.destination );
break;
case WIDTH:
this.object.resizeX( this.destination );
break;
case WIDTH_LEFT:
this.object.resizeX( this.destination );
this.object.moveX( this.init + this.startPos - this.destination );
break;
case HEIGHT:
this.object.resizeY( this.destination );
break;
case HEIGHT_UP:
this.object.resizeY( this.destination );
this.object.moveY( this.init + this.startPos - this.destination );
break;
case WIDTH_CENTER:
this.object.resizeX( this.destination );
this.object.moveX( this.init + this.startPos - (this.destination / 2) );
break;
case HEIGHT_CENTER:
this.object.resizeY( this.destination );
this.object.moveY( this.init + this.startPos - (this.destination / 2) );
break;
/*
case HEIGHT_CENTER_CLOSE:
this.object.resizeY( this.destination );
this.object.moveY( this.init + this.startPos - (this.destination / 2) );
break;
*/
case ALPHA:
this.object.alpha( this.destination );
break;
}
if ( this.onfinish )
this.onfinish( this );
if ( this.onfinal )
this.onfinal( this );
}
}
this.stop = function()
{
clearTimeout( this.timer );
}
this.pause = function( flag )
{
this.paused = flag;
}
this.incremental = function( n )
{
switch( this.action )
{
case UP:
case LEFT:
case SCROLL_LEFT:
case SLIDE_LEFT:
return n;
case DOWN:
case RIGHT:
case SCROLL_RIGHT:
case SLIDE_RIGHT:
return ++n;
}
}
/**
* Power function
*/
this.pow = function()
{
return this.distance - Math.round( Math.pow( this.duration - this.time, 2 ) * this.step ) + this.init;
}
/**
* Power function
*/
this.pow2 = function( p, x )
{
this.object.layer.innerHTML += "a ";
return Math.pow( p, x || 6 );
}
/**
* EXPO function
*/
this.expo = function( p )
{
this.object.layer.innerHTML += " e";
return Math.pow( 2, 8 * (p - 1) );
}
/**
* Circular function
*/
this.circ = function( p )
{
return 1 - Math.sin( Math.acos( p ) );
}
/**
* Sine function
*/
this.sine = function( p )
{
return 1 - Math.sin( (1 - p) * Math.PI / 2 );
}
/**
* Back function
*/
this.back = function( p, x )
{
x = x[0] || 1.618;
return Math.pow( p, 2 ) * ( (x + 1) * p - x );
}
/**
* Bounce function
*/
this.bounce = function( p )
{
var	value;
for( var a = 0, b = 1; 1; a += b, b /= 2 )
if ( p >= (7 - 4 * a) / 11 )
{
value = -Math.pow( (11 - 6 * a - 11 * p) / 4, 2 ) + b * b;
break;
}
return value;
}
/**
* Elastic function
*/
this.elastic = function( p, x )
{
return Math.pow( 2, 10 * --p ) * Math.cos( 20 * p * Math.PI * (x[0] || 1) / 3 );
}
// sets the default animation function
this.formula = this.pow;
}
/*-------------------------------------------------------------------------------------------------*/

/**---------------------------------------------------------------------------------------------------
*
* File:		layer.js
* Date:		25.07.2007
* Description:	Dynamic Adverts
*
* Usage:
*
*--------------------------------------------------------------------------------------------------*/
var	ie		= document.all,
dragObj	= null;
/**---------------------------------------------------------------------------------------------------
*
* Layer Object
*
*/
function Layer( name, layerName, parent )
{
this.obj			= name;
this.name			= layerName		|| null;
this.parent			= parent		|| null;
this.dragStatus		= false;
this.dragStarted	= false;
this.constrainX		= false;
this.constrainY		= false;
this.layer			= null;
this.alphaValue		= 100;
this.visible		= false;
this.type			= 'layer';
this.document		= document;
this.window			= window;
/**
* Only works in FireFox
*
*/
this.drag = function()
{
if ( this.layer )
this.layer.setAttribute( "onmousedown", this.obj + ".startDrag()" );
}
/**
* Layer constructor
*
*/
this.construct = function( id )
{
if ( id )
{
this.name					= id;
this.layer					= this.document.getElementById( id );
//	this.layer.style.position	= this.parent ? "relative" : "absolute";
this.parent					= this.parent ? this.parent : this.document.body;
}
else if ( this.name && this.document.getElementById( this.name ) )
{
this.layer					= this.document.getElementById( this.name );
this.parent					= this.parent ? this.parent : this.document.body;
}
else
{
this.name					= this.obj;
this.layer					= this.document.createElement( "DIV" );
this.layer.style.position	= this.parent ? "relative" : "absolute";
if ( this.parent )
this.parent.appendChild( this.layer );
else
{
this.parent				= this.document.body;
this.document.body.appendChild( this.layer );
}
this.layer.setAttribute( "id", this.name );
}
if ( this.layer )
this.layer.style.display = "none";
}
/**
* Removes the layer from the DOM
*
*/
this.close = function()
{
if ( this.layer )
{
this.document.body.removeChild( this.layer );
this.layer = null;
}
}
/**
* Moves the layer to position X
*
* @param int x
*/
this.moveX = function( x )
{
var	left = this.getBrowserLeft();
if ( ie )
{
if ( this.constrainX )
{
if ( x > this.parent.clientWidth - this.layer.clientWidth + left )
x = this.parent.clientWidth - this.layer.clientWidth + left;
if ( x < left )
x = left;
}
}
else
{
if ( this.constrainX )
{
if ( x > window.innerWidth - this.layer.offsetWidth + left )
x = window.innerWidth - this.layer.offsetWidth + left;
if ( x < left )
x = left;
}
}
if ( this.layer )
this.layer.style.left = x + 'px';
}
/**
* Moves the layer to position Y
*
* @param int y
*/
this.moveY = function( y )
{
var	top = this.getBrowserTop();
if ( ie )
{
if ( this.constrainY )
{
if ( y > this.parent.clientHeight - this.layer.clientHeight + top )
y = this.parent.clientHeight - this.layer.clientHeight + top;
if ( y < top )
y = top;
}
}
else
{
if ( this.constrainY )
{
if ( y > window.innerHeight - this.layer.offsetHeight + top )
y = window.innerHeight - this.layer.offsetHeight + top;
if ( y < top )
y = top;
}
}
if ( this.layer )
this.layer.style.top = y + 'px';
}
/**
* Moves the layer to position X, Y
*
* @param int x
* @param int y
*/
this.move = function( x, y )
{
this.moveX( x );
this.moveY( y );
}
/**
* Moves the layer at a given degree to a certain distance
*
* @param int x
* @param in ty
*/
this.moveTo = function( degree, distance )
{
var	x = distance * Math.cos( (degree - 90) * Math.PI / 180 ),
y = distance * Math.sin( (degree - 90) * Math.PI / 180 );
this.moveX( this.getX() + x );
this.moveY( this.getY() + y );
}
/**
* Sets the alpha blending of the layer
*
* @param int alpha
*/
this.alpha = function( alpha )
{
this.alphaValue = alpha;
if ( this.layer )
{
this.layer.style.opacity	= parseInt( alpha ) / 100;
this.layer.style.MozOpacity	= parseInt( alpha ) / 100;
if ( ie )
this.layer.style.filter	= "alpha(opacity=" + alpha + ")";
}
}
/**
* Writes content to the layer
*
* @param string str
*/
this.write = function( str )
{
if ( this.layer )
this.layer.innerHTML = str;
}
/**
* Outputs content to the layer
*
* @param string str
*/
this.output = function( str )
{
if ( this.layer )
this.layer.innerHTML += str;
}
/**
* Resizes the layer
*
* @param int xsize
* @param int ysize
*/
this.resize = function( xsize, ysize )
{
if ( this.layer )
{
this.layer.style.width	= xsize + 'px';
this.layer.style.height	= ysize + 'px';
}
}
/**
* Resizes the layer
*
* @param int xsize
*/
this.resizeX = function( xsize )
{
if ( this.layer )
this.layer.style.width	= xsize + 'px';
}
/**
* Resizes the layer
*
* @param int ysize
*/
this.resizeY = function( ysize )
{
if ( this.layer )
this.layer.style.height	= ysize + 'px';
}
/**
* Displays / Hides the layer
*
* @param bool flag
*/
this.show = function( flag )
{
this.visible = flag;
if ( this.layer )
this.layer.style.display = flag ? "block" : "none";
}
/**
* Gets the absolute position of the layer
*
* @param object obj
*/
this.getPos = function( object )
{
var	left	= 0,
top		= 0;
if ( object )
obj = object;
else
obj = this.layer;
if ( obj && obj.offsetParent )
{
left = obj ? obj.offsetLeft : 0;
top  = obj ? obj.offsetTop : 0;
if ( obj )
while( obj = obj.offsetParent )
{
left += obj.offsetLeft;
top  += obj.offsetTop;
}
}
return [ left, top, this.getWidth( object ), this.getHeight( object ) ];
}
/**
* Returns the alpha value of the layer
*
* @return int
*/
this.getAlpha = function()
{
return parseInt( this.alphaValue );
}
/**
* Returns the X position of the layer
*
* @return int
*/
this.getX = function()
{
if ( this.layer.position == undefined || this.layer.position == "relative" )
{
pos = this.getPos( this.layer );
return pos[0];
}
return parseInt( this.layer.style.left == "" ? 0 : this.layer.style.left );
}
/**
* Returns the Y position of the layer
*
* @return int
*/
this.getY = function()
{
if ( this.layer.position == undefined || this.layer.position == "relative" )
{
pos = this.getPos( this.layer );
return pos[1];
}
return parseInt( this.layer.style.top );
}
/**
* Returns the width of the layer
*
* @return int
*/
this.getWidth = function( obj )
{
if ( obj )
return parseInt( ie ? obj.offsetWidth + 2 : obj.offsetWidth );
else if ( this.layer )
return parseInt( ie ? this.layer.clientWidth + 2 : this.layer.offsetWidth );
}
/**
* Returns the height of the layer
*
* @return int
*/
this.getHeight = function( obj )
{
if ( obj )
return parseInt( ie ? obj.offsetHeight + 2 : obj.offsetHeight );
else if ( this.layer )
return parseInt( ie ? this.layer.clientHeight + 2 : this.layer.offsetHeight );
}
this.getBrowserLeft = function()
{
return ie ? (this.document.documentElement ? this.document.documentElement.scrollLeft : this.document.body.scrollLeft) : this.window.pageXOffset ;
}
this.getBrowserTop = function()
{
return ie ? (this.document.documentElement ? this.document.documentElement.scrollTop : this.document.body.scrolltop) : this.window.pageYOffset ;
}
this.getBrowserWidth = function()
{
//	return ie ? (this.document.documentElement ? this.document.documentElement.clientWidth : this.document.body.clientWidth) : this.window.innerWidth;
return ie ? this.document.body.clientWidth : this.window.innerWidth;
}
this.getBrowserHeight = function()
{
return ie ? this.document.body.clientHeight : this.window.innerHeight;
}
this.getWindowHeight = function()
{
return ie ? document.documentElement.clientHeight : this.window.innerHeight;
}
this.setWidth = function( width )
{
if ( this.layer )
this.layer.style.width = width + 'px';
}
this.setHeight = function( height )
{
if ( this.layer )
this.layer.style.height = height + 'px';
}
this.resize = function( width, height )
{
this.setWidth( width );
this.setHeight( height );
}
/**
* Sets the scroll of the layer
*
* @param int n
*/
this.scrollX = function( n )
{
if ( this.layer )
this.layer.scrollLeft = n;
}
/**
* Sets the scroll of the layer
*
* @param int n
*/
this.scrollY = function( n )
{
if ( this.layer )
this.layer.scrollTop = n;
}
this.getScrollX = function()
{
if ( this.layer )
return this.layer.scrollLeft;
}
this.getScrollY = function()
{
if ( this.layer )
return this.layer.scrollTop;
}
this.getScrollWidth = function()
{
if ( this.layer )
return this.layer.scrollWidth;
}
this.getScrollHeight = function()
{
if ( this.layer )
return this.layer.scrollHeight;
}
/**
* Starts the layer dragging process
*
* @param object e Event object
*/
this.startDrag = function( e )
{
dragObj					= this;
this.dragStatus			= true;
this.dragStarted		= true;
document.onmouseup		= this.endDrag;
document.onmousemove	= this.doDrag;
document.onselectstart	= function() { return false; };
document.onmousedown	= function() { return false; };
}
/**
* Starts the layer resizing process
*
* @param object a Event object
*/
this.startResize = function( e )
{
dragObj					= this;
this.dragStatus			= true;
this.dragStarted		= true;
document.onmouseup		= this.endDrag;
document.onmousemove	= this.doResize;
document.onselectstart	= function() { return false; };
document.onmousedown	= function() { return false; };
}
/**
* Ends the layer dragging process
*
*/
this.endDrag = function()
{
this.dragStatus			= false;
document.onmousemove	= null;
document.onselectstart	= null;
document.onmousedown	= null;
}
/**
* Performs the layer dragging
*
* @param object e Event object
*/
this.doDrag = function( e )
{
var	top		= document.body.scrollTop,
left	= document.body.scrollLeft;
if ( dragObj.dragStarted )
{
dragObj.dragStartX	= left + parseInt(ie ? window.event.clientX : e.pageX) - parseInt( dragObj.layer.style.left );
dragObj.dragStartY	= top + parseInt(ie ? window.event.clientY : e.pageY) - parseInt( dragObj.layer.style.top );
dragObj.dragStarted = false;
}
var	mouseX	= left + parseInt( ie ? window.event.clientX : e.pageX ) - parseInt( dragObj.dragStartX ),
mouseY	= top + parseInt( ie ? window.event.clientY : e.pageY ) - parseInt( dragObj.dragStartY );
dragObj.move( mouseX, mouseY );
}
/**
* Performs the layer resizing
*
* @param object a Event object
*/
this.doResize = function( e )
{
var	top		= document.body.scrollTop,
left	= document.body.scrollLeft;
if ( dragObj.dragStarted )
{
dragObj.dragStartX	= left + parseInt(ie ? window.event.clientX : e.pageX) - parseInt( dragObj.layer.style.left );
dragObj.dragStartY	= top + parseInt(ie ? window.event.clientY : e.pageY) - parseInt( dragObj.layer.style.top );
dragObj.dragStarted = false;
}
var	mouseX	= left + parseInt( ie ? window.event.clientX : e.pageX ) - parseInt( dragObj.dragStartX ),
mouseY	= top + parseInt( ie ? window.event.clientY : e.pageY ) - parseInt( dragObj.dragStartY );
dragObj.resize( mouseX, mouseY );
}
/**
* Changes the z-index of a layer
*
* @param integer n
*/
this.index = function( n )
{
if ( this.layer )
this.layer.style.zIndex = n;
}
/**
* Returns the visibility status of the layer
*
* @return Bool
*/
this.isVisible = function()
{
return this.visible;
}
}
/*--------------------------------------------------------------------------------------------------*/

