//Javascript used for Squareleg, aided by Mootools Library

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

	if(!window.ie6){
		/* Startup Animation */

		var fx = new Fx.Styles($("benefityear_logo"), {duration:400, wait:false});
		fx.start({
			'opacity': 1
		});		
		var fx = new Fx.Styles($("tpl_topline"), {duration:400, wait:false}); 
		fx.start({
			'width': $("tpl_top").getSize().scrollSize.x,
			'opacity': 1
		}).addEvent("onComplete",function() {
			var fx = new Fx.Styles($("tpl_page_leftline"), {duration:200, wait:false});
			$("tpl_page_leftline").setStyle("background-color","#ffffff");
			fx.start({
				'height': $("tpl_page").getSize().scrollSize.y-3,
				'opacity': 1
			}).addEvent("onComplete",function() {
				var fx = new Fx.Styles($("tpl_page_bottomline"), {duration:200, wait:false});
				$("tpl_page_bottomline").setStyle("background-color","#ffffff");
				fx.start({
					'width': $("tpl_page").getSize().scrollSize.x-(window.ie6?2:1)
				}).addEvent("onComplete",function() {
					var fx = new Fx.Styles($("tpl_page_rightline"), {duration:200, wait:false});
					$("tpl_page_rightline").setStyle("display","block");
					fx.start({
					'height': $("tpl_page").getSize().scrollSize.y-134
					}).addEvent("onComplete",function() {
						var fx = new Fx.Styles($("tpl_rightbar_topline"), {duration:200, wait:false});
						$("tpl_rightbar_topline").setStyle("background-color","#ffffff");
						fx.start({
							'width': $("tpl_rightbar").getSize().scrollSize.x
						}).addEvent("onComplete",function() {
							var fx = new Fx.Styles($("benefityear_subscribe"), {duration:200, wait:false});
							fx.start({
								'opacity': 1
							}).addEvent("onComplete",moo_finishAnim);
						});
					});
				});
			});
		});

		/* Navigation Effects */
		var list = $$('#tpl_nav li a');
		list.each(function(element) {	 
			var fx = new Fx.Styles(element, {duration:200, wait:false});
			
			if(element.getParent().getParent().getProperty("id") == "tpl_nav"){
				if(!element.hasClass("selected")){
					element.addEvent('mouseenter', function(){
						fx.start({
							'padding-right': 5
						});
					});	 
					element.addEvent('mouseleave', function(){
						fx.start({
							'padding-right': 15
						});
					});
				}
			}
		});
	}
});

//Prepares for Animation by removing CSS at earliest stage possible
function moo_prepare4Anim01(){
	if(!window.ie6){
		$("tpl_topline").setStyles({
			'width' : 0,
			'opacity' : 0,
			'float' : 'right'
		});

		$("benefityear_logo").setStyles({
			'opacity' : 0,
			'background-image' : 'none'
		});
		$("benefityear_subscribe").setStyles({
			'opacity' : 0
		});
	}
}
function moo_prepare4Anim02(){

	if(!window.ie6){
		$("tpl_rightbar").setStyles({
			'top' : 0,
			'left' : -2,
			'border-top' : 'none'
		});
	}
}

function moo_prepare4Anim03(){
	if(!window.ie6){	
		$("tpl_page_rightline").setStyles({
			'background-color' : '#ffffff',
			'width' : 2
		});

		$("tpl_page").setStyles({
			'border-left' : 'none',
			'border-right' : 'none',
			'border-bottom' : '1px solid #820023'
		});

		$("tpl_pageinner").setStyle("background-image","none");

		$("tpl_page_bottomline").setStyles({
			'width' : 0,
			'position' : 'relative',
			'top' : 0
		});
	}
}

function moo_finishAnim(){

	$("tpl_footer").setStyle("margin-top",1);
	
	$("tpl_rightbar").setStyles({
		'border-top' : '2px solid #ffffff'
	});

	$("tpl_rightbar_topline").setStyle("display","none");

	$("tpl_topline").setStyles({
		'display' : 'none',
		'width': '50%'
	});

	$("tpl_top").setStyle("border-bottom","2px solid #ffffff");	

	$("tpl_page_bottomline").setStyle("visibility","hidden");
	$("tpl_page_bottomline").setStyle('width','50%');

	$("tpl_page_leftline").setStyles({
		'visibility' : 'hidden',
		'width' : 0
	});
	
	$("tpl_page").setStyles({
		"border-right" : "2px solid #ffffff",
		"border-bottom" : "2px solid #ffffff",
		"border-left" : "2px solid #ffffff",
		"padding-right" : 0,
		"padding-bottom" : 0
	});
	
	$("tpl_pageinner").setStyles({
		'height' : '1%',
		'margin-left' : 0
	});

	$("tpl_page_rightline").setStyle("display","none");
}