﻿	function checkSubmitUser(){
		with(document.user){
			if(name.value==""){
				name.focus();
				alert("请输入您的用户名");
				return false;
			}
			if(password.value==""){
				password.focus();
				alert("请输入您的密码");
				return false;
			}
		}
		return true;
	}
	function ldg_search(){
		var l=document.getElementById("searchvalue");
		if(l.value=="请输入您想要搜索的节目、用户..."){
			l.value="";
		}
	} 	 
	function checkSearch(){
		with(document.search){
			if(searchvalue.value==""||searchvalue.value=="请输入您想要搜索的节目、用户..."){
				searchvalue.focus();
				alert("请输入您的节目或用户名");
				return false;
			}
			if(searchvalue.value!="")
			{
				searchvalue.value = searchvalue.value.replace(new RegExp("　","gm")," ");
				searchvalue.value = searchvalue.value.replace(/(^\s*)|(\s*$)/g, "");
			}
		}
		return true;
	}
	
	function confirmEmail(){
		var url = "/sendpassword.bo"; 
		window.open(url,'','height=100,width=400,toolbar=no, menubar=no,location=no, status=no,scrollbars=no');
	}
	
	function clickMenu(page){
		var menu=document.getElementById("menu"+page);
		menu.style.backgroundColor="#dfdfdf";
		menu.style.color="#ffa100";
	}

	//declaring the class
	var head = Class.create();
	head.prototype = {
		getUser:function(user){
			if(user==null){
				this.logHtml='<form name="user" method="post" action="/user.do" '+'onSubmit="return checkSubmitUser();">'+
'<input type="hidden" name="invokeMethod" value="doLogin" />'+
'<label>用户名：</label><input class="inputs" name="name" id="sendname" type="text"size="10" />'+'<label>密&nbsp;&nbsp;码：</label>'+'<input class="inputs" name="password" type="password" size="10" />'+
' <input name="Input" type="submit" class="buttons" value="登 陆" />'+
											'<input name="Input2" class="buttons" type="button" value="注 册"'+'onClick="javascript:location='+"'/signup.bo'"+'" />'
												+
											'<a href="javascript:confirmEmail();">取回密码</a>'+
'</form>';
				this.hasNew="";
			}else{
				if(user.cancreatespecial==0){
					this.logHtml='<a href="/myprofile.bo">'+user.name+'</a>&nbsp;&nbsp;|&nbsp;<a href="/myvideos.bo">我的节目</a>&nbsp;|&nbsp;<a href="/myfavorites.bo">我的收藏</a>&nbsp;|&nbsp;<a href="/mymessages.bo">我的消息</a>&nbsp;|&nbsp;<a href="/subscriptusers.bo">我的订阅</a>&nbsp;|&nbsp;<a href="/myfriends.bo">我的好友</a>&nbsp;|&nbsp;<a href="/myprofile.bo">我的空间</a>  &nbsp;|&nbsp;<a href="/user.do?invokeMethod=doLogout">离开</a>'
				}else{
					this.logHtml='<a href="/myprofile.bo">'+user.name+'</a>&nbsp;&nbsp;|&nbsp;<a href="/myvideos.bo">我的节目</a>&nbsp;|&nbsp;<a href="/myfavorites.bo">我的收藏</a>&nbsp;|&nbsp;<a href="/mymessages.bo">我的消息</a>&nbsp;|&nbsp;<a href="/subscriptusers.bo">我的订阅</a>&nbsp;|&nbsp;<a href="/myfriends.bo">我的好友</a>&nbsp;|&nbsp;<a href="/myprofile.bo">我的空间</a>  &nbsp;|&nbsp;<a href="/user.do?invokeMethod=doLogout">离开</a>'
				}
				if(user.hasNew!=""){
					this.hasNew='<img src="/images/newIndex/inbox.gif" /><a href="/mymessages.bo">您有<span class="color14 font14">新</span>消息</a>';
				}else{
					this.hasNew='您没有新消息';
				}
			}
			$("logDiv").innerHTML=this.logHtml;
			$("hasNew").innerHTML=this.hasNew;
		},
		initialize: function() {
			Head.checkUser(this.getUser);
		}
	}; 
