var mk_height=38;
var thef_X,thef_Y;

//-- 添加/修改视频对话框
var photo_content='<p>用户名称：<input name="subject" type="text" id="subject" size="16" maxlength="20"></p><p>密&nbsp;&nbsp;&nbsp;&nbsp;码：<input name="pwd" type="password" id="pwd" size="16" maxlength="20"></p><p>验&nbsp;证&nbsp;码：<input type="text" name="cmf" id="cmf" size=4 maxlength=4 onkeydown="if(event.keyCode==13)return do_video(this.form);" onfocus="show_img();"/>&nbsp;<img alt="点击更换验证码" src="" id="c_img" style="display:none" onclick="this.src=\'http://www.car136.com/tmp/register.php?act=get_pwd\';"/></p><p><input type="hidden" name="act" id="act"/><input type="button" name="Sm" value="登陆" onClick="return do_video(this.form);"/>&nbsp;&nbsp;<input type="button" name="Sm2" value="重置" onClick="return set_video(this.form);"/><input type="hidden" name="path_ref" value="'+window.location+'"/></p><p>-------------------------------------------</p><p>没有殿堂账号？</P><p><input type="button" value="立即注册殿堂帐户" onclick="window.location.href=\'http://www.car136.com/tmp/register.php?m_zj=1&referer='+escape(window.location)+'\';"/></p>';




function $(_target){
	return document.getElementById(_target);
};
function set_video(thef)
{
	thef.subject.value='';
	thef.pwd.value='';
	thef.cmf.value='';
}
function show_img()
{
	if($('c_img').style.display=='none')
	{
		$('c_img').style.display='inline';
		$('c_img').src='http://www.car136.com/tmp/register.php?act=get_pwd';	
	}

}
//----------------------handle_listDivmove
handle_listDivmove=function(e)
{
	var _tar=EventUtil.getEvent();


	$("listDiv").style.left=_tar.pageX-thef_X;

    $("listDiv").style.top=_tar.pageY-thef_Y;
	
	$("mkDiv").style.left=$("listDiv").style.left;
	$("mkDiv").style.top=parseInt($("listDiv").style.top)+mk_height;
	
	$("listDiv").style.display='block';

}
//----------------------handle_listDivup
handle_listDivup=function(e)
{
	var _e=EventUtil.getEvent();
	var _tar=_e.target;
	

	$("listDiv").style.left=_e.pageX-thef_X;
   	$("listDiv").style.top=_e.pageY-thef_Y;
	
	$("mkDiv").style.left=$("listDiv").style.left;
	$("mkDiv").style.top=parseInt($("listDiv").style.top)+mk_height;

	thef_X=thef_Y=0;

	EventUtil.removeEventHandler(document.body,"mousemove",handle_listDivmove);
	EventUtil.removeEventHandler(document.body,"mouseup",handle_listDivup);
}

if($("listDiv"))
{
	$("listDiv").onmousedown = function(e)
	{
		var _tar=EventUtil.getEvent();
		if (_tar.offsetX == undefined)
		{
			var evtOffsets = getOffset(_tar);
    		thef_X=evtOffsets.offsetX;
			thef_Y=evtOffsets.offsetY;

		}
		else
		{
			thef_X=_tar.offsetX;
			thef_Y=_tar.offsetY;
		}

		EventUtil.addEventHandler(document.body,"mousemove",handle_listDivmove);
		EventUtil.addEventHandler(document.body,"mouseup",handle_listDivup);

	}
}


showvideoDiv=function(_e,height)
{	
if($('overlay'))
{
	if(!height)height=200;
	$("mkDiv").innerHTML=photo_content;
	$('act').value='login';	
	if(EventUtil.isIE)
	{
		$("listDiv").style.left=document.body.clientWidth/3;
		$("listDiv").style.display='block';	
   		$("listDiv").style.top=_e.pageY+height;
		$("mkDiv").style.left=$("listDiv").style.left;

		$("mkDiv").style.top=parseInt($("listDiv").style.top)+mk_height;
	}
	else
	{
		$("listDiv").style.left=document.body.clientWidth/3+'px';
		$("listDiv").style.display='block';	
   		$("listDiv").style.top=_e.pageY+height+'px';
		$("mkDiv").style.left=$("listDiv").style.left;

		$("mkDiv").style.top=parseInt($("listDiv").style.top)+mk_height+'px';		
	}
	
	$("mkDiv").style.display='block';	

	addLightboxMarkup();
}
}

showvideoDivEdit=function(_e,vid)
{	

	
	Ajax.call('spacephoto.php', 'act=getvideo&vid=' +vid, getvideoResponse, 'POST', 'TEXT');	



	$("listDiv").style.left=document.body.clientWidth/3;
   	$("listDiv").style.top=_e.pageY-200;
	$("mkDiv").style.left=$("listDiv").style.left;

	$("mkDiv").style.top=parseInt($("listDiv").style.top)+mk_height;
	
	$("listDiv").style.display='block';	
	$("mkDiv").style.display='block';	

	addLightboxMarkup();
}

getvideoResponse=function(result,txt)
{
	if(result!='')
	{
		$("mkDiv").innerHTML=result;	
	}
}
deleteVideo=function(att_id)
{
	if(confirm('确定删除该视频？'))
	{
		Ajax.call('spacephoto.php', 'act=delvideo&vid=' +att_id, getDelvideoResponse, 'POST', 'TEXT');	
	}
}

getDelvideoResponse=function(result,txt)
{
	if(result=='true')
	{
		window.location.href=window.location;	
	}
}
closeWin=function()
{
	
	closeMarkup();
	$("listDiv").style.display='none';
	$("mkDiv").style.display='none';

}

//-- 批量操作
pl_do=function(thef,str)
{
	thef.pls.value=str;
	thef.path_url.value=window.location;
	thef.target='_self';
	thef.action='spacephoto.php';
	thef.submit();
}
pl_do2=function(thef,str)
{
	if(confirm('确定执行该操作？'))
	{
		thef.pls.value=str;
		thef.path_url.value=window.location;
		thef.target='_self';
		thef.action='spacephoto.php';
		thef.submit();
	}
}

function do_video(thef)
{
	if(trim(thef.subject.value)=='')
	{
		alert("会员名称为必填!");
		thef.subject.focus();
		return false;
	}
	
	
	if(trim(thef.pwd.value)=='')
	{
		alert("密码为必填!");
		thef.pwd.focus();
		return false;
	}
	
	if(trim(thef.cmf.value)=='')
	{
		alert("验证码为必填!");
		thef.cmf.focus();
		return false;
	}
	thef.target="spaceframe";
	thef.action="http://www.car136.com/tmp/register.php";
	thef.submit();
}


function CheckAll(form)
{         

  	for (var i=0;i<form.elements.length;i++)
  	{         

    	var e = form.elements[i];         

    	if (e.name != 'chkall')
		{
			e.checked = form.chkall.checked;   
		}
  
  	}
//var flag=false;

	if(e.checked)
	{
		form.mu.disabled=false;
		form.rm.disabled=false;
	}
	else
	{
		form.mu.disabled=true;
		form.rm.disabled=true;			
	}

} 
function Checkt(form)
{         

	var flag=false;
	
  	for (var i=0;i<form.elements.length;i++)
  	{         

    	var e = form.elements[i];         

    	if (e.name != 'chkall'&&e.type=='checkbox')
		{
			if(e.checked)
			{
				flag=true;
				break;
			}
		}
  
  	}
	
	if(flag)
	{
		form.mu.disabled=false;
		form.rm.disabled=false;
	}
	else
	{
		form.mu.disabled=true;
		form.rm.disabled=true;			
	}
}
