function mainmenu(){
$(".menu ul ").css({display: "none"}); // Opera Fix
$(".menu li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(400);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
}

$(document).ready(function(){
	mainmenu();
	$('ul.menu li.tab').hover(
		function (){
			$('ul.menu li.active').removeClass('active');
			$(this).addClass('active');
		}
	);
});
function login(lang)
{
	var uname = $("#lg_username").val();
	var pwd = $("#lg_password").val();
	var forward = $("#lg_forward").val();

	if (typeof(forward) == "undefined")
	{
		forward = "";
		
	}

	if (Utils.isEmpty(uname))
	{
		if (lang == "cn")
		{
			alert('会员名不能为空');
		}else
			alert('Please fill in your username');

		return;
	}
	if (Utils.isEmpty(pwd))
	{
		if (lang == "cn")
		{
			alert('密码不能为空');
		}else
			alert('Please fill in your password');

		return;
	}
	
	var url = _URL_ + "user/ajaxlogin";
	var data = "username=" + uname + "&password=" + pwd + "&forward=" + forward;
	$.ajax({
		type:'post',
		url:url,
		ifModified:true,
		data:data,
		dataType:'json',
		success:function(result){
			if (result.error == 1)
				alert(result.message);
			if (result.error == 0)
			{
				window.location.reload();
//与论坛登陆整合2010.09.10
//				window.location.href = result.content;
			}
		}
	});
}

function logout()
{
	var url = _URL_ + "user/logout";
	$.ajax({
		url:url,
		ifModified:true,
		dataType:'json',
		success:function(result){
			if (result.error == 0)
			{
				window.location.reload();
//与论坛登陆整合2010.09.10
//				window.location.href = result.content;
			}

		}
	});
}
/*
* 预定项目
*/
function yd(id,lang)
{
	if (typeof(lang) == "undefined")
	{
		lang = 'cn';
	}

	var url = _URL_ + "yuding/index" + "/" + id + "/" + lang;
	var url_1 = _URL_ + "yuding/load_yu" + "/" + id + "/" + lang;

	$.getJSON(
		url,'',
		function(result){
			if (result.error == 1)
			{
				alert(result.message);
				window.location.href = "#login";
				$("#lg_username").focus();
			}else
			if (result.error == 0)
			{
				$.fn.colorbox({opacity:0.4,iframe:true,href:url_1,innerWidth:300, innerHeight:350});
			}
		}
	);
}
	function jump_branch(id,lang)
	{
		if (typeof(lang) == "undefined")
		{
			lang = 'cn';
		}
		if (id != 0)
			window.location.href = _URL_ +lang+"/bi/"+ id;
	}

function search_1()
{
      var validator = new Validator('searchForm');
      validator.required('search', '搜索内容不能为空');
      if (validator.passed())
      {
		document.forms['searchForm'].submit();
	  }
}

