
function blink(objId,i){
   var tid = null;
   var obj = eval("document.all." + objId );
   var colors=new Array();
   //colors[0]="#FF0000";
   //colors[1]="#FF6699";
   //colors[2]="#0000FF";
   //colors[3]="#FF6600";
   //colors[4]="#9933CC";
   //colors[5]="#996600";
   //colors[6]="#330066";
   //colors[7]="#669933";
   colors[0]="#666666";
   colors[1]="#3685F5";
   //var i = parseInt((colors.length-0+1) * Math.random() + 1)
   if (parseInt(i)==0){
	   i=1;
   }
   else{
	   i=0;
   }
   obj.style.color = colors[i]; 
   tid = setTimeout("blink('"+ objId +"',"+ i +")",500);
}


function reset(objId,tid){
   clearTimeout(tid);
   var obj = eval("document.all." + objId );
   obj.style.color = '#000000';
}




function CopyURL(){
   var clipBoardContent="http://pic.jinti.com/intern/";
   if (window.clipboardData){window.clipboardData.setData("Text",clipBoardContent);
   alert("已经把当前网址复制到剪贴板，\n\n"+"您可以使用(Ctrl+V或鼠标右键)粘贴功能，\n\n"+"发送到MSN、QQ、Blog或者论坛。\n");}
  }

function CopyValue(obj)
{
	var clipBoardContent=getformvalue(obj);

	if (window.clipboardData)
	{
		window.clipboardData.setData("Text",clipBoardContent);
	
		alert("已复制到剪贴板！\n\n您可以使用(Ctrl+V或鼠标右键)进行粘贴！\n感谢您对今题网的支持！");

		obj.select();
	}

}



function ChkboxGroup(StrName,inum)
{
	var ischecked;
		ischecked=false;
	for (var i=1;i<=inum;i++)
	{
		if (document.getElementById(StrName+'_'+i).checked==true)
		{
			ischecked=true;break;
		}
	}
	return ischecked;
}


//去左空格;
function ltrim(s){
    return s.replace( /^\\s*/, "");
}
//去右空格;
function rtrim(s){
    return s.replace( /\\s*$/, "");
}

//去左右空格;
function trim(s){
    return rtrim(ltrim(s));
}
//是否为空值;
function IsEmpty(_str){
    var tmp_str = trim(_str);
    return tmp_str.length == 0;
}

function alertfilter(s)
{
	s=s.replace(/[^_a-zA-Z0-9-\.@,，]/g,"");
	s=s.replace("，",",");
	return s;
}


//是否有效的Email;
function IsMail(_str){
    var tmp_str = trim(_str);
	var pattern = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/gi;
	return pattern.test(tmp_str);
}


//是否有效的数字;
function IsNumber(_str){
    var tmp_str = trim(_str);
    var pattern = /^[0-9]/;
    return pattern.test(tmp_str);
}
//是否有效的颜色值;
function IsColor(color){
    var temp=color;
    if (temp=="") return true;
    if (temp.length!=7) return false;
    return (temp.search(/\\#[a-fA-F0-9]{6}/) != -1);
}


//是否有效的手机号码;
function IsMobile(_str){
    var tmp_str = trim(_str);
    var pattern = /^(13|15)+\d{9}$/;
    return pattern.test(tmp_str);
}


  //***JavaScript 表单域读写函数集*******//
function outcheck(check_value){
	if(check_value != ""){
		alert(check_value)
		return false; 
	}
	return true;
}


//身份证
function IsIDcard(_str)
{
	var pattern = /^\d{15}(\d{2}[A-Za-z0-9])?$/;
	_str = trim(_str);
	return pattern.test(_str)
}

function checkvalue(obj, low, up, mode, lable){
/*
Mode = 1 检测是否为空   2是否是数字  4是否整数
8是否是为数字、字母和_.-
16 自定义字符检测
32 长度检测
64 数字大小检测
*/
    var temp,type;
    var length, i, base, str;
    
    str=getformvalue(obj);
    if(str==null){
		lenght=0;
		str="";
	}	
	else{	
		str = str.replace(/(^\s+|\s+$)/g,""); 
		length = str.length
	}	
    temp=""
    if( mode % 2 >= 1 ){
        if( str == "" ){
            temp = temp + "“" + lable + "”" + "不能为空！" + "\n";
        }
    }
    
    if( mode % 4 >= 2 ){
        base = "0123456789."
        for(i = 0;i<=length-1;i++)
            if( base.indexOf(str.substring(i, i+1)) == -1  ){
				temp = temp + "“" + lable + "”" + "必须是数字！" + "\n";
				break;
            }    
    }
    
    if( mode % 8 >= 4 ){
        base = "0123456789"
        for(i = 0;i<=length-1;i++)
            if( base.indexOf(str.substring(i, i+1)) == -1  ){
                temp = temp + "“" + lable + "”" + "必须是整数！" + "\n";
                break;
            }    
    }
    
    if( mode % 16 >= 8 ){
        base = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789_-."
        for(i = 0;i<=length-1;i++)
            if( base.indexOf(str.substring(i, i+1)) == -1  ){
                temp = temp + "“" + lable + "”" + "包含非法字符！它只能是字母、数字和“- _ .”。" + "\n";
                break;
            }
    }
    
    if( mode % 32 >= 16 ){
        base = low.replace("[a-z]", "abcdefghijklmnopqrstuvwxyz")
        base = base.replace("[a-z]", "abcdefghijklmnopqrstuvwxyz")
        base = base.replace( "[0-9]", "0123456789")
        for(i = 0;i<=length-1;i++)
            if( base.indexOf(str.substring(i, i+1)) == -1 ){
                temp = temp + "“" + lable + "”" + "包含非法字符！它只能是" + up + "。" + "\n";
                break;
            }
    }
    
    if( mode % 64 >= 32 ){
        if( ! (length >= low && length <= up) ){
               temp = temp + "“" + lable + "”" + "的长度必须在" + low + "到" + up + "之间！" + "\n";
        }
    }
    
     if( mode % 128 >= 64 ){
        if( ! (parseInt(str) >= parseInt(low) && parseInt(str) <= parseInt(up)) ){
               temp = temp + "“" + lable + "”" + "必须在" + low + "到" + up + "之间！" + "\n";
        }

    }
    if(temp!=""){
    	alert(temp);
    	type=(getformtype(obj));
    	if(type!="radio" && type!="checkbox"){
    		obj.focus();
    	}
	return false; 
   }
   return true;
    
}

function getformtype(obj){
	var type;
	type=obj.type;
	if(typeof(type)=="undefined"){

		type=obj[0].type;
	}
	return type;		
}
function getformvalue(input){
//取表单域的值
	var type,temp;
	temp="";
	
	type=getformtype(input);	

	switch(type){
		case "radio":	//单选框
			n=input.length-1;

			if(isNaN(n)==true){
				if(input.checked == true){
					temp = input.value;
				}else{
					temp = "";
				}	
			}else{
				for(i=0;i<=n;i++){
					if(input[i].checked == true){
						return(input[i].value);
					}
				}
				break;
			}
			case "checkbox":	//复选框
			n=input.length-1;
			if(isNaN(n)==true){
				if(input.checked == true){
					temp = input.value;
				}else{
					temp = "";
				}	
			}else{
				for(i=0;i<=n;i++){
					if(input[i].checked == true){
						if(temp!=""){
							temp += ",";
						}
						temp += input[i].value;

					}	
				}
			}
			return(temp);
			break;
			
		case "select-one" :	//单选列表框
			n=input.length-1;	
			for(i=0;i<=n;i++){
				if(input.options[i].selected == true){
					temp = input.options[i].value;
					break;
				}			
			}
			return(temp);
			break;				
		case "select-multiple":	//多选列表框
			n=input.length-1;	
			for(i=0;i<=n;i++){
				if(input.options[i].selected == true){
					if(temp!=""){
						temp+=",";
					}					
					temp+=input.options[i].value;
				}			
			}
			return(temp);
			break;			
		default:				//其它
			return(input.value);
			break;
	
	}
	
	return(input.value);

}

function ischecked(group,value){
	var i,n;
	n=group.length-1;
	for(i=0;i<=n;i++){
		if(value==group[i]){
			return true;			
		}
	}
	return false;
}


function SetSelectedAndChecked(input,value){
//设置表单域的选择
	var type,temp,i,n;
	var split_value = new Array();
	temp="";
	
	type=input.type;
	
	if(typeof(type)=="undefined"){
		type=input[0].type;
	}
	

	switch(type){
		case "radio":	//单选框
			n=input.length-1;

			if(isNaN(n)==true){
				if(input.value = value){
					input.checked = true;
				}else{
					input.checked = false;
				}	
			}else{
				for(i=0;i<=n;i++){
					if(input[i].value == value){
						input[i].checked = true;
					}else{
						input[i].checked = false;					
					}
				}
			}
			break;

		case "checkbox":	//复选框
			n=input.length-1;
			split_value=value.split(",");
			if(isNaN(n)==true){
				if(ischecked(split_value,input.value)){
					input.checked = true;
				}else{
					input.checked = false;
				}	
			}else{
				for(i=0;i<=n;i++){
					if(ischecked(split_value,input[i].value)){
						input[i].checked = true;
					}else{
						input[i].checked = false;					
					}					
				}
				
			}
			break;
			
		case "select-one" :	//单选列表框
			n=input.options.length-1;	
			for(i=0;i<=n;i++){
				if(input.options[i].value == value){
					input.options[i].selected = true;
				}else{
					input.options[i].selected = false;				
				}
						
			}
			break;				
		case "select-multiple":	//多选列表框
			n=input.options.length-1;	
			split_value=value.split(",");
			for(i=0;i<=n;i++){
				if(ischecked(split_value,input.options[i].value)){
						input.options[i].selected = true;
				}else{
						input.options[i].selected = false;				
				}			
			}
			break;			
		default:				//其它
			return false;
			break;
	
	}
	
	return true;

}




function CopyText(id) {
	try{
		var targetText = document.getElementById(id);
		targetText.focus();
		targetText.select();
		var clipeText = targetText.createTextRange();
		clipeText.execCommand("Copy");
	}catch(e){}
}


function ShowMsgFont_Void(sDocId,sClass,sStyle,sMsgstr)
{
	document.getElementById(sDocId).innerHTML="<span id='"+sDocId+"' name='"+sDocId+"' class='"+sClass+"' style='"+sStyle+"' >"+sMsgstr+"</span>";
}