function isNull( str ){ 
	if ( str == "" ) return true; 
	var regu = "^[ ]+$"; 
	var re = new RegExp(regu); 
	return re.test(str); 
}

//验证email格式是否合法
function checkEmail(email)
{
		var reEmail=/^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,5}/;
        if (!(email.match(reEmail)&&email!=""))
        {
             return false;
        }
        else {
			return true;
		
		}
}

function login_check(id) {
	var keyword=document.getElementById(id).value;
		if (keyword==''){
			alert('请输入关键字!');
			return false;
		}else {
			return true;
		}
}
function setit(id) {
	var tiao=document.getElementById(id).getElementsByTagName('li');
		for(i=0; i<tiao.length; i++) {
			if(i == 0){
				tiao[i].className='li1';
			}
	}
}
function closeit(id) {
	var tiao=document.getElementById(id).getElementsByTagName('li');
	for(i=0; i<tiao.length; i++) {
		tiao[i].className='li2';
	}
}
function checkForm(theForm) {
	if(theForm.username.value == '') {
		alert('输入用户名');
		theForm.username.focus();
		return false;
	} else if(theForm.password.value == '') {
		alert('输入密码');
		theForm.password.focus();
		return false;
	} else if(theForm.logincode.value == '') {
		alert('输入验证码');
		theForm.logincode.focus();
		return false;
	} else if(theForm.cookieTime.value == '') {
		alert('登录有效期');
		theForm.logincode.focus();
		return false;
	}
	return true;
}
function regcheck(form1){
	if (isNull(form1.regname.value)){
		alert('用户名为空，请填写!');
		return false;
	}
	if (isNull(form1.regpwd.value)){
		alert('密码为空，请填写!');
		return false;
	}
	if (form1.regpwd.value!=form1.regpwdrepeat.value){
		alert('两次输入的密码不一致，请检查后重试。');
		return false;
	}
	if (!checkEmail(form1.email.value) || isNull(form1.email.value)){
		alert('Email格式错误!');
		return false;
	}
	//form1.regsubmit.disabled=true;
}
function checkpwd(){
	var pwd = document.getElementById("regpwd").value;
	var pwdrepeat = document.getElementById("regpwdrepeat").value;
	if (pwd.length<6){
		document.getElementById("pwd_info").innerHTML = "<font color=\"red\">密码太少，建议使用6位以上</font>";
	} else{
		document.getElementById("pwd_info").innerHTML = "";
	}
	if(pwdrepeat){
		checkpwdrepeat();
	}
}
function checkpwdrepeat(){
	var pwd = document.getElementById("regpwd").value;
	var pwdrepeat = document.getElementById("regpwdrepeat").value;
	if (pwdrepeat==pwd){
		document.getElementById("pwdrepeat_info").innerHTML = "";
	} else{
		document.getElementById("pwdrepeat_info").innerHTML = "<font color=\"red\">两次输入的密码不一致，请检查后重试。</font>";
	}
}

function faceupload(id){
	var pic=document.getElementById("pic");
	var pic2=document.getElementById("pic2");
	var imgshow=document.getElementById("imgshow");
	if (id=="pic"){
		pic2.style.display="none";
		imgshow.style.display="none";
		pic.style.display="";
		pic.value="http://";
	}else if(id=="pic2"){
		pic.style.display="none";
		if(pic2.value){
			document.getElementById('imgshow').style.display = ''
		}
		pic2.value="";
		pic2.style.display="";
	}
}
var is_check = true;
function CheckAll(form){
	for (var i=0;i<form.elements.length;i++){
		var e = form.elements[i];
		if(e.type=='checkbox') e.checked = is_check;
	}
	is_check = (is_check == true) ? false : true;
}
function flash_cc(key){
		if (key==1) {
			var toupload = true;
			if(document.getElementById("recording").style.display == "" && document.getElementById("ccvid").value != "") {
				toupload = confirm("您已经录制了视频，切换到上传模式将丢失录制的内容。您确定要这样做？");
			}
			if(toupload == true) {
				document.getElementById("ccvid").value = "" ;
				document.getElementById("pic").value = "" ;
				document.getElementById("up").style.display = "" ;
				document.getElementById("recording").style.display = "none" ;
				document.getElementById("quotelable").style.display = "none" ;
				document.getElementById("ccvid").readOnly = true ;
				document.getElementById("ccvid").style.color = "#999999" ;
				document.getElementById("pid").style.display = "none" ;
				document.getElementById("quote").value = '';
			} else {
				document.getElementById("isup_0").checked = true ;
			}
		}else if(key==2){
			var toupload = true;
			if(document.getElementById("up").style.display == "" && document.getElementById("ccvid").value != "") {
				toupload = confirm("您已经上传了视频文件，切换到录制模式将丢失上传的内容。您确定要这样做？");
			}
			if(toupload == true) {
				document.getElementById("ccvid").value = "" ;
				document.getElementById("pic").value = "" ;
				document.getElementById("up").style.display = "none" ;
				document.getElementById("recording").style.display = "" ;
				document.getElementById("quotelable").style.display = "none" ;
				document.getElementById("ccvid").readOnly = true ;
				document.getElementById("ccvid").style.color = "#999999" ;
				document.getElementById("pid").style.display = "none" ;
				document.getElementById("quote").value = '';
			} else {
				document.getElementById("isup_1").checked = true ;
			}
		}else if(key==3){
			document.getElementById("up").style.display = "none" ;
			document.getElementById("recording").style.display = "none" ;
			document.getElementById("quotelable").style.display = "" ;
			document.getElementById("ccvid").readOnly = false ;
			document.getElementById("ccvid").style.color = "#000000" ;
			document.getElementById("pid").style.display = "" ;
			document.getElementById("quote").value = 'ok';
		}
	}

function video_checkdata(form1) { 
	if(form1.channelid.value == '') {
	alert("请选择频道！")
	form1.channelid.focus()
	return false;
	}
	if(form1.title.value == '') {
	alert("请填写标题！")
	form1.title.focus()
	return false;
	}
	if(form1.tags.value == '') {
	alert("请填写标签！")
	form1.tags.focus()
	return false;
	}
	if(form1.pic.value == '') {
	alert("没有上传视频！")
	//form1.pic.focus()
	return false;
	}
	if(form1.ccvid.value == '') {
	alert("没有上传视频！")
	//form1.ccvid.focus()
	return false;
	}
	if(form1.quote.value == 'ok' && form1.pid.value == '') {
	alert("引用类型不能为空")
	//form1.pid.focus()
	return false;
	}
}

function setVideoInfo(vid, thumb) {
	document.getElementById("ccvid").value = vid;
	document.getElementById("pic").value = thumb;
}

function getInfo() {
	var returnStr = '';
	var form1 = document.getElementById("form1");
	if(form1.channelid.value == '') {
		alert('请选择频道！')
		from1.channelsub.focus()
		return false;
	}
	
	returnStr += 'class=' + form1.channelid.value.substr(form1.channelid.value.indexOf(',')+1,2) + '|';
	
	if(form1.title.value == '') {
		alert("请填写标题！")
		from1.title.focus()
		return false;
	}
	
	returnStr += 'title=' + form1.title.value + '|';
	
	if(form1.tags.value == '') {
		alert("请填写标签！")
		from1.tags.focus()
		return false;
	}
	
	//if(form1.h264.checked){
	//	h264 = form1.h264.value;
	//	tags = form1.tags.value + ' pocle高清|' ;
	//}else{
	//	h264 = "";
		tags = form1.tags.value;
	//}
	
	returnStr += 'tags=' + tags + '|';
	
	if(form1.pic.value == '') {
		alert("没有上传视频！")
		//from1.pic.focus()
		return false;
	}
	
	if(form1.ccvid.value == '') {
		alert("没有上传视频！")
		//from1.ccvid.focus()
		return false;
	}
		
	returnStr += 'ccvid=' + form1.ccvid.value + '|';	
	returnStr += 'description=' + form1.description.value + '|';
	
	for(i=0;i<form1.isup.length;i++)  { 
	  	if(form1.isup[i].checked){
	  		returnStr += 'isup=' + form1.isup[i].value + '|';
	  	}   
 	 }   
	returnStr += 'share=' + 1 + '|';

	//returnStr += 'h264=' + h264;
	
	//alert(returnStr);return false;
	return returnStr;
}

function toSubmit() {	
	var form1 = document.getElementById("form1");
	form1.submit();
}

function copyUrl(url){
var data = document.getElementById(url);
window.clipboardData.setData("Text",data.value);
data.select();
alert("代码复制成功，通过QQ/MSN或其它方式发给你朋友。");
}
function fenxiang(url){
	var curl=url.replace("http://union.bokecc.com/","");
	document.write('<style>#ubbcodeid,#htmlcodeid,#cccodeid{display:none;}</style>');
	document.write('<li id="ubbcodeid">Ubb 代码：<input type="text" id="ubbcode" onclick="copyUrl(\'ubbcode\')" value=\'[flash]'+url+'[/flash]\'/><button onclick="copyUrl(\'ubbcode\')">点击复制</button></li><li id="htmlcodeid">Html代码：<input type="text" id="htmlcode" onclick="copyUrl(\'htmlcode\')" value=\'<embed src="'+url+'" allowScriptAccess="always" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowfullscreen="true" height="373" width="438" />\'/><button onclick="copyUrl(\'htmlcode\')">点击复制</button></li><li id="cccodeid"></li>');
}
function morefx(){
	document.getElementById('ubbcodeid').style.display='block';
	document.getElementById('htmlcodeid').style.display='block';
	document.getElementById('closefx').style.display='block';
	document.getElementById('fxiang').style.display='none';
	document.getElementById('copycode').style.height='160px';
}
function closefx(){
	document.getElementById('ubbcodeid').style.display='none';
	document.getElementById('htmlcodeid').style.display='none';
	document.getElementById('closefx').style.display='none';
	document.getElementById('fxiang').style.display='block';
	document.getElementById('copycode').style.height='auto';
}
function clfx(id,id2){
	document.getElementById(id).style.display='none';
	document.getElementById(id2).innerHTML='<a href=\'javascript:mofx("'+id+'","'+id2+'");\'>全部显示</a>';
}
function mofx(id,id2){
	document.getElementById(id).style.display='block';
	document.getElementById(id2).innerHTML='<a href=\'javascript:clfx("'+id+'","'+id2+'");\'>关闭显示</a>';
	
}
function setTab(area,id) {
	var tabArea=document.getElementById(area);
	var contents=tabArea.childNodes;
	for(i=0; i<contents.length; i++) {
		if(contents[i].className=='tabul'){contents[i].style.display='none';}
	}
	document.getElementById(id+'tab').style.display='block'
	var tabs=document.getElementById('one'+area).getElementsByTagName('div');
	for(i=0; i<tabs.length; i++) { tabs[i].className='two'; }
	document.getElementById(id).className='one';
}


function multiTab(area,id) {
	var tabArea=document.getElementById(area);
	var contents=tabArea.childNodes;
	for(i=0; i<contents.length; i++) {
		if(contents[i].className=='tabul'){contents[i].style.display='none';}
		if(contents[i].id==id){contents[i].style.display='block'; }
	}
	var tabs=document.getElementById('one'+area).getElementsByTagName('div');
	for(i=0; i<tabs.length; i++) { 
		tabs[i].className='two';
		if (tabs[i].id==id){tabs[i].className='one';}		
		}
}

function showflash(swf,width,height,swfdiv){
	$(swfdiv).innerHTML='<object id="swfdivplayer" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+width+'" height="'+height+'"><param name="movie" value="'+swf+'" /><param name="quality" value="high" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><embed name="swfdivplayer" src="'+swf+'" quality="high" allowFullScreen="true" allowScriptAccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" /></object>'; 
}
function killErrors() {
return true;
}
window.onerror = killErrors;