var navivals=new Array("75px","153px","240px","342px","437px");
//var selindex=0;
var rolledover=selindex;

$(document).ready(function(){
						   
	$(window).bind("load",function(){
		
		$('#hw_images img').css("display","block");
		
		$('#hw_images').cycle({
			speed:800,
			timeout:6000
		});
		
		$('#hw_txt').cycle({
			speed:800,
			timeout:6000
		});
		
		$('#headnacv1 li a').mouseover(function(){
			if($('#headnacv1 li a').index(this)!=rolledover)
			{
				rolledover=$('#headnacv1 li a').index(this);
				NaviGateTo($('#headnacv1 li a').index(this));
			}
		});
		
		$('.headsubnavi').eq(0).customFadeIn(400);
		
		$('.specialoffer_con').fadeTo(100, 0.7,function(){
			ClearTypeFix(this);											
		});	
	});
	
	$('.classinfo').css("left","-700px").eq(0).css("left","0px");
	
	
	$('.class_button li').click(function(){
		thisindex=$('.class_button li').index(this)+1;

		if($('.classinfo').eq(thisindex).css("left")=="0px")
		{
			$('.classinfo').eq(thisindex).MyAnimate("-700px");
		}
		else
		{
			$('.classinfo').MyAnimate("-700px");
			$('.classinfo').eq(0).MyAnimate("0px");
			$('.classinfo').eq(thisindex).MyAnimate("0px");
		}	
	});
	
	
	
	$('.class_button li').mouseover(function(){
		$(this).css("backgroundPosition","left bottom");										 
	});
	
	$('.class_button li').mouseout(function(){
		$(this).css("backgroundPosition","left top");										 
	});
	
	$('#nav_arrow').css("left",navivals[0]);	
	
	$('#headnacv1 li a').eq(selindex).css({
		color: "#5EA6D0",
		"font-size": "1.0em"
	});

	$('#hw_images img').each(function(i){
		if(i>0)
		{
			$(this).css("display","none");	
		}
	});
	
});

function ClearTypeFix(selelement)
{
	if(jQuery.browser.msie)
	{
		$(selelement).get(0).style.removeAttribute('filter');
	}
}

(function($) {	
	$.fn.MyAnimate = function(moveleft, callback){
		$(this).animate({
			"left":	moveleft	
		},{ duration: 600, queue: false, "easing":"easeInOutExpo"});
	};
	  
	$.fn.customFadeIn = function(speed, callback) {
		$(this).fadeIn(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	
	$.fn.customFadeOut = function(speed, callback) {
		$(this).fadeOut(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
})(jQuery);

function NaviGateTo(aniindex)
{
	$('.headsubnavi').customFadeOut(400);
	
	$('#nav_arrow').stop().animate({
	left: navivals[aniindex]					
	},1000, "easeInOutExpo",function(){
			$('.headsubnavi').eq(rolledover).customFadeIn(400);
		});		
}