// JavaScript Document
window.addEvent('domready', function() {
	changeWorm(section);
	changeSubNav(subSection);
	
	if (section == 1) {
		var myVerticalSlide2 = new Fx.Slide('labelBG');
		myVerticalSlide2.hide();
		myVerticalSlide2.slideIn();
	}
	if (section == 2 || section == 3) {
		$('subNav'+section).style.display = "block";
		
		var myVerticalSlide = new Fx.Slide('subNav'+section);
		myVerticalSlide.hide();
		myVerticalSlide.slideIn();
	} else {
		//myVerticalSlide.hide();
	}
	
	$$('.nav').addEvent('mouseover', function(e){
		e.stop();
		var el = this.id
		changeWorm(el.substring(4,5));
	});
	
	$$('.subNav').addEvent('mouseover', function(e){
		e.stop();
		var el = this.id;
		changeSubNav(el.substring(8,9));
	});
	
	for (var i = 1; i <= 6; i++) {
		if (i != section) {
			$('nav_'+i).addEvent('mouseout', function(e){
				e.stop();
				changeWorm(section);
			});
		}
	}
	if (section == 2 || section == 3) {
		for (var i = 1; i <= 3; i++) {
			if (i != subSection) {
				$('subNav'+section+'_'+i).addEvent('mouseout', function(e){
					e.stop();
					changeSubNav(0);
				});
			}
		}
	}
});

$('btnInternational').addEvent("click", function(){
	$('boxIntBg').style.display				= 'block';
	$('boxIntContent').style.display	= 'block';
});
$$('.btnClose').addEvent("click", function(){
	$('boxIntBg').style.display				= 'none';
	$('boxIntContent').style.display	= 'none';
});
$('boxIntBg').addEvent("click", function(){
	$('boxIntBg').style.display				= 'none';
	$('boxIntContent').style.display	= 'none';
});

function changeWorm(el) {
	$('wurm').style.backgroundPosition = "-"+el*38+"px 0px";
	for (var i = 1; i <= 6; i++) {
		if (i != section) {
			$("nav_"+i).style.backgroundPosition = "top";
		}
	}
	if (el != 0) {
		if (section == 2) {
			if (el == 3) {
				$("wurm").style.backgroundPosition = "-"+5*38+"px 0px";
			} else if (el == 4) {
				$("wurm").style.backgroundPosition = "-"+6*38+"px 0px";
			} else if (el == 5) {
				$("wurm").style.backgroundPosition = "-"+7*38+"px 0px";
			} else if (el == 6) {
				$("wurm").style.backgroundPosition = "-"+8*38+"px 0px";
			}
		} else if (section == 3) {
			if (el == 4) {
				$("wurm").style.backgroundPosition = "-"+6*38+"px 0px";
			} else if (el == 5) {
				$("wurm").style.backgroundPosition = "-"+7*38+"px 0px";
			} else if (el == 6) {
				$("wurm").style.backgroundPosition = "-"+8*38+"px 0px";
			}
		}
		$("nav_"+el).style.backgroundPosition = "bottom";
	}
}
function changeSubNav(el) {
	if (section == 2 || section == 3) {
		for (var i = 1; i <= 3; i++) {
			if (i != subSection) {
				$("subNav"+section+"_"+i).style.backgroundPosition = "top";
			}
		}
		if (el != 0) {
			$("wurm").style.backgroundImage = "-"+section*38+"px 0px";
			$("subNav"+section+"_"+el).style.backgroundPosition = "bottom";
		}
	}
}