// JavaScript Document
$(function(){
	
	$(".wb_f a.close").click(function(){
		$(this).parent().remove();
		return false;
	});
	
	$(".ci_sns").animate({"top":$(window).scrollTop()+120},1000);
	
	goTop();
	$(window).scroll(function(){
		goTop();
	});

	$(window).scroll(function(){
		$(".ci_sns").stop().animate({"top":$(window).scrollTop()+120},1000);
	});
	
	$(window).resize(function(){
		ci_sns_po();
	});
	
	ci_sns_po();
	
	menu();
	
	if(getFileName()=="" || getFileName()=="ind"  || getFileName()=="IND" )
	{
		$("a").attr("target","_blank");
	}
	
	$("a").each(function(){
		
		if($(this).attr("href"))
		{		
			var t = $(this).attr("href").indexOf("#");
			
			if( $(this).attr("href")!="index.php" && t == (-1)  )
			{
				$(this).attr("href",$(this).attr("href")+"#main");
			}
		}
	})

$(".b1").scrollable({size:4,items:".b1 ul",loop:true,prev:".l1",next:".r1"});

$(".b2").scrollable({size:2,items:".b2 ul",loop:true,prev:".l2",next:".r2"}).autoscroll({ autoplay: true,interval:4000 });

$(".b3").scrollable({size:1,items:".b3 ul",loop:true,vertical:true}).autoscroll({ autoplay: true,interval:4000 }).navigator({navi:"dl.tab",naviItem:'dd',activeClass:"hover"});

$(".b4").scrollable({size:1,items:".b4 ul",loop:true,vertical:true}).autoscroll({ autoplay: true,interval:4000 });	

$("a.gtop").click(function(){$('html, body').animate({scrollTop:0},800);});

$("form#form").submit(function(){
	if( $(this).find("input[name='b_nicename']").val()=="" || $(this).find("input[name='b_nicename']").val()== "昵称：" )
	{
		alert("请填写昵称！");
		return false;
	}
	else if( $(this).find("textarea[name='b_content']").val()=="" || $(this).find("textarea[name='b_content']").val()== "请输入祝福语。。。" || $(this).find("texteara[name='b_content']").val()== "请输入您的点评。。。" )
	{
		alert("请填写详细信息！");
		return false;
	}
	else
	{
		return true;
	}
	
});

$("ul.rating li").hover(function(){$("ul.rating li").removeClass("current");$("ul.rating li").removeClass("on");$("ul.rating li").removeClass("hover");$(this).addClass("hover");$(this).prevAll().addClass("hover")},function(){$(this).removeClass("hover");$(this).prevAll().removeClass("hover");$("ul.rating li.ok").next().prevAll().addClass("on")});

$("ul.rating li").click(function(){$("ul.rating li").removeClass("ok");$("ul.rating li").removeClass("current");$("ul.rating li").removeClass("on");$(this).addClass("current");$(this).addClass("ok");$(this).prevAll().addClass("on");$("input.rv").val($(this).attr("rel"));});

$("ul.rating li").eq(3).click();

$(".mfb input.t,.mfb textarea").focus(function(){
if($(this).val()==this.defaultValue)
{$(this).val("");}
}).blur(function(){
if($(this).val()=="")
{$(this).val(this.defaultValue);}
});

var w = $('ul.nav div').width();
$('ul.nav div').css({"margin-left":-(w/2)+"px",width:w,"over-flow":"hidden"});
$('ul.nav li').hover(function(){
$(this).find('div').slideDown('fast')
},function(){
$(this).find('div').slideUp('fast')
})

$("ul.ptl li").not($("ul.ptl li.sp")).hover(function(){$(this).addClass("hover")},function(){$(this).removeClass("hover")});

if( $(".rside").height()<$(".lside").height() )
{$(".rside").height($(".lside").height())}
else
{$(".lside").height($(".rside").height())};

})

function menu(){
	var url=getFileName();
	if(url!=""){
		$(".nav li a[href*='"+url+"']").addClass("hover");
	}
};

function getFileName(){
var url = this.location.href;
var pos = url.lastIndexOf("/");
if(pos == -1){
   pos = url.lastIndexOf("\\");
}
var filename = url.substr(pos+1,3);
return filename;
}

function ci_sns_po()
{
	var winwidth=$(window).width();
	var sns_width=$(".ci_sns").width();
	if( winwidth>(980+sns_width*2))
	{
		var right_width=(winwidth-980)/2;
		var right_po=(right_width/2)-(sns_width/2);
		$(".ci_sns").css({"right":right_po+"px"});
		$(".wb_f").css({"left":right_po-20+"px"});
	}
	else
	{
		$(".ci_sns").css({"right":"0px"});
		$(".wb_f").css({"left":"0px"});
	}
}

function goTop(){

	$(".wb_f").stop().animate({"top":$(window).scrollTop()+120},1000);

}
