	/**
	 * JavaScript Library http://www.starcom.com.au/
	 * Initialises start up scripts
	 * @required MooTools v1.2
	 * @author Haruki Takechi
	 * @since 14/07/2008
	 */
	var Starcom = {
		Init : function() {
			Starcom.Rotator.Init();
		}
	};

	/**
	 * Menu functions for http://www.starcom.com.au/
	 * @required MooTools v1.2
	 * @author Haruki Takechi
	 * @since 14/07/2008
	 */
	Starcom.Menu = {
		Bar : null,
		Init : function() {
			$$('#menu ul li').each(function(el){
				if (Starcom.Menu.Bar.has(el.getElement('a').get('text'))) { // check for menu
					var items = Starcom.Menu.Bar.get(el.getElement('a').get('text'));
					if (items) { // check for sub-menu
						el.addEvents({
							'mouseenter': function(){
								if (!this.getElement('ul')) {
									Starcom.Menu.Generate(this,new Hash(items));
								} else if (this.getElement('ul').hasClass('sub-menu-off')) {
									var sm = this.getElement('ul');
									sm.removeClass('sub-menu-off');
									sm.set('styles',{'display':'block'});
									sm.set('tween',{duration: 500,transition: Fx.Transitions.Bounce.easeOut}).tween('line-height', [5,21]);
								}
							},
							'mouseleave': function(){
								var sm = this.getElement('ul');
								sm.addClass('sub-menu-off');
								sm.set('styles',{'display':'none','line-height':'0'});
							}
						});
					}
				}
			});
		},
		Generate : function(el,items) {
			//ul
			var ul = new Element('ul', {
				'class': 'sub-menu',
				'styles': {
					'top': el.getPosition().y + el.getSize().y,
					'left': el.getPosition().x - 1
				}
			});

			//li
			var li = new Element('li');

			//a
			var a = new Element('a', {
				'styles': {
					'opacity': '0.7'
				}
			});

			// attach anchor
			li.adopt(a);

			// sub-menu items
			var tmp;
			items.each(function(v,k){
				tmp = li.clone();
				tmp.getElement('a').set({
					'href': v,
					'html': k
				});
				ul.adopt(tmp);
			});

			// inject sub-menu into li
			el.adopt(ul);
			ul.set('tween',{duration: 500,transition: Fx.Transitions.Bounce.easeOut}).tween('line-height', [5,21]);

			a.dispose();
			li.dispose();
		}
	};

	/**
	 * Starcom Home Page Rotator functions for http://www.starcom.com.au/
	 * @required MooTools v1.2
	 * @author Haruki Takechi
	 * @since 09/08/2008
	 */
	Starcom.Rotator = {
		Index : null,
		Timer : null,
		Init : function() {
			if ($('rotator')) {
				var slideIt = null;
				var items = $$('.rotator-panel');
				this.Index = 0;
				items.each(function(el,index) {
					if (index != 0) {
						el.setStyle('opacity',0);
					}
				});

				$('rotator').addEvents({
					'mouseenter': function(){
						Starcom.Rotator.Timer = $clear(Starcom.Rotator.Timer);
					},
					'mouseleave': function(){
						if (!Starcom.Rotator.Timer) {
							Starcom.Rotator.Timer = slideIt.periodical(5000,slideIt);
						}
					}
				});

				var slideFunction = new function() {
					var items_length = items.length;
					Starcom.Rotator.Index = 0;
					slideIt = function() {
						Starcom.Rotator.Slide(items,items_length);
					};
					Starcom.Rotator.Timer = slideIt.periodical(5000,this);
				}
			}
		},
		Select : function(i) {
			var items = $$('.rotator-panel');
			var items_length = items.length;
			this.Slide(items,items_length,i);
		},
		Slide : function(items,items_length,i) {
			var curItem = items[this.Index];
			this.Index = (i !== undefined) ? i : (this.Index < (items_length - 1)) ? this.Index + 1 : 0;
			var newItem = items[this.Index];
			newItem.morph({'opacity':1});
			curItem.morph({'opacity':0});
		}
	};