function SetHome(obj,vrl){
	try{
		obj.style.behavior='url(#default#homepage)';
		obj.setHomePage(vrl);
	}
	catch(e){
		if(window.netscape) {
			try {
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			}
			catch (e) {
				alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'");
			}
			var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
			prefs.setCharPref('browser.startup.homepage',vrl);
		}
	}
}
function AddCollect(url,desc)
{
	window.external.addFavorite(url, desc);
}

function changelang(lang, domain1,nowurl)
{
	if('en_us' == lang){
		$.cookie('ZDLANG', 'zh_cn', {path: '/', domain: domain1 });
	}else {
		$.cookie('ZDLANG', 'en_us', {path: '/', domain: domain1 });
	}
	//新闻详细页面转换时需跳转到新闻首页---09.3.6王丽丹修改
	if(nowurl != ''){
		if(nowurl == '/news_view.php?xw'){
			window.location.href = "http://news.redoffice.com/?class=xw";
		}else if(nowurl == '/news_view.php?hqgs'){
			window.location.href = "http://story.redoffice.com/?class=hqgs";
		}else if(nowurl == '/news_view.php?ky'){
			window.location.href = "http://opensource.redoffice.com/?class=ky";
		}else if(nowurl == '/member_wdzp.php?'){//会员作品英文页面去掉
			window.location.href = "http://myspace.redoffice.com/?class=sy";
		}else{
			window.location.reload();
		}
		/*if(nowurl == '/blog_view.php'){
			window.location.href = "http://blog.redoffice.com";
		}else{
			window.location.reload();
		}*/
	}else{
		window.location.reload();
	}	
}
function logoutpage(domain,nowurl,wwwdomain){
	$.cookie('CUSERID','',{path: '/', domain: domain });
	$.cookie('zoneauth','',{path: '/', domain: domain });
	if(nowurl == 'myspace.redoffice.com'){
		window.location.href = wwwdomain;
	}
	else{
		window.location.reload();	
	}	
}

function showtrain(type, idv, domain, width, height)
{
	if (1 == type)
	{
		//打开视频
		window.open(domain+'/office_info.php?id='+idv,"视频","height="+height+",width="+width+",toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no");
	}else if(2 == type) {
		//打开音频
		window.open(domain+'/office-audio.php?id='+idv,"音频","height="+height+",width="+width+",toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no");
	}
	return false;
}

function usernameCheck()
{
	 var username = $('#username').val();
	  if (username == "") 
         $('#errinfo').text("请输入电子邮件!");
      else
	  	$('#errinfo').text("");
    
}
function passwordCheck()
{
	var password = $('#password').val();
	 if (password == "") 
         $('#errinfo').text("请输入密码!");
      else
	  	$('#errinfo').text("");

}

function indexlogincheck(){
	var username = $('#indexusername').val();
	var pwd = $('#indexpassword').val();
	if('' == username){
		$('#cwarea').html('电子邮件不能为空');
		return false;
	}else if('' == pwd){
		$('#cwarea').html('密码不能为空！');
		return false;
	}else {
		$.cookie('tmppw',pwd,{path: '/', domain: 'redoffice.com' });
		$('#indexlogin').submit();
	}
}

function changevalidateimg(id){
	$("#"+id).attr('src', 'http://login.redoffice.com/validatecode.php?'+Math.random());
}

function showlogoutnote()
{
	$("#redlogout").css('z-index', 1000);
	$("#redlogout").show();
}

function hidelogoutnote()
{
	$("#redlogout").css('z-index', 0);
	$("#redlogout").hide();
}

$(function(){
	$("#indexusername").keydown(function(event){
    	//if(event.keyCode == 13)
    		//indexlogincheck();
    });
	$("#indexpassword").keydown(function(event){
    	if(event.keyCode == 13)
    		indexlogincheck();
    });
	$("#password").keydown(function(event){
    	if(event.keyCode == 13)
    		loginCheck3();
    });

});