function Getcolor(img_val){
	var obj = document.getElementById("colourPalette");
	ColorImg = img_val;
	if (obj){
	obj.style.left = $(ColorImg).offset().left+ "px";
	obj.style.top = ($(ColorImg).offset().top + ColorImg.offsetHeight) + "px";
	obj.style.visibility=obj.style.visibility=="hidden"?"visible":"hidden";
	}
}
function setColor(color)
{
	if(ColorImg){ColorImg.style.backgroundColor = color;ColorImg.value = color;}
	document.getElementById("colourPalette").style.visibility="hidden";
}
function UpReturn(err,msg,t,id)
{
	if(err!=""){
		alert(err);
	}else if(msg!=''){
		if(id=='')id='previewpic';
		var upext = 'jpg,jpeg,gif,png';
		if(!msg.match(new RegExp('\.('+upext.replace(/,/g,'|')+')$','i'))){alert('只支持：'+upext);return false;}
		if(t==0)
		{
			$("#"+id).val(msg);
			$("#preview_"+id).html('<img src="'+msg+'"/>');
		}else{
			$("#"+id).val($("#"+id).val()+","+msg);
			$("#preview_"+id).append('<div style="position:relative;height150px;width:100px;"><img src="Images/close.gif" style="position:absolute;cursor:pointer;right:0;top:0" onClick="$(this).parent().remove();$(\'#'+id+'\').val($(\'#'+id+'\').val().replace(\''+msg+'\',\'\'));"/><img src="'+msg+'" style="max-height:150px; max-width:100px"/></div>');
		}
	}
}
function InfoCalss()
{
	this.WebPath='';
	this.UseEditor=0;
	this.Rannum='';
	this.UsePics=0;
	this.EditorTools = "GStart,GStart,Blocktag,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,Removeformat,GEnd,Separator,GStart,Align,List,Outdent,Indent,GEnd,Separator,GStart,Link,Unlink,Img,Flash,Media,Emot,Table,GEnd,Separator,GStart,Source,Preview,Fullscreen,GEnd";
	this.Exe=function(){
		var Path = this.WebPath;
		var UpLink='';
		if(this.UsePics>0)UpLink=Path+'upload.asp?r='+this.Rannum;
		if(this.UseEditor)
		{
			if(this.UsePics>0)
			{
				if($('#pic').length==0)$('#text').after('<input name="pic" id="pic" type="hidden" value="">');
				$('#pic').attr('box','text');
			}
			$('#text').xheditor(true,{tools:this.EditorTools,keepValue:true,showBlocktag:false,beforeSetSource:ubb2html,beforeGetSource:html2ubb,upImgUrl:UpLink,blur:function(){ $('#text').valid();$.ajax({type:'GET',url:Path+'ajax/GetUpPic.asp?t='+this.Rannum,cache:false,success:function(str){if(str!=''){var s=str.split(',');str=','+str+',';var v = $('#text').val();for(var i=0;i<s.length;i++){if(v.indexOf(s[i])==-1)str=str.replace(','+s[i]+',',',');}str=str==','?'':str.substring(1,str.length-1);}$('#pic').val(str);if(str!='')$('#pic').valid();}});}});
		}
		if($('#pic').length!=0)
		{
			$('#pic').rules('add',{CheckPics:this.UsePics});
		}
		if($('#color').length!=0)
		{
			if($('#colourPalette').length==0)$('<IFRAME width="245" height="165" id="colourPalette" src="'+Path+'nc_selcolor.htm" style="visibility:hidden; position: absolute; left: 0px; top: 0px;border:1px gray solid; z-index:10" frameborder="0" scrolling="no" ></IFRAME>').appendTo("body"); 
			$('#color').click(function(){Getcolor(this);});
			$('#color').attr('readonly',true);
		}
		if( $('#verifya').length!=0)
		{
			$('#verifya').rules('add',{required:true,remote:{url:Path+'Ajax/CheckVerify.asp',type:'get',dataType:'json',data:{'verifya':function(){return escape($('#verifya').val());}},cache:false},messages:{required:'请填写问题答案!',remote:function(){ $.ajax({type:'GET',url:Path+'ajax/GetVerify.asp',cache:false,success:function(msg){ $('#verifyq').text(unescape(msg));}});return '问题答案错误!';}}});
		}
		if( $('#proof').length!=0)
		{
			if($('#imgid').length==0)$('#proof').after('<span id="imgid" style="color:red">点击获取验证码</span>');
			if(!$('#proof').attr('onfocus')){ $('#proof').one('focus',function(){get_Code(Path)});}
			$('#proof').rules('add',{required: true,remote: {url:Path+'Ajax/CheckCode.asp',type:'get',dataType:'json',data:{'proof':function(){return escape($('#proof').val());}},cache:false},messages:{required:'请填写验证码!',remote:function(){get_Code(Path);return '验证码错误!'}}});
		}
		if( $('#tel').length!=0)
		{
			$('#tel').rules('add',{remote:Path+'Ajax/CheckTel.asp',messages:{remote:'此号码已被禁用！'}});
		}
	}
}
