
var ids = new Array('name','age','height','area','enjoy','email','address','tel','content');
var submited = false;
function check(){
	
	var message = new Array('请填写您的姓名','请填写您的年龄','请填写您的身高(CM)','请填写您所在的地区','请填写您的爱好与特长','请填写您的邮箱(保密)','请填写您的邮寄地址(保密)','请填写您的电话(保密)','请填写您的宣言');
	for(var k=0; k<ids.length; k++) {
		
	if( document.getElementById(ids[k]).value == '' ){
		alert( message[k]);
		//document.getElementById(ids[k]).className = '';
		document.getElementById(ids[k]).focus();
		return false;
	}
	
	}
	if( stringCount($(ids[8]).value) > 1000 )
	{
		alert("请您节省笔墨，取其精华，最多500个中文了");
		document.getElementById(ids[8]).focus();
		return false;
	}
	
	if(submted){
      	alert('已经提交，请稍后');
        return false;
    }
    submited=true;
	if(confirm("确定要提交吗?")){
		return true;
	}
	return false;
}

function checkarticle(){
	if( stringCount($('content').value) > 1000 )
	{
		alert("请您节省笔墨，取其精华，最多500个中文了");
		document.getElementById('content').focus();
		return false;
	}
	if( stringCount($('content').value) < 200 )
	{
		alert("如果想免费拿到拉票,请至少写100个汉字或英文200个,加油!");
		document.getElementById('content').focus();
		return false;
	}
	
	if(submted){
      	alert('已经提交，请稍后');
        return false;
    }
    submited=true;
	if(confirm("确定要提交吗?文章生成后不可以修改")){
		return true;
	}
	return false;
}


function showLoginWin(divid){
	
}

function geturl(form,baseurl,missid){
	var url = "http://go.ent.163.com/tvbmiss/ecard.jsp?missid="+missid;
	document.getElementById('ecardurl').value = url;
	if( confirm("本次投票将消费10点网易一卡通点卡,您确定要投票吗?") )
	{
		this.form.submit();
	}
	return false;
}
function formsubmit(form,mode){
	var url = '../admin/dodelete.jsp?status='+mode;
	this.form.action=url;
	this.form.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;
	}
}

function copyUrl()
{
	var txt = this.location.href;
	if(window.clipboardData) {       
            window.clipboardData.clearData();       
            window.clipboardData.setData("Text", txt);       
    } else if(navigator.userAgent.indexOf("Opera") != -1) {       
         window.location = txt;       
    } else if (window.netscape) {       
        try {       
              netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");       
         } catch (e) {       
              alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");       
         }       
        var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);       
        if (!clip)       
             return;       
        var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);       
        if (!trans)       
             return;       
         trans.addDataFlavor('text/unicode');       
        var str = new Object();       
        var len = new Object();       
        var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);       
        var copytext = txt;       
         str.data = copytext;       
         trans.setTransferData("text/unicode",str,copytext.length*2);       
        var clipid = Components.interfaces.nsIClipboard;       
        if (!clip)       
             return false;       
        clip.setData(trans,null,clipid.kGlobalClipboard);       
		alert("已经将链接复制！\n\n您可以使用（Ctrl+V或鼠标右键）粘贴,\n\n推荐给您的亲友");
    }        
	//var url = this.location.href;
	//window.clipboardData.setData("Text",url);   
  	//alert("已经将链接复制！\n\n您可以使用（Ctrl+V或鼠标右键）粘贴,\n\n推荐给您的亲友");
}
function copyToClipBoard(){
	var clipBoardContent=this.location.href;
	//clipBoardContent+="标题";
	//clipBoardContent+='\r\n'+ document.URL;
	copy_clip(clipBoardContent);
	document.getElementById("_copybutton").value="复制成功请发给好友！";
}
function copy_clip(text2copy)
{
	if (window.clipboardData)
	{
		window.clipboardData.setData("Text",text2copy);
	}
	else
	{
		var flashcopier = 'flashcopier';
		if(!document.getElementById(flashcopier))
		{
			var divholder = document.createElement('div'); divholder.id = flashcopier; document.body.appendChild(divholder);
		}
		document.getElementById(flashcopier).innerHTML = ''; 
		var divinfo = '<embed src="http://swf.news.163.com/2008/clipBoard.swf?data='+escape(text2copy)+'"width="0" height="0" type="application/x-shockwave-flash"></embed>';
		document.getElementById(flashcopier).innerHTML = divinfo; 
	}
	alert("已经将链接复制！\n\n您可以使用（Ctrl+V或鼠标右键）粘贴,\n\n推荐给您的亲友");
	return true; 
} 

String.prototype.trim = function()
{
    // 用正则表达式将前后空格
    // 用空字符串替代。
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
function stringCount(txt) 
{
	txt = txt.replace(/(<.*?>)/ig,'');
	txt = txt.replace(/([\u0391-\uFFE5])/ig,'11');
	return txt.length;
}

function inputProc(id)
{
	//$(id).select();
	$(id).focus();
	for(var index=0; index<ids.length; index++) {
		if( $F(id) == array[index]){
			$(id).value = '';
			//$(id).className = ''; //字体样式
			$(id).style.color = "#000000";
			$(id).focus();
		}
	}
}
function checkNull(id,length){
	
	if( stringCount($(id).value) > length )
	{
		alert('最多'+length+'个字符');
		document.getElementById(id).focus();
	}
	
}

var showcount=1;
function addpic()
{
	showcount=showcount+1;
	if(showcount>10)
	{
		alert("已达到最大可增加数");
	}
	else
	{
		var name="upload"+showcount;
		document.getElementById(name).innerHTML=getAddText(showcount);
	}

   
}

function getAddText(countnow )
{
	var re = '';
	re+="<table width=\"90%\" border=\"0\" cellspacing=\"10\" cellpadding=\"0\" class=\"tabForm\">";
	re+="<tr>";
	re+="<td colspan=\"2\" class=\"f14px\"><input type=\"file\" name=\"file"+countnow+"\" id=\"file"+countnow+"\" class=\"inpText\" style=\"width:400px;\" />";
	//re+="<input value=\"删除\" class=\"inpSub\" onclick=\"removefile(upload"+countnow+")\" type=\"button\">";
	re+="</td>";
	re+="</tr>";
	re+="</table>";	
    return re;
}
function removefile(name){
	document.getElementById(name).display.style='none';
}
function ShowBox(dname,missid)
{
   	//当前时间大于stoptime
	if( endtime() )
		alert('数据在统计，暂时停止初赛投票,谢谢支持!');
	else{
		var arrayWH= document.documentElement.scrollTop + 200;
		var arrayWW= 250;
		document.getElementById(dname+'SelName').style.top=arrayWH+"px";
		document.getElementById(dname+'SelName').style.left=arrayWW+"px";
			
		
	  	var buyDiv=document.getElementById(dname+'SelName');
	    var objDiv=document.getElementById(dname+'objText');
	    var disable=document.getElementById(dname+'disableDiv');
	  	if(buyDiv.style.display=='none')
	  	{
	   		buyDiv.style.display='block';
		    disable.style.display='block';
	   		buyDiv.innerHTML=objDiv.innerHTML;
		
	  	}else{
	   		buyDiv.style.display='none';
	   		disable.style.display='none';
	  	}
	}
}
function endvote(){
	alert('数据在统计，暂时停止初赛投票,谢谢支持!');
	return;
}

function gotovote(missid){
	//当前时间大于stoptime
	if( endtime() )
		alert('数据在统计，暂时停止初赛投票,谢谢支持!');
	else
		window.open('','_blank').location.href='http://go.ent.163.com/tvbmiss/htmlfile/'+missid+'.html';
}
function endtime(){
    var stoptime = '2008-10-20 10:0:0';
	var starttime = '2008-10-20 17:58:0';
	var myDate=new Date();
	var cur = myDate.getFullYear()+'-'+ (myDate.getMonth()+1)+'-'+myDate.getDate()+' '+ myDate.toLocaleTimeString();
	return g( cur,stoptime)&&g(starttime,cur);
}
//比较时间
function g(d1,d2){
return Date.parse(d1.replace(/-/g,"/"))>Date.parse(d2.replace(/-/g,"/"))
}

function checkMail(mail)
  {
   if(mail=='' ||mail.length<5) return false;
    var mailReg=/[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-])+/i;
     if(mailReg.test(mail)) return true;
     else false;
  }
  function checkTel(tel)
  {
   if(tel==''||tel.length<7) return false;
   var telReg=/[0-9]{7,14}/;
   if(telReg.test(tel)) return true;
   else return false;
  }
  function checkByEmail()
  {
    var mail = document.getElementById('email').value;
    if(mail=='') {alert('请填写好邮箱！');document.saveForm.email.focus();return;}
    if(!checkMail(mail)) {alert('您邮箱格式不对！');document.saveForm.email.focus();return;}
   
  }
