
function switchTag(tag)
{
        for(i=1; i <7; i++)
        {
                if ("a"+i==tag)
                {
                        document.getElementById(tag).getElementsByTagName("a")[0].className="navsel";
                }else{
                        document.getElementById("a"+i).getElementsByTagName("a")[0].className="nav";
                }
        }
}

function main_menu(self,value) {
	$("li.newhovertab").removeClass().addClass("newnormaltab");
	if(value == "community") {
		
		$(self).addClass("newhovertab");
		
		$("#"+value).css("display","block");
		$("#travel_guide").css("display","none");
	}
	else if(value == "travel_guide") {
		$(self).addClass("newhovertab");
		$("#"+value).css("display","block");
		$("#community").css("display","none");
	}
}

function check_mail() {
	var top_email = $("#send_mail_top").val();
	if(top_email == "") {
		alert("请输入Email");
		return false;
	}
	
	var url = window.location.href;
	var check = chk_email(top_email);
	if(check == true) {
		$.ajax({
				url: '?q=community/top16/email',
				type : "POST",
				timeout: 3000,
				data: "url="+url+"&email="+top_email,
				success: function(msg) {
					if(msg == 1) {
						alert("提交成功");
						return false;
					}
					else {
						alert("提交失败,请重新输入");
						return false;
					}
				}
		});
		return false;
	}
	else {
		return false;
	}
}

function comingsoon_mail(loc) {
	var top_email = $("#cs-email").val();
	if(top_email == "") {
		alert("请输入Email")
		return false;
	}
	
	var url = window.location.href;
	var check = chk_email(top_email);
	if(check == true) {
		$.ajax({
				url: '?q=community/top16/comingsoon_email',
				type : "POST",
				timeout: 3000,
				data: "url="+url+"&email="+top_email+"&loc="+loc,
				success: function(msg) {
					if(msg == 1) {
						alert("提交成功");
						return false;
					}
					else {
						alert("提交失败,请重新输入");
						return false;
					}
				}
		});
		return false;
	}
	else {
		return false;
	}
}

function chk_email(top_email){
	var isEmail1 = /^\w+([\.\-]\w+)*\@\w+([\.\-]\w+)*\.\w+$/;
	if(!isEmail1.test(top_email)) {
		alert("请输入正确的email地址");
		return false;
	}
	return true;
}