/*index header menu*/
$(function(){
	$('.content>ul:last').css({"border-bottom":"none"});
	$('.why51pigai>li:last').css({"border-bottom":"none"});
})

/*index header menu*/
$(function(){
	for(var i=0;i<=4;i++){
		$('#memu'+i).hover(function(){
			$(this).addClass("show");
		},
		function(){
			$(this).removeClass("show");
		});
	}
})

/* index banner */
$(function(){
	$("#pg_header_3 div:not(:first)").hide();
	$(".pg_header_4 li").each(function(index){
		$(this).mouseenter(
		function(){
			for(var i=0;i<=4;i++){
				$(".pg_header_4 li.change"+i).removeClass("change"+i);
			}
			$(this).addClass("change"+index);

			//$("#pg_header_3 > div:visible").fadeOut();
			//$("#pg_header_3 > div:visible").css('position','absolute');
			$("#pg_header_3 > div:not(" + index + ")").fadeOut();
			$("#pg_header_3 > div:not(" + index + ")").css('position','absolute');

			$("#pg_header_3 div:eq(" + index + ")").fadeIn();
			$("#pg_header_3 div:eq(" + index + ")").css('position','absolute');

		})
	})
})

/* check submit gbook form*/
function checkFrom()
{
	var name = $('#name').val();
	var email = $('#email').val();
	var message = $('#message').val();

	if(name || email || message){
		$('.gbook span').html('');
	}

	if(!name){
		$('.err_name').html('请填写姓名！');
		$('#name').focus();
		return false;
	}
	if(!email){
		$('.err_email').html('请填写E-mail！');
		$('#email').focus();
		return false;
	}
	if(!message){
		$('.err_message').html('请填写信息！');
		$('#message').focus();
		return false;
	}
}

/* check input by gbook form */
function checkInput(obj)
{
	var object = $('#'+obj).val();
	if(object){
		$('.err_'+obj).html('');
	}
}
/* search word */
function searchW(){
	var search_word = $('.search_word').val();
	if(!search_word){
		$('.search_alert').html("请输入关键词!");
		$('.search_alert').css("z-index","100");
		$(document).ready(function() {
			function jump(count) {
				window.setTimeout(function(){
					count--;
					if(count > 0) {
						jump(count);
					} else {
						$(".search_alert").html('');
						$('.search_alert').css("z-index","-100");
					}
				}, 1000);
			}
			jump(1);
		});
		return false;
	}
	window.open("search.php?keyword="+encodeURIComponent(search_word),"_blank");
}

/* set news email */
function setEmail()
{
	var rss = $('#rss_email').val();
	if(rss=="请输入email地址"){
		$('#rss_email').css("border","1px solid red");
		$(document).ready(function() {
			function jump(count) {
				window.setTimeout(function(){
					count--;
					if(count > 0) {
						jump(count);
					} else {
						$('#rss_email').css("border","1px solid #B0CFE0");
					}
				}, 1000);
			}
			jump(1);
		});
		return ;
	}else{

		$.ajax({
			type: "GET",
			url: "/page.php?act=setemail",
			timeout: 20000,
			data: "email="+rss,

			error: function(){
				alert("提示：服务器忙，稍后再试！");
			},
			success: function(res){
				alert(res);
			}
		});

	}
}

function h(i){
	if (i.value=='请输入email地址'){
		$("#rss_email").val("");
		$("#rss_email").css({color:"#000000"});
	}
}
function s(i){
	if (i.value==''){
		$("#rss_email").val("请输入email地址");
		$("#rss_email").css({color:"#8F9AA0"});
	}
}
