// JavaScript Document
$(function(){

$(".scrb1").scrollable({size:1,items:".scrb1 ul",loop:true,prev:".arrw_l",next:".arrw_r"}).autoscroll({ autoplay: true,interval:4000 }).navigator({navi:".tab01",naviItem:'dd',activeClass:"active"});
$(".scrb2").scrollable({size:4,items:".scrb2 ul",loop:true,prev:".arr_l",next:".arr_r"});
$(".scrb3").scrollable({size:1,items:".scrb3 ul",loop:true,prev:".arr_l",next:".arr_r"}).autoscroll({ autoplay: true,interval:4000 }).navigator({navi:".tab02",naviItem:'dd',activeClass:"active"});
$(".scrb4").scrollable({size:1,items:".scrb4 ul",loop:true,prev:".arrll",next:".arrlr"});
$(".scrb5").scrollable({size:3,items:".scrb5 ul",loop:true}).autoscroll({ autoplay: true,interval:4000 }).navigator({navi:".tab03",naviItem:'dd',activeClass:"active"});
$(".scrb6").scrollable({size:3,items:".scrb6 ul",loop:true});
$(".scrb7").scrollable({size:8,items:".scrb7 ul",loop:true,prev:".arr_l",next:".arr_r"});
$(".scrb8").scrollable({size:5,items:".scrb8 ul",loop:true,prev:".arr_l",next:".arr_r"}).autoscroll({ autoplay: true,interval:4000 });

var io=0;
$(function(){
$(".scrb2 li").click(function(){
$(".bigimg").empty();
$(".txtb").empty();
//$(".bigimg").fadeTo("medium", 0.5);
$(".big .pic",this).clone().appendTo($(".bigimg"));
$(".big .txt",this).clone().appendTo($(".txtb"));
//$(".bigimg").fadeTo("medium", 1);
});
$(".scrb2 li:eq(0)").click();
io=1;
setInterval(function(){
$(".scrb2 li:eq("+io+")").click();
io++;
if(io>=$(".scrb2 li").length)
{
io=0	
}
},4000);
});
$(".scrb2 li").mousedown(
function(){
io=$(this).prevAll().length	+1
});

$(".scrb6 li").click(function(){$(".bpic").empty();
//$(".bpic").fadeTo("medium", 0.5);
$(".spic",this).clone().appendTo($(".bpic"));
//$(".bpic").fadeTo("medium", 1);
});
$(".scrb6 li:eq(0)").click();

$(".msg :input,.msg textarea").focus(function(){
if($(this).val()==this.defaultValue)
{$(this).val("");}
}).blur(function(){
if($(this).val()=="")
{$(this).val(this.defaultValue);}
})

$('#select dd input,#select2 dd input,#select3 dd input,#select4 dd input').click(function(){
$(this).attr('checked','checked');
$(this).parent().parent().siblings().find('input').attr('checked','');
$(this).parent().parent().addClass('active');
$(this).parent().parent().siblings().removeClass('active');
});

$("ul.tab04").tabs("div.pannel > div.box",{current:"active"});
$("ul.tab05").tabs("div.pannel2 > div.box",{current:"active",event:'mouseover'});

$('.l_nav a.arr_r').click(function(){
var i = $('.scrb8 a').index($('.scrb8 a.hover'));
var o = i + 1;
$('.scrb8 a').removeClass('hover');
$('.scrb8 a').eq(o).addClass('hover');
if( o >= $('.scrb8 a').length - 2 ){
o = $('.scrb8 a').length - 2
$('.scrb8 a').eq(o).addClass('hover');
$('.scrb8 a').eq((o+1)).removeClass('hover');
}
})

$('.l_nav a.arr_l').click(function(){
var i = $('.scrb8 a').index($('.scrb8 a.hover'));
var o = i - 1;
$('.scrb8 a').removeClass('hover');
$('.scrb8 a').eq(o).addClass('hover');
if( i <= 1 ){
o = 1
$('.scrb8 a').eq(o-1).removeClass('hover');
$('.scrb8 a').eq((o)).addClass('hover');
}
})


var href=window.location.href.split('/')[window.location.href.split('/').length-1].substr(0,4).toLowerCase();
if(href=="news")
{
   href=window.location.href.split('/')[window.location.href.split('/').length-1];
   $(".hd_1 ul li").find("a[href="+href+"]").addClass("hover");
}
if(href.length>0&&$(".hd_1 ul li").find("a[href*="+href+"]").length>0)
{
	$(".hd_1 ul li").find("a[href*="+href+"]:first").addClass("hover");
}


else{
	$(".hd_1 ul li").find("a:eq(0)").addClass("hover")
}


$(".hd_1 ul a").not($(".hd_1 ul a.hover")).hover(function(){
$(this).find("i").stop().animate({top:'-25px'}).animate({top:'-30px',opacity:'1'},300)
},function(){
$(this).find("i").stop().animate({top:'-25px'}).animate({top:'-40px',opacity:'0'},300)
});


$("h4.tm ul li:eq(0) a").addClass("hover"); 
   
var href=window.location.href.substr(window.location.href.length-6,1).toLowerCase();

$("h4.tm ul li").each(function(i){
    if(href==(i))
    {
        $(this).find("a").addClass("hover");
        if(href!=0)
        {
          $("h4.tm ul li:eq(0) a").removeClass("hover"); 
        }
        return;
    }
});
})


//menu
$(document).ready(function(){
	$(".mainnav a").mouseover(function(){
		//$(".mainnav a").attr("class","");
		//$("#"+this.id).attr("class","");
		var currentMenuNo = parseInt(this.id.substring(1));
		$(".secondnav div").each(function(){
			$(this).hide();
			$("#subnav"+currentMenuNo).show();
		});
	});
//formwork	
//	$("input[type='radio']").click(function(){
//		if(confirm("确定要选择吗？"))
//		{
//			window.location.href="";
//		}
//	})
});


//scroll
$(function(){
$.fn.ScrollTo = function(speed, callback) {
var top = $(this).offset().top;
if ('BODY' == $(this).attr('tagName')) {// for IE6
top = 0;
}
//	$($.browser.safari ? 'body' : 'html')
$('html, body').animate({scrollTop: top}, speed, 'swing', callback);
};

$(".gotop").click(function(){
var scrolltargetval = $(this).attr('href')			
if (scrolltargetval.length == 1){
var scrolltarget = 'body'
}
else {
var scrolltarget = scrolltargetval
}
$(scrolltarget).ScrollTo(800);
return false;})
});

