function gID(str){return (document.getElementById(str))?document.getElementById(str):false;}

function refreshimg()
{
	document.all.getcode.src='Images/GetCode.asp';
}

function check_in(o,name,str){
	if(o[name]){
		if(o[name].value==""){
			if(str!=""){
				alert("请填写"+str);
				if(o[name].style.display!="none")o[name].focus();
				return false;
			}
		};
	}else{
		alert("[ "+name+" ]不存在！");return false;
	};
	return true;
}

function checklogin(o){
	if(!check_in(o,"UserName","用户名")){return false;};
	if(!check_in(o,"PassWord","密码")){return false;};
	if(!check_in(o,"CheckCode","验证码")){return false;};
}

function showmenu_item(sid)
{
	which = eval("menu_item" + sid);
	if (which.style.display == "none")
	{
		var i = 1
		while(i<5)
		{
			eval("menu_item"+ i +".style.display=\"none\";");
			eval("menuTitle"+ i +".className=\"\";");
			i++;
		}
		eval("menu_item" + sid + ".style.display=\"\";");
		eval("menuTitle"+ sid + ".className=\"yc\";");
	}
	else
	{
		eval("menu_item" + sid + ".style.display=\"none\";");
		eval("menuTitle"+ sid + ".className=\"\";")
	}
}

function CheckAll(form) {  
	for (var i=0;i<form.elements.length;i++)  {  
		var e = form.elements[i];  
		if (e.name != 'chkall')  
		e.checked = true
	}  
}
function CheckCel(form) {
	for (var i=0;i<form.elements.length;i++){
		var e = form.elements[i];
		if (e.name != 'chkall')
                e.checked = false
	}
}
function CheckSel(form) {
	for (var i=0;i<form.elements.length;i++){
		var e = form.elements[i];
		if (e.name != 'chkall')
		e.checked=!e.checked;
	}
}

function userspell(){
  var upinyin = document.form1.uspell;
  var tpobj = document.form1.ClassEName;
  if(upinyin.checked) tpobj.style.display = "none";
  else tpobj.style.display = "block";
}

function change()
{
 	gID("oResult").value="document.writeln(\""+gID("oSource").value.replace(/\\/g,"\\\\").replace(/\//g,"\\/").replace(/\'/g,"\\\'").replace(/\"/g,"\\\"").split('\r\n').join("\");\ndocument.writeln(\"")+"\")"
} 

function checkvtitle()
{
	ajax_get("Admin_CheckVideo.asp?Title="+gID('VideoName').value,"errmsg")
}

function getOffsetTop(elm) {
	var mOffsetTop = elm.offsetTop;
	var mOffsetParent = elm.offsetParent;
	while(mOffsetParent){
		mOffsetTop += mOffsetParent.offsetTop;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	return mOffsetTop;
}
function getOffsetLeft(elm) {
	var mOffsetLeft = elm.offsetLeft;
	var mOffsetParent = elm.offsetParent;
	while(mOffsetParent) {
		mOffsetLeft += mOffsetParent.offsetLeft;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	return mOffsetLeft;
}

function GetColor(img_val,input_val)
{
	var PaletteLeft,PaletteTop
	var obj = document.getElementById("colorPalette");
	ColorImg = img_val;
	ColorValue = document.getElementById(input_val);	
	if (obj){
		PaletteLeft = getOffsetLeft(ColorImg)
		PaletteTop = (getOffsetTop(ColorImg) + ColorImg.offsetHeight)
		if (PaletteLeft+250 > parseInt(document.body.clientWidth)) PaletteLeft = parseInt(event.clientX)-260;
		obj.style.left = PaletteLeft + "px";
		obj.style.top = PaletteTop + "px";
		if (obj.style.visibility=="hidden")
		{
			obj.style.visibility="visible";
		}else {
			obj.style.visibility="hidden";
		}
	}
}
function setColor(color)
{
	if(ColorImg.id=="FontColorShow"&&color=="#") color='#000000';
	if(ColorImg.id=="FontBgColorShow"&&color=="#") color='#FFFFFF';
	if (ColorValue){ColorValue.value = '#'+color.substr(1);}
	if (ColorImg && color.length>1){
		ColorImg.src='Images/setcolor.gif';
		ColorImg.style.backgroundColor = color;
	}else if(color=='#'){ ColorImg.src='Images/nocolor.gif';}
	document.getElementById("colorPalette").style.visibility="hidden";
}