//用户登录表单Check
function checkLogin(){
	var LoginForm=document.getElementById("LoginForm");
	if (LoginForm.userName.value ==""){
		alert("请输入用户名！");
		LoginForm.userName.focus();
		return false;
	}
	if (LoginForm.password.value ==""){
		alert("请输入用户密码！");
		LoginForm.password.focus();
		return false;
	}
	return true;
}
//加入收藏
function addFavorite(sURL,sName){
	if (document.all){
		window.external.addFavorite(sURL,sName);
	}
 	else if (window.sidebar){
		window.sidebar.addPanel(sName,sURL, "");
	}
}
//设为首页
function setHomePage(obj,sURL){
	if (document.all){
		obj.style.behavior='url(#default#homepage)';
		obj.setHomePage(sURL);
	}
 	else if (window.sidebar){
		if(window.netscape){
			alert("抱歉，由于浏览器的原因，不能进行此操作。");
		}
	}
}
//显示隐藏功能菜单
function showHiddenFunctionMenu(){
	var functionArea=document.getElementById("functionArea");
	var contentArea=document.getElementById("contentArea");
	var mainArea=document.getElementById("mainArea");
	var albumTree=document.getElementById("albumTree");
	if(functionArea){
		if(functionArea.style.display=='none'){
			functionArea.style.display="";
			contentArea.style.width = contentArea.offsetWidth +4 - functionArea.offsetWidth - 6; //留6px
			setSameHeight(); //同步高度
			
			if(albumTree){
				albumTree.style.display="none";
			}
		}
		else{
			functionArea.style.display="none";
			contentArea.style.width=mainArea.offsetWidth-4; //留4px空隙，别太满
			if(albumTree){
				albumTree.style.display="";
			}
		}
	}
}
//隐藏功能菜单
function hiddenFunctionMenu(){
	var functionArea=document.getElementById("functionArea");
	var contentArea=document.getElementById("contentArea");
	var mainArea=document.getElementById("mainArea");
	if(functionArea){
		functionArea.style.display="none";
	}
		contentArea.style.width=mainArea.offsetWidth-4; //留4px空隙，别太满
}
//同步功能区和内容区的高度
function setSameHeight(){
	var functionArea=document.getElementById("functionArea");
	var contentArea=document.getElementById("contentArea");
	if(functionArea && contentArea && functionArea.style.display!='none'){
		if(functionArea.offsetHeight<contentArea.offsetHeight){
			functionArea.style.height=contentArea.offsetHeight;
		}
	}
}
//参数：true|false,内容
function setLocation(isAppend,htmlContent){
	var myLocation=document.getElementById("myLocation");
	if(isAppend){
		myLocation.innerHTML += htmlContent;
	}else{
		myLocation.innerHTML += htmlContent;
	}
}
//取得cookie
function getCookie(sName,sSubName){
	if(sName==null || sName.length==0)return "";
	
	var cookieArray = document.cookie.split("; "); //使用split方法拆分字符串
	for (var i=0;i<cookieArray.length;i++){
		var index=cookieArray[i].indexOf("="); //查找“=”的第一个位置
		var key=cookieArray[i].substring(0,index); //取得Cookie的名称
		if(unescape(key).toLowerCase()==sName.toLowerCase()) //转换为小写字母，然后比较
		{
			var value=cookieArray[i].substring(index+1); //取得Cookie的值
			//判断参数“子名称”是否为空。
			if(sSubName!=null && sSubName.length>0){
				//判断value中是否存在=，存在则继续拆分，不存在返回空字符串
				if(value.indexOf("=")>=0){
					var subArray=value.split("&"); //根据&拆分
					for (var j=0;j<subArray.length;j++){
						var index=subArray[j].indexOf("="); 
						var key=subArray[j].substring(0,index);
						if(unescape(key).toLowerCase()==sSubName.toLowerCase()){
							return unescape(subArray[j].substring(index+1));
						}
					}
				}else{
					return ""; //不存在子项目，直接返回空字符串。
				}
			}else{
				return unescape(value); //参数“子名称”为空，所以直接返回该Cookie的值
			}
		}
	}
	return ""; //没有匹配的名称，则返回空字符串。
}
//设置cookie，有效期单位：天
function setCookie(key,value,days){
	var now=new Date( )
　 	now.setTime(now.getTime() + 1000 * 60 * 60 * 24 * days) // 单位是毫秒
	document.cookie = key + "=" + value + "; expires=" + now.toGMTString();
}
