$(window).ready(function () {
	var picNum = $("#button a").length-1;
	var picInt = 0;
	var state  = true;
	var aaa  = true;
	var time   = 5000;
	hoverTimer = setInterval(function () {
		if(state){
		if(picInt < picNum){
			picInt ++;
			serviceNote(picInt,-960);
		}else{
			picInt = 0;
			serviceNote(picInt,-960);
		}

		}
	}, time);
	function serviceNote(i,value) {
		
		aaa = false;
		$("#pic").animate({left:value},500,
		function(){
		var len = String(value/960).substring(1);
		len = (len>0)?len:0;
		var i=0
		for(i=0;i<len;i++){
		var one = $("#pic a").eq(0);
		$("#pic a").eq(0).remove();
		$("#pic").append(one);
		}
		$("#pic").css("left",0);
		aaa = true;
		});
	
		$("#button a").removeClass("active");
		$("#button a").eq(i).addClass("active");
		$("#button a").css("background-position","-580px -51px");		$("#button a").eq(i).css("background-position","-558px -51px");
		
    };
	
	$("#button a").each(function (i) {
        $(this).hover(
        function () {
            var index = $(this).attr("id").replace("b","a");
           var left = $("#pic").find("#"+index).position().left;
          //  var aaa = $("#pic").find("#"+index);
           // $("#pic").find("#"+index).remove();
           // $("#pic a").eq(0).after(aaa);
			state = false;
			picInt = i;
			if(aaa){
			serviceNote(picInt,-left);
			}
            
        }, function () {
			state = true;
			picInt = i;
        });
    });
	
	
	
	

	var boxNum   = $(".box ul li").length;
	var boxEq    = boxNum - 6;
	var boxInt   = 0;
	var boxUl    = 0;
	$(".prev").click(function(){
		if(boxInt < boxEq){
			boxInt ++;
			boxNote(true);
		};
	});
	$(".next").click(function(){
		if(boxInt > 0){
			boxInt --;
			boxNote(false);
		};
	});
	function boxNote(type) {
		if(boxNum > 6){
			if(type){
				boxUl = -(118*boxInt);
				$(".box ul").animate({left:boxUl}, 300);
			}else{
				boxUl = boxUl + 118;
				$(".box ul").animate({left:boxUl}, 300);
			};
		};
	};
	
	
	
	var picNum2 = $("#button2 a").length - 1;
	var picInt2 = 0;
	var state2  = true;
	var time2   = 3000;
	
	function serviceNote2(i) {
		$("#button2 a img").removeClass("active");
		$("#pic2").animate({left:i*-210}, 300);
		$("#button2 a img").eq(i).addClass("active");
    };
	
	$("#button2 a").each(function (i) {
        $(this).hover(
        function () {
			state2 = false;
			picInt2 = i;
            serviceNote2(picInt2);
        }, function () {
			state2 = true;
			picInt2 = i;
        });
    });
	
	
	
	var picNum3 = $("#ms ul li").length - 1;
	var picInt3 = 0;
	var state3  = true;
	var time3   = 3000;
	hoverTimer3 = setInterval(function () {
		if(state3){
		if(picInt3 < picNum3){
			picInt3 ++;
			serviceNote3(picInt3);
		}else{
			picInt3 = 0;
			serviceNote3(picInt3);
		}
		}
	}, time);
	function serviceNote3(i) {

		$("#pic3").animate({left:i*-85}, 300);

    };
	
	$("#button3 a").each(function (i) {
        $(this).hover(
        function () {
			state3 = false;
			picInt3 = i;
            serviceNote3(picInt3);
        }, function () {
			state3 = true;
			picInt3 = i;
        });
    })
	
	
	
	
	
	//alert($("#menuname").attr("value"));
	var menuvalue = $("#menuname").attr("value");
	var menuname = $("#menuname").attr("name");
	if(menuvalue >= 0){
	  $(".nav .image").eq(menuvalue).addClass(menuname+"1");
	}else{
	
	}
	
	var time;
	$(".nav li").hover(function () {
	var target = $(this).find(".subNav");
	
	time = setTimeout(function(){
	
	target.slideDown("200",function(){
	if ($.browser.msie) {
	target.css("width",target.width()+"px");
	}
	});
	if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style) {
	target.css("width",target.width()+"px");
	}

	clearTimeout(time);
	},250);
	}, function () {
	$(this).find(".subNav").slideUp("100");
	clearTimeout(time);
	});
	
	$(".value li").each(function (i) {
	if(i%2 == 0){
	$(this).removeClass("to");
	}
	});
//	$("#sidemenu ul li a").click(function () {
//        $(this).next("ul").slideToggle("200").siblings("ul").slideUp("200");
//    });
     
    
    
    
    
    if($("#abc1").height() > 100){
      $("#abb1").click(function(){
        if($("#ab1").height() != 100){
          $("#abb1").removeClass("abb2");
          $("#ab1").css("height","100");
        }else{
          $("#abb1").addClass("abb2");
          $("#ab1").css("height","auto");
        };
      });
    }else{
      $("#ab1").css("height","auto");
      $("#abb1").css("display","none");
    };
    if($("#abc2").height() > 100){
      $("#abb2").click(function(){
        if($("#ab2").height() != 100){
          $("#abb2").removeClass("abb2");
          $("#ab2").css("height","100");
        }else{
          $("#abb2").addClass("abb2");
          $("#ab2").css("height","auto");
        };
      });
    }else{
      $("#ab2").css("height","auto");
      $("#abb2").css("display","none");
    };
});
