window.addEvent('domready', function() {

//Tooltips		
var avsTip = new Tips($$('.avsTip'));	

Accordion
var accordion = new Accordion('h3.atStart', 'div.atStart', {
	// Options:
//	show: 'none',
	alwaysHide: true,
//	start: 'all-closed',
	duration: 500,

	onActive: function(toggler, element){
		toggler.setStyle('color', '#0086c6');
		toggler.setStyle('cursor', 'pointer');
        toggler.setStyle('cursor', 'hand');
	},
 
	onBackground: function(toggler, panels,options){
		toggler.setStyle('color', '#222');
		toggler.setStyle('cursor', 'pointer');
        toggler.setStyle('cursor', 'hand');		
	}
}, $('accordion'));

//SmoothScroll
	new SmoothScroll({ duration: 1000 });
});



/*
Class: SmoothScroll
	Auto targets all the anchors in a page and display a smooth scrolling effect upon clicking them.
	Inherits methods, properties, options and events from <Fx.Scroll>.

Note:
	SmoothScroll requires an XHTML doctype.

Arguments:
	options - the Fx.Scroll options (see: <Fx.Scroll>) plus links, a collection of elements you want your smoothscroll on. Defaults to document.links.

Example:
	>new SmoothScroll();
*/

var SmoothScroll = Fx.Scroll.extend({
	initialize: function(options){
		this.parent(window, options);
		this.links = (this.options.links) ? $$(this.options.links) : $$(document.links);
		var location = window.location.href.match(/^[^#]*/)[0] + '#';
		this.links.each(function(link){
			if (link.href.indexOf(location) != 0) return;
			var anchor = link.href.substr(location.length);
			if (anchor && $(anchor)) this.useLink(link, anchor);
		}, this);
		if (!window.webkit419) this.addEvent('onComplete', function(){
			window.location.hash = this.anchor;
		});
	},

	useLink: function(link, anchor){
		link.addEvent('click', function(event){
			this.anchor = anchor;
			this.toElement(anchor);
			event.stop();
		}.bindWithEvent(this));
	},
	
	toElement: function( el ){
		var parent = this.element.getPosition(this.options.overflown);
		var target = $(el).getPosition(this.options.overflown);
		return this.scrollTo( 0, target.y - parent.y );
	}
});




//External links
function setExternalLinks() {
if ( !document.getElementsByTagName ) {
return null;
 }
var anchors = document.getElementsByTagName( "a" );
for ( var i = 0; i < anchors.length; i++ ) {
var anchor = anchors[i];
if ( anchor.getAttribute( "href" ) &&
anchor.getAttribute( "rel" ) == "external" ) {
anchor.setAttribute( "target", "_blank" );
          }
       }
    }
	
window.onload = setExternalLinks;



/*
Class: PopWindow
	Provides additional functionaility to the standard window.open() function
*/

var PopWindow = new Class
({
	/*
	Constructor: initialize
		Instantiate a new instance of this object
		
	Arguments:
		url - The URL for the contents of the window.
		title - Title to be assigned to the window
		width - Initial width of the window
		height - Initial height of the window
		features - Custom features for the window
		
	Example:
		>var myPop = new PopWindow( 'http://www.google.com', 'MyTitle', 500, 500, 'scrollbars=1, status=1' );
		>myPop.Open();
	*/
	initialize: function( url, title, width, height, features ){
		if( width == 0 ) width = screen.width;
		if( height == 0 ) height = screen.height;
		
		this.Url = url;
		this.Title = title;
		this.Width = width;
		this.Height = height;
		
		this.Left = ( screen.width - width ) / 2;
		this.Top = ( screen.height - height ) / 2;
		
		this.Features = ( features + "" ).length > 0 ? features + ',' : '';
		this.Features += 'left=' + this.Left + ', top=' + this.Top + ', status = 1';
	},
	
	/*
	Method: Open
		Open the window
	*/
	Open: function(){
		this.Window = Window.open( 
			this.Url, 
			this.Title, 
			this.Features + ( ( this.Features != '' ) ? ',':'' ) + 'width=' + this.Width + ',height=' + this.Height 
			);
	    this.Window.focus();
	},
	
	/*
	Method: Close
		Closes the window
	*/
	Close: function(){
		this.Window.close();
	}
});
