function $showmov(v)
{
	return document.getElementById(v);
}
function ajax(url) 
{ 
	var showmov = null; 
	if ( window.XMLHttpRequest )
	{
		showmov = new XMLHttpRequest();
	}else{
		showmov = new ActiveXObject("Msxml2.XMLHTTP");
	}
	showmov.open("GET",url,false);
	showmov.send(null);
	if(showmov.readyState == 4 && showmov.status == 200){
		return showmov.responseText;
	}else{
		alert(showmov.status)
		return false;
	}
	delete(showmov);
}
function Chanage(id, type, obj)
{
	var newobj,patten;
	newobj = document.getElementsByName('address');
	y = 1;
	for(i=0;i<newobj.length;i++)
	{	
		y++;
		newobj[i].parentNode.className = 'server_title_mid';
		
	}
	obj.parentNode.className = 'server_title_mid2';
	var src = $showmov('vodcms_player').src;
	if (type =='sid' )
	{
		patten = /\&sid\=(\d+)/;
	}else{
		patten = /\&player\=(\d+)/;
	}
	$showmov('vodcms_player').src = src.replace(patten,'')+'&'+type+'='+id;
}
function CheckComemnt()
{
	if ($showmov('content').value=='')
	{
		alert('请填写评论内容!')
		$showmov('content').focus();
		return false;
	}
	if ($showmov('content').value.lenght>250)
	{
		alert('评论内容长度不能大于250个字!')
		$showmov('content').focus();
		return false;
	}
	return true;
}
function delcomment(id,obj)
{
	var result = parseInt(ajax('?mod=comments&action=del&id='+id));
	if (result == 200)
	{
		alert('删除成功!');
		obj.parentNode.parentNode.parentNode.parentNode.parentNode.removeChild(obj.parentNode.parentNode.parentNode.parentNode)
	}else if (result == 400)
	{
		alert('删除失败!您可能没有删除权限!');
	}else{
		alert('页面出错!')
	}
}
function checkpass(v)
{
	var h = $showmov(v).parentNode.parentNode;
	var o = h.getElementsByTagName("div");
	var obj = o[1];
	if (v == 'oldpass')
	{
		if ( $showmov(v).value == '' )
		{
			obj.style.display = 'block';
			obj.innerHTML = '<img src=images/check_error.gif style=float:left>请输入密码!';
			$showmov('submit').disabled =true
			t = false
		}else{
			obj.style.display = 'none';
			$showmov('submit').disabled =false;
			t = true
		}
		if ( ajax("index.php?mod=register&action=ajax&pass="+$showmov(v).value)  != 200 )
		{
			obj.style.display = 'block';
			obj.innerHTML = '<img src=images/check_error.gif style=float:left>您输入的密码与历史密码不匹配！!';
			$showmov('submit').disabled =true
			t = false
		}else{
			obj.style.display = 'none';
			$showmov('submit').disabled =false;
			t = true
		}
	}else if (v == 'pass1')
	{
		if ( $showmov(v).value == '' )
		{
			obj.style.display = 'block';
			obj.innerHTML = '<img src=images/check_error.gif style=float:left>请输入新密码!';
			$showmov('submit').disabled =true
			t = false
		}else if( $showmov(v).value.length < 6 ){
			obj.style.display = 'block';
			obj.innerHTML = '<img src=images/check_error.gif style=float:left>请输入大于6位长度的密码!';
			$showmov('submit').disabled =true
			t = false
		}else{
			obj.style.display = 'none';
			$showmov('submit').disabled =false
			t = true
		}
	}else if (v == 'pass2')
	{
		//alert(checkpass('pass1'));
		if ( $showmov(v).value != $showmov('pass1').value )
		{
			obj.style.display = 'block';
			obj.innerHTML = '<img src=images/check_error.gif style=float:left>两次密码不一致!';
			$showmov('submit').disabled =true
			t = false
		}else{
			obj.style.display = 'none';
			$showmov('submit').disabled =false
			t =true
		}
		if ($showmov('pass1').value == '' )
		{
			obj.style.display = 'block';
			obj.innerHTML = '<img src=images/check_error.gif style=float:left>请输入新密码!';
			$showmov('submit').disabled =true
			t = false
		}
	}
	return t
}
function register(v)
{
	var h = $showmov(v).parentNode.parentNode;
	var o = h.getElementsByTagName("div");
	var obj = o[1];
	if (v == 'username')
	{
		if ($showmov(v).value == '' )
		{
			obj.style.display = 'block';
			obj.innerHTML = '<img src=images/check_error.gif style=float:left> 请填写用户名!';
			$showmov('submit').disabled =true;
			$showmov(v).className = 'on_input';
			return false
		}else{
			obj.style.display = 'block';
			obj.innerHTML = '<img src=images/check_right.gif style=float:left> 用户名验证正确!';
			$showmov('submit').disabled = false;
		}
		if (ajax("index.php?mod=register&action=ajax&username="+$showmov(v).value) != 200 )
		{
			obj.style.display = 'block';
			obj.innerHTML = '<img src=images/check_error.gif style=float:left>用户名已经被占用!请更换!';
			$showmov('submit').disabled =true;
			$showmov(v).className = 'on_input';
			return false
		}
		if ( ($showmov(v).value.length <5) || ($showmov(v).value.length>30) )
		{
			obj.style.display = 'block';
			obj.innerHTML = '<img src=images/check_error.gif style=float:left>用户长度必须大于五位小于三十位';
			$showmov('submit').disabled =true;
			$showmov(v).className = 'on_input';
			return false
		}
	}
	if (v == 'password')
	{
		if ($showmov(v).value == '' || $showmov(v).value.length < 5)
		{
			obj.style.display = 'block';
			obj.innerHTML = '<img src=images/check_error.gif style=float:left>请输入大约或者等于六位的密码';
			$showmov('submit').disabled =true;
			$showmov(v).className = 'on_input';
			return false
		}else{
			obj.style.display = 'none';
			$showmov('submit').disabled = false
		}
	}
	if (v == 'returnpass')
	{
		if ($showmov(v).value == '' || $showmov(v).value.length < 5)
		{
			obj.style.display = 'block';
			obj.innerHTML = '<img src=images/check_error.gif style=float:left>请输入大约或者等于六位的密码';
			$showmov('submit').disabled =true;
			$showmov(v).className = 'on_input';
			return false
		}
		if ($showmov(v).value != $showmov('password').value)
		{
			obj.style.display = 'block';
			obj.innerHTML = '<img src=images/check_error.gif style=float:left>确认密码不一致！';
			$showmov('submit').disabled =true;
			$showmov(v).className = 'on_input';
			return false;
		}else{
			obj.style.display = 'none';
			$showmov('submit').disabled = false;
		}
	}
	if (v == 'email')
	{
		if( !isEmail($showmov(v).value) )
		{
			obj.style.display = 'block';
			obj.innerHTML = '<img src=images/check_error.gif style=float:left>邮件地址不正确!';
			$showmov('submit').disabled =true;
			$showmov(v).className = 'on_input';
			return false
		}else{
			obj.style.display = 'none';
			$showmov('submit').disabled = false;
			
		}
	}
	return true
}
function isEmail(strEmail) {
	if(new RegExp(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(strEmail))
	{
		return true
	}else{
		return false;
	}
}
function CheckRegister()
{
	var t = register('username');
	var t = register('password');
	var t = register('returnpass');
	var t = register('email');
	return t
}
function news(url)
{
	newWidnow(url, "news","width=420,height=500");
}
function OpenWindow(openurl)
{
	//window.showModelessDialog(openurl,window,"status:false;dialogWidth:540px;dialogHeight:430px;edge:Raised; enter: Yes; help: No; resizable: Yes; status: No");
	var paramet = 'toolbar=no,width=540,height=430,location=no,status=no,scrollbars=no,menubar=no,resizable=yes';
	newWindow =parent.window.open(openurl,"vodcms",paramet);
	newWindow.focus();
}

function newWidnow(theURL,winName,features) { //v2.0
 
  return  parent.window.open(theURL,winName,features);
}
function Copy(ob)
{
	ob.select();
	js=ob.createTextRange();
	js.execCommand("Copy");
	alert("复制成功！");
}
function jumpage(classid, ext)
{
	if($showmov('jumppage').value == '')
	{
		alert('请输入要转至页码!');
		$showmov('jumppage').focus();
	}else{
	location.href = classid + '_' + $showmov('jumppage').value + ext;
	}
}
/*秀影图片自适应处理函数*/
function zoonImg(id, width)
{
	images = document.getElementById(id).getElementsByTagName("img");
	for (i = 0; i < images.length; i++)
	{
		img = images[i];
		img.onload = function()
		{
			w = this.width;
			h = this.height;
			if (w > width)
			{
				this.style.cursor = "hand";
				this.width = width;
				this.height = width / w * h;
			}
		}
	}
}
